Make WordPress Core


Ignore:
Timestamp:
09/04/2012 04:54:01 AM (12 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].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.