Skip to content

Commit

Permalink
Merge pull request #41 from WP-Translations/dev
Browse files Browse the repository at this point in the history
Fix file type permission error
  • Loading branch information
fxbenard authored Feb 22, 2022
2 parents 93a4fd7 + f1643a7 commit 590570b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion inc/admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand Down
18 changes: 18 additions & 0 deletions inc/functions/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ function wpt_customofile_filter_upload_dir( $upload_dir ) {
}


/**
* Filter for upload mime types.
*
* @since 1.2.1
*
* @param array<mixed> $wp_get_mime_types Get upload mime types.
*
* @return array<mixed> 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.
Expand Down
Binary file modified languages/wpt-custom-mo-file-pt_PT.mo
Binary file not shown.
14 changes: 7 additions & 7 deletions languages/wpt-custom-mo-file-pt_PT.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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 <[email protected]>\n"
"Language-Team: Pedro Mendonça <[email protected]>\n"
"Language: pt_PT\n"
"MIME-Version: 1.0\n"
"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"
Expand All @@ -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"
Expand All @@ -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..."
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wpt-custom-mo-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 590570b

Please sign in to comment.