Skip to content

Commit 3bb2e13

Browse files
committed
Refactor Browse string to Choose File
Browse is not part of the Wordpress translatation file so it doesn't get translated. Choose File is and will be translated according to the langauge Wordpress is set. Also add option to pass button label. Signed-off-by: Roi Dayan <[email protected]>
1 parent eaacd6a commit 3bb2e13

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

example/oop-example.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ function get_settings_fields() {
130130
'label' => __( 'File', 'wedevs' ),
131131
'desc' => __( 'File description', 'wedevs' ),
132132
'type' => 'file',
133-
'default' => ''
133+
'default' => '',
134+
'options' => array(
135+
'button_label' => 'Choose Image'
136+
)
134137
)
135138
),
136139
'wedevs_advanced' => array(

src/class.settings-api.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,12 @@ function callback_file( $args ) {
343343
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
344344
$size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
345345
$id = $args['section'] . '[' . $args['id'] . ']';
346+
$label = isset( $args['options']['button_label'] ) ?
347+
$args['options']['button_label'] :
348+
__( 'Choose File' );
346349

347350
$html = sprintf( '<input type="text" class="%1$s-text wpsa-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
348-
$html .= '<input type="button" class="button wpsa-browse" value="'.__( 'Browse' ).'" />';
351+
$html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />';
349352
$html .= $this->get_field_description( $args );
350353

351354
echo $html;

0 commit comments

Comments
 (0)