telemetry = new Telemetry(); $this->existing_content = new Existing_Content(); $this->markdown_controller = new Markdown_Controller( $this->telemetry ); $this->llms_txt = new Llms_Txt( $this->telemetry ); $this->mcp_server = new Mcp_Server( new Mcp_Tools(), $this->telemetry ); $this->mcp_discovery = new Mcp_Discovery(); $this->connect = new Connect( new Api_Client() ); $this->telemetry->register_hooks(); $this->existing_content->register_hooks(); $this->markdown_controller->register_hooks(); $this->llms_txt->register_hooks(); $this->mcp_server->register_hooks(); $this->mcp_discovery->register_hooks(); $this->connect->register_hooks(); if ( is_admin() && class_exists( '\\AEL42A\\Admin\\Admin_Page' ) ) { $this->admin_page = new Admin\Admin_Page( $this->connect ); $this->admin_page->register_hooks(); } // Load bundled translations (es_ES, fr_FR, pt_BR ship in /languages). // Must run on init: loading text domains earlier trips a _doing_it_wrong // notice in WordPress 6.7+. add_action( 'init', array( $this, 'load_textdomain' ) ); // Make sure the daily cron survives environments that wipe cron arrays. add_action( 'init', array( $this, 'ensure_cron' ) ); } /** * Load the plugin text domain so bundled .mo files resolve for the * current site locale. Translations live in the plugin's /languages * directory (see the Domain Path header); a user-supplied override in * wp-content/languages/plugins takes precedence automatically. */ public function load_textdomain() { load_plugin_textdomain( 'ael-42a', false, dirname( plugin_basename( AEL42A_FILE ) ) . '/languages' ); } /** * Schedule the shared daily event if missing. */ public function ensure_cron() { if ( ! wp_next_scheduled( 'ael42a_daily' ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'ael42a_daily' ); } } /** * Activation: register rewrites and flush, schedule cron. */ public static function activate() { // Components are not constructed yet during activation - register the // rewrite rules directly so the flush below picks them up. Markdown_Controller::add_rewrite_rules(); Llms_Txt::add_rewrite_rules(); Mcp_Discovery::add_rewrite_rules(); flush_rewrite_rules(); if ( ! wp_next_scheduled( 'ael42a_daily' ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'ael42a_daily' ); } // Detect artifacts the site already provides (needs a loopback, so // it runs as a one-off event shortly after activation rather than // inline). wp_schedule_single_event( time() + 30, 'ael42a_detect_existing' ); } /** * Deactivation: flush rewrites, clear cron. */ public static function deactivate() { flush_rewrite_rules(); wp_clear_scheduled_hook( 'ael42a_daily' ); wp_clear_scheduled_hook( 'ael42a_detect_existing' ); } }