Automattic\WooCommerce\Internal\MCP

McpEndpointRemoval::handle_admin_notices │ public │ WC 1.0

Handle the admin_notices hook.

Tells stores that had the WooCommerce MCP feature enabled what was removed and how to keep using WooCommerce with MCP.

Метод класса: McpEndpointRemoval{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$McpEndpointRemoval = new McpEndpointRemoval();
$McpEndpointRemoval->handle_admin_notices(): void;

Код McpEndpointRemoval::handle_admin_notices() WC 11.3.0

public function handle_admin_notices(): void {
	if ( ! $this->should_show_removed_notice() ) {
		return;
	}

	$message = sprintf(
		'<strong>%1$s</strong> %2$s <a href="%3$s" target="_blank" rel="noopener noreferrer">%4$s</a>',
		esc_html__( 'WooCommerce MCP has been removed.', 'woocommerce' ),
		esc_html(
			sprintf(
				/* translators: %s: WooCommerce version. */
				__( 'As of WooCommerce %s, the WooCommerce MCP endpoint (/wp-json/woocommerce/mcp), its REST API key authentication, and its REST-based product and order tools are no longer available. WooCommerce abilities are still available through the WordPress Abilities API. Use the MCP Adapter plugin to connect MCP clients to them.', 'woocommerce' ),
				self::REMOVED_IN
			)
		),
		esc_url( self::DOCS_URL ),
		esc_html__( 'Learn more', 'woocommerce' )
	);

	$link_type = $this->get_adapter_link_type();
	if ( 'install' === $link_type ) {
		$message .= sprintf(
			' | <a href="%1$s" class="thickbox open-plugin-details-modal" data-title="%2$s">%3$s</a>',
			esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=mcp-adapter&TB_iframe=true&width=600&height=550' ) ),
			esc_attr__( 'MCP Adapter', 'woocommerce' ),
			esc_html__( 'Install MCP Adapter', 'woocommerce' )
		);
	} elseif ( 'activate' === $link_type ) {
		$message .= sprintf(
			' | <a href="%1$s">%2$s</a>',
			esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . rawurlencode( self::ADAPTER_PLUGIN_FILE ) . '&' . self::NOTICE_ACTIVATION_ARG . '=1' ), 'activate-plugin_' . self::ADAPTER_PLUGIN_FILE ) ),
			esc_html__( 'Activate MCP Adapter', 'woocommerce' )
		);
	}

	$dismiss_url = wp_nonce_url(
		add_query_arg( 'wc-hide-notice', self::REMOVED_NOTICE ),
		'woocommerce_hide_notices_nonce',
		'_wc_notice_nonce'
	);

	echo wp_kses_post(
		'<div class="notice notice-warning is-dismissible">'
		. '<a class="woocommerce-message-close notice-dismiss" style="text-decoration: none;" href="' . esc_url( $dismiss_url ) . '" aria-label="' . esc_attr__( 'Dismiss this notice', 'woocommerce' ) . '"></a>'
		. '<p>' . $message . '</p>'
		. '</div>'
	);
}