Make WordPress Core

Ticket #30683: 30683.2.patch

File 30683.2.patch, 4.1 KB (added by ocean90, 10 years ago)
  • src/wp-admin/css/customize-controls.css

     
    605605}
    606606
    607607.customize-control-upload .remove-button,
     608.customize-control-upload .default-button,
    608609.customize-control-upload .upload-button,
    609610.customize-control-image .remove-button,
     611.customize-control-image .default-button,
    610612.customize-control-image .upload-button,
    611613.customize-control-header button.new,
    612614.customize-control-header button.remove {
     
    797799        border-radius: 2px;
    798800}
    799801
    800 .customize-control-upload .remove-button
    801 .customize-control-image .remove-button
     802.customize-control-upload .remove-button,
     803.customize-control-upload .default-button,
     804.customize-control-image .remove-button,
     805.customize-control-image .default-button,
    802806.customize-control-header .remove {
    803807        float: left;
    804808        margin-right: 3px;
  • src/wp-includes/class-wp-customize-control.php

     
    687687                $this->json['mime_type'] = $this->mime_type;
    688688                $this->json['button_labels'] = $this->button_labels;
    689689
     690                $current = $this->value();
     691
    690692                if ( is_object( $this->setting ) ) {
    691693                        if ( $this->setting->default ) {
    692694                                // Fake an attachment model - needs all fields used by template.
     
    704706                                $this->json['defaultAttachment'] = $default_attachment;
    705707                        }
    706708
    707                         // Get the attachment model for the existing file.
    708                         if ( $this->value() ) {
    709                                 $attachment_id = attachment_url_to_postid( $this->value() );
     709                        if ( $current && $this->setting->default && $current === $this->setting->default ) {
     710                                $this->json['attachment'] = $this->json['defaultAttachment'];
     711                        } elseif ( $current ) {
     712                                $attachment_id = attachment_url_to_postid( $current );
    710713                                if ( $attachment_id ) {
    711                                         $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id);
     714                                        $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
    712715                                }
    713                         } else if ( $this->setting->default ) {
    714                                 // Set the default as the attachment.
    715                                 $this->json['attachment'] = $default_attachment;
    716716                        }
    717717                }
    718718        }
     
    741741                        <# } #>
    742742                </label>
    743743
    744                 <# // Ensure that the default attachment is used if it exists.
    745                 if ( _.isEmpty( data.attachment ) && data.defaultAttachment ) {
    746                         data.attachment = data.defaultAttachment;
    747                 }
    748 
    749                 if ( data.attachment && data.attachment.id ) { #>
     744                <# if ( data.attachment && data.attachment.id ) { #>
    750745                        <div class="current">
    751746                                <div class="container">
    752747                                        <div class="attachment-media-view attachment-media-view-{{ data.attachment.type }} {{ data.attachment.orientation }}">
     
    773768                                </div>
    774769                        </div>
    775770                        <div class="actions">
    776                                 <# if ( data.defaultAttachment && data.defaultAttachment.id !== data.attachment.id ) { #>
    777                                         <button type="button" class="button default-button remove-button"><?php echo $this->button_labels['default']; ?></button>
    778                                 <# } else if ( ! data.defaultAttachment ) { #>
    779                                         <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
    780                                 <# } #>
     771                                <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
    781772                                <button type="button" class="button upload-button" id="{{ data.settings.default }}-button"><?php echo $this->button_labels['change']; ?></button>
    782773                                <div style="clear:both"></div>
    783774                        </div>
     
    795786                        </div>
    796787                        <div class="actions">
    797788                                <# if ( data.defaultAttachment ) { #>
    798                                         <button type="button" class="button default-button remove-button"><?php echo $this->button_labels['default']; ?></button>
     789                                        <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button>
    799790                                <# } #>
    800791                                <button type="button" class="button upload-button" id="{{ data.settings.default }}-button"><?php echo $this->button_labels['select']; ?></button>
    801792                                <div style="clear:both"></div>