# force-refresh/3.2.1/includes/api/classes/class-api-handler-admin-refresh-page.php

Force Refresh, version 3.2.1. 82 lines.

- Page: https://pluginprobe.com/plugins/force-refresh/3.2.1/code/includes/api/classes/class-api-handler-admin-refresh-page.php
- Raw: https://pluginprobe.com/plugins/force-refresh/3.2.1/raw/includes/api/classes/class-api-handler-admin-refresh-page.php
- Modified: 2026-05-16T15:47:08+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/3.2.1/code/includes/api/classes/class-api-handler-admin-refresh-page.php#L10-L20`.

```php
<?php
/**
 * Our API calls responsible for handling requests from admins requesting a refresh for the page.
 *
 * @package ForceRefresh
 */

namespace JordanLeven\Plugins\ForceRefresh\Api;

use JordanLeven\Plugins\ForceRefresh\Api\Api_Handler_Admin;
use JordanLeven\Plugins\ForceRefresh\Api\Interfaces\Api_Handler_Admin_Interface;
use JordanLeven\Plugins\ForceRefresh\Services\Options_Storage_Service;
use JordanLeven\Plugins\ForceRefresh\Services\Refresh_Service;

/**
 * Main class controller.
 */
class Api_Handler_Admin_Refresh_Page extends Api_Handler_Admin implements Api_Handler_Admin_Interface {

    /**
     * The path for this endpoint.
     *
     * @var string
     */
    const ENDPOINT_PATH = '/page-version';

    /**
     * The version for this endpoint.
     *
     * @var int
     */
    const ENDPOINT_VERSION = 1;

    /**
     * Method for registering the endpoints for this class.
     *
     * @return void
     */
    public function register_routes(): void {
        self::register_rest_endpoint(
            self::ENDPOINT_PATH,
            self::ENDPOINT_VERSION,
            array(
                'methods'             => \WP_REST_Server::CREATABLE,
                'callback'            => array( $this, 'refresh_page' ),
                'permission_callback' => $this->get_admin_permission_callback(),
            ),
        );
    }

    /**
     * Method for refreshing the page version.
     *
     * @param \WP_REST_Request $request The request object.
     *
     * @return \WP_REST_Response
     */
    public function refresh_page( \WP_REST_Request $request ): \WP_REST_Response {
        $page_id      = $request->get_param( 'postId' ) ?? null;
        $page_version = Refresh_Service::update_version_page( $page_id );

        return $this->return_api_response(
            \WP_Http::CREATED,
            'You\'ve successfully requested all browsers to refresh this page.',
            array(
                'new_page_version' => $page_version,
                'page_id'          => $page_id,
                'refresh_interval' => Options_Storage_Service::get_refresh_interval(),
            )
        );
    }

    /**
     * Method for getting the endpoint for this service.
     *
     * @return  string  The service endpoint.
     */
    public static function get_rest_endpoint(): string {
        return self::get_formatted_rest_endpoint( self::ENDPOINT_PATH, self::ENDPOINT_VERSION );
    }
}

```
