| Server IP : 38.190.208.107 / Your IP : 216.73.217.13 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 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,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.12/wp-content/themes/dt-the7/inc/classes/ |
Upload File : |
<?php
/**
* Config class.
*
* @since presscore 1.0
*/
interface Presscore_Config_Interface {
public function set( $name, $value = null, $default = null );
public function reset( $options = array() );
public function get( $name = '', $default = null );
}
/**
* Singleton.
*
*/
class Presscore_Config implements Presscore_Config_Interface{
public static function get_instance() {
if ( !self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
public static $instance = null;
private $meta_prefix = '';
private $post_id = 0;
private $page_id = 0;
private $options = array();
/**
* Description here
*
* @param string $name Setting name
* @param mixed $value Setting value
* @param mixed $default Setting default value, used if $value === '' or $value === null
*/
public function set( $name, $value = null, $default = null ) {
if ( ('' === $value || null === $value) && isset($default) ) {
$this->options[ $name ] = $default;
} else {
$this->options[ $name ] = $value;
}
}
public function reset( $options = array() ) {
$this->options = $options;
}
public function get( $name = '', $default = null ) {
if ( '' == $name ) {
return $this->options;
}
if ( isset( $this->options[ $name ] ) ) {
return $this->options[ $name ];
}
return $default;
}
public function get_bool( $name = '', $default = null ) {
$value = $this->get( $name, $default );
return in_array( $value, array( '1', 'true', 'y', 'on', 'enabled' ) );
}
public function set_meta_prefix( $meta_prefix = '' ) {
$this->meta_prefix = (string) $meta_prefix;
}
public function get_meta_prefix() {
return $this->meta_prefix;
}
public function set_post_id( $post_id = 0 ) {
$this->post_id = absint( $post_id );
}
public function get_post_id() {
return $this->post_id;
}
public function set_page_id( $page_id = 0 ) {
$this->page_id = absint( $page_id );
}
public function get_page_id() {
return $this->page_id;
}
public function map( $options ) {
if ( is_array( $options ) ) {
foreach ( $options as $opt_name=>$opt_data ) {
$opt_data = array_values( (array) $opt_data );
if ( count( $opt_data ) >= 2 ) {
$opt_type = $opt_data[0];
$opt_val = $opt_data[1];
$def = isset( $opt_data[2] ) ? $opt_data[2] : null;
switch( $opt_type ) {
case 'meta':
$this->set_meta( $opt_name, $opt_val, $def );
break;
case 'option':
$this->set_option( $opt_name, $opt_val, $def );
break;
case 'value':
$this->set( $opt_name, $opt_val, $def );
break;
}
}
}
}
}
public function set_meta( $name, $meta_key, $default = null ) {
$meta_value = null;
if ( $this->post_id ) {
$meta_value = get_post_meta( $this->post_id, $this->meta_prefix . $meta_key, true );
}
$this->set( $name, $meta_value, $default );
}
public function set_option( $name, $option_key, $default = null ) {
$this->set( $name, $this->get_option( $option_key ), $default );
}
/**
* Debug method. Dump setting array that contains $search_name. If $search_name is empty - dump all stored settings.
*
* @since 4.1.4
* @param string $search_name Setting name for search
*/
public function dump( $search_name = '' ) {
echo '<pre style="background-color: #F1F1F1; padding: 10px;">';
echo '<span style="background-color: #FFFFFF; color: red;">' . __METHOD__ . ' => ' . $search_name . '</span></br>';
if ( $search_name ) {
$options = array();
foreach ( $this->options as $option_name => $value ) {
if ( false !== strpos($option_name, $search_name) ) {
$options[ $option_name ] = $value;
}
}
var_dump( $options );
} else {
var_dump( $this->options );
}
echo '</pre>';
}
protected function get_option( $name ) {
return of_get_option( $name );
}
}