/home/techb158/balacoffee.com/wp-content/plugins/wpforms/src/Integrations/WPorg
Edit: /home/techb158/balacoffee.com/wp-content/plugins/wpforms/src/Integrations/WPorg/Translations.php (3717B)
[
'plugins' => wp_json_encode(
[
'plugins' => [
'wpforms-lite/wpforms.php' => $plugin_data,
],
'active' => [],
]
),
'locale' => wp_json_encode( get_available_languages() ),
],
]
);
$code = wp_remote_retrieve_response_code( $request );
$body = wp_remote_retrieve_body( $request );
if ( $code !== 200 || $body === 'error' || is_wp_error( $body ) ) {
return [];
}
$body = json_decode( $body, true );
return ! empty( $body['translations'] ) ? $body['translations'] : [];
}
/**
* Download translations for all available languages.
*
* @since 1.6.9
*/
public function download_translations() {
$translations = $this->get_translation_packages();
if ( empty( $translations ) ) {
return;
}
$skin = new Automatic_Upgrader_Skin();
$upgrader = new Language_Pack_Upgrader( $skin );
foreach ( $translations as $language ) {
// Sometimes a language can be passed as array.
$this->download_package( (object) $language, $upgrader, $skin );
}
}
/**
* Download translation for the language.
*
* @since 1.6.9
*
* @param object $language Language package.
* @param Language_Pack_Upgrader $upgrader The instance of the core class used for updating/installing language packs (translations).
* @param Automatic_Upgrader_Skin $skin Upgrader Skin for Automatic WordPress Upgrades.
*/
private function download_package( $language, Language_Pack_Upgrader $upgrader, Automatic_Upgrader_Skin $skin ) {
if ( ! property_exists( $language, 'package' ) || empty( $language->package ) ) {
return;
}
$skin->language_update = $language;
$upgrader->run(
[
'package' => $language->package,
'destination' => WP_LANG_DIR . '/plugins',
'abort_if_destination_exists' => false,
'is_multi' => true,
'hook_extra' => [
'language_update_type' => $language->type,
'language_update' => $language,
],
]
);
}
}