| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/admin-menu-editor-pro/customizables/ |
Upload File : |
<?php
namespace YahnisElsts\AdminMenuEditor\Customizable;
use YahnisElsts\AdminMenuEditor\Customizable\Builders\FormBuilder;
use YahnisElsts\AdminMenuEditor\Customizable\HtmlHelper;
use YahnisElsts\AdminMenuEditor\Customizable\Rendering\FormTableRenderer;
class SettingsForm {
/**
* @var string
*/
protected $action = '';
/**
* @var string
*/
protected $submitUrl = '';
/**
* @var string
*/
protected $method = 'post';
/**
* @var \YahnisElsts\AdminMenuEditor\Customizable\Controls\InterfaceStructure
*/
protected $structure = null;
/**
* @var \YahnisElsts\AdminMenuEditor\Customizable\Rendering\Renderer
*/
protected $renderer;
/**
* @var null|array<string,\YahnisElsts\AdminMenuEditor\Customizable\Settings\AbstractSetting>
*/
protected $settings = null;
/**
* @var string|null ID attribute of the form element.
*/
protected $id = null;
protected $defaultSubmitButtonEnabled = true;
protected $errorReporting = UpdateRequestHandler::DIE_ON_ERRORS;
protected $errorTransientName = null;
protected $redirectUrl = '';
protected $successParams = array('updated' => 1);
protected $passThroughParams = array();
/**
* @var null|string
*/
protected $requiredCapability = null;
/**
* @var null|callable
*/
protected $permissionCallback = null;
/**
* @var null|callable
*/
protected $postProcessingCallback = null;
/**
* @var array
*/
protected $configurationParams;
public function __construct($params = array()) {
$this->configurationParams = $params;
$copyProperties = array(
'action',
'submitUrl',
'method',
'structure',
'settings',
'id',
'defaultSubmitButtonEnabled',
'errorReporting',
'errorTransientName',
'redirectUrl',
'successParams',
'passThroughParams',
'requiredCapability',
'permissionCallback',
'postProcessingCallback',
);
foreach ($copyProperties as $property) {
if ( isset($params[$property]) ) {
$this->$property = $params[$property];
}
}
if ( isset($params['renderer']) ) {
$this->renderer = $params['renderer'];
} else {
$this->renderer = new FormTableRenderer();
}
}
public function output() {
if ( $this->id !== null ) {
$formId = $this->id;
} else {
$formId = 'ame-struct-form-' . time();
}
echo HtmlHelper::tag('form', array(
'action' => $this->submitUrl,
'method' => $this->method,
'id' => $formId,
));
$this->renderer->renderStructure($this->structure);
if ( !empty($this->action) ) {
echo HtmlHelper::tag('input', array(
'type' => 'hidden',
'name' => 'action',
'value' => $this->action,
));
wp_nonce_field($this->action);
}
if ( $this->defaultSubmitButtonEnabled ) {
submit_button('Save Changes');
}
echo '</form>';
$this->renderer->enqueueDependencies('#' . $formId);
}
public function handleUpdateRequest($requestParams, $queryParams = []) {
$handler = new UpdateRequestHandler(
$this->settings,
array_merge(
//Pass through most parameters.
$this->configurationParams,
[
'errorReporting' => $this->errorReporting,
'errorTransientName' => $this->errorTransientName,
'redirectUrl' => $this->redirectUrl,
'successParams' => $this->successParams,
'passThroughParams' => $this->passThroughParams,
'requiredCapability' => $this->requiredCapability,
'permissionCallback' => $this->permissionCallback,
'postProcessingCallback' => $this->postProcessingCallback,
]
)
);
$handler->handleRequest($requestParams, $queryParams);
}
public static function builder($action = null) {
return (new FormBuilder())->actionName($action);
}
}