logger = new Aizen_Logger(); $this->abilities = new Aizen_Abilities($this->logger); $this->connection = new Aizen_Connection(); if (is_admin()) { $this->admin = new Aizen_Admin($this->abilities, $this->logger, $this->connection); } add_action('admin_notices', array($this, 'maybe_show_requirement_notices')); add_filter('plugin_action_links_' . AIZEN_BASENAME, array($this, 'plugin_action_links')); } /** * Adds a "Settings" shortcut on the Plugins screen. * * @param array $links Existing links. * @return array */ public function plugin_action_links($links) { $settings_link = sprintf( '%s', esc_url(admin_url('admin.php?page=ai-zen')), 'Dashboard' ); array_unshift($links, $settings_link); return $links; } /** * Warn the admin (without breaking anything) when requirements are missing. */ public function maybe_show_requirement_notices() { if (! current_user_can('manage_options')) { return; } $screen = function_exists('get_current_screen') ? get_current_screen() : null; // Only nag on the plugins screen and our own dashboard to avoid notice fatigue. $show_everywhere = $screen && in_array($screen->id, array('plugins', 'toplevel_page_aizen'), true); if (! $show_everywhere) { return; } if (! function_exists('wp_register_ability')) { printf( '

%s

', wp_kses_post( sprintf( /* translators: %s: required WordPress version */ __('AbiliZen requires WordPress %s or later (the built-in Abilities API). Please update WordPress.', 'abilizen-ai-abilities'), AIZEN_MIN_WP ) ) ); return; } if (! class_exists('WP\MCP\Core\McpAdapter')) { printf( '

%s

', wp_kses_post( sprintf( /* translators: 1: opening link tag, 2: closing link tag */ __('AbiliZen needs the official %1$sMCP Adapter plugin%2$s installed and active to expose abilities to AI assistants. Abilities can still be managed below, but nothing will be reachable over MCP until it is installed.', 'abilizen-ai-abilities'), '', '' ) ) ); } } /** * Activation: create the log table, seed default options. */ public static function activate() { require_once AIZEN_PATH . 'includes/class-aizen-logger.php'; Aizen_Logger::create_table(); add_option(AIZEN_OPTION_DISABLED_ABILITIES, array()); add_option( AIZEN_OPTION_SETTINGS, array( 'server_slug' => 'mcp-adapter-default-server', 'namespace' => 'mcp', ) ); add_option(AIZEN_OPTION_DB_VERSION, AIZEN_DB_VERSION); flush_rewrite_rules(); } /** * Deactivation: flush rewrite rules only. We deliberately keep options, * the toggle state and the log table intact so re-activating the plugin * restores things exactly as they were. */ public static function deactivate() { flush_rewrite_rules(); } }