array( 'url' => $image_url, 'label' => $text_label ), * $value => array( 'url' => $image_url, 'label' => $text_label ), * )` * * @package Hybrid * @subpackage Customize * @author Justin Tadlock * @copyright Copyright (c) 2008 - 2015, Justin Tadlock * @link http://themehybrid.com/hybrid-core * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ /** * Radio image customize control. * * @since 3.0.0 * @access public */ class Hybrid_Customize_Control_Radio_Image extends WP_Customize_Control { /** * The type of customize control being rendered. * * @since 3.0.0 * @access public * @var string */ public $type = 'radio-image'; /** * Loads the framework scripts/styles. * * @since 3.0.0 * @access public * @return void */ public function enqueue() { wp_enqueue_script( 'hybrid-customize-controls' ); wp_enqueue_style( 'hybrid-customize-controls' ); } /** * Add custom parameters to pass to the JS via JSON. * * @since 3.0.0 * @access public * @return void */ public function to_json() { parent::to_json(); // We need to make sure we have the correct image URL. foreach ( $this->choices as $value => $args ) $this->choices[ $value ]['url'] = esc_url( hybrid_sprintf_theme_uri( $args['url'] ) ); $this->json['choices'] = $this->choices; $this->json['link'] = $this->get_link(); $this->json['value'] = $this->value(); $this->json['id'] = $this->id; } /** * Underscore JS template to handle the control's output. * * @since 3.0.0 * @access public * @return void */ public function content_template() { ?> <# if ( ! data.choices ) { return; } #> <# if ( data.label ) { #> {{ data.label }} <# } #> <# if ( data.description ) { #> {{{ data.description }}} <# } #> <# _.each( data.choices, function( args, choice ) { #> <# } ) #>