PluginProbe
Force Refresh / 3.2.1
Force Refresh v3.2.1
3.2.1 3.2.0 3.1.2 3.1.1 3.1.0 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.11.0 2.11.1 2.12.0 All 54 releases
← All changes | includes/api/classes/class-api-handler-client.php +6 -10 2.12.03.2.1 View file →
@@ -7,8 +7,9 @@
7 7
8 8 namespace JordanLeven\Plugins\ForceRefresh\Api;
9 9
10 10 use JordanLeven\Plugins\ForceRefresh\Api\Api_Handler;
11 +use JordanLeven\Plugins\ForceRefresh\Services\Versions_Storage_Service;
11 12
12 13 /**
13 14 * Main class controller.
14 15 */
@@ -49,11 +50,11 @@
49 50 * Method used by ajax requests to get the current site version.
50 51 *
51 52 * @param \WP_REST_Request $request The ReST Request object.
52 53 *
53 - * @return void
54 + * @return \WP_REST_Response
54 55 */
55 - public function get_version( \WP_REST_Request $request ): void {
56 + public function get_version( \WP_REST_Request $request ): \WP_REST_Response {
56 57 $post_id = $request->get_param( 'postId' ) ?? null;
57 58
58 59 $response = array(
59 60 'currentVersionSite' => $this->get_current_version_site(),
@@ -62,10 +63,10 @@
62 63 if ( $post_id ) {
63 64 $response['currentVersionPage'] = $this->get_current_version_post( $post_id );
64 65 }
65 66
66 - $this->return_api_response(
67 - 200,
67 + return $this->return_api_response(
68 + \WP_Http::OK,
68 69 'The current site version has been successfully retrieved.',
69 70 $response,
70 71 );
71 72 }
@@ -87,14 +88,9 @@
87 88 *
88 89 * @return string The version of the provided post
89 90 */
90 91 private static function get_current_version_post( int $post_id ): string {
91 - $current_page_version = get_post_meta(
92 - $post_id,
93 - 'force_refresh_current_page_version',
94 - true
95 - );
96 - return (bool) $current_page_version ? $current_page_version : '0';
92 + return Versions_Storage_Service::get_page_version( $post_id );
97 93 }
98 94
99 95 /**
100 96 * Method for getting the endpoint for this service.