Skip to content

Commit

Permalink
Merge pull request #140 from mihdan/v6.0.4
Browse files Browse the repository at this point in the history
V6.0.4
  • Loading branch information
kagg-design committed Sep 23, 2023
2 parents 7779ef8 + f9dde9a commit 2239cd9
Show file tree
Hide file tree
Showing 27 changed files with 145 additions and 156 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/ci.yml
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -24,19 +24,8 @@ jobs:
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Set up Composer caching
uses: actions/cache@master
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup Composer caching
uses: ramsey/composer-install@v2

- name: Install dependencies and update PHPUnit
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-readme-assets-to-wp-org.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
uses: actions/checkout@v3

- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/deploy-to-wp-org.yml
Expand Up @@ -10,21 +10,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@master
uses: actions/checkout@v3

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Set up Composer caching
uses: actions/cache@master
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Setup Composer caching
uses: ramsey/composer-install@v2

- name: Install dependencies in prod version
run: |
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## 6.0.4 (23.09.2023) ##
* Fixed disappeared file descriptions on the Theme File Editor page.

## 6.0.3 (29.07.2023) ##
* Fixed fatal error with Jetpack sync.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

Converts Cyrillic characters in post, page and term slugs to Latin characters. Useful for creating human-readable URLs.

![](./assets/banner-772x250.png)
![Banner](./.wordpress-org/banner-772x250.png)

## Features

Expand Down
11 changes: 7 additions & 4 deletions composer.json
Expand Up @@ -36,6 +36,11 @@
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
"ext-json": "*"
},
Expand All @@ -47,7 +52,7 @@
"squizlabs/php_codesniffer": "^3.7.2",
"phpcompatibility/php-compatibility": "^9.3.5",
"phpcompatibility/phpcompatibility-wp": "^2.1.4",
"wp-coding-standards/wpcs": "^2.3.0",
"wp-coding-standards/wpcs": "^3.0.1",
"php-coveralls/php-coveralls": "^v2.6.0"
},
"autoload": {
Expand Down Expand Up @@ -78,8 +83,6 @@
"update-tests": "update-tests",
"revert-tests": "update-tests revert",
"phpcs": "vendor/bin/phpcs --colors --standard=phpcs.xml",
"acceptance": "codecept run acceptance -c .codeception.yml",
"integration": "codecept run integration -c .codeception.yml",
"unit": "codecept run unit -c .codeception.yml"
"unit": "vendor/bin/phpunit"
}
}
6 changes: 3 additions & 3 deletions cyr-to-lat.php
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Cyr-To-Lat
* Plugin URI: https://wordpress.org/plugins/cyr2lat/
* Description: Convert Non-Latin characters in post and term slugs to Latin characters. Useful for creating human-readable URLs. Based on the original plugin by Anton Skorobogatov.
* Version: 6.0.3
* Version: 6.0.4
* Requires at least: 5.1
* Requires PHP: 7.0.0
* Author: Sergey Biryukov, Mikhail Kobzarev, Igor Gergel
Expand All @@ -22,7 +22,7 @@
*
*
* WC requires at least: 3.0
* WC tested up to: 7.9
* WC tested up to: 8.1
*/

// phpcs:ignore Generic.Commenting.DocComment.MissingShort
Expand All @@ -43,7 +43,7 @@
/**
* Plugin version.
*/
define( 'CYR_TO_LAT_VERSION', '6.0.3' );
define( 'CYR_TO_LAT_VERSION', '6.0.4' );

/**
* Path to the plugin dir.
Expand Down
31 changes: 10 additions & 21 deletions phpcs.xml
Expand Up @@ -22,33 +22,22 @@
<arg name="parallel" value="12"/><!-- Enables parallel processing when available for faster results. -->
<arg name="cache" value=".phpcs.cache"/>

<config name="installed_paths" value="vendor/phpcompatibility/php-compatibility,vendor/phpcompatibility/phpcompatibility-paragonie,vendor/phpcompatibility/phpcompatibility-wp,vendor/wp-coding-standards/wpcs"/>
<config name="installed_paths" value="vendor/phpcompatibility/php-compatibility,vendor/phpcompatibility/phpcompatibility-paragonie,vendor/phpcompatibility/phpcompatibility-wp,vendor/phpcsstandards/phpcsextra,vendor/phpcsstandards/phpcsutils,vendor/wp-coding-standards/wpcs"/>
<config name="testVersion" value="7.0-"/>

<!-- Rules: Check PHP version compatibility -->
<rule ref="PHPCompatibility"/>
<rule ref="PHPCompatibilityWP"/>

<!-- Rules: WordPress Coding Standards -->
<config name="minimum_supported_wp_version" value="5.1"/>
<rule ref="WordPress"/>

<!-- Allow only short array syntax -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
<severity>0</severity>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>

<!-- Allow short ternary syntax -->
<rule ref="WordPress.PHP.DisallowShortTernary.Found">
<severity>0</severity>
</rule>

<!-- Rules to follow PSR4 -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<severity>0</severity>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<severity>0</severity>
<config name="minimum_supported_wp_version" value="5.0"/>
<rule ref="WordPress">
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found"/>
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed"/>
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found"/>
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>
<!-- Rules to follow PSR4 -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
</rule>
</ruleset>
7 changes: 5 additions & 2 deletions readme.txt
Expand Up @@ -3,7 +3,7 @@ Contributors: SergeyBiryukov, mihdan, karevn, webvitaly, kaggdesign
Tags: cyrillic, belorussian, ukrainian, bulgarian, macedonian, georgian, kazakh, latin, l10n, russian, cyr-to-lat, cyr2lat, rustolat, slugs, translations, transliteration
Requires at least: 5.1
Tested up to: 6.3
Stable tag: 6.0.3
Stable tag: 6.0.4
Requires PHP: 7.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -221,7 +221,10 @@ Yes you can!

== Changelog ==

= 6.0.3 (29.07.2023) =
= 6.0.4 (23.09.2023) =
* Fixed disappeared file descriptions on the Theme File Editor page.

* = 6.0.3 (29.07.2023) =
* Fixed fatal error with Jetpack sync.

= 6.0.2 (26.07.2023) =
Expand Down
12 changes: 6 additions & 6 deletions src/php/AdminNotices.php
Expand Up @@ -31,15 +31,15 @@ public function __construct() {
/**
* Add admin notice.
*
* @param string $message Message to show.
* @param string $class Message class: notice notice-success notice-error notice-warning notice-info
* is-dismissible.
* @param array $options Notice options.
* @param string $message Message to show.
* @param string $class_name Message class: notice notice-success notice-error notice-warning notice-info
* is-dismissible.
* @param array $options Notice options.
*/
public function add_notice( string $message, string $class = 'notice', array $options = [] ) {
public function add_notice( string $message, string $class_name = 'notice', array $options = [] ) {
$this->notices[] = [
'message' => $message,
'class' => $class,
'class' => $class_name,
'options' => $options,
];
}
Expand Down
1 change: 1 addition & 0 deletions src/php/BackgroundProcesses/PostConversionProcess.php
Expand Up @@ -184,6 +184,7 @@ protected function rename_file( string $file, string $new_file ) {
$new_filename = $new_path['filename'];

if ( $new_filename !== $filename ) {
// phpcs:ignore WordPress.WP.AlternativeFunctions.rename_rename
return rename( $file, $new_file );
}

Expand Down
6 changes: 3 additions & 3 deletions src/php/ConversionTables.php
Expand Up @@ -694,13 +694,13 @@ public static function get( string $locale = '' ): array {
'ש' => 'sh',
'ת' => 'th',
];
for ( $code = 0x0590; $code <= 0x05CF; $code ++ ) {
for ( $code = 0x0590; $code <= 0x05CF; $code++ ) {
$table[ Mbstring::mb_chr( $code ) ] = '';
}
for ( $code = 0x05F0; $code <= 0x05F5; $code ++ ) {
for ( $code = 0x05F0; $code <= 0x05F5; $code++ ) {
$table[ Mbstring::mb_chr( $code ) ] = '';
}
for ( $code = 0xFB1D; $code <= 0xFB4F; $code ++ ) {
for ( $code = 0xFB1D; $code <= 0xFB4F; $code++ ) {
$table[ Mbstring::mb_chr( $code ) ] = '';
}
break;
Expand Down
38 changes: 19 additions & 19 deletions src/php/Main.php
Expand Up @@ -422,12 +422,12 @@ public function min_suffix(): string {
/**
* Fix string encoding on macOS.
*
* @param string $string String.
* @param array $table Conversion table.
* @param string $str String.
* @param array $table Conversion table.
*
* @return string
*/
private function fix_mac_string( string $string, array $table ): string {
private function fix_mac_string( string $str, array $table ): string {
$fix_table = ConversionTables::get_fix_table_for_mac();

$fix = [];
Expand All @@ -437,50 +437,50 @@ private function fix_mac_string( string $string, array $table ): string {
}
}

return strtr( $string, $fix );
return strtr( $str, $fix );
}

/**
* Split Chinese string by hyphens.
*
* @param string $string String.
* @param array $table Conversion table.
* @param string $str String.
* @param array $table Conversion table.
*
* @return string
*/
protected function split_chinese_string( string $string, array $table ): string {
if ( ! $this->settings->is_chinese_locale() || mb_strlen( $string ) < 4 ) {
return $string;
protected function split_chinese_string( string $str, array $table ): string {
if ( ! $this->settings->is_chinese_locale() || mb_strlen( $str ) < 4 ) {
return $str;
}

$chars = Mbstring::mb_str_split( $string );
$string = '';
$chars = Mbstring::mb_str_split( $str );
$str = '';

foreach ( $chars as $char ) {
if ( isset( $table[ $char ] ) ) {
$string .= '-' . $char . '-';
$str .= '-' . $char . '-';
} else {
$string .= $char;
$str .= $char;
}
}

return $string;
return $str;
}

/**
* Transliterate string using a table.
*
* @param string $string String.
* @param string $str String.
*
* @return string
*/
public function transliterate( string $string ): string {
public function transliterate( string $str ): string {
$table = (array) apply_filters( 'ctl_table', $this->settings->get_table() );

$string = $this->fix_mac_string( $string, $table );
$string = $this->split_chinese_string( $string, $table );
$str = $this->fix_mac_string( $str, $table );
$str = $this->split_chinese_string( $str, $table );

return strtr( $string, $table );
return strtr( $str, $table );
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/php/Requirements.php
Expand Up @@ -53,6 +53,8 @@ class Requirements {
* @param Settings $settings Settings.
* @param AdminNotices $admin_notices Admin notices.
* @param WP_Filesystem_Direct|null $wp_filesystem File system.
*
* @noinspection PhpUnusedLocalVariableInspection
*/
public function __construct( Settings $settings, AdminNotices $admin_notices, WP_Filesystem_Direct $wp_filesystem = null ) {
$this->settings = $settings;
Expand All @@ -62,6 +64,12 @@ public function __construct( Settings $settings, AdminNotices $admin_notices, WP

// @codeCoverageIgnoreStart
if ( ! function_exists( 'WP_Filesystem' ) ) {
/**
* Make the scope of $wp_file_descriptions global,
* so that when wp-admin/includes/file.php assigns to it, it is adjusting the global variable as intended.
*/
global $wp_file_descriptions;

require_once ABSPATH . 'wp-admin/includes/file.php';
}
// @codeCoverageIgnoreEnd
Expand Down
6 changes: 3 additions & 3 deletions src/php/Settings/Abstracts/SettingsBase.php
Expand Up @@ -760,7 +760,7 @@ private function print_checkbox_field( array $arguments ) {
}

foreach ( $arguments['options'] as $key => $label ) {
$iterator ++;
++$iterator;
$options_markup .= sprintf(
'<label for="%2$s_%7$s">' .
'<input id="%2$s_%7$s" name="%1$s[%2$s][]" type="%3$s" value="%4$s" %5$s %8$s />' .
Expand Down Expand Up @@ -826,7 +826,7 @@ private function print_radio_field( array $arguments ) {
}

foreach ( $arguments['options'] as $key => $label ) {
$iterator ++;
++$iterator;
$options_markup .= sprintf(
'<label for="%2$s_%7$s">' .
'<input id="%2$s_%7$s" name="%1$s[%2$s]" type="%3$s" value="%4$s" %5$s %8$s />' .
Expand Down Expand Up @@ -1020,7 +1020,7 @@ private function print_table_field( array $arguments ) {
);
echo '</div>';

$iterator ++;
++$iterator;
}

echo '</fieldset>';
Expand Down
2 changes: 1 addition & 1 deletion src/php/Settings/PluginSettingsBase.php
Expand Up @@ -193,7 +193,7 @@ public function admin_footer_text( $text ) {
return wp_kses(
sprintf(
/* translators: 1: plugin name, 2: wp.org review link with stars, 3: wp.org review link with text. */
__( 'Please rate %1$s %2$s on %3$s</a>. Thank you!', 'cyr2lat' ),
__( 'Please rate %1$s %2$s on %3$s. Thank you!', 'cyr2lat' ),
'<strong>Cyr To Lat</strong>',
sprintf(
'<a href="%s" target="_blank" rel="noopener noreferrer">★★★★★</a>',
Expand Down

0 comments on commit 2239cd9

Please sign in to comment.