WordPress.org

Make WordPress Core

Ticket #18200: 18200.4.diff

File 18200.4.diff, 4.8 KB (added by nacin, 8 years ago)
  • src/wp-admin/includes/class-wp-upgrader-skins.php

     
    5151                        return;
    5252                $this->done_header = true;
    5353                echo '<div class="wrap">';
    54                 screen_icon();
     54                if ( ! empty( $this->options['screen'] ) )
     55                        screen_icon( $this->options['screen'] );
     56                else
     57                        screen_icon();
    5558                echo '<h2>' . $this->options['title'] . '</h2>';
    5659        }
    5760        function footer() {
     
    529532}
    530533
    531534/**
     535 * Translation Upgrader Skin for WordPress Translation Upgrades.
     536 *
     537 * @package WordPress
     538 * @subpackage Upgrader
     539 * @since 2.8.0
     540 */
     541class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
     542        var $theme = '';
     543
     544        function __construct( $args = array() ) {
     545                $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ) );
     546                $args = wp_parse_args( $args, $defaults );
     547                parent::__construct( $args );
     548        }
     549
     550        function footer() {
     551                $update_actions = array();
     552                $update_actions['updates_page'] = '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>';
     553                $update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
     554                if ( $update_actions )
     555                        $this->feedback( implode(' | ', $update_actions ) );
     556                parent::footer();
     557        }
     558}
     559
     560/**
    532561 * Upgrader Skin for Automatic WordPress Upgrades
    533562 *
    534563 * This skin is designed to be used when no output is intended, all output
  • src/wp-admin/includes/class-wp-upgrader.php

     
    11751175                                break;
    11761176                }
    11771177
     1178                $this->skin->footer();
     1179
    11781180                // Clean up our hooks, in case something else does an upgrade on this connection.
    11791181                remove_filter( 'upgrader_source_selection', array( &$this, 'check_package' ), 10, 2 );
    11801182
  • src/wp-admin/update-core.php

     
    321321<?php
    322322}
    323323
     324function list_translation_updates() {
     325        $updates = wp_get_translation_updates();
     326        if ( ! $updates ) {
     327                if ( 'en_US' != get_locale() ) {
     328                        echo '<h3>' . __( 'Translations' ) . '</h3>';
     329                        echo '<p>' . __( 'Your translations are all up to date.' ) . '</p>';
     330                }
     331                return;
     332        }
     333
     334        $form_action = 'update-core.php?action=do-translation-upgrade';
     335        ?>
     336        <h3><?php _e( 'Translations' ); ?></h3>
     337        <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
     338                <p><?php _e( 'Some of your translations are out of date.' ); ?></p>
     339                <?php wp_nonce_field('upgrade-translations'); ?>
     340                <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
     341        </form>
     342        <?php
     343}
     344
    324345/**
    325346 * Upgrade WordPress core display.
    326347 *
     
    474495        echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
    475496        echo '</p>';
    476497
    477         if ( current_user_can( 'update_core' ) )
     498        if ( $core = current_user_can( 'update_core' ) )
    478499                core_upgrade_preamble();
    479         if ( current_user_can( 'update_plugins' ) )
     500        if ( $plugins = current_user_can( 'update_plugins' ) )
    480501                list_plugin_updates();
    481         if ( current_user_can( 'update_themes' ) )
     502        if ( $themes = current_user_can( 'update_themes' ) )
    482503                list_theme_updates();
     504        if ( $core || $plugins || $themes )
     505                list_translation_updates();
     506        unset( $core, $plugins, $themes );
    483507        do_action('core_upgrade_preamble');
    484508        echo '</div>';
    485509        include(ABSPATH . 'wp-admin/admin-footer.php');
     
    567591        echo '</div>';
    568592        include(ABSPATH . 'wp-admin/admin-footer.php');
    569593
     594} elseif ( 'do-translation-upgrade' == $action ) {
     595
     596        if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
     597                wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
     598
     599        check_admin_referer( 'upgrade-translations' );
     600
     601        require_once ABSPATH . 'wp-admin/admin-header.php';
     602        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     603
     604        $url = 'update-core.php?action=do-translation-upgrade';
     605        $nonce = 'upgrade-translations';
     606        $title = __( 'Update Translations' );
     607        $context = WP_LANG_DIR;
     608        $screen = 'tools';
     609
     610        $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context', 'screen' ) ) );
     611        $result = $upgrader->bulk_upgrade();
     612
     613        require_once( ABSPATH . 'wp-admin/admin-footer.php' );
     614
    570615} else {
    571616        do_action('update-core-custom_' . $action);
    572617}