diff --git a/README.md b/README.md index 6c41bdc..612b3f6 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,10 @@ Yes you can! Join in on our [GitHub repository](https://github.com/WP-Translatio ## Changelog +### 1.2.1 - 22 Feb 2022 + +* Fix mime type according to WordPress core fileinfo mime type check. + ### 1.2.0 - 22 Feb 2022 * Tested up to WP 5.9 diff --git a/inc/admin/options.php b/inc/admin/options.php index 6630396..71d33e6 100644 --- a/inc/admin/options.php +++ b/inc/admin/options.php @@ -146,13 +146,15 @@ function wpt_customofile_add_rule_validate( $input ) { if ( $input['wpt-customofile-add-rule'] && isset( $_FILES['wpt_customofile_mo_file']['name'] ) ) { add_filter( 'upload_dir', 'wpt_customofile_filter_upload_dir' ); + add_filter( 'upload_mimes', 'wpt_customofile_filter_upload_mimes' ); $mo_file = wp_handle_upload( $_FILES['wpt_customofile_mo_file'], // phpcs:ignore array( 'test_form' => false, - 'mimes' => array( 'mo' => 'application/octet-stream' ), + 'mimes' => array( 'mo' => 'application/x-gettext-translation' ), ) ); + remove_filter( 'upload_mimes', 'wpt_customofile_filter_upload_mimes' ); remove_filter( 'upload_dir', 'wpt_customofile_filter_upload_dir' ); if ( $mo_file && empty( $mo_file['error'] ) ) { diff --git a/inc/functions/functions.php b/inc/functions/functions.php index 1017129..1f776c6 100644 --- a/inc/functions/functions.php +++ b/inc/functions/functions.php @@ -38,6 +38,24 @@ function wpt_customofile_filter_upload_dir( $upload_dir ) { } +/** + * Filter for upload mime types. + * + * @since 1.2.1 + * + * @param array $wp_get_mime_types Get upload mime types. + * + * @return array Filtered array of upload mime types. + */ +function wpt_customofile_filter_upload_mimes( $wp_get_mime_types ) { + + // Add 'mo' mime type. + $wp_get_mime_types['mo'] = 'application/x-gettext-translation'; + + return $wp_get_mime_types; +} + + /** * Prepare uploads folder. * Check if folder exist and has empty index, create both if don't exist. diff --git a/languages/wpt-custom-mo-file-pt_PT.mo b/languages/wpt-custom-mo-file-pt_PT.mo index a5c3914..4f65dbc 100644 Binary files a/languages/wpt-custom-mo-file-pt_PT.mo and b/languages/wpt-custom-mo-file-pt_PT.mo differ diff --git a/languages/wpt-custom-mo-file-pt_PT.po b/languages/wpt-custom-mo-file-pt_PT.po index 79f85b2..42f2eee 100644 --- a/languages/wpt-custom-mo-file-pt_PT.po +++ b/languages/wpt-custom-mo-file-pt_PT.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WPT Custom Mo File\n" "POT-Creation-Date: 2022-02-19 10:10+0000\n" -"PO-Revision-Date: 2022-02-19 10:10+0000\n" +"PO-Revision-Date: 2022-02-22 11:55+0000\n" "Last-Translator: Pedro Mendonça \n" "Language-Team: Pedro Mendonça \n" "Language: pt_PT\n" @@ -10,7 +10,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 2.4.2\n" +"X-Generator: Poedit 3.0.1\n" "X-Poedit-Basepath: ..\n" "X-Poedit-WPHeader: wpt-custom-mo-file.php\n" "X-Poedit-SourceCharset: UTF-8\n" @@ -25,7 +25,7 @@ msgstr "Sem dados disponíveis na tabela" #: inc/admin/enqueue.php:71 msgctxt "Please do not translate: _START_ _END_ _TOTAL_" msgid "Showing _START_ to _END_ of _TOTAL_ entries" -msgstr "A mostrar _START_ a _END_ do total de _TOTAL_ entradas" +msgstr "A mostrar de _START_ a _END_ de _TOTAL_ entradas" #: inc/admin/enqueue.php:72 msgid "Showing 0 to 0 of 0 entries" @@ -39,7 +39,7 @@ msgstr "filtradas de um total de _MAX_ entradas" #: inc/admin/enqueue.php:74 msgctxt "Please do not translate: _MENU_" msgid "Show _MENU_ entries" -msgstr "Mostrar entradas de _MENU_" +msgstr "Mostrar _MENU_ entradas" #: inc/admin/enqueue.php:75 msgid "Loading..." @@ -146,11 +146,11 @@ msgstr "Por favor, seleccione primeiro uma acção" #: inc/admin/ui/options.php:42 msgid "Join us" -msgstr "Junta-te à nós" +msgstr "Junte-se a nós" #: inc/admin/ui/options.php:55 msgid "Create, activate, desactivate your own set of rules to get full control of any translations in your WordPress installation." -msgstr "Criar, activar, desactivar o seu próprio conjunto de regras para ter controlo completo sobre quaisquer traduções na sua instalação WordPress." +msgstr "Crie, active ou desactive o seu próprio conjunto de regras para ter controlo completo sobre quaisquer traduções na sua instalação WordPress." #: inc/admin/ui/options.php:58 msgctxt "Company name, don't translate" @@ -163,7 +163,7 @@ msgstr "Adicionar nova regra" #: inc/admin/ui/options.php:77 msgid "There is no available textdomain." -msgstr "Não há nenhum text domain disponível." +msgstr "Não há nenhum textdomain disponível." #: inc/admin/ui/options.php:122 #, php-format diff --git a/readme.txt b/readme.txt index b580d5a..593b8cd 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate link: https://paypal.me/wptranslations Requires at least: 5.3 Tested up to: 5.9 Requires PHP: 7.2 -Stable tag: 1.2.0 +Stable tag: 1.2.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -82,6 +82,9 @@ Yes you can! Join in on our [GitHub repository](https://github.com/WP-Translatio == Changelog == += 1.2.1 - 22 Feb 2022 = +* Fix mime type according to WordPress core fileinfo mime type check. + = 1.2.0 - 22 Feb 2022 = * Tested up to WP 5.9 * Minimum requirement: WP 5.3 and PHP 7.2 diff --git a/wpt-custom-mo-file.php b/wpt-custom-mo-file.php index 9101565..fdca998 100644 --- a/wpt-custom-mo-file.php +++ b/wpt-custom-mo-file.php @@ -11,7 +11,7 @@ * Plugin Name: WPT Custom Mo File * Plugin URI: https://wordpress.org/plugins/wpt-custom-mo-file/ * Description: A powerful WordPress plugin that let you use your own translation .mo files. Simple as that. - * Version: 1.2.0 + * Version: 1.2.1 * Requires at least: 5.3 * Tested up to: 5.9 * Requires PHP: 7.2