'; echo esc_html__('AEOLynx for WebMCP requires PHP 7.4 or newer. The plugin has been deactivated. Please ask your host to upgrade PHP, then reactivate it.', 'aeolynx-for-webmcp'); echo '

'; } } if ( ! defined( 'AEOLYNX_CORE_VERSION' ) ) { define( 'AEOLYNX_CORE_VERSION', '1.5.2' ); } if (!defined('AEOLYNX_CORE_PATH')) { define('AEOLYNX_CORE_PATH', plugin_dir_path(__FILE__)); } if (!defined('AEOLYNX_CORE_URL')) { define('AEOLYNX_CORE_URL', plugin_dir_url(__FILE__)); } if (!defined('AEOLYNX_CORE_BASENAME')) { define('AEOLYNX_CORE_BASENAME', plugin_basename(__FILE__)); } require_once __DIR__ . '/includes/class-aeolynx-for-webmcp-core.php'; // Guarantee that all modular classes are loaded immediately into PHP memory. AEOLynx_Core::load_dependencies(); if (!function_exists('aeolynx_default_options')) { /** * Default plugin settings helper. * * @return array */ function aeolynx_default_options() { return array( 'aeolynx_enabled' => 1, 'aeolynx_schema_enabled' => 1, 'aeolynx_speakable_enabled' => 1, 'aeolynx_auto_faq_enabled' => 1, 'aeolynx_woo_schema_on' => 1, 'aeolynx_markdown_enabled' => 1, 'aeolynx_llmstxt_enabled' => 1, 'aeolynx_llmsfull_enabled' => 1, 'aeolynx_robots_enabled' => 1, 'aeolynx_bot_oai_search' => 'allow', 'aeolynx_bot_chatgpt_user' => 'allow', 'aeolynx_bot_perplexity' => 'allow', 'aeolynx_bot_claude' => 'allow', 'aeolynx_bot_google_ext' => 'allow', 'aeolynx_bot_gptbot' => 'allow', 'aeolynx_bot_ccbot' => 'allow', 'aeolynx_activity_log_on' => 1, 'aeolynx_rate_limit' => 60, 'aeolynx_entity_type' => 'Organization', 'aeolynx_entity_name' => '', 'aeolynx_logo_url' => '', 'aeolynx_same_as' => '', 'aeolynx_speakable_css' => 'h1.entry-title, .entry-title, .entry-content > p:first-of-type, .wp-block-post-content > p:first-of-type, .wm-ai-box__summary', 'aeolynx_default_schema' => 'BlogPosting', 'aeolynx_ai_summary_render' => 0, 'aeolynx_cite_bar_render' => 0, 'aeolynx_ai_box_theme' => 'auto', 'aeolynx_content_signal' => 'allow_all', 'aeolynx_cloudflare_scan' => 0, ); } } if (!function_exists('aeolynx_word_count')) { /** * Multibyte-safe word counter (str_word_count is ASCII-only). * * @param string $text Plain text to count. * @return int */ function aeolynx_word_count($text) { $text = (string) $text; if ('' === $text) { return 0; } if (function_exists('preg_match_all')) { preg_match_all('/[\p{L}\p{N}]+/u', $text, $matches); return isset($matches[0]) ? count($matches[0]) : 0; } return count(preg_split('/\s+/', trim($text))); } } if (!function_exists('aeolynx_bootstrap')) { /** * Bootstrap the AEOLynx for WebMCP plugin safely on plugins_loaded. * * @return void */ function aeolynx_bootstrap() { AEOLynx_Core::instance()->run(); } add_action('plugins_loaded', 'aeolynx_bootstrap', 20); } if (!function_exists('aeolynx_maybe_upgrade')) { /** * Flush rewrite rules once after a plugin update so newly added discovery * endpoints (e.g. /.well-known aliases) route without a manual re-activation. * * @return void */ function aeolynx_maybe_upgrade() { $installed = (string) get_option('aeolynx_installed_version', ''); if (AEOLYNX_CORE_VERSION === $installed) { return; } // Any version change invalidates the previous audit report: views must // never display numbers produced by an older build. delete_transient('aeolynx_audit_cache'); // One-time cleanup of any legacy/stale rate-limit & throttle rows left by pre-1.4.10 builds. global $wpdb; foreach (array('webmcp_rl_', 'webmcp_throttle_') as $legacy_prefix) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time upgrade maintenance DELETE. $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like($legacy_prefix) . '%')); } if (class_exists('AEOLynx_REST') && method_exists('AEOLynx_REST', 'sql_sweep_window_counters')) { AEOLynx_REST::sql_sweep_window_counters(time()); } if (class_exists('AEOLynx_Admin') && method_exists('AEOLynx_Admin', 'sql_sweep_throttle_counters')) { AEOLynx_Admin::sql_sweep_throttle_counters(time()); } if (class_exists('AEOLynx_LlmsTxt')) { AEOLynx_LlmsTxt::add_rewrite_rules(); } if (class_exists('AEOLynx_Well_Known')) { AEOLynx_Well_Known::add_rewrite_rules(); } flush_rewrite_rules(); update_option('aeolynx_installed_version', AEOLYNX_CORE_VERSION, false); } add_action('admin_init', 'aeolynx_maybe_upgrade', 5); } if (!function_exists('aeolynx_activate')) { /** * Activation hook: seed default options and register rewrite endpoints safely. * * @return void */ function aeolynx_activate() { AEOLynx_Core::load_dependencies(); $defaults = aeolynx_default_options(); foreach ($defaults as $key => $val) { if (false === get_option($key, false)) { add_option($key, $val); } } if (class_exists('AEOLynx_LlmsTxt')) { AEOLynx_LlmsTxt::add_rewrite_rules(); } if (class_exists('AEOLynx_Well_Known')) { AEOLynx_Well_Known::add_rewrite_rules(); } flush_rewrite_rules(); } register_activation_hook(__FILE__, 'aeolynx_activate'); } if (!function_exists('aeolynx_deactivate')) { /** * Deactivation hook: flush rewrite rules cleanly. * * @return void */ function aeolynx_deactivate() { // Delete rewrite_rules option instead of calling flush_rewrite_rules() while this // plugin's init callbacks are still registered in the same request (BUG-008). delete_option('rewrite_rules'); } register_deactivation_hook(__FILE__, 'aeolynx_deactivate'); } // Translations for the aeolynx-for-webmcp text domain are loaded automatically by // WordPress.org (since WP 4.6). Do not call load_plugin_textdomain() here.