Changeset 20319 for trunk/wp-includes/class-wp-customize-control.php
- Timestamp:
- 03/29/2012 06:35:54 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-customize-control.php
r20302 r20319 18 18 public $section = ''; 19 19 public $label = ''; 20 // @todo: remove control_params21 public $control_params = array();22 20 // @todo: remove choices 23 21 public $choices = array(); 24 22 23 public $json = array(); 24 25 25 public $visibility; 26 26 … … 36 36 */ 37 37 function __construct( $manager, $id, $args = array() ) { 38 $keys = array_keys( get_ class_vars( __CLASS__) );38 $keys = array_keys( get_object_vars( $this ) ); 39 39 foreach ( $keys as $key ) { 40 40 if ( isset( $args[ $key ] ) ) … … 91 91 } 92 92 93 public function json( $args = array() ) { 94 $settings = array(); 93 /** 94 * Refresh the parameters passed to the JavaScript via JSON. 95 * 96 * @since 3.4.0 97 */ 98 public function to_json() { 99 $this->json['settings'] = array(); 95 100 foreach ( $this->settings as $key => $setting ) { 96 $settings[ $key ] = $setting->id; 97 } 98 99 return array( 100 'type' => $this->type, 101 'params' => wp_parse_args( wp_parse_args( $args, array( 102 'settings' => $settings, 103 ) ), $this->control_params ), 104 ); 101 $this->json['settings'][ $key ] = $setting->id; 102 } 103 104 $this->json['type'] = $this->type; 105 106 if ( $this->visibility ) { 107 if ( is_string( $this->visibility ) ) { 108 $this->json['visibility'] = array( 109 'id' => $this->visibility, 110 'value' => true, 111 ); 112 } else { 113 $this->json['visibility'] = array( 114 'id' => $this->visibility[0], 115 'value' => $this->visibility[1], 116 ); 117 } 118 119 } 105 120 } 106 121 … … 259 274 <?php 260 275 break; 261 case 'upload':262 ?>263 <label>264 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>265 <div>266 <input type="hidden" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />267 <a href="#" class="button-secondary upload"><?php _e( 'Upload' ); ?></a>268 <a href="#" class="remove"><?php _e( 'Remove' ); ?></a>269 </div>270 </label>271 <?php272 break;273 case 'image':274 $value = $this->value();275 276 $image = $value;277 if ( isset( $this->control_params['get_url'] ) )278 $image = call_user_func( $this->control_params['get_url'], $image );279 280 ?>281 <label>282 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>283 <input type="hidden" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />284 <div class="customize-image-picker">285 <div class="thumbnail">286 <?php if ( empty( $image ) ): ?>287 <img style="display:none;" />288 <?php else: ?>289 <img src="<?php echo esc_url( $image ); ?>" />290 <?php endif; ?>291 </div>292 <div class="actions">293 <a href="#" class="upload"><?php _e( 'Upload New' ); ?></a>294 <a href="#" class="change"><?php _e( 'Change Image' ); ?></a>295 <a href="#" class="remove"><?php _e( 'Remove Image' ); ?></a>296 </div>297 <div class="library">298 <ul>299 <?php foreach ( $this->control_params['tabs'] as $tab ): ?>300 <li data-customize-tab='<?php echo esc_attr( $tab[0] ); ?>'>301 <?php echo esc_html( $tab[1] ); ?>302 </li>303 <?php endforeach; ?>304 </ul>305 <?php foreach ( $this->control_params['tabs'] as $tab ): ?>306 <div class="library-content" data-customize-tab='<?php echo esc_attr( $tab[0] ); ?>'>307 <?php call_user_func( $tab[2] ); ?>308 </div>309 <?php endforeach; ?>310 </div>311 </div>312 </label>313 <?php314 break;315 276 case 'dropdown-pages': 316 277 $dropdown = wp_dropdown_pages( … … 336 297 } 337 298 } 299 300 class WP_Customize_Upload_Control extends WP_Customize_Control { 301 public $type = 'upload'; 302 public $removed = ''; 303 public $context; 304 305 public function enqueue() { 306 wp_enqueue_script( 'wp-plupload' ); 307 } 308 309 public function to_json() { 310 parent::to_json(); 311 312 $this->json['removed'] = $this->removed; 313 314 if ( $this->context ) 315 $this->json['context'] = $this->context; 316 } 317 318 public function render_content() { 319 ?> 320 <label> 321 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> 322 <div> 323 <a href="#" class="button-secondary upload"><?php _e( 'Upload' ); ?></a> 324 <a href="#" class="remove"><?php _e( 'Remove' ); ?></a> 325 </div> 326 </label> 327 <?php 328 } 329 } 330 331 class WP_Customize_Image_Control extends WP_Customize_Upload_Control { 332 public $type = 'image'; 333 public $tabs = array(); 334 public $get_url; 335 336 public function render_content() { 337 $src = $this->value(); 338 if ( isset( $this->get_url ) ) 339 $src = call_user_func( $this->get_url, $src ); 340 341 ?> 342 <label> 343 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> 344 <div class="customize-image-picker"> 345 <div class="thumbnail"> 346 <?php if ( empty( $src ) ): ?> 347 <img style="display:none;" /> 348 <?php else: ?> 349 <img src="<?php echo esc_url( $src ); ?>" /> 350 <?php endif; ?> 351 </div> 352 <div class="actions"> 353 <a href="#" class="upload"><?php _e( 'Upload New' ); ?></a> 354 <a href="#" class="change"><?php _e( 'Change Image' ); ?></a> 355 <a href="#" class="remove"><?php _e( 'Remove Image' ); ?></a> 356 </div> 357 <div class="library"> 358 <ul> 359 <?php foreach ( $this->tabs as $tab ): ?> 360 <li data-customize-tab='<?php echo esc_attr( $tab[0] ); ?>'> 361 <?php echo esc_html( $tab[1] ); ?> 362 </li> 363 <?php endforeach; ?> 364 </ul> 365 <?php foreach ( $this->tabs as $tab ): ?> 366 <div class="library-content" data-customize-tab='<?php echo esc_attr( $tab[0] ); ?>'> 367 <?php call_user_func( $tab[2] ); ?> 368 </div> 369 <?php endforeach; ?> 370 </div> 371 </div> 372 </label> 373 <?php 374 } 375 }
Note: See TracChangeset
for help on using the changeset viewer.