Making Loco Translate Wordpress plugin to identify MU-PLUGINS Making Loco Translate Wordpress plugin to identify MU-PLUGINS wordpress wordpress

Making Loco Translate Wordpress plugin to identify MU-PLUGINS


Welcome to stack overflow Jonathan Darchy!

Here is an example of adding an unregistered MU plugin to Loco TranslateRaw, taken from this gist

I think it answers your question:

<?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 );