__( 'Get Imagify settings', 'imagify' ), 'description' => __( 'Returns all Imagify configuration options and their current values.', 'imagify' ), 'category' => 'imagify', 'execute_callback' => [ $this, 'execute' ], 'permission_callback' => [ $this, 'check_permissions' ], 'meta' => [ 'show_in_rest' => true, 'mcp' => [ 'public' => true, ], 'annotations' => [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, ], ], ] ); } /** * Routes through Imagify's capability abstraction so the `imagify_capacity` * filter and multisite network-admin logic are honoured. * * @return bool True when the current user has the Imagify `manage` capability. */ protected function has_permission(): bool { return imagify_get_context( 'wp' )->current_user_can( 'manage' ); } /** * Fetch the raw settings array from the options layer. * * Extracted into a protected method so that unit tests can override * this call without needing to re-mock the legacy singleton. * * @return array */ protected function fetch_raw_settings(): array { return \Imagify_Options::get_instance()->get_all(); } /** * Execute the ability: return all Imagify settings. * * Strips the internal `version` key and omits `api_key` to * avoid leaking credentials over the MCP endpoint. * * @return array All user-facing Imagify options. */ public function execute(): array { $start_time = microtime( true ); $result = $this->do_execute(); $this->fire_executed( $result, $start_time ); return $result; } /** * Internal execution logic for the ability. * * @return array */ private function do_execute(): array { $settings = $this->fetch_raw_settings(); unset( $settings['version'] ); unset( $settings['api_key'] ); return $settings; } }