Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account for translations_api returning WP_Error #105

Merged
merged 1 commit into from
Apr 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions admin/qtx_update_gettext_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ function qtranxf_updateGettextDatabases($force = false, $only_for_language = '')
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
$result = translations_api( 'core', array( 'version' => $wp_version ) );

foreach ( $result['translations'] as $translation ) {
$locale = substr($translation['language'], 0, 2);
if (
isset( $q_config['locale'][$locale] )
&& $q_config['locale'][$locale] == $translation['language']
&& qtranxf_isEnabled($locale)
) {
$translation = (object) $translation;
$skin = new Automatic_Upgrader_Skin;
$upgrader = new Language_Pack_Upgrader( $skin );
$translation->type = 'core';
$result = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
if ( ! is_wp_error( $result = translations_api( 'core', array( 'version' => $wp_version ) ) ) ) {
foreach ( $result['translations'] as $translation ) {
$locale = substr($translation['language'], 0, 2);
if (
isset( $q_config['locale'][$locale] )
&& $q_config['locale'][$locale] == $translation['language']
&& qtranxf_isEnabled($locale)
) {
$translation = (object) $translation;
$skin = new Automatic_Upgrader_Skin;
$upgrader = new Language_Pack_Upgrader( $skin );
$translation->type = 'core';
$result = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
}
}
return true;
}
return true;
else
return false;
}