PluginProbe
Force Refresh / 2.1.1
Force Refresh v2.1.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
force-refresh / includes / ajax-calls-client.php

ajax-calls-client.php in Force Refresh 2.1.1, at includes/ajax-calls-client.php

58 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // The call used for users requesting the current site version from non-admins
4 add_action( 'wp_ajax_nopriv_force_refresh_get_version', __NAMESPACE__ . "\\ajax_request_get_version");
5
6 // The call used for users requesting the current site version from admins
7 add_action( 'wp_ajax_force_refresh_get_version', __NAMESPACE__ . "\\ajax_request_get_version");
8
9 /**
10 * The function used by ajax requests to get the current site version.
11 *
12 * @return void
13 *
14 * @version 1.0 Introducted in version 1.0
15 */
16 function ajax_request_get_version(){
17 // Get the data
18 $data = $_REQUEST;
19 // Declare our return
20 $return_array = array();
21 // Whether or not the call was successful
22 $success = true;
23 // The HTTP status code
24 $status_code = 200;
25 // The status text
26 $status_text = "The current site version has been successfully retrieved.";
27 // Get the post ID
28 $post_id = isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null;
29 // The return data
30 $return_data = array();
31 // Get the current site version
32 $current_site_version = get_option("force_refresh_current_site_version");
33 // Get the current site version
34 $current_page_version = get_post_meta( $post_id, 'force_refresh_current_page_version', true);
35 // If no current site version exists, then the site version will default to version 0. This should be a string and not an integer
36 if ( !$current_site_version ){
37 $current_site_version = "0";
38 }
39 if ( !$current_page_version ){
40 $current_page_version = "0";
41 }
42 $return_data['current_site_version'] = $current_site_version;
43 $return_data['current_page_version'] = $current_page_version;
44 // Set the HTTP code
45 status_header($status_code);
46 // Return the success
47 $return_array['success'] = $success;
48 // Return the status code
49 $return_array['status_code'] = $status_code;
50 // Return the status text
51 $return_array['status_text'] = $status_text;
52 // Return the return data
53 $return_array['return_data'] = $return_data;
54 print json_encode($return_array);
55 wp_die();
56 }
57
58 ?>