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. git-svn-id: https://develop.svn.wordpress.org/trunk@36769 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
92dbe29078
commit
f60e7fd99d
|
@ -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' ),
|
||||||
);
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue