HEX
Server: LiteSpeed
System: Linux node612.namehero.net 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: dfwparty (1186)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/dfwparty/santabootshop.com/wp-content/mu-plugins/wp-toolkit/Common/SwitchableCommand.php
<?php
// Copyright 1999-2026. WebPros International GmbH. All rights reserved.

namespace Webpros\WptkWpPlugin\WpToolkit\Common;

use WP_CLI;
use WP_CLI\ExitException;
use WP_CLI_Command;

abstract class SwitchableCommand extends WP_CLI_Command
{
    /**
     * @return string
     */
    abstract protected function getSwitchOption();

    /**
     * @subcommand enable
     *
     * @return void
     */
    public function enable()
    {
        WordPressHelper::upsert_option($this->getSwitchOption(), true);
    }

    /**
     * @subcommand disable
     *
     * @return void
     */
    public function disable()
    {
        WordPressHelper::upsert_option($this->getSwitchOption(), false);
    }

    /**
     * @subcommand status
     *
     * @return void
     */
    public function status()
    {
        $status = get_option($this->getSwitchOption(), false);
        WP_CLI::print_value((int)$status);
    }

    private function isEnabled()
    {
        return (bool) get_option($this->getSwitchOption(), false);
    }

    /**
     * @throws ExitException
     */
    protected function ensureCommandEnabled()
    {
        if (!$this->isEnabled()) {
            WP_CLI::error(\sprintf("Command `%s` isn't enabled", \get_class($this)));
        }
    }
}