add_cap(WP_FORCE_REFRESH_CAPABILITY); }); // Add the script for normal frontfacing pages (non-admin) add_action("wp_enqueue_scripts", function(){ // Include the normal JS add_script("force-refresh-js", "/library/dist/js/force-refresh.built.min.js", true); // Localize the admin ajax URL. This doesn't sound like the best idea but WP is into it (https://codex.wordpress.org/AJAX_in_Plugins) wp_localize_script( "force-refresh-js", "force_refresh_js_object", array( // Get the ajax URL 'ajax_url' => admin_url( 'admin-ajax.php' ), // Get the post ID 'post_id' => get_the_ID(), // Get the refresh interval 'refresh_interval' => get_option( WP_FORCE_REFRESH_OPTION_REFRESH_INTERVAL_IN_SECONDS, WP_FORCE_REFRESH_OPTION_REFRESH_INTERVAL_IN_SECONDS_DEFAULT ) ) ); // Now that it's registered, enqueue the script wp_enqueue_script("force-refresh-js"); }); // Add meta boxes for specific pages that we want to refresh add_action('add_meta_boxes', function(){ // An array of all screens where we want to implement the meta box $screens = array("page", "post"); foreach ($screens as $screen) { // Add the box add_meta_box( 'force_refresh_specific_page_refresh', 'Force Refresh', __NAMESPACE__ . '\\force_refresh_specific_page_refresh_html', $screen, 'side' ); } }); ?>