> */ const DETECTED_PLUGINS = array( 'Rank Math' => array('seo-by-rank-math/rank-math.php', 'seo-by-rankmath/rank-math.php'), 'Yoast SEO' => array('wordpress-seo/wp-seo.php', 'wordpress-seo-premium/wp-seo-premium.php'), 'All in One SEO' => array('all-in-one-seo-pack/all_in_one_seo_pack.php', 'all-in-one-seo-pack-pro/all_in_one_seo_pack.php'), ); /** * Whether the section should appear at all. * * Shown when an SEO plugin is active, OR the switch is on, OR originals are * already on file. The last two conditions matter: without them the section * — and with it the only view onto the saved originals — would vanish the * day someone deactivated Rank Math. * * @return bool */ public static function should_display() { if (!empty(self::get_active_plugin_names())) { return true; } if (class_exists('Metasync_Seo_Backup') && Metasync_Seo_Backup::is_enabled()) { return true; } $counts = self::get_backup_counts(); return ($counts['posts'] + $counts['terms']) > 0; } /** * Render the section body. */ public static function render() { $option_key = Metasync_Admin::option_key; $field_name = $option_key . '[general][' . Metasync_Seo_Backup::CONSENT_OPTION_KEY . ']'; $field_id = 'metasync_' . Metasync_Seo_Backup::CONSENT_OPTION_KEY; $enabled = class_exists('Metasync_Seo_Backup') && Metasync_Seo_Backup::is_enabled(); $product = Metasync::get_effective_plugin_name(); $otto = Metasync::get_whitelabel_otto_name(); $active = self::get_active_plugin_names(); $counts = self::get_backup_counts(); $total_saved = $counts['posts'] + $counts['terms']; $batch = class_exists('Metasync_Seo_Restore') ? Metasync_Seo_Restore::get_progress() : ['status' => 'idle', 'total' => 0, 'processed' => 0, 'failed' => 0, 'fields_restored' => 0]; $is_running = ($batch['status'] === 'running'); ?>

 
0 || $is_running): ?>

>
/
*/ private static function get_active_plugin_names() { if (!function_exists('is_plugin_active')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $names = array(); foreach (self::DETECTED_PLUGINS as $name => $files) { foreach ($files as $file) { if (is_plugin_active($file)) { $names[] = $name; break; } } } return $names; } /** * How many posts and terms hold saved originals. * * @return array{posts:int,terms:int} */ private static function get_backup_counts() { if (!class_exists('Metasync_Seo_Backup')) { return array('posts' => 0, 'terms' => 0); } // Memoised for the request: should_display() and render() both need it, // and each call is two indexed COUNT queries we have no reason to repeat. static $counts = null; if ($counts === null) { $counts = Metasync_Seo_Backup::count_objects_with_backups(); } return $counts; } }