# force-refresh/2.12.0/includes/actions/client/actions-client.php

Force Refresh, version 2.12.0. 40 lines.

- Page: https://pluginprobe.com/plugins/force-refresh/2.12.0/code/includes/actions/client/actions-client.php
- Raw: https://pluginprobe.com/plugins/force-refresh/2.12.0/raw/includes/actions/client/actions-client.php
- Modified: 2024-05-27T19:35:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/force-refresh/2.12.0/code/includes/actions/client/actions-client.php#L10-L20`.

```php
<?php
/**
 * The actions to register and enqueue all of our client-side JavaScript
 * to request site versions.
 *
 * @package ForceRefresh
 */

namespace JordanLeven\Plugins\ForceRefresh;

use JordanLeven\Plugins\ForceRefresh\Api\Api_Handler_Client;
use JordanLeven\Plugins\ForceRefresh\Services\Debug_Storage_Service;
use JordanLeven\Plugins\ForceRefresh\Services\Options_Storage_Service;

// Add the script for normal front-facing pages (non-admin).
add_action(
    'wp_enqueue_scripts',
    function () {
        // Include the normal JS.
        add_script( 'force-refresh-js', '/dist/js/force-refresh.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',
            'forceRefreshLocalizedData',
            array(
                // Get the ajax URL.
                'apiEndpoint'     => Api_Handler_Client::get_rest_endpoint(),
                // Get the post ID.
                'postId'          => get_the_ID(),
                'isDebugActive'   => Debug_Storage_Service::debug_mode_is_active(),
                // Get the refresh interval.
                'refreshInterval' => Options_Storage_Service::get_refresh_interval(),
            )
        );
        // Now that it's registered, enqueue the script.
        wp_enqueue_script( 'force-refresh-js' );
    }
);

```
