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

git-svn-id: https://develop.svn.wordpress.org/trunk@20261 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith 2012-03-22 07:30:44 +00:00
parent 7dc476bd8b
commit f28d57454f
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 );
}
});