composer install' ); ?>

$links Existing action links. * @return array Modified action links. */ function plugin_action_links( array $links ): array { $settings_link = sprintf( '%2$s', admin_url( 'options-general.php?page=ai-experiments' ), esc_html__( 'Settings', 'ai' ) ); array_unshift( $links, $settings_link ); return $links; } /** * Loads the plugin after checking requirements. * * @since 0.1.0 */ function load(): void { static $loaded = false; // Prevent loading twice. if ( $loaded ) { return; } // Check version requirements. if ( ! check_php_version() || ! check_wp_version() ) { return; } // Load the Jetpack autoloader. if ( ! file_exists( AI_EXPERIMENTS_PLUGIN_DIR . 'vendor/autoload_packages.php' ) ) { add_action( 'admin_notices', __NAMESPACE__ . '\display_composer_notice' ); return; } require_once AI_EXPERIMENTS_PLUGIN_DIR . 'vendor/autoload_packages.php'; $loaded = true; // Add plugin action links. add_filter( 'plugin_action_links_' . plugin_basename( AI_EXPERIMENTS_PLUGIN_FILE ), __NAMESPACE__ . '\plugin_action_links' ); // Hook experiment initialization to init. add_action( 'init', __NAMESPACE__ . '\initialize_experiments' ); } /** * Initializes plugin experiments. * * @since 0.1.0 */ function initialize_experiments(): void { try { // Initialize the WP AI Client. AI_Client::init(); $registry = new Experiment_Registry(); $loader = new Experiment_Loader( $registry ); $loader->register_default_experiments(); $loader->initialize_experiments(); // Initialize settings registration. $settings_registration = new Settings_Registration( $registry ); $settings_registration->init(); // Initialize admin settings page. if ( is_admin() ) { $settings_page = new Settings_Page( $registry ); $settings_page->init(); } // Register our post-related WordPress Abilities. $post_abilities = new Posts(); $post_abilities->register(); add_action( 'wp_abilities_api_categories_init', static function () { /** * Register a generic catch-all category that all * Abilities we register can use. Can re-evaluate this * in the future if we need/want more specific categories. */ wp_register_ability_category( AI_EXPERIMENTS_DEFAULT_ABILITY_CATEGORY, array( 'label' => __( 'AI Experiments', 'ai' ), 'description' => __( 'Various AI experiments.', 'ai' ), ), ); } ); } catch ( \Throwable $t ) { _doing_it_wrong( __NAMESPACE__ . '\initialize_experiments', sprintf( /* translators: %s: Error message. */ esc_html__( 'AI Plugin initialization failed: %s', 'ai' ), esc_html( $t->getMessage() ) ), '0.1.0' ); } } add_action( 'plugins_loaded', __NAMESPACE__ . '\load' );