| Server IP : 146.59.209.152 / Your IP : 216.73.216.46 Web Server : Apache System : Linux webm005.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : infrafs ( 43850) PHP Version : 8.2.29 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/infrafs/bike/wp-content/themes/colibri-wp/inc/src/Customizer/Controls/ |
Upload File : |
<?php
namespace ColibriWP\Theme\Customizer\Controls;
use ColibriWP\Theme\Translations;
use WP_Customize_Control;
use WP_Customize_Manager;
use WP_Error;
class ColibriControl extends WP_Customize_Control {
const DEFAULT_COLIBRI_TAB = 'content';
const STYLE_COLIBRI_TAB = 'style';
protected $colibri_tab = self::DEFAULT_COLIBRI_TAB;
protected $default = '';
private $extra_json_params = array();
public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) {
parent::__construct( $manager, $id, $args );
$exclude_keys = array_merge(
array_keys( get_object_vars( $this ) ),
array(
"transport",
"colibri_selective_refresh_key",
"colibri_selective_refresh_class",
"css_output",
)
);
$args_keys = array_keys( $args );
$extra_json_params = array_diff( $args_keys, $exclude_keys );
foreach ( $extra_json_params as $param ) {
$this->extra_json_params[ $param ] = $args[ $param ];
}
}
/**
* Default sanitization function for Colibri Controls.
* This is added to force a sanitization implementation for each Colibri Control
*
* @param $value
* @param $control_data
*
* @param string $default
*
* @return mixed
*/
public static function sanitize( $value, $control_data, $default = '' ) {
return new WP_Error( 'colibri_undefined_sanitize_function_for_control',
Translations::get( 'undefined_sanitize_function_for_control', array( $control_data['type'] ) ) );
}
public function json() {
$json = parent::json();
$json_data = $this->extra_json_params;
$json['choices'] = $this->choices;
$json['colibri_tab'] = $this->colibri_tab;
return array_merge( $json, $json_data );
}
protected function hasParam( $name, $in_extra = true ) {
if ( property_exists( $this, $name ) ) {
return true;
}
if ( $in_extra && array_key_exists( $name, $this->extra_json_params ) ) {
return true;
}
return false;
}
protected function getParam( $name, $default = null, $in_extra = true ) {
if ( property_exists( $this, $name ) ) {
return $this->{$name};
}
if ( $in_extra && array_key_exists( $name, $this->getExtraJsonParams() ) ) {
return $this->getExtraJsonParams()[ $name ];
}
return null;
}
/**
* @return array
*/
public function getExtraJsonParams() {
return $this->extra_json_params;
}
protected function getProps( $props = array() ) {
$props = is_array( $props ) ? $props : array( $props );
$props = array_flip( $props );
foreach ( $props as $key => $prop ) {
$props[ $key ] = null;
if ( property_exists( $this, $key ) ) {
$props[ $key ] = $this->$key;
}
}
return $props;
}
}