Customize: Allow button_labels to be overridden in $args passed to WP_Customize_Media_Control and WP_Customize_Image_Control.

Props chetanchauhan, celloexpressions.
See #33755.
Fixes #35542.

Built from https://develop.svn.wordpress.org/trunk@36769


git-svn-id: http://core.svn.wordpress.org/trunk@36736 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-02-29 00:40:26 +00:00
parent 5be4e67c8e
commit 0e5bb06cb8
3 changed files with 19 additions and 17 deletions

View File

@ -31,7 +31,7 @@ class WP_Customize_Image_Control extends WP_Customize_Upload_Control {
public function __construct( $manager, $id, $args = array() ) { public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args ); parent::__construct( $manager, $id, $args );
$this->button_labels = array( $this->button_labels = wp_parse_args( $this->button_labels, array(
'select' => __( 'Select Image' ), 'select' => __( 'Select Image' ),
'change' => __( 'Change Image' ), 'change' => __( 'Change Image' ),
'remove' => __( 'Remove' ), 'remove' => __( 'Remove' ),
@ -39,7 +39,7 @@ class WP_Customize_Image_Control extends WP_Customize_Upload_Control {
'placeholder' => __( 'No image selected' ), 'placeholder' => __( 'No image selected' ),
'frame_title' => __( 'Select Image' ), 'frame_title' => __( 'Select Image' ),
'frame_button' => __( 'Choose Image' ), 'frame_button' => __( 'Choose Image' ),
); ) );
} }
/** /**

View File

@ -55,7 +55,8 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
public function __construct( $manager, $id, $args = array() ) { public function __construct( $manager, $id, $args = array() ) {
parent::__construct( $manager, $id, $args ); parent::__construct( $manager, $id, $args );
$this->button_labels = array( if ( ! ( $this instanceof WP_Customize_Image_Control ) ) {
$this->button_labels = wp_parse_args( $this->button_labels, array(
'select' => __( 'Select File' ), 'select' => __( 'Select File' ),
'change' => __( 'Change File' ), 'change' => __( 'Change File' ),
'default' => __( 'Default' ), 'default' => __( 'Default' ),
@ -63,7 +64,8 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
'placeholder' => __( 'No file selected' ), 'placeholder' => __( 'No file selected' ),
'frame_title' => __( 'Select File' ), 'frame_title' => __( 'Select File' ),
'frame_button' => __( 'Choose File' ), 'frame_button' => __( 'Choose File' ),
); ) );
}
} }
/** /**
@ -193,8 +195,8 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
</div> </div>
<div class="actions"> <div class="actions">
<# if ( data.canUpload ) { #> <# if ( data.canUpload ) { #>
<button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button> <button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
<button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['change']; ?></button> <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
<div style="clear:both"></div> <div style="clear:both"></div>
<# } #> <# } #>
</div> </div>
@ -204,7 +206,7 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
<div class="placeholder"> <div class="placeholder">
<div class="inner"> <div class="inner">
<span> <span>
<?php echo $this->button_labels['placeholder']; ?> {{ data.button_labels.placeholder }}
</span> </span>
</div> </div>
</div> </div>
@ -212,10 +214,10 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
</div> </div>
<div class="actions"> <div class="actions">
<# if ( data.defaultAttachment ) { #> <# if ( data.defaultAttachment ) { #>
<button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button> <button type="button" class="button default-button">{{ data.button_labels.default }}</button>
<# } #> <# } #>
<# if ( data.canUpload ) { #> <# if ( data.canUpload ) { #>
<button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['select']; ?></button> <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button">{{ data.button_labels.select }}</button>
<# } #> <# } #>
<div style="clear:both"></div> <div style="clear:both"></div>
</div> </div>

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.5-beta1-36768'; $wp_version = '4.5-beta1-36769';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.