Make WordPress Core

Ticket #40702: 40702.12.diff

File 40702.12.diff, 8.3 KB (added by obenland, 7 years ago)
  • src/wp-admin/includes/dashboard.php

     
    130130}
    131131
    132132/**
    133  * Gets the community events data that needs to be passed to dashboard.js.
    134  *
    135  * @since 4.8.0
    136  *
    137  * @return array The script data.
    138  */
    139 function wp_get_community_events_script_data() {
    140         require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
    141 
    142         $user_id       = get_current_user_id();
    143         $user_location = get_user_option( 'community-events-location', $user_id );
    144         $events_client = new WP_Community_Events( $user_id, $user_location );
    145 
    146         $script_data = array(
    147                 'nonce' => wp_create_nonce( 'community_events' ),
    148                 'cache' => $events_client->get_cached_events(),
    149 
    150                 'l10n' => array(
    151                         'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),
    152                         'error_occurred_please_try_again' => __( 'An error occured. Please try again.' ),
    153 
    154                         /*
    155                          * These specific examples were chosen to highlight the fact that a
    156                          * state is not needed, even for cities whose name is not unique.
    157                          * It would be too cumbersome to include that in the instructions
    158                          * to the user, so it's left as an implication.
    159                          */
    160                         /* translators: %s is the name of the city we couldn't locate. Replace the examples with cities in your locale, but test that they match the expected location before including them. Use endonyms (native locale names) whenever possible. */
    161                         'could_not_locate_city' => __( "We couldn't locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland." ),
    162 
    163                         // This one is only used with wp.a11y.speak(), so it can/should be more brief.
    164                         /* translators: %s is the name of a city. */
    165                         'city_updated' => __( 'City updated. Listing events near %s.' ),
    166                 )
    167         );
    168 
    169         return $script_data;
    170 }
    171 
    172 /**
    173133 * Adds a new dashboard widget.
    174134 *
    175135 * @since 2.7.0
     
    11701130 * @since 4.8.0
    11711131 */
    11721132function wp_print_community_events_markup() {
    1173         $script_data = wp_get_community_events_script_data();
    1174 
    11751133        ?>
    11761134
    11771135        <div class="community-events-errors notice notice-error inline hide-if-js">
    11781136                <p class="hide-if-js">
    1179                         <?php _e( 'This widget requires JavaScript.'); ?>
     1137                        <?php _e( 'This widget requires JavaScript.' ); ?>
    11801138                </p>
    11811139
    11821140                <p class="community-events-error-occurred" aria-hidden="true">
    1183                         <?php echo $script_data['l10n']['error_occurred_please_try_again']; ?>
     1141                        <?php _e( 'An error occurred. Please try again.' ); ?>
    11841142                </p>
    11851143
    11861144                <p class="community-events-could-not-locate" aria-hidden="true"></p>
    11871145        </div>
    11881146
    11891147        <div class="community-events-loading hide-if-no-js">
    1190                 <?php _e( 'Loading&hellip;'); ?>
     1148                <?php _e( 'Loading&hellip;' ); ?>
    11911149        </div>
    11921150
    11931151        <?php
     
    12011159                        <p>
    12021160                                <span id="community-events-location-message"></span>
    12031161
    1204                                 <button class="button-link community-events-toggle-location" aria-label="<?php _e( 'Edit city'); ?>" aria-expanded="false">
     1162                                <button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
    12051163                                        <span class="dashicons dashicons-edit"></span>
    12061164                                </button>
    12071165                        </p>
     
    12111169                                        <?php _e( 'City:' ); ?>
    12121170                                </label>
    12131171                                <?php /* translators: Replace with the name of a city in your locale that shows events. Use only the city name itself, without any region or country. Use the endonym instead of the English name. */ ?>
    1214                                 <input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php _e( 'Cincinnati' ); ?>" />
     1172                                <input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
    12151173
    12161174                                <?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
    12171175
     
    12351193 * @since 4.8.0
    12361194 */
    12371195function wp_print_community_events_templates() {
    1238         $script_data = wp_get_community_events_script_data();
    1239 
    12401196        ?>
    12411197
    12421198        <script id="tmpl-community-events-attend-event-near" type="text/template">
     
    12491205
    12501206        <script id="tmpl-community-events-could-not-locate" type="text/template">
    12511207                <?php printf(
    1252                         $script_data['l10n']['could_not_locate_city'],
     1208                        /* translators: %s is the name of the city we couldn't locate. Replace the examples with cities in your locale, but test that they match the expected location before including them. Use endonyms (native locale names) whenever possible. */
     1209                        __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
    12531210                        '<em>{{data.unknownCity}}</em>'
    12541211                ); ?>
    12551212        </script>
  • src/wp-admin/index.php

     
    1515wp_dashboard_setup();
    1616
    1717wp_enqueue_script( 'dashboard' );
    18 wp_localize_script( 'dashboard', 'communityEventsData', wp_get_community_events_script_data() );
    1918
    2019if ( current_user_can( 'edit_theme_options' ) )
    2120        wp_enqueue_script( 'customize-loader' );
  • src/wp-admin/network/index.php

     
    5454wp_dashboard_setup();
    5555
    5656wp_enqueue_script( 'dashboard' );
    57 wp_localize_script( 'dashboard', 'communityEventsData', wp_get_community_events_script_data() );
    5857wp_enqueue_script( 'plugin-install' );
    5958add_thickbox();
    6059
  • src/wp-includes/default-filters.php

     
    434434add_action( 'wp_default_scripts', 'wp_default_scripts' );
    435435add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
    436436add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
     437add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' );
    437438add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
    438439add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
    439440add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
  • src/wp-includes/script-loader.php

     
    10011001}
    10021002
    10031003/**
     1004 * Gets the community events data that needs to be passed to dashboard.js.
     1005 *
     1006 * @since 4.8.0
     1007 *
     1008 * @return array The script data.
     1009 */
     1010function wp_localize_community_events() {
     1011        require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
     1012
     1013        $user_id       = get_current_user_id();
     1014        $user_location = get_user_option( 'community-events-location', $user_id );
     1015        $events_client = new WP_Community_Events( $user_id, $user_location );
     1016
     1017        wp_localize_script( 'dashboard', 'communityEventsData', array(
     1018                'nonce' => wp_create_nonce( 'community_events' ),
     1019                'cache' => $events_client->get_cached_events(),
     1020
     1021                'l10n' => array(
     1022                        'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),
     1023                        'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
     1024
     1025                        /*
     1026                         * These specific examples were chosen to highlight the fact that a
     1027                         * state is not needed, even for cities whose name is not unique.
     1028                         * It would be too cumbersome to include that in the instructions
     1029                         * to the user, so it's left as an implication.
     1030                         */
     1031                        /* translators: %s is the name of the city we couldn't locate. Replace the examples with cities in your locale, but test that they match the expected location before including them. Use endonyms (native locale names) whenever possible. */
     1032                        'could_not_locate_city' => __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
     1033
     1034                        // This one is only used with wp.a11y.speak(), so it can/should be more brief.
     1035                        /* translators: %s is the name of a city. */
     1036                        'city_updated' => __( 'City updated. Listing events near %s.' ),
     1037                )
     1038        ) );
     1039}
     1040
     1041/**
    10041042 * Administration Screen CSS for changing the styles.
    10051043 *
    10061044 * If installing the 'wp-admin/' directory will be replaced with './'.