invalidate_site_resolution(); } catch (\Throwable $e) { /* swallow */ } if (method_exists($client, 'bust_manifest_caches')) { try { $client->bust_manifest_caches(); } catch (\Throwable $e) { /* swallow */ } } } else { // Defensive: invalidate site resolution directly if ApiClient // hasn't loaded yet at this hook firing. delete_transient('aacb_site_options_cache'); delete_option('aacb_siteID'); } if (class_exists('AllAccessible_PostLinkBackfill')) { try { AllAccessible_PostLinkBackfill::on_activate(); } catch (\Throwable $e) { /* swallow */ } } // Image grid cache stamp — bump even if the helpers above didn't // load. Default is 1, increment past it so the version-stamp // cache key changes and next Image Manager render misses cache. $current = (int) get_option('aacb_image_grid_cache_stamp', 1); update_option('aacb_image_grid_cache_stamp', $current + 1, false); } /** * Upgrade routine for version 1.3.0 */ private static function upgrade_to_1_3_0() { // Example: Add new option // add_option('aacb_new_feature_enabled', true); } /** * Upgrade routine for version 1.3.5 */ private static function upgrade_to_1_3_5() { // Example: Security improvements // delete_option('aacb_deprecated_setting'); } /** * Upgrade routine for version 1.3.7 */ private static function upgrade_to_1_3_7() { // Migrate to new version management system $options = get_option('aacb_options', array()); if (!empty($options) && !isset($options['version'])) { $options['version'] = AACB_VERSION; update_option('aacb_options', $options); } } /** * Upgrade routine for version 2.0.0 * Handles migration from 1.x to 2.0 - new wizard system */ private static function upgrade_to_2_0_0() { $account_id = get_option('aacb_accountID'); // If user already has accountID (upgraded from 1.x), mark wizard as completed if (!empty($account_id)) { update_option('aacb_wizard_completed', true); // Set tier to 'unknown' since we don't know if they were free or premium in 1.x // They can continue using their existing account if (!get_option('aacb_account_tier')) { update_option('aacb_account_tier', 'legacy'); } } // Clean up old options that are no longer used in 2.0 delete_option('aacb_engagement_score'); delete_option('aacb_widget_opens_count'); delete_option('aacb_days_since_install'); delete_option('aacb_conversion_events'); delete_option('aacb_email_capture_shown'); delete_option('aacb_email_capture_count'); } /** * Upgrade routine for version 2.1.4 — move the signing secret off * autoload on existing installs. Re-add each row with autoload='no' * (delete+add, since update_option won't change an existing row's * autoload flag). Idempotent and safe if the rows are absent. */ private static function upgrade_to_2_1_4() { $keys = array('aacb_plugin_secret', 'aacb_plugin_secret_canon', 'aacb_plugin_secret_version'); foreach ($keys as $key) { $val = get_option($key, null); if ($val === null) { continue; } delete_option($key); add_option($key, $val, '', 'no'); } } /** * Update database check */ private static function update_db_check() { // This is where you would run any database schema updates if needed } } // Initialize the version manager AllAccessible_VersionManager::init();