Changeset 40776
- Timestamp:
- 05/18/2017 02:33:04 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/dashboard.php
r40651 r40776 128 128 /** This action is documented in wp-admin/edit-form-advanced.php */ 129 129 do_action( 'do_meta_boxes', $screen->id, 'side', '' ); 130 }131 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 130 } 171 131 … … 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 … … 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 … … 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> … … 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 ); ?> … … 1236 1194 */ 1237 1195 function wp_print_community_events_templates() { 1238 $script_data = wp_get_community_events_script_data();1239 1240 1196 ?> 1241 1197 … … 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 ); ?> -
trunk/src/wp-admin/index.php
r40607 r40776 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' ) ) -
trunk/src/wp-admin/network/index.php
r40607 r40776 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(); -
trunk/src/wp-includes/default-filters.php
r40676 r40776 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' ); -
trunk/src/wp-includes/script-loader.php
r40775 r40776 1002 1002 1003 1003 /** 1004 * Localizes community events data that needs to be passed to dashboard.js. 1005 * 1006 * @since 4.8.0 1007 */ 1008 function wp_localize_community_events() { 1009 if ( ! wp_script_is( 'dashboard' ) ) { 1010 return; 1011 } 1012 1013 require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' ); 1014 1015 $user_id = get_current_user_id(); 1016 $user_location = get_user_option( 'community-events-location', $user_id ); 1017 $events_client = new WP_Community_Events( $user_id, $user_location ); 1018 1019 wp_localize_script( 'dashboard', 'communityEventsData', array( 1020 'nonce' => wp_create_nonce( 'community_events' ), 1021 'cache' => $events_client->get_cached_events(), 1022 1023 'l10n' => array( 1024 'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ), 1025 'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ), 1026 1027 /* 1028 * These specific examples were chosen to highlight the fact that a 1029 * state is not needed, even for cities whose name is not unique. 1030 * It would be too cumbersome to include that in the instructions 1031 * to the user, so it's left as an implication. 1032 */ 1033 /* 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. */ 1034 'could_not_locate_city' => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), 1035 1036 // This one is only used with wp.a11y.speak(), so it can/should be more brief. 1037 /* translators: %s is the name of a city. */ 1038 'city_updated' => __( 'City updated. Listing events near %s.' ), 1039 ) 1040 ) ); 1041 } 1042 1043 /** 1004 1044 * Administration Screen CSS for changing the styles. 1005 1045 *
Note: See TracChangeset
for help on using the changeset viewer.