'install-plugin', 'plugin' => self::SLUG, ], $installer ), 'install-plugin_' . self::SLUG ); } $plugins_screen = self::network_wide() ? network_admin_url( 'plugins.php' ) : admin_url( 'plugins.php' ); $args = [ 'action' => 'activate', 'plugin' => rawurlencode( AdapterSource::PLUGIN_FILE ), ]; if ( self::network_wide() ) { $args['networkwide'] = '1'; } return wp_nonce_url( add_query_arg( $args, $plugins_screen ), 'activate-plugin_' . AdapterSource::PLUGIN_FILE ); } /** * Whether the one-click button can do the job in place. * * Not on multisite, where installing belongs to the network admin and core's * own screens handle it. * * @return bool * @since 1.5.0 */ public static function supports_one_click(): bool { return ! is_multisite() && self::current_user_can_fix(); } /** * The button's label. * * @return string * @since 1.5.0 */ public static function action_label(): string { return self::is_installed() ? __( 'Activate MCP Adapter', 'albert-ai-butler' ) : __( 'Install and activate MCP Adapter', 'albert-ai-butler' ); } /** * A short title for the situation. * * @return string * @since 1.5.0 */ public static function title(): string { return self::is_installed() ? __( 'Activate the MCP Adapter plugin', 'albert-ai-butler' ) : __( 'Install the MCP Adapter plugin', 'albert-ai-butler' ); } /** * Why it matters, in one or two sentences. * * @return string * @since 1.5.0 */ public static function explanation(): string { $why = __( 'Albert talks to AI assistants through the MCP Adapter, which now comes as its own plugin from WordPress.org. Albert still includes a copy, but a coming update will rely on the plugin.', 'albert-ai-butler' ); return self::is_installed() ? $why . ' ' . __( 'It is installed on this site but not active.', 'albert-ai-butler' ) : $why; } /** * What to do when there is no button: who has to act. * * @return string Plain text. * @since 1.5.0 */ public static function guidance(): string { if ( self::route() === self::ROUTE_DEPLOY ) { return is_multisite() ? __( 'Plugin installs are switched off on this site, so a network administrator needs to look at it.', 'albert-ai-butler' ) : __( 'Plugin installs are switched off on this site, so a site administrator needs to look at it.', 'albert-ai-butler' ); } if ( self::is_installed() ) { return __( 'Only a site administrator can activate it, so please let them know.', 'albert-ai-butler' ); } return is_multisite() ? __( 'Only a network administrator can install it, so please let them know.', 'albert-ai-butler' ) : __( 'Only a site administrator can install it, so please let them know.', 'albert-ai-butler' ); } /** * What Albert tells a connected assistant, for it to pass on. * * @return string * @since 1.5.0 */ public static function assistant_notice(): string { if ( self::route() === self::ROUTE_DEPLOY ) { return __( 'Albert, the plugin connecting you to this site, needs the MCP Adapter plugin from WordPress.org. Albert still works for now, but a coming update will require it. Plugin installs are switched off on this site, so tell the user a site administrator needs to look at it.', 'albert-ai-butler' ); } return self::is_installed() ? __( 'Albert, the plugin connecting you to this site, needs the MCP Adapter plugin to be active. It is installed but switched off. Albert still works for now, but a coming update will require it. Tell the user to open Albert > Dashboard in their WordPress admin and choose "Activate MCP Adapter".', 'albert-ai-butler' ) : __( 'Albert, the plugin connecting you to this site, needs the MCP Adapter plugin from WordPress.org. Albert still works for now, but a coming update will require it. Tell the user to open Albert > Dashboard in their WordPress admin and choose "Install and activate MCP Adapter".', 'albert-ai-butler' ); } /** * Whether Albert runs network-wide, so the adapter should too. * * @return bool * @since 1.5.0 */ private static function network_wide(): bool { if ( ! is_multisite() ) { return false; } if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return is_plugin_active_for_network( ALBERT_PLUGIN_BASENAME ); } }