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; } }