WordPress.org

Make WordPress Core

Changeset 21724


Ignore:
Timestamp:
09/04/12 04:54:01 (2 years ago)
Author:
nacin
Message:

Remove custom header uploads from the customizer.

For the 3.4 branch. It will return when crop ability is added.

props koopersmith.
see #21355. fixes #21515. fixes #21707.
merges [21379] [21380] [21383] [21385] [21386] [21497] [21722].

Location:
branches/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.4/wp-admin/js/customize-controls.dev.js

    r21136 r21724  
    221221            }); 
    222222 
    223             // Select a tab 
    224             this.selected = this.tabs[ panels.first().data('customizeTab') ]; 
    225             this.selected.both.addClass('library-selected'); 
    226  
    227223            // Bind tab switch events 
    228224            this.library.children('ul').on( 'click', 'li', function( event ) { 
     
    255251                    this.tabs.uploaded.both.addClass('hidden'); 
    256252            } 
     253 
     254            // Select a tab 
     255            panels.each( function() { 
     256                var tab = control.tabs[ $(this).data('customizeTab') ]; 
     257 
     258                // Select the first visible tab. 
     259                if ( ! tab.link.hasClass('hidden') ) { 
     260                    control.selected = tab; 
     261                    tab.both.addClass('library-selected'); 
     262                    return false; 
     263                } 
     264            }); 
    257265 
    258266            this.dropdownInit(); 
  • branches/3.4/wp-includes/class-wp-customize-control.php

    r21037 r21724  
    322322        $this->add_tab( 'upload-new', __('Upload New'), array( $this, 'tab_upload_new' ) ); 
    323323        $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 ); 
    324339    } 
    325340 
     
    456471 
    457472class 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 
    458487    public function __construct( $manager ) { 
    459488        parent::__construct( $manager, 'header_image', array( 
     
    475504        ) ); 
    476505 
    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(); 
    478534    } 
    479535 
     
    499555 
    500556    public function tab_uploaded() { 
    501         $headers = get_uploaded_header_images(); 
    502  
    503557        ?><div class="uploaded-target"></div><?php 
    504558 
    505         foreach ( $headers as $choice => $header ) 
     559        foreach ( $this->uploaded_headers as $choice => $header ) 
    506560            $this->print_header_image( $choice, $header ); 
    507561    } 
    508562 
    509563    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 ) 
    514565            $this->print_header_image( $choice, $header ); 
    515566    } 
  • branches/3.4/wp-includes/js/plupload/wp-plupload.dev.js

    r21014 r21724  
    7474        } 
    7575 
     76        // If the uploader has neither a browse button nor a dropzone, bail. 
     77        if ( ! ( this.browser && this.browser.length ) && ! ( this.dropzone && this.dropzone.length ) ) 
     78            return; 
     79 
    7680        this.uploader = new plupload.Uploader( this.plupload ); 
    7781        delete this.plupload; 
     
    114118        }( this.dropzone, this.supports.dragdrop )); 
    115119 
    116         this.browser.on( 'mouseenter', this.refresh ); 
     120        if ( this.browser ) { 
     121            this.browser.on( 'mouseenter', this.refresh ); 
     122        } else { 
     123            this.uploader.disableBrowse( true ); 
     124            // If HTML5 mode, hide the auto-created file container. 
     125            $('#' + this.uploader.id + '_html5_container').hide(); 
     126        } 
    117127 
    118128        this.uploader.bind( 'UploadProgress', this.progress ); 
Note: See TracChangeset for help on using the changeset viewer.