Download translations in setup wizard
This commit is contained in:
parent
1d6fb39dbe
commit
aa8e469a9d
|
@ -201,6 +201,10 @@ class WC_Admin_Setup_Wizard {
|
|||
* Introduction step
|
||||
*/
|
||||
public function wc_setup_introduction() {
|
||||
if ( isset( $_GET['translation_updated'] ) ) {
|
||||
WC_Language_Pack_Upgrader::language_update_messages();
|
||||
}
|
||||
|
||||
?>
|
||||
<h1><?php _e( 'Welcome to the world of WooCommerce!', 'woocommerce' ); ?></h1>
|
||||
<p><?php _e( 'Thank you for choosing WooCommerce to power your online store! This quick setup wizard will help you configure the basic settings. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>', 'woocommerce' ); ?></p>
|
||||
|
|
|
@ -143,24 +143,7 @@ class WC_Admin_Status {
|
|||
|
||||
// Manual translation update messages
|
||||
if ( isset( $_GET['translation_updated'] ) ) {
|
||||
switch ( $_GET['translation_updated'] ) {
|
||||
case 2 :
|
||||
echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woocommerce' ) . ' ' . __( 'Seems you don\'t have permission to do this!', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
case 3 :
|
||||
echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woocommerce' ) . ' ' . sprintf( __( 'An authentication error occurred while updating the translation. Please try again or configure your %sUpgrade Constants%s.', 'woocommerce' ), '<a href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">', '</a>' ) . '</p></div>';
|
||||
break;
|
||||
case 4 :
|
||||
echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woocommerce' ) . ' ' . __( 'Sorry but there is no translation available for your language =/', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
|
||||
default :
|
||||
// Force WordPress find for new updates and hide the WooCommerce translation update
|
||||
set_site_transient( 'update_plugins', null );
|
||||
|
||||
echo '<div class="updated"><p>' . __( 'Translations installed/updated successfully!', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
}
|
||||
WC_Language_Pack_Upgrader::language_update_messages();
|
||||
}
|
||||
|
||||
// Display message if settings settings have been saved
|
||||
|
|
|
@ -111,7 +111,13 @@ class WC_Admin {
|
|||
|
||||
// If the user needs to install, send them to the setup wizard
|
||||
if ( WC_Admin_Notices::has_notice( 'install' ) ) {
|
||||
wp_safe_redirect( admin_url( 'index.php?page=wc-setup' ) );
|
||||
if ( 'en_US' === $locale ) {
|
||||
$url = admin_url( 'index.php?page=wc-setup' );
|
||||
} else {
|
||||
$url = wp_nonce_url( admin_url( 'index.php?page=wc-setup&action=translation_upgrade' ), 'setup_language' );
|
||||
}
|
||||
|
||||
wp_safe_redirect( $url );
|
||||
exit;
|
||||
|
||||
// Otherwise, the welcome page
|
||||
|
|
|
@ -32,7 +32,7 @@ class WC_Language_Pack_Upgrader {
|
|||
add_filter( 'upgrader_pre_download', array( $this, 'version_update' ), 10, 2 );
|
||||
add_action( 'woocommerce_installed', array( $this, 'has_available_update' ) );
|
||||
add_action( 'update_option_WPLANG', array( $this, 'updated_language_option' ), 10, 2 );
|
||||
add_filter( 'admin_init', array( $this, 'manual_language_update' ), 999 );
|
||||
add_filter( 'admin_init', array( $this, 'manual_language_update' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,15 +173,21 @@ class WC_Language_Pack_Upgrader {
|
|||
is_admin()
|
||||
&& current_user_can( 'update_plugins' )
|
||||
&& isset( $_GET['page'] )
|
||||
&& 'wc-status' == $_GET['page']
|
||||
&& in_array( $_GET['page'], array( 'wc-status', 'wc-setup' ) )
|
||||
&& isset( $_GET['action'] )
|
||||
&& 'translation_upgrade' == $_GET['action']
|
||||
) {
|
||||
$page = 'wc-status&tab=tools';
|
||||
$wpnonce = 'debug_action';
|
||||
if ( 'wc-setup' == $_GET['page'] ) {
|
||||
$page = 'wc-setup';
|
||||
$wpnonce = 'setup_language';
|
||||
}
|
||||
|
||||
$url = wp_nonce_url( admin_url( 'admin.php?page=wc-status&tab=tools&action=translation_upgrade' ), 'language_update' );
|
||||
$tools_url = admin_url( 'admin.php?page=wc-status&tab=tools' );
|
||||
$url = wp_nonce_url( admin_url( 'admin.php?page=' . $page . '&action=translation_upgrade' ), 'language_update' );
|
||||
$tools_url = admin_url( 'admin.php?page=' . $page );
|
||||
|
||||
if ( ! isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'debug_action' ) ) {
|
||||
if ( ! isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], $wpnonce ) ) {
|
||||
wp_redirect( add_query_arg( array( 'translation_updated' => 2 ), $tools_url ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -237,6 +243,31 @@ class WC_Language_Pack_Upgrader {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Language update messages
|
||||
*
|
||||
* @since 2.4.5
|
||||
*/
|
||||
public static function language_update_messages() {
|
||||
switch ( $_GET['translation_updated'] ) {
|
||||
case 2 :
|
||||
echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woocommerce' ) . ' ' . __( 'Seems you don\'t have permission to do this!', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
case 3 :
|
||||
echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woocommerce' ) . ' ' . sprintf( __( 'An authentication error occurred while updating the translation. Please try again or configure your %sUpgrade Constants%s.', 'woocommerce' ), '<a href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">', '</a>' ) . '</p></div>';
|
||||
break;
|
||||
case 4 :
|
||||
echo '<div class="error"><p>' . __( 'Failed to install/update the translation:', 'woocommerce' ) . ' ' . __( 'Sorry but there is no translation available for your language =/', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
|
||||
default :
|
||||
// Force WordPress find for new updates and hide the WooCommerce translation update
|
||||
set_site_transient( 'update_plugins', null );
|
||||
|
||||
echo '<div class="updated"><p>' . __( 'Translations installed/updated successfully!', 'woocommerce' ) . '</p></div>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new WC_Language_Pack_Upgrader();
|
||||
|
|
Loading…
Reference in New Issue