Skip to content

Commit

Permalink
Merge pull request #105 from entr/master
Browse files Browse the repository at this point in the history
account for translations_api returning WP_Error
  • Loading branch information
johnclause committed Apr 2, 2015
2 parents 46f8876 + 4f259d0 commit 9fb7561
Showing 1 changed file with 17 additions and 14 deletions.
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;
}

0 comments on commit 9fb7561

Please sign in to comment.