[], ]; } /** * Render select control output in the editor. * * Used to generate the control HTML in the editor using Underscore JS * template. The variables for the class are available using `data` JS * object. * * @since 1.0.0 * @access public */ public function content_template() { $control_uid = $this->get_control_uid(); ?>
<# if ( data.label ) {#> <# } #>
<# if ( data.description ) { #>
{{{ data.description }}}
<# } #> validate_value( $value, $config ); } /** * Validate the value is listed in the control options config. * * Avoid change settings like `html_tag` & `title_size` to a `script` tag. * * @param string $value * @param array $config * * @return mixed|string */ private function validate_value( $value, array $config ) { $is_valid = false; // Handle options groups. if ( isset( $config['groups'] ) ) { foreach ( $config['groups'] as $index => $group ) { if ( isset( $group['options'][ $value ] ) ) { $is_valid = true; break; } } } else { $is_valid = isset( $config['options'][ $value ] ); } // If it's not one of the control options. reset it to default. if ( ! $is_valid ) { $value = $config['default']; } return $value; } }