2017-01-18 4 views
1

私はWordpress 4.7インストールでLoco Translate翻訳プラグインを使用しています。Locoを作成するWordpressのプラグインを使用してMU-PLUGINSを識別する

MU-Pluginが正しく登録され、テキストドメインを読み込むように正しく設定されています。

しかし、ロコの翻訳では、テーマと正規のプラグインしか認識できないため、プラグインの翻訳にはLoco Translate UIは使用できません。

お願いします。 ありがとう

答えて

1

ようこそJonathan Darchy!ここで

this gist

から取られ、 生を翻訳ロコに未登録のMUプラグインを追加する例である私はそれがあなたの質問に答えると思う:

<?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); 
関連する問題