WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/24/2010 09:43:09 AM (11 years ago)
Author:
markjaquith
Message:

Remove Resetting, remove Enabling, enable deletion, etc. see #11817

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/nav-menus.php

    r13368 r13369  
    7171}
    7272
    73 if ( isset( $_POST['set_wp_menu'] ) ) {
    74     // @todo validate set_wp_menu
    75     update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] );
    76     $updated = true;
    77     $messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . __('Menu has been updated!') . '</p></div>';
    78 }
    79 
    8073if ( isset( $_POST['licount'] ) )
    8174    $postCounter = $_POST['licount'];
     
    8578// Create a new menu. Menus are stored as terms in the 'menu' taxonomy.
    8679if ( isset( $_POST['add_menu'] ) && ! $updated ) {
     80    update_option( 'wp_custom_nav_menu', $_POST['enable_wp_menu'] ); // Do we need this?
    8781    $insert_menu_name = $_POST['add_menu_name'];
    8882
     
    9589            $menu_selected_id = $menu->term_id;
    9690            $menu_id_in_edit = $menu_selected_id;
     91            $menu_title = $menu->name;
    9792            $messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . esc_html( sprintf( __('"%s" menu has been created!'), $menu->name ) ) . '</p></div>';
    9893            $postCounter = 0;
     
    10499}
    105100
    106 if ( isset($_POST['reset_wp_menu']) && ! $updated ) {
    107     $success = wp_reset_nav_menu();
    108     if ( $success ) {
    109         // DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly
    110         $messagesdiv = '<div id="message" class="updated fade below-h2"><p>' . __('The menu has been reset.') . '</p></div>';
    111         // GET reset menu id
    112         $custom_menus = array();
    113         $menu_selected_id = 0;
    114     } else {
    115         // DISPLAY SUCCESS MESSAGE IF Menu Reset Correctly
    116         $messagesdiv = '<div id="message" class="error fade below-h2"><p>' . __('The menu could not be reset. Please try again.') . '</p></div>';
    117     }
    118 } elseif ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
     101if ( $postCounter > 0 && $menu_selected_id > 0 && ! $updated ) {
    119102    $menu_items = wp_get_nav_menu_items( $menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
    120103    $parent_menu_ids = array();
     
    175158    <div class="hide-if-no-js">
    176159    <div id="pages-left">
     160    <?php if ( ! empty( $custom_menus ) && count( $custom_menus ) > 1 ) { ?>
    177161        <ul class="subsubsub">
    178 <?php       if ( ! empty( $custom_menus ) ) {
     162<?php
    179163                foreach ( $custom_menus as $menu ) {
    180164                    $sep = end($custom_menus) == $menu ? '' : ' | ';
     
    186170<?php               }
    187171                }
    188             } else { ?>
    189             <li><?php _e( 'Default' ); ?></li>
    190 <?php       } ?>
     172?>
    191173        </ul>
    192174        <div class="clear"></div>
     175<?php } ?>
     176        <form onsubmit="updatepostdata()" action="nav-menus.php" method="post"  enctype="multipart/form-data">
    193177        <div class="inside">
    194         <?php
    195             // CHECK if custom menu has been enabled
    196             $enabled_menu = get_option('wp_custom_nav_menu');
    197             $checked = strtolower($enabled_menu);
    198 
    199             if ( $checked != 'true' )
    200                 echo '<div id="message-enabled" class="error fade below-h2"><p><strong>' . __('Menu editing has not been Enabled yet. Please enable it in order to use it -------->') . '</strong></p></div>';
    201         ?>
     178        <?php if ( ! empty( $custom_menus ) ) : ?>
    202179        <?php echo $messagesdiv; ?>
    203         <form onsubmit="updatepostdata()" action="nav-menus.php" method="post"  enctype="multipart/form-data">
    204180
    205181        <input type="hidden" name="licount" id="licount" value="0" />
     
    207183
    208184        <div class="sidebar-name">
    209 
    210185            <div class="sidebar-name-arrow">
    211186                <br/>
     
    236211            updatepostdata();
    237212        </script>
    238         <!-- <input id="delete_menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" /> -->
    239         <input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" /></p>
     213        <input id="save_bottom" name="save_bottom" type="submit" value="<?php esc_attr_e('Save All Changes'); ?>" />
     214        <input id="delete_menu" name="delete_menu" type="submit" value="<?php esc_attr_e('Delete This Menu'); ?>" />
     215        </p>
     216
     217    <?php else : ?>
     218        <div class="updated below-h2"><p><?php _e( 'Add a menu to start editing!' ); ?></p></div>
     219    <?php endif; ?>
    240220        </div><!-- /.inside -->
    241221    </div>
     
    245225            <div class="sidebar-name">
    246226                <div class="sidebar-name-arrow"></div>
    247                 <h3><?php esc_html_e('Setup Menus'); ?></h3>
     227                <h3><?php esc_html_e('Add Menu'); ?></h3>
    248228            </div>
    249229            <div class="widget-holder">
    250230
    251                 <?php
    252                 // Setup custom menu
    253                 $enabled_menu = get_option('wp_custom_nav_menu');
    254                 $checked = strtolower($enabled_menu);
    255                 ?>
    256 
    257                 <span >
    258                     <label><?php _e('Enable'); ?></label><input type="radio" name="enable_wp_menu" value="true" <?php if ($checked=='true') { echo 'checked="checked"'; } ?> />
    259                     <label><?php _e('Disable'); ?></label><input type="radio" name="enable_wp_menu" value="false" <?php if ($checked=='true') { } else { echo 'checked="checked"'; } ?> />
    260                 </span><!-- /.checkboxes -->
    261 
    262                 <input id="set_wp_menu" type="submit" value="<?php esc_attr_e('Set Menu'); ?>" name="set_wp_menu" class="button" /><br />
    263 
    264                 <span>
    265                     <label><?php _e('Reset Menu to Default'); ?></label>
    266                     <input id="reset_wp_menu" type="submit" value="Reset" name="reset_wp_menu" class="button" onclick="return confirm('<?php _e('Are you sure you want to reset the menu to its default settings?'); ?>');" />
    267                 </span>
    268                 <br /><br />
    269231                <span>
    270232                <input id="add_menu_name" name="add_menu_name" type="text" value=""  />
     
    273235            </div>
    274236        </div><!-- /.widgets-holder-wrap -->
     237<?php /* ?>
    275238        <?php $advanced_option_descriptions = get_option('wp_settings_custom_nav_advanced_options'); ?>
    276239        <div class="widgets-holder-wrap" style="display:none;">
     
    310273            </div>
    311274        </div><!-- /.widgets-holder-wrap -->
    312 
     275<?php */ ?>
    313276        <div class="widgets-holder-wrap">
    314277            <div class="sidebar-name">
Note: See TracChangeset for help on using the changeset viewer.