page_cache = $page_cache; } /** * {@inheritdoc} */ public function get_path(): string { return '/page/status'; } /** * {@inheritdoc} */ public function get_methods() { return WP_REST_Server::READABLE; } /** * {@inheritdoc} */ public function callback( WP_REST_Request $request ) { $result = $this->page_cache->is_on(); if ( $result ) { return new WP_REST_Response( [ 'enabled' => true, 'code' => 'solid_performance_page_cache_on', 'message' => 'Page caching is currently enabled', ] ); } return new WP_REST_Response( [ 'enabled' => false, 'code' => 'solid_performance_page_cache_off', 'message' => 'Page caching is currently disabled', ] ); } /** * {@inheritdoc} */ public function schema_callback(): array { return [ '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'setting', 'type' => 'object', 'properties' => [ 'enabled' => [ 'description' => esc_html__( 'The current status of the page cache.', 'solid-performance' ), 'type' => 'boolean', 'readonly' => true, ], 'code' => [ 'description' => esc_html__( 'The identification code of the setting state.', 'solid-performance' ), 'type' => 'string', 'enum' => [ 'solid_performance_page_cache_on', 'solid_performance_page_cache_off', ], 'readonly' => true, ], 'message' => [ 'description' => esc_html__( 'The formatted message of the setting state.', 'solid-performance' ), 'type' => 'string', 'readonly' => true, ], ], ]; } }