Ticket #38057: 38057.patch
| File 38057.patch, 4.5 KB (added by , 9 years ago) |
|---|
-
wp-admin/includes/nav-menu.php
1074 1074 1075 1075 wp_defer_term_counting( false ); 1076 1076 1077 // Backwards compatibility similar to wp-includes/nav-menu.php 1078 $menu_data = get_term( $nav_menu_selected_id, '', ARRAY_A ); 1079 if ( ! empty( $menu_data['name'] ) ) { 1080 $menu_data['menu-name'] = $menu_data['name']; 1081 } 1082 1077 1083 /** This action is documented in wp-includes/nav-menu.php */ 1078 do_action( 'wp_update_nav_menu', $nav_menu_selected_id );1084 do_action( 'wp_update_nav_menu', $nav_menu_selected_id, $menu_data ); 1079 1085 1080 1086 $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . 1081 1087 /* translators: %s: nav menu title */ -
wp-includes/nav-menu.php
262 262 * @since 3.0.0 263 263 * 264 264 * @param int $menu_id The ID of the menu or "0" to create a new menu. 265 * @param array $menu_data The array of menu data.265 * @param array $menu_data The array of menu term metadata. 266 266 * @return int|WP_Error Menu ID on success, WP_Error object on failure. 267 267 */ 268 268 function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { … … 271 271 272 272 $_menu = wp_get_nav_menu_object( $menu_id ); 273 273 274 // Also accept a `menu` key as fallback 275 if ( empty( $menu_data['menu-name'] ) && ! empty( $menu_data['name'] ) ) { 276 $menu_data['menu-name'] = $menu_data['name']; 277 } 278 274 279 $args = array( 275 'description' => ( isset( $menu_data['description'] ) ? $menu_data['description'] : '' ),276 'name' => ( isset( $menu_data['menu-name'] ) ? $menu_data['menu-name'] : ''),277 'parent' => ( isset( $menu_data['parent'] ) ? (int) $menu_data['parent'] : 0 ),280 'description' => ( ! empty( $menu_data['description'] ) ? $menu_data['description'] : '' ), 281 'name' => ( ! empty( $menu_data['menu-name'] ) ? $menu_data['menu-name'] : _x( '(unnamed)', 'Missing menu name.' ) ), 282 'parent' => ( ! empty( $menu_data['parent'] ) ? (int) $menu_data['parent'] : 0 ), 278 283 'slug' => null, 279 284 ); 280 285 286 // backwards compatibility for action hooks 287 $args['menu-name'] = $args['name']; 288 281 289 // double-check that we're not going to have one menu take the name of another 282 $_possible_existing = get_term_by( 'name', $ menu_data['menu-name'], 'nav_menu' );290 $_possible_existing = get_term_by( 'name', $args['name'], 'nav_menu' ); 283 291 if ( 284 292 $_possible_existing && 285 293 ! is_wp_error( $_possible_existing ) && … … 289 297 return new WP_Error( 'menu_exists', 290 298 /* translators: %s: menu name */ 291 299 sprintf( __( 'The menu name %s conflicts with another menu name. Please try another.' ), 292 '<strong>' . esc_html( $ menu_data['menu-name'] ) . '</strong>'300 '<strong>' . esc_html( $args['name'] ) . '</strong>' 293 301 ) 294 302 ); 295 303 } … … 296 304 297 305 // menu doesn't already exist, so create a new menu 298 306 if ( ! $_menu || is_wp_error( $_menu ) ) { 299 $menu_exists = get_term_by( 'name', $ menu_data['menu-name'], 'nav_menu' );307 $menu_exists = get_term_by( 'name', $args['name'], 'nav_menu' ); 300 308 301 309 if ( $menu_exists ) { 302 310 return new WP_Error( 'menu_exists', 303 311 /* translators: %s: menu name */ 304 312 sprintf( __( 'The menu name %s conflicts with another menu name. Please try another.' ), 305 '<strong>' . esc_html( $ menu_data['menu-name'] ) . '</strong>'313 '<strong>' . esc_html( $args['name'] ) . '</strong>' 306 314 ) 307 315 ); 308 316 } 309 317 310 $_menu = wp_insert_term( $ menu_data['menu-name'], 'nav_menu', $args );318 $_menu = wp_insert_term( $args['name'], 'nav_menu', $args ); 311 319 312 320 if ( is_wp_error( $_menu ) ) 313 321 return $_menu; … … 318 326 * @since 3.0.0 319 327 * 320 328 * @param int $term_id ID of the new menu. 321 * @param array $menu_data An array of menu data.329 * @param array $menu_data An array of menu term metadata currently available. 322 330 */ 323 do_action( 'wp_create_nav_menu', $_menu['term_id'], $ menu_data);331 do_action( 'wp_create_nav_menu', $_menu['term_id'], $args ); 324 332 325 333 return (int) $_menu['term_id']; 326 334 } … … 343 351 * @since 3.0.0 344 352 * 345 353 * @param int $menu_id ID of the updated menu. 346 * @param array $menu_data An array of menu data.354 * @param array $menu_data An array of menu term metadata currently available. 347 355 */ 348 do_action( 'wp_update_nav_menu', $menu_id, $ menu_data);356 do_action( 'wp_update_nav_menu', $menu_id, $args ); 349 357 return $menu_id; 350 358 } 351 359