get_method() ); if ( in_array( $method, [ 'GET', 'HEAD', 'OPTIONS' ], true ) ) { return $result; } $route = (string) $request->get_route(); // AICOM's own REST endpoints (/wp-json/aicom/*) — the MCP entry point. if ( strpos( $route, '/aicom/' ) === 0 ) { return $result; } // Gutenberg and wp-admin attach a wp_rest nonce; verify it. $nonce = $request->get_header( 'x_wp_nonce' ); if ( $nonce && wp_verify_nonce( $nonce, 'wp_rest' ) ) { return $result; } return new WP_Error( 'aicom_lockdown_rest_blocked', __( 'External REST writes are disabled — site is in AICOM-only mode. Use the AICOM MCP endpoint or the wp-admin interface.', 'aicom' ), [ 'status' => 403 ] ); } }