# reviewx/trunk/app/Rest/Controllers/PingController.php

ReviewX – Multi-Criteria Reviews for WooCommerce with Google Reviews &amp; Schema, version trunk. 40 lines.

- Page: https://pluginprobe.com/plugins/reviewx/trunk/code/app/Rest/Controllers/PingController.php
- Raw: https://pluginprobe.com/plugins/reviewx/trunk/raw/app/Rest/Controllers/PingController.php
- Modified: 2026-03-15T12:18:40+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/reviewx/trunk/code/app/Rest/Controllers/PingController.php#L10-L20`.

```php
<?php

namespace ReviewX\Rest\Controllers;

\defined("ABSPATH") || exit;
use Exception;
use WP_REST_Response;
use ReviewX\Services\PingService;
use ReviewX\Utilities\Helper;
class PingController
{
    protected PingService $pingService;
    public function __construct()
    {
        $this->pingService = new PingService();
    }
    /**
     * Ping from sass and (cached for 2 hours) return site info.
     *
     * @return WP_REST_Response
     */
    public function ping() : WP_REST_Response
    {
        // Cache time-to-live: 2 hours
        $cache_duration = 3600 * 2;
        try {
            // Try to get cache
            $data = \get_transient('rvx_ping_cache');
            if (\false === $data) {
                // Cache miss: fetch fresh data, store and return
                $data = $this->pingService->ping();
                \set_transient('rvx_ping_cache', $data, $cache_duration);
            }
            return Helper::rvxApi($data)->success(\__('Plugin Active', 'reviewx'), 200);
        } catch (Exception $e) {
            return Helper::rvxApi()->fails(\__('Plugin deactivated or uninstalled', 'reviewx'), 404);
        }
    }
}

```
