From faa72918e766ef8bc5f407322a1b1b81b58a9d5a Mon Sep 17 00:00:00 2001 From: Barry Ceelen Date: Mon, 29 Aug 2016 16:45:25 +0200 Subject: [PATCH 1/4] Make 'Select File' label translatable --- classes.fields.php | 8 +++++++- js/file-upload.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/classes.fields.php b/classes.fields.php index bc9238f7..cfcd391f 100644 --- a/classes.fields.php +++ b/classes.fields.php @@ -427,7 +427,8 @@ public function get_default_args() { return array_merge( parent::get_default_args(), array( - 'library-type' => array( 'video', 'audio', 'text', 'application' ) + 'library-type' => array( 'video', 'audio', 'text', 'application' ), + 'string-select-file' => esc_html__( 'Select File', 'cmb' ), ) ); } @@ -442,6 +443,11 @@ function enqueue_scripts() { wp_enqueue_media( array( 'post' => $post_ID )); wp_enqueue_script( 'cmb-file-upload', trailingslashit( CMB_URL ) . 'js/file-upload.js', array( 'jquery', 'cmb-scripts' ) ); + wp_localize_script( 'cmb-file-upload', 'CMBFile', array( + 'strings' => array( + 'selectFile' => $this->args['string-select-file'], + ) + ) ); } public function html() { diff --git a/js/file-upload.js b/js/file-upload.js index d03d0a4a..d92be666 100644 --- a/js/file-upload.js +++ b/js/file-upload.js @@ -9,7 +9,7 @@ jQuery( document ).ready( function() { var frameArgs = { multiple: false, - title: 'Select File', + title: CMBFile.strings.selectFile } library = container.attr( 'data-type' ).split(','); From 5efe115c84aab844efa4299ae733d1f5c046df9d Mon Sep 17 00:00:00 2001 From: Barry Ceelen Date: Mon, 29 Aug 2016 17:54:03 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Make=20'Select=20Image=E2=80=99=20label=20t?= =?UTF-8?q?ranslatable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes.fields.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes.fields.php b/classes.fields.php index cfcd391f..858d0092 100644 --- a/classes.fields.php +++ b/classes.fields.php @@ -511,9 +511,10 @@ public function get_default_args() { return array_merge( parent::get_default_args(), array( - 'size' => 'thumbnail', - 'library-type' => array( 'image' ), - 'show_size' => false + 'size' => 'thumbnail', + 'library-type' => array( 'image' ), + 'show_size' => false, + 'string-select-file' => esc_html__( 'Select Image', 'cmb' ), ) ); } From 74d5d4ecede5278231b7d8830bb79a8c88eb87f1 Mon Sep 17 00:00:00 2001 From: Barry Ceelen Date: Fri, 24 Mar 2017 17:40:11 +0100 Subject: [PATCH 3/4] Re-add file field strings and script localization --- fields/class-cmb-file-field.php | 7 +++++++ fields/class-cmb-image-field.php | 1 + 2 files changed, 8 insertions(+) diff --git a/fields/class-cmb-file-field.php b/fields/class-cmb-file-field.php index 929f2e3b..be6dba60 100644 --- a/fields/class-cmb-file-field.php +++ b/fields/class-cmb-file-field.php @@ -29,6 +29,7 @@ public function default_args() { 'text', 'application', ), + 'string-select-file' => esc_html__( 'Select File', 'cmb' ), ) ); } @@ -48,6 +49,12 @@ function enqueue_scripts() { wp_enqueue_media( array( 'post' => $post_ID ) ); wp_enqueue_script( 'cmb-file-upload', trailingslashit( CMB_URL ) . 'js/file-upload.js', array( 'jquery', 'cmb-scripts' ), CMB_VERSION ); + wp_localize_script( 'cmb-file-upload', 'CMBFile', array( + 'strings' => array( + 'selectFile' => $this->args['string-select-file'], + ) + ) ); + } /** diff --git a/fields/class-cmb-image-field.php b/fields/class-cmb-image-field.php index 66ccfc60..4efeced2 100644 --- a/fields/class-cmb-image-field.php +++ b/fields/class-cmb-image-field.php @@ -26,6 +26,7 @@ public function default_args() { 'image', ), 'show_size' => false, + 'string-select-file' => esc_html__( 'Select Image', 'cmb' ), ) ); } From 5c753b21584a6e026ad2e1584fe9449223bfb260 Mon Sep 17 00:00:00 2001 From: Barry Ceelen Date: Fri, 24 Mar 2017 17:44:52 +0100 Subject: [PATCH 4/4] Add trailing comma to last line in array --- fields/class-cmb-file-field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fields/class-cmb-file-field.php b/fields/class-cmb-file-field.php index be6dba60..9a3b60a5 100644 --- a/fields/class-cmb-file-field.php +++ b/fields/class-cmb-file-field.php @@ -52,7 +52,7 @@ function enqueue_scripts() { wp_localize_script( 'cmb-file-upload', 'CMBFile', array( 'strings' => array( 'selectFile' => $this->args['string-select-file'], - ) + ), ) ); }