daily pastebin goal
53%
SHARE
TWEET

Custom Image Select Class for Options Framework

a guest Feb 5th, 2013 110 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. class CustomizeImageListControl extends \WP_Customize_Control {
  2.        
  3.         protected function render_content() {
  4.                 if ( empty( $this->choices ) )
  5.                         return;
  6.  
  7.                 $name = '_customize-radio-' . $this->id;
  8.  
  9.                 ?>
  10.                 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
  11.                 <?php
  12.                
  13.                
  14.                 foreach ( $this->choices as $value => $label ) :
  15.  
  16.                         $selected = '';
  17.                         $checked = '';
  18.                         if ( $this->value() != '' ) {
  19.                                 if ( $this->value() == $value ) {
  20.                                         $selected = ' of-radio-img-selected';
  21.                                         $checked = ' checked="checked"';
  22.                                 }
  23.                         }
  24.                         echo '<label><input type="radio" id="' . esc_attr( $name .'_'. $value) . '" class="of-radio-img-radio" value="' . esc_attr( $value ) . '" name="' . esc_attr( $name ) . '" '. $checked .' '. $this->get_link() .' />';
  25.                         echo '<div class="of-radio-img-label">' . esc_html( $value ) . '</div>';
  26.                         echo '<img src="' . esc_url( $label ) . '" alt="' . $label .'" class="of-radio-img-img' . $selected .'"
  27.                                         onclick="jQuery(\'#'. esc_attr($name .'_'. $value) .'\').click();" /></label>';
  28.  
  29.                 endforeach;
  30.                
  31.         }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top