Advertisement
Guest User

Custom Image Select Class for Options Framework

a guest
Feb 5th, 2013
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement