get_col($wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('adghost_') . '%' )); $saved = []; foreach ($names as $name) { if (in_array($name, self::KEEP, true)) { continue; } $saved[$name] = get_option($name); delete_option($name); } AdGhost_Script_Generator::delete_local_scripts(); update_option(self::PARKED, [ 'from' => $from, 'reason' => $reason, 'at' => current_time('mysql'), 'options' => $saved, ], false); update_option('adghost_site_id', wp_generate_uuid4(), false); delete_option(self::DISMISSED); self::stamp(); if (class_exists('AdGhost_Helper')) { AdGhost_Helper::purge_page_cache(); } } private static function parked() { $parked = get_option(self::PARKED, null); return (is_array($parked) && !empty($parked['options'])) ? $parked : null; } public static function on_activate() { if ((string) get_option(self::HOME_URL, '') === '' && self::configured()) { $from = self::infer_home(); self::park($from === self::home() ? '' : $from, $from === self::home() ? 'unknown' : 'moved'); return; } self::guard(); self::stamp(); } public static function handle_actions() { $action = isset($_GET['adghost_setup']) ? sanitize_key(wp_unslash($_GET['adghost_setup'])) : ''; if ($action === '') { return; } if (!current_user_can('manage_options') || !check_admin_referer('adghost_setup_' . $action)) { return; } if ($action === 'dismiss') { update_option(self::DISMISSED, true, false); } elseif ($action === 'tour') { delete_option(self::DISMISSED); } elseif ($action === 'forget') { delete_option(self::PARKED); } elseif ($action === 'restore') { self::restore(); } elseif ($action === 'fresh') { self::park((string) get_option(self::HOME_URL, '')); } wp_safe_redirect(AdGhost_Admin_Page::url()); exit; } public static function restore() { $parked = self::parked(); if ($parked === null) { return; } foreach ($parked['options'] as $name => $value) { if (strpos((string) $name, 'adghost_') !== 0 || in_array($name, self::KEEP, true)) { continue; } update_option($name, $value); } delete_option('adghost_is_active'); delete_option('adghost_local_script'); delete_option('adghost_script_url'); delete_option(self::PARKED); self::stamp(); } public static function action_url($action) { return wp_nonce_url( admin_url('admin.php?page=adghost&adghost_setup=' . $action), 'adghost_setup_' . $action ); } public static function render_moved_notice() { $parked = self::parked(); if ($parked === null) { return; } $from = (string) ($parked['from'] ?? ''); $count = count((array) $parked['options']); ?>

' . esc_html($from) . '', '' . esc_html(self::home()) . '' ); } else { esc_html_e('AdGhost settings were already in this site\'s database when the plugin was activated, with no record of the site they were configured on. They were set aside rather than used: a network code that arrived with a copied database belongs to whoever set it up, and this site must not earn against it.', 'adghost-lite'); } ?>

'#network_code', 'doneUrl' => self::action_url('dismiss'), 'title' => __('Start here', 'adghost-lite'), 'body' => __('Your GAM network code, from Admin → Global settings in Google Ad Manager.', 'adghost-lite'), 'then' => __('Then match your ad units with Ad Manager: Import from GAM brings yours in from a CSV, or Export for GAM writes the ones here as a CSV to upload there. An ad unit Ad Manager does not have returns nothing. Everything else on this page already has a sensible default.', 'adghost-lite'), 'none' => __('No Google Ad Manager account yet?', 'adghost-lite'), 'noneLink' => __('How to get one, and what to do with AdSense', 'adghost-lite'), 'noneUrl' => 'https://theadghost.com/gam-ads-inserter#no-ad-manager', 'done' => __('Got it', 'adghost-lite'), 'close' => __('Close', 'adghost-lite'), ]); } }