fixed the language pack upgrader to works well with WP 4.0, closes #6183
This commit is contained in:
parent
7ecd0009d0
commit
8f4e28b0be
|
@ -28,7 +28,7 @@ class WC_Language_Pack_Upgrader {
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_for_update' ) );
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_for_update' ) );
|
||||||
add_filter( 'upgrader_post_install', array( $this, 'version_update' ), 999, 2 );
|
add_filter( 'upgrader_pre_download', array( $this, 'version_update' ), 10, 2 );
|
||||||
add_action( 'woocommerce_language_pack_updater_check', array( $this, 'has_available_update' ) );
|
add_action( 'woocommerce_language_pack_updater_check', array( $this, 'has_available_update' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,17 +117,17 @@ class WC_Language_Pack_Upgrader {
|
||||||
/**
|
/**
|
||||||
* Update the language version in database
|
* Update the language version in database
|
||||||
*
|
*
|
||||||
* @param bool $response Install response (true = success, false = fail)
|
* Take advance it while downloads the package and updates the database
|
||||||
* @param array $hook_extra Extra arguments passed to hooked filters
|
* This ensures not generate a loop download
|
||||||
|
* If installation fails you can redo it in: WooCommerce > Sistem Status > Tools > Force Translation Upgrade
|
||||||
|
*
|
||||||
|
* @param bool $reply Whether to bail without returning the package (default: false)
|
||||||
|
* @param string $package Package URL
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function version_update( $response, $hook_extra ) {
|
public function version_update( $reply, $package ) {
|
||||||
if ( $response ) {
|
if ( $package === $this->get_language_package_uri() ) {
|
||||||
if (
|
|
||||||
( isset( $hook_extra['language_update_type'] ) && 'plugin' == $hook_extra['language_update_type'] )
|
|
||||||
&& ( isset( $hook_extra['language_update']->slug ) && 'woocommerce' == $hook_extra['language_update']->slug )
|
|
||||||
) {
|
|
||||||
// Update the language pack version
|
// Update the language pack version
|
||||||
update_option( 'woocommerce_language_pack_version', array( WC_VERSION , get_locale() ) );
|
update_option( 'woocommerce_language_pack_version', array( WC_VERSION , get_locale() ) );
|
||||||
|
|
||||||
|
@ -136,9 +136,8 @@ class WC_Language_Pack_Upgrader {
|
||||||
$notices = array_diff( $notices, array( 'translation_upgrade' ) );
|
$notices = array_diff( $notices, array( 'translation_upgrade' ) );
|
||||||
update_option( 'woocommerce_admin_notices', $notices );
|
update_option( 'woocommerce_admin_notices', $notices );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $response;
|
return $reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue