NOX-ROOT-MARAZ Manager v2
PHP 8+ Secure
/
home
/
xiedrke
/
entrepot
/
wp-content
/
plugins
/
realpress
/
app
/
Register
/
Name
Size
Perms
Actions
📁 BlockTemplate
-
0755
Chmod
|
Delete
📄 Setting.php
2,553 B
0644
Edit
|
Chmod
|
Delete
📄 Widgets.php
752 B
0644
Edit
|
Chmod
|
Delete
Editing: Setting.php
<?php namespace RealPress\Register; use RealPress\Helpers\Config; use RealPress\Helpers\Settings; use RealPress\Helpers\Template; use RealPress\Helpers\Validation; /** * Class Setting * @package RealPress\Register */ class Setting { /** * @var array|mixed */ public $config = array(); /** * @var array|false|mixed|void|null */ public $data = array(); public function __construct() { add_action( 'init', array( $this, 'init' ) ); add_action( 'admin_menu', array( $this, 'register' ) ); add_action( 'admin_init', array( $this, 'save_settings' ) ); } public function init() { $this->config = Config::instance()->get( 'realpress-setting' ); $this->data = Settings::get_all_settings(); } /** * @return void */ public function register() { add_submenu_page( $this->config['parent_slug'], $this->config['page_title'], $this->config['menu_title'], $this->config['capability'], $this->config['slug'], array( $this, 'show_settings' ) ); } /** * @return void */ public function show_settings() { $config = $this->config; $data = $this->data; Template::instance()->get_admin_template( 'settings', compact( 'config', 'data' ) ); } /** * Save config * * @return void */ public function save_settings() { $nonce = Validation::sanitize_params_submitted( $_POST['realpress-option-setting-name'] ?? '' ); if ( ! wp_verify_nonce( $nonce, 'realpress-option-setting-action' ) ) { return; } $data = $this->data; $enable_email = 'on'; foreach ( $data as $name => $value ) { $field = Config::instance()->get( 'realpress-setting:' . $name ); $key = Validation::sanitize_params_submitted( isset( $_POST[ REALPRESS_OPTION_KEY ][ $name ] ) ); if ( $key ) { //email if ( strpos( $name, 'group:email:section' ) !== false ) { if ( strpos( $name, 'enable' ) !== false ) { $enable_email = $_POST[ REALPRESS_OPTION_KEY ][ $name ]; $data[ $name ] = $enable_email; } else { if ( $enable_email === 'on' ) { $data[ $name ] = $_POST[ REALPRESS_OPTION_KEY ][ $name ]; } else { $data[ $name ] = $field['default']; } } } else { //other $data[ $name ] = $_POST[ REALPRESS_OPTION_KEY ][ $name ]; } $sanitize = $field['sanitize'] ?? 'text'; $data[ $name ] = Validation::sanitize_params_submitted( $data[ $name ], $sanitize ); } } update_option( Settings::get_option_key(), $data ); wp_redirect( Validation::sanitize_params_submitted( $_SERVER['HTTP_REFERER'] ) ); } }
Cancel