REST API: Install plugin translations after the plugin install. This only installs for the plugin in question, not all plugins.
Support for retrieving the langauge pack alongside the install API request was added in https://meta.trac.wordpress.org/changeset/10091 to avoid having to make a plugin update check during the REST API check. Fixes #50732. Props dd32, ocean90, ryelle, swissspidy, tellyworth, whyisjake, TimothyBlynJacobs. git-svn-id: https://develop.svn.wordpress.org/trunk@48641 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
598a5a5bc2
commit
beba4bb73a
@ -286,6 +286,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
|
||||
'slug' => $slug,
|
||||
'fields' => array(
|
||||
'sections' => false,
|
||||
'language_packs' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -355,6 +356,32 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// Install translations.
|
||||
$installed_locales = array_values( get_available_languages() );
|
||||
/** This filter is documented in wp-includes/update.php */
|
||||
$installed_locales = apply_filters( 'plugins_update_check_locales', $installed_locales );
|
||||
|
||||
$language_packs = array_map(
|
||||
function( $item ) {
|
||||
return (object) $item;
|
||||
},
|
||||
$api->language_packs
|
||||
);
|
||||
|
||||
$language_packs = array_filter(
|
||||
$language_packs,
|
||||
function( $pack ) use ( $installed_locales ) {
|
||||
return in_array( $pack->language, $installed_locales, true );
|
||||
}
|
||||
);
|
||||
|
||||
if ( $language_packs ) {
|
||||
$lp_upgrader = new Language_Pack_Upgrader( $skin );
|
||||
|
||||
// Install all applicable language packs for the plugin.
|
||||
$lp_upgrader->bulk_upgrade( $language_packs );
|
||||
}
|
||||
|
||||
$path = WP_PLUGIN_DIR . '/' . $file;
|
||||
$data = get_plugin_data( $path, false, false );
|
||||
$data['_file'] = $file;
|
||||
|
Loading…
Reference in New Issue
Block a user