page_cache = $page_cache; } /** * {@inheritdoc} */ public function get_path(): string { return '/page/clear'; } /** * {@inheritdoc} */ public function get_methods() { return WP_REST_Server::CREATABLE; } /** * {@inheritdoc} */ public function callback( WP_REST_Request $request ) { $result = $this->page_cache->clear(); if ( ! $result ) { return new WP_Error( 'solid_performance_page_cache_clear_error', 'Page cache could not be cleared', ); } return new WP_REST_Response( [ 'code' => 'solid_performance_page_cache_cleared', 'message' => 'Page cache cleared successfully', ] ); } /** * {@inheritdoc} */ public function schema_callback(): array { return [ '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'setting', 'type' => 'object', 'properties' => [ 'code' => [ 'description' => esc_html__( 'The identification code of the action.', 'solid-performance' ), 'type' => 'string', 'enum' => [ 'solid_performance_page_cache_cleared', 'solid_performance_page_cache_clear_error', ], 'readonly' => true, ], 'message' => [ 'description' => esc_html__( 'The formatted message of the action change.', 'solid-performance' ), 'type' => 'string', 'readonly' => true, ], ], ]; } }