PluginProbe
Force Refresh / 2.10.0
Force Refresh v2.10.0
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 / actions / client / actions-client.php

actions-client.php in Force Refresh 2.10.0, at includes/actions/client/actions-client.php

40 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The actions to register and enqueue all of our client-side JavaScript
4 * to request site versions.
5 *
6 * @package ForceRefresh
7 */
8
9 namespace JordanLeven\Plugins\ForceRefresh;
10
11 use JordanLeven\Plugins\ForceRefresh\Api\Api_Handler_Client;
12 use JordanLeven\Plugins\ForceRefresh\Services\Debug_Storage_Service;
13 use JordanLeven\Plugins\ForceRefresh\Services\Options_Storage_Service;
14
15 // Add the script for normal front-facing pages (non-admin).
16 add_action(
17 'wp_enqueue_scripts',
18 function() {
19 // Include the normal JS.
20 add_script( 'force-refresh-js', '/dist/js/force-refresh.js', true );
21 // Localize the admin ajax URL. This doesn't sound like the best idea but WP is into
22 // it (https://codex.wordpress.org/AJAX_in_Plugins).
23 wp_localize_script(
24 'force-refresh-js',
25 'forceRefreshLocalizedData',
26 array(
27 // Get the ajax URL.
28 'apiEndpoint' => Api_Handler_Client::get_rest_endpoint(),
29 // Get the post ID.
30 'postId' => get_the_ID(),
31 'isDebugActive' => Debug_Storage_Service::debug_mode_is_active(),
32 // Get the refresh interval.
33 'refreshInterval' => Options_Storage_Service::get_refresh_interval(),
34 )
35 );
36 // Now that it's registered, enqueue the script.
37 wp_enqueue_script( 'force-refresh-js' );
38 }
39 );
40