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 / actions / admin / inc.admin-js.php

inc.admin-js.php in Force Refresh 2.1.4, at includes/actions/admin/inc.admin-js.php

46 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Our action to enqueue our Admin JavaScript.
4 *
5 * @package ForceRefresh
6 */
7
8 namespace JordanLeven\Plugins\ForceRefresh;
9
10 /**
11 * Hook used to enqueue CSS and JS.
12 *
13 * @return void
14 */
15 add_action(
16 'admin_head',
17 function () {
18 // Include the admin JS.
19 add_script( 'force-refresh-main-admin-js', '/dist/js/force-refresh-main-admin.js', true );
20 // Create the data we're going to localize to the script.
21 $localized_data = array();
22 // Add the API URL for the script.
23 $localized_data['api_url'] = get_stylesheet_directory_uri();
24 // Add the API URL for the script.
25 $localized_data['site_id'] = get_current_blog_id();
26 // Create a nonce for the user.
27 $localized_data['nonce'] = wp_create_nonce( WP_FORCE_REFRESH_ACTION );
28 // Add the ID of the handlebars notice.
29 $localized_data['handlebars_admin_notice_template_id'] =
30 WP_FORCE_REFRESH_HANDLEBARS_ADMIN_NOTICE_TEMPLATE_ID;
31 // Add the refresh interval.
32 $localized_data['refresh_interval'] = get_option(
33 WP_FORCE_REFRESH_OPTION_REFRESH_INTERVAL_IN_SECONDS,
34 WP_FORCE_REFRESH_OPTION_REFRESH_INTERVAL_IN_SECONDS_DEFAULT
35 );
36 // Localize the data.
37 wp_localize_script(
38 'force-refresh-main-admin-js',
39 'force_refresh_local_js',
40 $localized_data
41 );
42 // Now that it's registered, enqueue the script.
43 wp_enqueue_script( 'force-refresh-main-admin-js' );
44 }
45 );
46