Make WordPress Core


Ignore:
Timestamp:
10/16/2013 04:14:29 AM (13 years ago)
Author:
dd32
Message:

Language Packs: Many many fixes such as:

  • Add a "Update Translations" stand-alone button to the updates page
  • Shift Language feedback to before update process completion action links & limit the verbosity of output (name + success/errors)
  • Simplify/combine the language update descriptive string to only include a plugin/theme name
  • Properly handle cache clearing after language updates to prevent langs being repeditively updated
  • Display a "All items up to date" string when there's nothing to do
  • Reduce the 'Connection Information' from a <h2> to a <h3> to remove duplicate h2's and screen icons from update screens
  • Fix the Direct filesystem method not being used for Language updates because WP_LANG_DIR doesn't exist (check it's parent for writable instead)

See #18200, #22704

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/update-core.php

    r25784 r25806  
    325325}
    326326
     327function list_translation_updates() {
     328        $updates = wp_get_translation_updates();
     329        if ( ! $updates ) {
     330                if ( 'en_US' != get_locale() ) {
     331                        echo '<h3>' . __( 'Translations' ) . '</h3>';
     332                        echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
     333                }
     334                return;
     335        }
     336
     337        $form_action = 'update-core.php?action=do-translation-upgrade';
     338        ?>
     339        <h3><?php _e( 'Translations' ); ?></h3>
     340        <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
     341                <p><?php _e( 'Some of your translations are out of date.' ); ?></p>
     342                <?php wp_nonce_field('upgrade-translations'); ?>
     343                <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
     344        </form>
     345        <?php
     346}
     347
    327348/**
    328349 * Upgrade WordPress core display.
     
    342363                $url = 'update-core.php?action=do-core-upgrade';
    343364        $url = wp_nonce_url($url, 'upgrade-core');
    344         if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
    345                 return;
    346365
    347366        $version = isset( $_POST['version'] )? $_POST['version'] : false;
     
    351370                return;
    352371
    353         if ( ! WP_Filesystem($credentials, ABSPATH) ) {
    354                 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
    355                 return;
    356         }
    357372?>
    358373        <div class="wrap">
     
    360375        <h2><?php _e('Update WordPress'); ?></h2>
    361376<?php
     377
     378        if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH ) ) ) {
     379                echo '</div>';
     380                return;
     381        }
     382
     383        if ( ! WP_Filesystem( $credentials, ABSPATH ) ) {
     384                // Failed to connect, Error and request again
     385                request_filesystem_credentials( $url, '', true, ABSPATH );
     386                echo '</div>';
     387                return;
     388        }
     389
    362390        if ( $wp_filesystem->errors->get_error_code() ) {
    363391                foreach ( $wp_filesystem->errors->get_error_messages() as $message )
     
    478506        echo '</p>';
    479507
    480         if ( current_user_can( 'update_core' ) )
     508        if ( $core = current_user_can( 'update_core' ) )
    481509                core_upgrade_preamble();
    482         if ( current_user_can( 'update_plugins' ) )
     510        if ( $plugins = current_user_can( 'update_plugins' ) )
    483511                list_plugin_updates();
    484         if ( current_user_can( 'update_themes' ) )
     512        if ( $themes = current_user_can( 'update_themes' ) )
    485513                list_theme_updates();
     514        if ( $core || $plugins || $themes )
     515                list_translation_updates();
     516        unset( $core, $plugins, $themes );
    486517        do_action('core_upgrade_preamble');
    487518        echo '</div>';
     
    571602        include(ABSPATH . 'wp-admin/admin-footer.php');
    572603
     604} elseif ( 'do-translation-upgrade' == $action ) {
     605
     606        if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
     607                wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
     608
     609        check_admin_referer( 'upgrade-translations' );
     610
     611        require_once( ABSPATH . 'wp-admin/admin-header.php' );
     612        include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
     613
     614        $url = 'update-core.php?action=do-translation-upgrade';
     615        $nonce = 'upgrade-translations';
     616        $title = __( 'Update Translations' );
     617        $context = WP_LANG_DIR;
     618
     619        $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
     620        $result = $upgrader->bulk_upgrade();
     621
     622        require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     623
    573624} else {
    574625        do_action('update-core-custom_' . $action);
Note: See TracChangeset for help on using the changeset viewer.