作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在安装 Wordpress 4.7 时使用 Loco Translate 翻译插件。
我的 MU-Plugin 已正确注册并正确配置以加载其文本域。
但 Loco Translate 只能识别主题和常规插件,因此我无法使用 Loco Translate UI 来翻译我的插件。
帮助将不胜感激。谢谢
最佳答案
欢迎来到 stack overflow Jonathan Darchy!
这里是一个将未注册的 MU 插件添加到 Loco Translate 的例子原始,取自 this gist
我认为它回答了您的问题:
<?php
/**
* MU plugins inside directories are not returned in `get_mu_plugins`.
* This filter modifies the array obtained from Wordpress when Loco grabs it.
*
* Note that this filter only runs once per script execution, because the value is cached.
* Define the function *before* Loco Translate plugin is even included by WP.
*/
function add_unregistered_plugins_to_loco( array $plugins ){
// we know the plugin by this handle, even if WordPress doesn't
$handle = 'foo-bar/foo-bar.php';
// fetch the plugin's meta data from the would-be plugin file
$data = get_plugin_data( trailingslashit(WPMU_PLUGIN_DIR).$handle );
// extra requirement of Loco - $handle must be resolvable to full path
$data['basedir'] = WPMU_PLUGIN_DIR;
// add to array and return back to Loco Translate
$plugins[$handle] = $data;
return $plugins;
}
add_filter('loco_plugins_data', 'add_unregistered_plugins_to_loco', 10, 1 );
关于wordpress - 制作 Loco Translate Wordpress 插件以识别 MU-PLUGINS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41719521/
我正在尝试使用 loco 做一个基本的优化示例. 我有一个成本向量,其索引对应于多个插槽的整数值,并希望最小化插槽的不同子集的成本总和。 请参阅下面我的尝试,该尝试失败了,因为选择的插槽和成本之间没有
JPEG-LS 压缩标准有哪些可用的实现? JPEG-LS 是基于 HP LOCO-I(图像的低 COmplexity LOssless COmpression)算法的新型(相对而言)无损 JPEG
我在安装 Wordpress 4.7 时使用 Loco Translate 翻译插件。 我的 MU-Plugin 已正确注册并正确配置以加载其文本域。 但 Loco Translate 只能识别主题和
我是一名优秀的程序员,十分优秀!