From 957e8314b1644c11bf32fcc3de5284ee234033a1 Mon Sep 17 00:00:00 2001 From: Alex Lion Date: Fri, 7 Jun 2019 22:25:07 +0800 Subject: [PATCH 1/3] Declare and Define Text Domain and Domain Path Declare and define Text Domain and Domain Path, add missing Text Domain which is the same as plugin's slug. --- external-media-without-import.php | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/external-media-without-import.php b/external-media-without-import.php index 8d24845..8bd0bce 100644 --- a/external-media-without-import.php +++ b/external-media-without-import.php @@ -5,6 +5,8 @@ Version: 1.1.2 Author: Zhixiang Zhu Author URI: http://zxtechart.com +Text Domain: external-media-without-import +Domain Path: /languages License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0-standalone.html @@ -25,6 +27,7 @@ namespace emwi; function init_emwi() { + $domain = 'external-media-without-import'; $style = 'emwi-css'; $css_file = plugins_url( '/external-media-without-import.css', __FILE__ ); wp_register_style( $style, $css_file ); @@ -55,9 +58,7 @@ function init_emwi() { add_filter( 'get_attached_file', function( $file, $attachment_id ) { if ( empty( $file ) ) { $post = get_post( $attachment_id ); - if ( get_post_type( $post ) == 'attachment' ) { - return $post->guid; - } + return $post->guid; } return $file; }, 10, 2 ); @@ -65,8 +66,8 @@ function init_emwi() { function add_submenu() { add_submenu_page( 'upload.php', - __( 'Add External Media without Import' ), - __( 'Add External Media without Import' ), + __( 'Add External Media without Import', 'external-media-without-import' ), + __( 'Add External Media without Import', 'external-media-without-import' ), 'manage_options', 'add-external-media-without-import', 'emwi\print_submenu_page' @@ -78,17 +79,17 @@ function post_upload_ui() { ?>
- +
- +
@@ -107,29 +108,29 @@ function print_submenu_page() { function print_media_new_panel( $is_in_upload_ui ) { ?>
style="display: none"> - - + +
style="display: none">
- +
- + - + - +
- - + + - +
@@ -190,14 +191,14 @@ function sanitize_and_validate_input() { $width_str = $input['width']; $width_int = intval( $width_str ); if ( ! empty( $width_str ) && $width_int <= 0 ) { - $input['error'] = _('Width and height must be non-negative integers.'); + $input['error'] = _('Width and height must be non-negative integers.', 'external-media-without-import' ); return $input; } $height_str = $input['height']; $height_int = intval( $height_str ); if ( ! empty( $height_str ) && $height_int <= 0 ) { - $input['error'] = _('Width and height must be non-negative integers.'); + $input['error'] = _('Width and height must be non-negative integers.', 'external-media-without-import' ); return $input; } From 60aa141947f3aa1c818ba74a1d183868a5c03af4 Mon Sep 17 00:00:00 2001 From: Alex Lion Date: Fri, 7 Jun 2019 23:09:48 +0800 Subject: [PATCH 2/3] Minor Code Modification Line 116. --- external-media-without-import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external-media-without-import.php b/external-media-without-import.php index 8bd0bce..5f68d27 100644 --- a/external-media-without-import.php +++ b/external-media-without-import.php @@ -113,7 +113,7 @@ function print_media_new_panel( $is_in_upload_ui ) {
style="display: none">
- +
From e5f92efc5ecd347bf53bb512639d55bc3e28ba46 Mon Sep 17 00:00:00 2001 From: Alex Lion Date: Sat, 14 Aug 2021 23:05:16 -0700 Subject: [PATCH 3/3] Fix L10N Issues --- external-media-without-import.php | 38 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/external-media-without-import.php b/external-media-without-import.php index 5f68d27..2563288 100644 --- a/external-media-without-import.php +++ b/external-media-without-import.php @@ -5,10 +5,9 @@ Version: 1.1.2 Author: Zhixiang Zhu Author URI: http://zxtechart.com -Text Domain: external-media-without-import -Domain Path: /languages License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0-standalone.html +Text Domain: external-media-without-import External Media without Import is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,7 +26,6 @@ namespace emwi; function init_emwi() { - $domain = 'external-media-without-import'; $style = 'emwi-css'; $css_file = plugins_url( '/external-media-without-import.css', __FILE__ ); wp_register_style( $style, $css_file ); @@ -79,17 +77,17 @@ function post_upload_ui() { ?>
- +
- +
@@ -108,29 +106,29 @@ function print_submenu_page() { function print_media_new_panel( $is_in_upload_ui ) { ?>
style="display: none"> - - + +
style="display: none">
- +
- + - + - +
- - + + - +
@@ -145,12 +143,12 @@ function wp_ajax_add_external_media_without_import() { if ( $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) { array_push( $attachments, $attachment ); } else { - $error = "There's an attachment sucessfully inserted to the media library but failed to be retrieved from the database to be displayed on the page."; + $error = __( "There's an attachment sucessfully inserted to the media library but failed to be retrieved from the database to be displayed on the page.", 'external-media-without-import' ); } } $info['attachments'] = $attachments; if ( isset( $error ) ) { - $info['error'] = isset( $info['error'] ) ? $info['error'] . "\nAnother error also occurred. " . $error : $error; + $info['error'] = isset( $info['error'] ) ? $info['error'] . __( "\nAnother error also occurred.", 'external-media-without-import' ) . $error : $error; } wp_send_json_success( $info ); } @@ -191,14 +189,14 @@ function sanitize_and_validate_input() { $width_str = $input['width']; $width_int = intval( $width_str ); if ( ! empty( $width_str ) && $width_int <= 0 ) { - $input['error'] = _('Width and height must be non-negative integers.', 'external-media-without-import' ); + $input['error'] = __( 'Width and height must be non-negative integers.', 'external-media-without-import' ); return $input; } $height_str = $input['height']; $height_int = intval( $height_str ); if ( ! empty( $height_str ) && $height_int <= 0 ) { - $input['error'] = _('Width and height must be non-negative integers.', 'external-media-without-import' ); + $input['error'] = __( 'Width and height must be non-negative integers.', 'external-media-without-import' ); return $input; } @@ -265,7 +263,7 @@ function add_external_media_without_import() { $info['urls'] = $failed_urls_string; if ( ! empty( $failed_urls_string ) ) { - $info['error'] = 'Failed to get info of the image(s).'; + $info['error'] = __( 'Failed to get info of the image(s).', 'external-media-without-import' ); } return $info;