Ticket #40702: 40702.12.diff
File 40702.12.diff, 8.3 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/dashboard.php
130 130 } 131 131 132 132 /** 133 * Gets the community events data that needs to be passed to dashboard.js.134 *135 * @since 4.8.0136 *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 a156 * state is not needed, even for cities whose name is not unique.157 * It would be too cumbersome to include that in the instructions158 * 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 /**173 133 * Adds a new dashboard widget. 174 134 * 175 135 * @since 2.7.0 … … 1170 1130 * @since 4.8.0 1171 1131 */ 1172 1132 function wp_print_community_events_markup() { 1173 $script_data = wp_get_community_events_script_data();1174 1175 1133 ?> 1176 1134 1177 1135 <div class="community-events-errors notice notice-error inline hide-if-js"> 1178 1136 <p class="hide-if-js"> 1179 <?php _e( 'This widget requires JavaScript.' ); ?>1137 <?php _e( 'This widget requires JavaScript.' ); ?> 1180 1138 </p> 1181 1139 1182 1140 <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.' ); ?> 1184 1142 </p> 1185 1143 1186 1144 <p class="community-events-could-not-locate" aria-hidden="true"></p> 1187 1145 </div> 1188 1146 1189 1147 <div class="community-events-loading hide-if-no-js"> 1190 <?php _e( 'Loading…' ); ?>1148 <?php _e( 'Loading…' ); ?> 1191 1149 </div> 1192 1150 1193 1151 <?php … … 1201 1159 <p> 1202 1160 <span id="community-events-location-message"></span> 1203 1161 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"> 1205 1163 <span class="dashicons dashicons-edit"></span> 1206 1164 </button> 1207 1165 </p> … … 1211 1169 <?php _e( 'City:' ); ?> 1212 1170 </label> 1213 1171 <?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' ); ?>" /> 1215 1173 1216 1174 <?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?> 1217 1175 … … 1235 1193 * @since 4.8.0 1236 1194 */ 1237 1195 function wp_print_community_events_templates() { 1238 $script_data = wp_get_community_events_script_data();1239 1240 1196 ?> 1241 1197 1242 1198 <script id="tmpl-community-events-attend-event-near" type="text/template"> … … 1249 1205 1250 1206 <script id="tmpl-community-events-could-not-locate" type="text/template"> 1251 1207 <?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’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), 1253 1210 '<em>{{data.unknownCity}}</em>' 1254 1211 ); ?> 1255 1212 </script> -
src/wp-admin/index.php
15 15 wp_dashboard_setup(); 16 16 17 17 wp_enqueue_script( 'dashboard' ); 18 wp_localize_script( 'dashboard', 'communityEventsData', wp_get_community_events_script_data() );19 18 20 19 if ( current_user_can( 'edit_theme_options' ) ) 21 20 wp_enqueue_script( 'customize-loader' ); -
src/wp-admin/network/index.php
54 54 wp_dashboard_setup(); 55 55 56 56 wp_enqueue_script( 'dashboard' ); 57 wp_localize_script( 'dashboard', 'communityEventsData', wp_get_community_events_script_data() );58 57 wp_enqueue_script( 'plugin-install' ); 59 58 add_thickbox(); 60 59 -
src/wp-includes/default-filters.php
434 434 add_action( 'wp_default_scripts', 'wp_default_scripts' ); 435 435 add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); 436 436 add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); 437 add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' ); 437 438 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); 438 439 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); 439 440 add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 ); -
src/wp-includes/script-loader.php
1001 1001 } 1002 1002 1003 1003 /** 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 */ 1010 function 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’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 /** 1004 1042 * Administration Screen CSS for changing the styles. 1005 1043 * 1006 1044 * If installing the 'wp-admin/' directory will be replaced with './'.