承接 soderlind/a-faster-load-textdomain 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soderlind/a-faster-load-textdomain

最新稳定版本:2.3.2

Composer 安装命令:

composer require soderlind/a-faster-load-textdomain

包简介

A faster load_textdomain

README 文档

README

NOTE This plugin is not needed if you are running WordPress 6.5 or later, as the functionality is built into WordPress core. If you need to generate translation in the new .l10n.php format, use the Performant Translations plugin instead.

This is a WordPress plugin that caches the .mo file as an PHP array, and include the array instead of the .mo file. In theory, nothing is faster in PHP than loading and executing another PHP file.

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

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 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. 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';
} );

Changelog

See CHANGELOG.md.

Credits

Orignal file: https://github.com/lynt-smitka/WP-nginx-config/blob/master/extras/mu-plugins/lynt-mo-cache.php

Copyright and License

This plugin is copyright © 2023 Per Soderlind.

This plugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE for more information.

统计信息

  • 总下载量: 1.52k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-08-11