Skip to content

Commit

Permalink
Update plugin version and add notice for WordPress 6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
soderlind committed Feb 27, 2024
1 parent 3ff82fb commit 1815da1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
## Changelog

### 2.3.0

- If running WordPress 6.5, give a notice that the plugin is not needed.

### 2.2.4

- Fail gracefully if cache directory can't be created.
- Fail gracefully if cache directory can't be created.

### 2.2.3

Expand All @@ -12,7 +16,6 @@

- Add uninstall handler. Will remove the cache directory when the plugin is uninstalled.


### 2.2.1

- Fix bug in cache handler.
Expand Down
18 changes: 15 additions & 3 deletions a-faster-load-textdomain.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: A faster load_textdomain
* Version: 2.2.4
* Version: 2.3.0
* Description: Cache the .mo file as an PHP array, and load the array instead of the .mo file.
* Author: Per Soderlind
* Author URI: https://soderlind.no
Expand All @@ -11,7 +11,7 @@
* @package a-faster-load-textdomain
*/

declare( strict_types = 1 );
declare(strict_types=1);
namespace Soderlind\Plugin\A_Faster_Load_Textdomain;

if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -76,7 +76,7 @@ function a_faster_load_textdomain( $loaded, $domain, $mofile, $locale = null ) {
}

// Prepare the data to be cached.
$data = [
$data = [
'mtime' => $mtime, // The last modification time of the MO file.
'file' => $mofile, // The path to the MO file.
'entries' => $mo->entries, // The entries from the MO file.
Expand Down Expand Up @@ -104,8 +104,20 @@ function a_faster_load_textdomain( $loaded, $domain, $mofile, $locale = null ) {
}



if ( version_compare( $GLOBALS['wp_version'], '6.3' ) >= 0 ) {
\add_filter( 'pre_load_textdomain', __NAMESPACE__ . '\a_faster_load_textdomain', 1, 4 );
} else {
\add_filter( 'override_load_textdomain', __NAMESPACE__ . '\a_faster_load_textdomain', 0, 3 );
}
if ( version_compare( $GLOBALS['wp_version'], '6.5', '>=' ) ) {
//admin messages
\add_action( 'admin_notices', function () {
?>
<div class="notice notice-error">
<p><?php _e( '<strong>A faster load_textdomain</strong> is not needed in WordPress 6.5 and later, please deactivate the plugin.', 'a-faster-load-textdomain' ); ?></p>
<p><?php _e( 'The functionality is now <a href="https://make.wordpress.org/core/2024/02/27/i18n-improvements-6-5-performant-translations/">built into WordPress core</a>.', 'a-faster-load-textdomain' ); ?></p>
<p><?php _e( 'If you need to generate translation in the new <code>.l10n.php</code> format, use the <a href="https://wordpress.org/plugins/performant-translations/">Performant Translations</a> plugin', 'a-faster-load-textdomain' ); ?></p>
</div><?php
} );
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "a-faster-load-textdomain",
"version": "2.2.4",
"version": "2.3.0",
"description": "A faster load_textdomain",
"author": "Per Søderlind <[email protected]>",
"license": "GPL-2.0-or-later",
Expand All @@ -11,4 +11,4 @@
"dependencies": {
"@soderlind/wp-project-version-sync": "^2.0.1"
}
}
}
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: l10n, load_textdomain, cache, performance
Requires at least: 5.9
Requires PHP: 7.4
Tested up to: 6.4
Stable tag: 2.2.4
Stable tag: 2.3.0
Donate link: https://paypal.me/PerSoderlind
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -13,6 +13,8 @@ A faster load_textdomain

== Description ==

>**NOTE** This plugin is not needed if you are running WordPress 6.5 or later, as the functionality is built into WordPress. If you need to generate translation in the new <code>.l10n.php</code> format, use the <a href="https://wordpress.org/plugins/performant-translations/">Performant Translations</a> plugin instead.

This is a WordPress plugin that caches the .mo file as an PHP array, and [include](https://www.php.net/manual/en/function.include.php) the array instead of the .mo file.
In theory, nothing is faster in PHP than loading and executing another PHP file.

Expand Down Expand Up @@ -58,6 +60,10 @@ It's also possible to install the plugin via Composer:

== Changelog ==

= 2.3.0 =

* If running WordPress 6.5, give a notice that the plugin is not needed.

= 2.2.4 =

* Fail gracefully if cache directory can't be created.
Expand Down

0 comments on commit 1815da1

Please sign in to comment.