-
-
+
+
+ <# // Ensure that the default attachment is used if it exists.
+ if ( _.isEmpty( data.attachment ) && data.defaultAttachment ) {
+ data.attachment = data.defaultAttachment;
+ }
+
+ if ( data.attachment && data.attachment.id ) { #>
+
-
+
button_labels['change']; ?>
+ <# if ( data.defaultAttachment && data.defaultAttachment.id !== data.attachment.id ) { #>
+
button_labels['default']; ?>
+ <# } else { #>
+
button_labels['remove']; ?>
+ <# } #>
+ <# } else { #>
+
button_labels['placeholder']; ?>
+
button_labels['select']; ?>
+ <# if ( ! data.defaultAttachment ) { #>
+
button_labels['default']; ?>
+ <# } #>
+ <# } #>
statuses = array( '' => __('No Image') );
-
+ public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args );
- $this->add_tab( 'upload-new', __('Upload New'), array( $this, 'tab_upload_new' ) );
- $this->add_tab( 'uploaded', __('Uploaded'), array( $this, 'tab_uploaded' ) );
-
- // Early priority to occur before $this->manager->prepare_controls();
- add_action( 'customize_controls_init', array( $this, 'prepare_control' ), 5 );
+ $this->button_labels = array(
+ 'select' => __( 'Select Image' ),
+ 'change' => __( 'Change Image' ),
+ 'remove' => __( 'Remove' ),
+ 'default' => __( 'Default' ),
+ 'placeholder' => __( 'No image selected' ),
+ 'frame_title' => __( 'Select Image' ),
+ 'frame_button' => __( 'Choose Image' ),
+ );
}
/**
- * Prepares the control.
- *
- * If no tabs exist, removes the control from the manager.
- *
* @since 3.4.2
+ * @deprecated 4.1.0
*/
- public function prepare_control() {
- if ( ! $this->tabs )
- $this->manager->remove_control( $this->id );
- }
+ public function prepare_control() {}
/**
- * Refresh the parameters passed to the JavaScript via JSON.
- *
* @since 3.4.0
- * @uses WP_Customize_Upload_Control::to_json()
- */
- public function to_json() {
- parent::to_json();
- $this->json['statuses'] = $this->statuses;
- }
-
- /**
- * Render the control's content.
+ * @deprecated 4.1.0
*
- * @since 3.4.0
- */
- public function render_content() {
- $src = $this->value();
- if ( isset( $this->get_url ) )
- $src = call_user_func( $this->get_url, $src );
-
- ?>
-
- label ) ) : ?>
-
label ); ?>
- description ) ) : ?>
-
description; ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- tabs as $id => $tab ): ?>
- -
-
-
-
-
- tabs as $id => $tab ): ?>
-
-
-
-
-
-
-
-
- tabs[ $id ] = array(
- 'label' => $label,
- 'callback' => $callback,
- );
- }
+ public function add_tab( $id, $label, $callback ) {}
/**
- * Remove a tab from the control.
- *
* @since 3.4.0
+ * @deprecated 4.1.0
*
* @param string $id
*/
- public function remove_tab( $id ) {
- unset( $this->tabs[ $id ] );
- }
+ public function remove_tab( $id ) {}
/**
* @since 3.4.0
- */
- public function tab_upload_new() {
- if ( ! _device_can_upload() ) {
- echo '
' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the native app for your device instead.'), 'https://apps.wordpress.org/' ) . '
';
- } else {
- ?>
-
- select a file.'); ?>
-
-
-
-
-
-
-
-
-
-
- __( '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' ) );
}
-
- /**
- * @since 3.4.0
- */
- 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,
- ) );
-
- ?>
print_tab_image( esc_url_raw( $background->guid ) );
- }
-
- /**
- * @since 3.4.0
- * @uses WP_Customize_Image_Control::print_tab_image()
- */
- public function tab_default_background() {
- $this->print_tab_image( $this->setting->default );
- }
}
class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
Index: src/wp-includes/class-wp-customize-manager.php
===================================================================
--- src/wp-includes/class-wp-customize-manager.php (revision 30297)
+++ src/wp-includes/class-wp-customize-manager.php (working copy)
@@ -965,6 +965,8 @@
/* Control Types (custom control classes) */
$this->register_control_type( 'WP_Customize_Color_Control' );
+ $this->register_control_type( 'WP_Customize_Upload_Control' );
+ $this->register_control_type( 'WP_Customize_Image_Control' );
/* Site Title & Tagline */