' . esc_html__( 'AdMindra MCP: the bundled OAuth library could not be loaded, so remote MCP access is not available. Reinstall the plugin from its original zip.', 'admindra-mcp' ) . '
';
}
/**
* Tools → AdMindra MCP.
*/
public static function menu() {
add_management_page(
__( 'AdMindra MCP', 'admindra-mcp' ),
__( 'AdMindra MCP', 'admindra-mcp' ),
'manage_options',
self::PAGE,
array( __CLASS__, 'page' )
);
}
/**
* Whether the MCP Adapter's main class is loaded.
*
* @return bool
*/
private static function adapter_loaded() {
return AdMindra_MCP_Setup::ready();
}
/**
* Whether the bundled OAuth library is loaded.
*
* @return bool
*/
public static function oauth_loaded() {
return class_exists( '\WPMedia\MCP\OAuth\Bootstrap' );
}
/**
* The settings screen's own stylesheet and copy button, on that screen only.
*
* @param string $hook Admin page hook.
*/
public static function assets( $hook ) {
if ( 'tools_page_' . self::PAGE !== $hook ) {
return;
}
wp_enqueue_style( 'admindra-mcp-admin', plugins_url( 'assets/admin.css', ADMINDRA_MCP_FILE ), array(), ADMINDRA_MCP_VERSION );
wp_enqueue_script( 'admindra-mcp-admin', plugins_url( 'assets/admin.js', ADMINDRA_MCP_FILE ), array(), ADMINDRA_MCP_VERSION, true );
}
/**
* A status chip: green when ready, amber when not.
*
* @param string $label Label.
* @param bool $ok Ready.
* @return string
*/
private static function chip( $label, $ok ) {
return '';
// WordPress moves admin notices under the first h1 or h2; this one keeps them out of the header.
echo '
' . esc_html__( 'AdMindra MCP', 'admindra-mcp' ) . '
';
echo '
MCP ' . esc_html( ADMINDRA_MCP_VERSION ) . ' ';
echo '' . esc_html__( 'Connect ChatGPT or Claude to this site. The assistant reads it, explains it and, when you allow it, edits its posts and pages.', 'admindra-mcp' ) . '
';
echo '';
echo self::chip( __( 'MCP Adapter', 'admindra-mcp' ), self::adapter_loaded() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- chip() escapes.
echo self::chip( __( 'OAuth', 'admindra-mcp' ), self::oauth_loaded() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- chip() escapes.
echo self::chip( __( 'HTTPS', 'admindra-mcp' ), $https ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- chip() escapes.
echo self::chip( __( 'Pretty permalinks', 'admindra-mcp' ), (bool) get_option( 'permalink_structure' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- chip() escapes.
echo '' . esc_html( $content ? __( 'Content edits on', 'admindra-mcp' ) : __( 'Reads only', 'admindra-mcp' ) ) . '';
echo '
';
/* MCP Adapter has its own step below; this line is for what the site
itself must change. */
if ( ! $ready && ( ! $https || ! get_option( 'permalink_structure' ) || ! self::oauth_loaded() ) ) {
echo '' . esc_html__( 'Fix what is amber above before connecting: the assistant signs in over OAuth, which needs HTTPS and pretty permalinks (Settings → Permalinks, anything but "Plain").', 'admindra-mcp' ) . '
';
}
echo '';
echo '
';
self::setup_box();
AdMindra_MCP_Connect::panel();
echo '
' . esc_html__( 'What the assistant may do', 'admindra-mcp' ) . '
';
echo '- ' . esc_html__( 'Site status, plugins and themes, and the updates WordPress found', 'admindra-mcp' ) . '
';
echo '- ' . esc_html__( 'Find pages with shortcodes that are not registered', 'admindra-mcp' ) . '
';
echo '- ' . esc_html__( 'Find and read posts, pages and plugin or theme source files', 'admindra-mcp' ) . '
';
echo '- ' . esc_html__( 'Edit the title, text and excerpt of posts and pages, and the site title and tagline', 'admindra-mcp' ) . '
';
echo '
';
echo '';
echo '' . esc_html__( 'Never: installing, updating or deleting plugins and themes, writing files, publishing or deleting posts, users or other settings.', 'admindra-mcp' ) . '
';
echo '
';
if ( has_action( 'admindra_mcp_addon_panel' ) ) {
/* The add-on draws its own part here: its connection to AdMindra,
its switch and its log. */
do_action( 'admindra_mcp_addon_panel' );
} else {
self::addon_box();
}
echo '';
self::more_box();
echo '
';
AdMindra_MCP_Connect::advanced();
echo '
';
}
/**
* The step before anything can connect, while MCP Adapter is missing or
* inactive; a confirmation once WordPress has activated it.
*/
private static function setup_box() {
$state = AdMindra_MCP_Setup::state();
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- only chooses which confirmation to show.
$done = isset( $_GET['adm-setup'] ) && 'done' === $_GET['adm-setup'];
if ( 'active' === $state ) {
if ( $done ) {
echo '' . esc_html__( 'Ask an administrator who can install plugins to install and activate MCP Adapter.', 'admindra-mcp' ) . '
';
}
}
/**
* What the add-on adds, on this screen only.
*/
private static function addon_box() {
echo '