Theme Customizer: Only show uploader 'remove' links when there is an image to remove. see #19910.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith 2012-03-22 07:30:44 +00:00
parent 5443bec597
commit c6ae8b8e51
2 changed files with 10 additions and 2 deletions

View File

@ -398,13 +398,15 @@ class WP_Customize_Setting {
<?php
break;
case 'upload':
$value = $this->value();
$style = empty( $value ) ? 'style="display:none;"' : '';
?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<div>
<input type="hidden" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->name(); ?> />
<a href="#" class="button-secondary upload"><?php _e( 'Upload' ); ?></a>
<a href="#" class="remove"><?php _e( 'Remove' ); ?></a>
<a href="#" class="remove" <?php echo $style; ?>><?php _e( 'Remove' ); ?></a>
</div>
</label>
<?php

View File

@ -83,10 +83,16 @@
}
});
this.container.on( 'click', '.remove', function( event ) {
this.remover = this.container.find('.remove');
this.remover.click( function( event ) {
control.set('');
event.preventDefault();
});
this.bind( this.removerVisibility );
},
removerVisibility: function( on ) {
this.remover.toggle( !! on );
}
});