-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
readme.txt
135 lines (81 loc) · 3.95 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
=== A faster load_textdomain ===
Contributors: PerS
Tags: l10n, load_textdomain, cache, performance
Requires at least: 5.9
Requires PHP: 7.4
Tested up to: 6.4
Stable tag: 2.3.2
Donate link: https://paypal.me/PerSoderlind
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
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 core](https://make.wordpress.org/core/2024/02/27/i18n-improvements-6-5-performant-translations/). 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.
= How it works =
If you have a plugin or theme that loads a textdomain, e.g. `load_textdomain( 'textdomain', $path_to_mo_file )`, then this plugin will:
1. Look for a PHP version of the .mo file in `WP_CONTENT_DIR . '/cache/a-faster-load-textdomain'` directory.
2. If the PHP version exists, [include](https://www.php.net/manual/en/function.include.php) the file.
3. If the PHP version doesn't exist, load the .mo file, and save the file as an PHP array in `wp-content/cache/a-faster-load-textdomain/` directory.
The localized PHP array can be cached via [PHP OPcache](http://blog.jpauli.tech/2015-03-05-opcache-html/). If you have PHP OPcache enabled, then the localized PHP array will be cached in memory, and the PHP file will not be parsed again.
= Filters =
`a_faster_load_textdomain_cache_path`
Change the cache path, default is `WP_CONTENT_DIR . '/cache/a-faster-load-textdomain'`.
`
add_filter( 'a_faster_load_textdomain_cache_path', function( $path ) {
return WP_CONTENT_DIR . '/cache/my-cache';
} );
`
= GitHub =
The plugin source is available at [GitHub](https://github.com/soderlind/a-faster-load-textdomain/blob/main/a-faster-load-textdomain.php)
== Installation ==
Either (recommended):
- Download the plugin files and extract `a-faster-load-textdomain.php` and `class-afld-cachehandler.php` to the `wp-content/mu-plugins` directory.
Or:
- Search for "A faster load_textdomain" and install with the WordPress plugin installer.
- (Network) Activate the plugin through the 'Plugins' menu in WordPress.
It's also possible to install the plugin via Composer:
`composer require soderlind/a-faster-load-textdomain`
== Changelog ==
= 2.3.2 =
* Housekeeping.
= 2.3.1 =
* Catch errors in the cache handler. If the cache file is corrupt, update the file and return the .mo file.
= 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.
= 2.2.3 =
* Housekeeping.
= 2.2.2 =
* Add uninstall handler. Will remove the cache directory when the plugin is uninstalled.
= 2.2.1 =
* Fix bug in cache handler.
= 2.2.0 =
* Refactor cache handler.
= 2.1.5 =
- Bump version to force deploy to WordPress.org
= 2.1.4 =
- Deploy with GitHub Actions to WordPress.org
= 2.1.3 =
- Remove `mkdir()`
= 2.1.2 =
* Fail gracefully if `$cache_path` can't be created.
= 2.1.1 =
* Add `aflt_load_textdomain` filter.
= 2.1.0 =
* Rename namespace to `Soderlind\Plugin\A_Faster_Load_Textdomain`
* Rename cache directory to `WP_CONTENT_DIR . '/cache/a-faster-load-textdomain'`
= 2.0.1 =
* Rename file to `a-faster-load-textdomain.php` to follow WordPress plugin standards.
= 2.0.0 =
* Refactor code, instead of using a transient, save .mo file as an PHP array, and [include](https://www.php.net/manual/en/function.include.php) the array instead of the .mo file.
= 1.0.3 =
* Housekeeping.
= 1.0.2 =
* DRY (Don't Repeat Yourself) code. Add namespace.
= 1.0.1 =
* Add multisite support
= 1.0.0 =
* Initial release