0; if ($isInstall) { // Persist immediately so subsequent requests don't re-enter update_option('wuadblockguard_version', self::$new_version, false); set_transient('wuadblockguard_version', self::$new_version, DAY_IN_SECONDS); self::pre_install(); // no migrations on fresh install self::post_install(); } elseif ($isUpgrade) { // Persist immediately to prevent re-entry on the very next request update_option('wuadblockguard_version', self::$new_version, false); set_transient('wuadblockguard_version', self::$new_version, DAY_IN_SECONDS); self::pre_upgrade(); if (version_compare($new_version, '2.6.0', '==')) { $notices = \AdBlockGuard\Notices::instance(); $notices->clear_all_notices(); if (!LicenseChecker::getInstance()->isLicenseValid()) { // update options to best values update_option( '_wuadblockguard_live_easylist', 'no' ); update_option( '_wuadblockguard_network_detection', 'yes' ); update_option( '_wuadblockguard_prevent_masquerading', 'no' ); } else { // update options to best values update_option( '_wuadblockguard_live_easylist', 'yes' ); update_option( '_wuadblockguard_network_detection', 'yes' ); update_option( '_wuadblockguard_prevent_masquerading', 'yes' ); } } if (version_compare($new_version, '2.6.6', '==')) { $notices = \AdBlockGuard\Notices::instance(); $notices->clear_all_notices(); } self::post_upgrade(); // logs + promo to free users } else { // downgrade or equal if ($isDowngrade) { PluginLogger::log('warning', 'DOWNGRADE DETECTED', [ 'old_version' => $old_version, 'new_version' => $new_version, 'bypass' => true, ]); } // no-op for equal } // NOTE: no persisting at the end; we've already persisted up front. } private static function pre_install() {} private static function pre_upgrade() {} private static function post_install() { PluginLogger::log('info', 'INSTALL COMPLETED: v' . self::$new_version, [ 'old_version' => (string) (self::$old_version ?? ''), 'new_version' => self::$new_version, 'bypass' => true, ]); } private static function post_upgrade() { PluginLogger::log('info', 'UPGRADE COMPLETED: v' . self::$new_version, [ 'old_version' => (string) (self::$old_version ?? ''), 'new_version' => self::$new_version, 'bypass' => true, ]); // promo only on real upgrade // self::free_users_upgrade_notice(); } /** * Upgrade notice for any version update */ private static function free_users_upgrade_notice() { if (!LicenseChecker::getInstance()->isLicenseValid()) { $notices = \AdBlockGuard\Notices::instance(); // delete previous notices that might be lingering $notices->clear_all_notices(); // stable ID per target version, e.g., wuadblockguard_notice_upgrade_255 $notice_id = 'wuadblockguard_notice_upgrade_' . str_replace('.', '', self::$new_version); // Build dynamic utm_campaign like upgrade_252_to_255 (keep if you like) $utm_campaign = 'upgrade_' . str_replace('.', '', (string) self::$old_version) . '_to_' . str_replace('.', '', self::$new_version); // Use raw string without __() // Figure out which month to display $now = new \DateTime(); $day = (int) $now->format('j'); // Day of month $month = (int) $now->format('n'); $year = (int) $now->format('Y'); if ($day > 15) { // Jump to next month $month++; if ($month > 12) { $month = 1; $year++; } } $monthName = gmdate('F', gmmktime(0, 0, 0, $month, 1, $year)); // Build the message $message = sprintf( 'Upgrade to AdBlock Guard Pro and save 30%%! Get enhanced ad-block detection for all AdBlock Extensions for only $21.

Limited-time offer - claim before %s %d, %d!

', $monthName, cal_days_in_month(CAL_GREGORIAN, $month, $year), // last day of that month $year ); $notices->add_notice( $notice_id, $message, 'success', true, true, [ 'label' => 'Claim 30% Off Now', // Raw string 'url' => 'https://www.wutime.com/?edd_action=add_to_cart&download_id=4952&discount=30PERCENT_OFF' . '&utm_source=wordpress' . '&utm_medium=admin_notice' . '&utm_campaign=' . $utm_campaign, 'type' => 'button', 'target' => '_blank', // Open in new window ] ); } } }