PluginProbe
Force Refresh / 2.1.4
Force Refresh v2.1.4
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
force-refresh / includes / api / admin / inc.refresh-site.php

inc.refresh-site.php in Force Refresh 2.1.4, at includes/api/admin/inc.refresh-site.php

42 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Our API calls responsible for handling requests from admins requesting a refresh for the site.
4 *
5 * @package ForceRefresh
6 */
7
8 namespace JordanLeven\Plugins\ForceRefresh;
9
10 /**
11 * Function used by administrators to request a refresh of the site.
12 *
13 * @return void
14 */
15 function request_refresh_site() {
16 if ( ! is_user_authorized_to_request_refresh() ) {
17 return_api_response(
18 401,
19 MESSAGE_ERROR_UNAUTHORIZED
20 );
21 } else {
22 $site_version = get_new_version();
23 // Remove the old option.
24 delete_option( 'force_refresh_current_site_version' );
25 // Add the new option.
26 add_option( 'force_refresh_current_site_version', $site_version );
27 return_api_response(
28 200,
29 MESSAGE_SUCCESS_SITE,
30 array(
31 'new_site_version' => $site_version,
32 )
33 );
34 }
35 }
36
37 // Register the action used by administrators to refresh the site.
38 add_action(
39 'wp_ajax_force_refresh_update_site_version',
40 __NAMESPACE__ . '\\request_refresh_site',
41 );
42