PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / wp-media / mcp-oauth / inc / Context.php

Context.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, at vendor/wp-media/mcp-oauth/inc/Context.php

61 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3
4 namespace WPMedia\MCP\OAuth;
5
6 use WP\MCP\Infrastructure\Observability\Contracts\McpObservabilityHandlerInterface;
7 use WP\MCP\Infrastructure\Observability\NullMcpObservabilityHandler;
8
9 class Context {
10 /**
11 * Determines whether the MCP OAuth server is enabled.
12 *
13 * @return bool True when the OAuth server (rewrite rules, endpoints,
14 * discovery documents, transport) should be registered; false otherwise.
15 */
16 public function is_enabled(): bool {
17 $enabled = apply_filters_deprecated( 'rocket_mcp_oauth_server_enabled', [ true ], '1.0.1', 'wpmedia_mcp_oauth_server_enabled' );
18
19 /**
20 * Filters whether the MCP OAuth server is enabled.
21 *
22 * When `false`, the host plugin does not register the OAuth rewrite rules
23 * or respond to any /oauth/* endpoint or /.well-known discovery request,
24 * and does not register the MCP OAuth transport server.
25 *
26 * @param bool $enabled Whether the MCP OAuth server is enabled. Default true.
27 */
28 return wpm_apply_filters_typed( 'boolean', 'wpmedia_mcp_oauth_server_enabled', $enabled );
29 }
30
31 /**
32 * Observability handler class used by the MCP server.
33 *
34 * Defaults to the mcp-adapter's null handler, so no observability event is
35 * written unless a site opts in. The verbose handler
36 * (`WPMedia\MCP\OAuth\Transport\McpObservabilityHandler`) records one event per
37 * server creation, i.e. once per REST request, which floods debug.log on sites
38 * running with WP_DEBUG and WP_DEBUG_LOG enabled.
39 *
40 * @return class-string<McpObservabilityHandlerInterface> Observability handler class name.
41 */
42 public function observability_handler(): string {
43 /**
44 * Filters the observability handler class used by the MCP server.
45 *
46 * The value must be a class implementing the mcp-adapter's
47 * McpObservabilityHandlerInterface; any other value is ignored and the
48 * null handler is used instead.
49 *
50 * @param string $handler Observability handler class name. Default NullMcpObservabilityHandler.
51 */
52 $handler = wpm_apply_filters_typed( 'string', 'wpmedia_mcp_oauth_observability_handler', NullMcpObservabilityHandler::class );
53
54 if ( ! is_a( $handler, McpObservabilityHandlerInterface::class, true ) ) {
55 return NullMcpObservabilityHandler::class;
56 }
57
58 return $handler;
59 }
60 }
61