- public function tab_uploaded() {
- ?>
- <div class="uploaded-target"></div>
- <?php
- }
-
- public function print_tab_image( $url, $thumbnail_url = null ) {
- $url = set_url_scheme( $url );
- $thumbnail_url = ( $thumbnail_url ) ? set_url_scheme( $thumbnail_url ) : $url;
- ?>
- <a href="#" class="thumbnail" data-customize-image-value="<?php echo esc_url( $url ); ?>">
- <img src="<?php echo esc_url( $thumbnail_url ); ?>" />
- </a>
- <?php
- }
-}
-
-class WP_Customize_Background_Image_Control extends WP_Customize_Image_Control {
- public function __construct( $manager ) {
- parent::__construct( $manager, 'background_image', array(
- 'label' => __( 'Background Image' ),
- 'section' => 'background_image',
- 'context' => 'custom-background',
- 'get_url' => 'get_background_image',
- ) );
-
- if ( $this->setting->default )
- $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_background' ) );
- }
-
- public function tab_uploaded() {
- $backgrounds = get_posts( array(
- 'post_type' => 'attachment',
- 'meta_key' => '_wp_attachment_is_custom_background',
- 'meta_value' => $this->manager->get_stylesheet(),
- 'orderby' => 'none',
- 'nopaging' => true,
- ) );
-
- ?><div class="uploaded-target"></div><?php
-
- if ( empty( $backgrounds ) )
- return;
-
- foreach ( (array) $backgrounds as $background )
- $this->print_tab_image( esc_url_raw( $background->guid ) );
- }
-
- public function tab_default_background() {
- $this->print_tab_image( $this->setting->default );
- }
-}
-
-class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
- public function __construct( $manager ) {
- parent::__construct( $manager, 'header_image', array(
- 'label' => __( 'Header Image' ),
- 'settings' => array(
- 'default' => 'header_image',
- 'data' => 'header_image_data',
- ),
- 'section' => 'header_image',
- 'context' => 'custom-header',
- 'removed' => 'remove-header',
- 'get_url' => 'get_header_image',
- 'statuses' => array(
- '' => __('Default'),
- 'remove-header' => __('No Image'),
- 'random-default-image' => __('Random Default Image'),
- 'random-uploaded-image' => __('Random Uploaded Image'),
- )
- ) );
-
- $this->add_tab( 'default', __('Default'), array( $this, 'tab_default_headers' ) );
- }
-
- public function print_header_image( $choice, $header ) {
- $header['url'] = set_url_scheme( $header['url'] );
- $header['thumbnail_url'] = set_url_scheme( $header['thumbnail_url'] );
-
- $header_image_data = array( 'choice' => $choice );
- foreach ( array( 'attachment_id', 'width', 'height', 'url', 'thumbnail_url' ) as $key ) {
- if ( isset( $header[ $key ] ) )
- $header_image_data[ $key ] = $header[ $key ];
- }