]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/nav-menus.php
WordPress 3.4.2-scripts
[autoinstalls/wordpress.git] / wp-admin / nav-menus.php
index 5b4bd44e00bd978dae0ab749bd388423f0751f92..6b4b032389d13fc16f39e59eaa9f73dee6db7ef4 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 /** Load WordPress Administration Bootstrap */
-require_once( 'admin.php' );
+require_once( './admin.php' );
 
 // Load all the nav menu interface functions
 require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
@@ -22,11 +22,7 @@ if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets'
 if ( ! current_user_can('edit_theme_options') )
        wp_die( __( 'Cheatin’ uh?' ) );
 
-// Nav Menu CSS
-wp_admin_css( 'nav-menu' );
-
 // jQuery
-wp_enqueue_script( 'jquery' );
 wp_enqueue_script( 'jquery-ui-draggable' );
 wp_enqueue_script( 'jquery-ui-droppable' );
 wp_enqueue_script( 'jquery-ui-sortable' );
@@ -39,6 +35,9 @@ wp_enqueue_script( 'common' );
 wp_enqueue_script( 'wp-lists' );
 wp_enqueue_script( 'postbox' );
 
+if ( wp_is_mobile() )
+       wp_enqueue_script( 'jquery-touch-punch' );
+
 // Container for any messages displayed to the user
 $messages = array();
 
@@ -70,7 +69,7 @@ switch ( $action ) {
                                $ordered_menu_items = wp_get_nav_menu_items( $menu_id );
                                $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
 
-                               // setup the data we need in one pass through the array of menu items
+                               // set up the data we need in one pass through the array of menu items
                                $dbids_to_orders = array();
                                $orders_to_dbids = array();
                                foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
@@ -121,7 +120,6 @@ switch ( $action ) {
                                                wp_update_post($next_item_data);
                                        }
 
-
                                // the item is last but still has a parent, so bubble up
                                } elseif (
                                        ! empty( $menu_item_data['menu_item_parent'] ) &&
@@ -144,7 +142,7 @@ switch ( $action ) {
                                $ordered_menu_items = wp_get_nav_menu_items( $menu_id );
                                $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
 
-                               // setup the data we need in one pass through the array of menu items
+                               // set up the data we need in one pass through the array of menu items
                                $dbids_to_orders = array();
                                $orders_to_dbids = array();
                                foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
@@ -156,7 +154,6 @@ switch ( $action ) {
                                        }
                                }
 
-
                                // if this menu item is not first
                                if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) {
 
@@ -232,7 +229,6 @@ switch ( $action ) {
 
                check_admin_referer( 'delete-menu_item_' . $menu_item_id );
 
-
                if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) )
                        $messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
                break;
@@ -290,9 +286,6 @@ switch ( $action ) {
                                if ( is_wp_error( $_nav_menu_selected_id ) ) {
                                        $messages[] = '<div id="message" class="error"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
                                } else {
-                                       if ( ( $_menu_locations = get_registered_nav_menus() ) && 1 == count( wp_get_nav_menus() ) )
-                                               set_theme_mod( 'nav_menu_locations', array( key( $_menu_locations ) => $_nav_menu_selected_id ) );
-                                       unset( $_menu_locations );
                                        $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
                                        $nav_menu_selected_id = $_nav_menu_selected_id;
                                        $nav_menu_selected_title = $_menu_object->name;
@@ -437,32 +430,44 @@ $_wp_nav_menu_max_depth = 0;
 
 // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth
 if ( is_nav_menu( $nav_menu_selected_id ) )
-       $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id  );
+       $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id );
 
-function wp_nav_menu_max_depth() {
+function wp_nav_menu_max_depth($classes) {
        global $_wp_nav_menu_max_depth;
-       return "menu-max-depth-$_wp_nav_menu_max_depth";
+       return "$classes menu-max-depth-$_wp_nav_menu_max_depth";
 }
 
-add_action('admin_body_class','wp_nav_menu_max_depth');
+add_filter('admin_body_class', 'wp_nav_menu_max_depth');
 
 wp_nav_menu_setup();
 wp_initial_nav_menu_meta_boxes();
 
 if ( ! current_theme_supports( 'menus' ) && ! wp_get_nav_menus() )
-       echo '<div id="message" class="updated"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
-
-$help =  '<p>' . __('This feature is new in version 3.0; to use a custom menu in place of your theme&#8217;s default menus, support for this feature must be registered in the theme&#8217;s functions.php file. If your theme does not support the custom menus feature yet (the new default theme, Twenty Ten, does), you can learn about adding support yourself by following the below link.') . '</p>';
-$help .= '<p>' . __('You can create custom menus for your site. These menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '</p>';
-$help .= '<p>' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You&#8217;ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. You&#8217;ll see when the position of the drop target shifts over to create the nested placement. Don&#8217;t forget to click Save when you&#8217;re finished.') . '</p>';
-$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
-$help .= '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Menus_SubPanel" target="_blank">Menus Documentation</a>') . '</p>';
-$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
-
-add_contextual_help($current_screen, $help);
+       $messages[] = '<div id="message" class="updated"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
+
+get_current_screen()->add_help_tab( array(
+'id'           => 'overview',
+'title'                => __('Overview'),
+'content'      =>
+       '<p>' . __('This feature allows you to use a custom menu in place of your theme&#8217;s default menus.') . '</p>' .
+       '<p>' . __('Custom menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '</p>' .
+       '<p>' . __('If your theme does not support the custom menus feature yet (the default themes, Twenty Eleven and Twenty Ten, do), you can learn about adding this support by following the Documentation link to the side.') . '</p>'
+) );
+get_current_screen()->add_help_tab( array(
+'id'           => 'create-menus',
+'title'                => __('Create Menus'),
+'content'      =>
+       '<p>' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You&#8217;ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. Drop the item into its new nested placement when the dotted rectangle target shifts over, also a little to the right. Don&#8217;t forget to click Save when you&#8217;re finished.') . '</p>'
+) );
+
+get_current_screen()->set_help_sidebar(
+       '<p><strong>' . __('For more information:') . '</strong></p>' .
+       '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Menus_Screen" target="_blank">Documentation on Menus</a>') . '</p>' .
+       '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
 
 // Get the admin header
-require_once( 'admin-header.php' );
+require_once( './admin-header.php' );
 ?>
 <div class="wrap">
        <?php screen_icon(); ?>
@@ -497,7 +502,7 @@ require_once( 'admin-header.php' );
                                                <option value="0"><?php esc_html_e('Add New Menu'); ?></option>
                                        </select>
                                        <input type="hidden" name="action" value="edit" />
-                                       <input class="button-secondary" name="select_menu" type="submit" value="<?php esc_attr_e('Select'); ?>" />
+                                       <?php submit_button( __( 'Select' ), 'secondary', 'select_menu', false ); ?>
                                </form>
                        </div>
                        <div class="nav-tabs-wrapper">
@@ -540,7 +545,7 @@ require_once( 'admin-header.php' );
                                                        <div class="major-publishing-actions">
                                                                <label class="menu-name-label howto open-label" for="menu-name">
                                                                        <span><?php _e('Menu Name'); ?></span>
-                                                                       <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Enter menu name here'); ?>" value="<?php echo esc_attr( $nav_menu_selected_title  ); ?>" />
+                                                                       <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Enter menu name here'); ?>" value="<?php echo esc_attr( $nav_menu_selected_title ); ?>" />
                                                                </label>
                                                                <?php if ( !empty( $nav_menu_selected_id ) ) :
                                                                        if ( ! isset( $auto_add ) ) {
@@ -559,7 +564,7 @@ require_once( 'admin-header.php' );
                                                                <?php endif; ?>
                                                                <br class="clear" />
                                                                <div class="publishing-action">
-                                                                       <input class="button-primary menu-save" name="save_menu" type="submit" value="<?php empty($nav_menu_selected_id) ? esc_attr_e('Create Menu') : esc_attr_e('Save Menu'); ?>" />
+                                                                       <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?>
                                                                </div><!-- END .publishing-action -->
 
                                                                <?php if ( ! empty( $nav_menu_selected_id ) ) : ?>
@@ -593,6 +598,16 @@ require_once( 'admin-header.php' );
                                                        ?>
                                                </div><!-- /#post-body-content -->
                                        </div><!-- /#post-body -->
+                                       <div id="nav-menu-footer">
+                                               <div class="major-publishing-actions">
+                                               <div class="publishing-action">
+                                                       <?php
+                                                       if ( ! empty( $nav_menu_selected_id ) )
+                                                               submit_button( __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_footer' ) );
+                                                       ?>
+                                               </div>
+                                               </div>
+                                       </div><!-- /#nav-menu-footer -->
                                </form><!-- /#update-nav-menu -->
                        </div><!-- /.menu-edit -->
                </div><!-- /#menu-management -->
@@ -600,5 +615,4 @@ require_once( 'admin-header.php' );
        </div><!-- /#nav-menus-frame -->
 </div><!-- /.wrap-->
 
-
-<?php include( 'admin-footer.php' ); ?>
+<?php include( './admin-footer.php' ); ?>