Changeset 21724 for branches/3.4/wp-includes/class-wp-customize-control.php
- Timestamp:
- 09/04/2012 04:54:01 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.4/wp-includes/class-wp-customize-control.php
r21037 r21724 322 322 $this->add_tab( 'upload-new', __('Upload New'), array( $this, 'tab_upload_new' ) ); 323 323 $this->add_tab( 'uploaded', __('Uploaded'), array( $this, 'tab_uploaded' ) ); 324 325 // Early priority to occur before $this->manager->prepare_controls(); 326 add_action( 'customize_controls_init', array( $this, 'prepare_control' ), 5 ); 327 } 328 329 /** 330 * Prepares the control. 331 * 332 * If no tabs exist, removes the control from the manager. 333 * 334 * @since 3.4.2 335 */ 336 public function prepare_control() { 337 if ( ! $this->tabs ) 338 $this->manager->remove_control( $this->id ); 324 339 } 325 340 … … 456 471 457 472 class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control { 473 /** 474 * The processed default headers. 475 * @since 3.4.2 476 * @var array 477 */ 478 protected $default_headers; 479 480 /** 481 * The uploaded headers. 482 * @since 3.4.2 483 * @var array 484 */ 485 protected $uploaded_headers; 486 458 487 public function __construct( $manager ) { 459 488 parent::__construct( $manager, 'header_image', array( … … 475 504 ) ); 476 505 477 $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_headers' ) ); 506 // Remove the upload tab. 507 $this->remove_tab( 'upload-new' ); 508 } 509 510 /** 511 * Prepares the control. 512 * 513 * If no tabs exist, removes the control from the manager. 514 * 515 * @since 3.4.2 516 */ 517 public function prepare_control() { 518 global $custom_image_header; 519 if ( empty( $custom_image_header ) ) 520 return parent::prepare_control(); 521 522 // Process default headers and uploaded headers. 523 $custom_image_header->process_default_headers(); 524 $this->default_headers = $custom_image_header->default_headers; 525 $this->uploaded_headers = get_uploaded_header_images(); 526 527 if ( $this->default_headers ) 528 $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_headers' ) ); 529 530 if ( ! $this->uploaded_headers ) 531 $this->remove_tab( 'uploaded' ); 532 533 return parent::prepare_control(); 478 534 } 479 535 … … 499 555 500 556 public function tab_uploaded() { 501 $headers = get_uploaded_header_images();502 503 557 ?><div class="uploaded-target"></div><?php 504 558 505 foreach ( $ headers as $choice => $header )559 foreach ( $this->uploaded_headers as $choice => $header ) 506 560 $this->print_header_image( $choice, $header ); 507 561 } 508 562 509 563 public function tab_default_headers() { 510 global $custom_image_header; 511 $custom_image_header->process_default_headers(); 512 513 foreach ( $custom_image_header->default_headers as $choice => $header ) 564 foreach ( $this->default_headers as $choice => $header ) 514 565 $this->print_header_image( $choice, $header ); 515 566 }
Note: See TracChangeset
for help on using the changeset viewer.