CustomPanelExample.php
| 3.7 KB | Satir:
0
| php
Geri
<?php /** ****************************************** * LiteSpeed Web Server Cache Manager * * @author LiteSpeed Technologies, Inc. (https://www.litespeedtech.com) * @copyright 2026 LiteSpeed Technologies, Inc. * @since 1.17.8 * ******************************************* */ namespace Lsc\Wp\Panel; use Lsc\Wp\WPInstall; /** * Example CustomPanel implementation for third-party integrators. * * To use this template: * 1. Copy this file to $lsws_home/admin/lscdata/custom/CustomPanel.php * 2. Rename both the file and the class: file must be CustomPanel.php and * the class declaration must read "class CustomPanel" * 3. Customize the method implementations for your panel * * The framework expects the deployed file to declare class * \Lsc\Wp\Panel\CustomPanel extending \Lsc\Wp\Panel\CustomPanelBase. * * @see \Lsc\Wp\Panel\CustomPanelBase * @see \Lsc\Wp\Panel\ControlPanel::initByClassName() * @since 1.17.8 */ class CustomPanelExample extends CustomPanelBase { /** * * @since 1.17.8 */ protected function __construct() { /** @noinspection PhpUnhandledExceptionInspection */ parent::__construct(); } /** * * @since 1.17.8 */ protected function init2() { /** * Panel name can be set to whatever you'd like. */ $this->panelName = 'customPanel'; /** * Optionally set a default server-level cache root directory. * This is used when no explicit cache root has been configured. * Example: $this->defaultSvrCacheRoot = '/var/lscache/'; */ /** @noinspection PhpUnhandledExceptionInspection */ parent::init2(); } /** * Gets a list of found docroots and associated server names. * Only needed for lscmctl 'scan' command. * * @since 1.17.8 */ protected function prepareDocrootMap() { /** * This function can be left as is if you do not intend to use * the lscmctl 'scan' command. In this case lscmctl command * 'addinstalls' can be used to add WordPress installations to the * custom data file instead. * * If you would like to add support for the lscmctl 'scan' command, * implement this function so that it searches for all document root, * server name, and server alias groups and uses this information to * populate $this->docRootMap as follows: * * array( * 'docroots' => array(index => docroot), * 'names' => array("server name/alias" => index) * ); * * Where the value of each discovered servername/alias in the 'names' * array matches the index of the related document root in the * 'docroots' array. */ $this->docRootMap = array('docroots' => array(), 'names' => array()); } /** * This function returns the PHP binary to be used when performing * WordPress related actions for the WordPress installation associated with * the passed in WPInstall object. * * @since 1.17.8 * * @param WPInstall $wpInstall * @return string */ public function getPhpBinary( WPInstall $wpInstall ) { /** * If PHP binary $phpBin can be more accurately detected for the given * installation, do so here. The $wpInstall object provides context * such as the install's document root and owner information that can * be used to select the correct PHP binary, e.g.: * $ownerInfo = $wpInstall->getOwnerInfo(); * $user = $ownerInfo['user_name']; */ $phpBin = 'php'; return "{$phpBin} {$this->phpOptions}"; } }
Kaydet
Ctrl+S ile kaydet