Make WordPress Core

Ticket #21355: 21355-for-branch.diff

File 21355-for-branch.diff, 4.7 KB (added by koopersmith, 11 years ago)

Port for the 3.4 branch.

  • wp-includes/js/plupload/wp-plupload.dev.js

     
    113113                        });
    114114                }( this.dropzone, this.supports.dragdrop ));
    115115
    116                 this.browser.on( 'mouseenter', this.refresh );
     116                if ( this.browser ) {
     117                        this.browser.on( 'mouseenter', this.refresh );
     118                } else {
     119                        this.uploader.disableBrowse( true );
     120                        // If HTML5 mode, hide the auto-created file container.
     121                        $('#' + this.uploader.id + '_html5_container').hide();
     122                }
    117123
    118124                this.uploader.bind( 'UploadProgress', this.progress );
    119125
  • wp-includes/class-wp-customize-control.php

     
    321321
    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 );
    324327        }
    325328
     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 );
     339        }
     340
    326341        public function to_json() {
    327342                parent::to_json();
    328343                $this->json['statuses'] = $this->statuses;
     
    455470}
    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(
    460489                        'label'    => __( 'Header Image' ),
     
    474503                        )
    475504                ) );
    476505
    477                 $this->add_tab( 'default',  __('Default'),  array( $this, 'tab_default_headers' ) );
     506                // Remove the upload tab.
     507                $this->remove_tab( 'upload-new' );
    478508        }
    479509
     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
     520                // Process default headers and uploaded headers.
     521                $custom_image_header->process_default_headers();
     522                $this->default_headers = $custom_image_header->default_headers;
     523                $this->uploaded_headers = get_uploaded_header_images();
     524
     525                if ( $this->default_headers )
     526                        $this->add_tab( 'default',  __('Default'),  array( $this, 'tab_default_headers' ) );
     527
     528                if ( ! $this->uploaded_headers )
     529                        $this->remove_tab( 'uploaded' );
     530
     531                return parent::prepare_control();
     532        }
     533
    480534        public function print_header_image( $choice, $header ) {
    481535                $header['url']           = set_url_scheme( $header['url'] );
    482536                $header['thumbnail_url'] = set_url_scheme( $header['thumbnail_url'] );
     
    498552        }
    499553
    500554        public function tab_uploaded() {
    501                 $headers = get_uploaded_header_images();
    502 
    503555                ?><div class="uploaded-target"></div><?php
    504556
    505                 foreach ( $headers as $choice => $header )
     557                foreach ( $this->uploaded_headers as $choice => $header )
    506558                        $this->print_header_image( $choice, $header );
    507559        }
    508560
    509561        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 )
     562                foreach ( $this->default_headers as $choice => $header )
    514563                        $this->print_header_image( $choice, $header );
    515564        }
    516565}
     566 No newline at end of file
  • wp-admin/js/customize-controls.dev.js

     
    220220                                };
    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 ) {
    229225                                var id  = $(this).data('customizeTab'),
     
    255251                                        this.tabs.uploaded.both.addClass('hidden');
    256252                        }
    257253
     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                        });
     265
    258266                        this.dropdownInit();
    259267                },
    260268                success: function( attachment ) {