Changeset 13352
- Timestamp:
- 02/23/2010 11:53:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-navigation.php
r13348 r13352 38 38 $messagesdiv = ''; 39 39 $menu_id_in_edit = 0; 40 $updated = false; 40 41 41 42 // Check which menu is selected and if menu is in edit already 42 if ( isset( $_POST['switch_menu'] ) ) 43 if ( isset( $_POST['switch_menu'] ) ) { 43 44 $menu_selected_id = (int) $_POST['menu_select']; 44 elseif ( isset( $_POST['menu_id_in_edit'] ) ) 45 $updated = true; 46 } elseif ( isset( $_POST['menu_id_in_edit'] ) ) { 45 47 $menu_selected_id = (int) $_POST['menu_id_in_edit']; 46 else 48 } else { 47 49 $menu_selected_id = 0; 48 50 } 51 52 if ( isset( $_POST[ 'delete_menu' ] ) && $menu_selected_id > 0 ) { 53 wp_delete_nav_menu( $menu_selected_id ); 54 $menu_selected_id = 0; 55 $updated = true; 56 } 49 57 // Default Menu to show 50 58 $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); 51 if ( ! empty( $custom_menus ) )59 if ( ! $menu_selected_id && ! empty( $custom_menus ) ) 52 60 $menu_selected_id = $custom_menus[0]->term_id; 53 61 … … 65 73 // @todo validate set_wp_menu 66 74 update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] ); 75 $updated = true; 67 76 $messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . __('Menu has been updated!') . '</p></div>'; 68 77 } … … 74 83 75 84 // Create a new menu. Menus are stored as terms in the 'menu' taxonomy. 76 if ( isset( $_POST['add_menu'] ) ) {85 if ( isset( $_POST['add_menu'] ) && ! $updated ) { 77 86 $insert_menu_name = $_POST['add_menu_name']; 78 87 … … 91 100 $messagesdiv = '<div id="message" class="error fade below-h2"><p>' . __('Please enter a valid menu name.') . '</p></div>'; 92 101 } 93 } 94 95 if ( isset($_POST['reset_wp_menu']) ) { 102 $updated = true; 103 } 104 105 if ( isset($_POST['reset_wp_menu']) && ! $updated ) { 96 106 $success = wp_reset_nav_menu(); 97 107 if ( $success ) { … … 105 115 $messagesdiv = '<div id="message" class="error fade below-h2"><p>' . __('The menu could not be reset. Please try again.') . '</p></div>'; 106 116 } 107 } elseif ( $postCounter > 0 && $menu_selected_id > 0 ) {117 } elseif ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) { 108 118 $menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') ); 109 119 $parent_menu_ids = array(); … … 210 220 </script> 211 221 222 <input id="delete_menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" /> 212 223 <input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" /></p> 213 224 </div><!-- /.inside -->
Note: See TracChangeset
for help on using the changeset viewer.