Make WordPress Core

Ticket #23119: 23119.15.diff

File 23119.15.diff, 33.5 KB (added by jkudish, 11 years ago)

first implementation of WP_Menus_List_Table

  • wp-admin/includes/list-table.php

     
    2323                'WP_Posts_List_Table' => 'posts',
    2424                'WP_Media_List_Table' => 'media',
    2525                'WP_Terms_List_Table' => 'terms',
     26                'WP_Menus_List_Table' => 'menus',
    2627                'WP_Users_List_Table' => 'users',
    2728                'WP_Comments_List_Table' => 'comments',
    2829                'WP_Post_Comments_List_Table' => 'comments',
  • wp-admin/includes/misc.php

     
    346346                        case 'upload_per_page':
    347347                        case 'edit_tags_per_page':
    348348                        case 'plugins_per_page':
     349                        case 'nav_menus_per_page':
    349350                        // Network admin
    350351                        case 'sites_network_per_page':
    351352                        case 'users_network_per_page':
  • wp-admin/includes/class-wp-menus-list-table.php

     
     1<?php
     2
     3/**
     4 * Nav Menus List Table class.
     5 *
     6 * @package WordPress
     7 * @subpackage List_Table
     8 * @since 3.6
     9 * @access private
     10 */
     11class WP_Menus_List_Table extends WP_List_Table {
     12
     13        function __construct( $args = array() ) {
     14
     15                parent::__construct( array(
     16                                'plural' => 'menus',
     17                                'singular' => 'menu',
     18                                'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     19                        ) );
     20
     21        }
     22
     23        function ajax_user_can() {
     24                return current_user_can( 'edit_theme_options' );
     25        }
     26
     27        function prepare_items() {
     28
     29                $args = array();
     30
     31                // order & orderby
     32                $valid_arg_options = array(
     33                        'orderby' => $this->get_sortable_columns(),
     34                        'order' => array( 'asc', 'desc' ),
     35                );
     36                foreach ( $valid_arg_options as $arg_key => $valid_options ) {
     37                        if ( ! empty( $_REQUEST[$arg_key] ) && in_array( $_REQUEST[$arg_key], $valid_options ) )
     38                                $args[$arg_key] = $_REQUEST[$arg_key];
     39                }
     40
     41                // search
     42                if ( ! empty( $_REQUEST['s'] ) )
     43                        $args['search'] = strip_tags( trim( $_REQUEST['s'] ) );
     44
     45                // pagination
     46                $per_page = apply_filters( 'nav_menus_per_page', $this->get_items_per_page( 'nav_menus_per_page' ) );
     47                $page = $this->get_pagenum();
     48                $total_items = wp_get_nav_menus( $args );
     49
     50                $defaults = array(
     51                        'orderby' => 'name',
     52                        'order' => 'asc',
     53                        'offset' => ( $page - 1 ) * $per_page,
     54                        'number' => $per_page,
     55                );
     56                $args = wp_parse_args( $args, $defaults );
     57                $args = apply_filters( 'nav_menus_table_list_prepare_items_args', $args );
     58
     59                $_args_to_calc_total_items = $args;
     60                unset( $_args_to_calc_total_items['offset'] );
     61                $_args_to_calc_total_items['fields'] = 'count';
     62                $total_items = absint( wp_get_nav_menus( $_args_to_calc_total_items ) );
     63
     64                $this->items = wp_get_nav_menus( $args );
     65
     66                $this->set_pagination_args( array(
     67                        'total_items' => $total_items,
     68                        'per_page' => $per_page,
     69                ) );
     70
     71        }
     72
     73        function get_bulk_actions() {
     74                $actions = array();
     75                $actions['delete'] = __( 'Delete' );
     76
     77                return apply_filters( 'nav_menus_bulk_actions', $actions );
     78        }
     79
     80        function current_action() {
     81                if ( 'delete' == $_REQUEST['action'] || 'delete_menus' == $_REQUEST['action2'] )
     82                        return 'bulk-delete';
     83
     84                return parent::current_action();
     85        }
     86
     87        function get_columns() {
     88                $columns = array(
     89                        'cb'          => '<input type="checkbox" />',
     90                        'name'            => __( 'Menu Name' ),
     91                        'count'       => __( '# of links' ),
     92                );
     93
     94                return $columns;
     95        }
     96
     97        function get_sortable_columns() {
     98                $sortable_columns = array(
     99                        'name'  => 'name',
     100                        'count' => 'count',
     101                );
     102
     103                return $sortable_columns;
     104        }
     105
     106
     107        function single_row( $nav_menu, $level = 0 ) {
     108                static $row_class = '';
     109                $row_class = ( $row_class == '' ? ' class="alternate"' : '' );
     110
     111                echo '<tr id="' . esc_attr( 'menu-' . $nav_menu->term_id  ) . '"' . $row_class . '>';
     112                echo $this->single_row_columns( $nav_menu );
     113                echo '</tr>';
     114        }
     115
     116        function column_default( $nav_menu, $column_name ) {
     117                return apply_filters( 'manage_nav_menu_custom_column', '', $column_name, $nav_menu->term_id );
     118        }
     119
     120
     121        function column_cb( $nav_menu ) {
     122                return '<label class="screen-reader-text" for="' . esc_attr( 'cb-select-' . $nav_menu->term_id . '">' . sprintf( __( 'Select %s' ), $nav_menu->name ) ) . '"></label>' . '<input type="checkbox" name="delete_menus[]" value="' . esc_attr( $nav_menu->term_id ) . '" id="' . esc_attr( 'cb-select-' . $nav_menu->term_id ) . '" />';
     123
     124                return '&nbsp;';
     125        }
     126
     127        function column_name( $nav_menu ) {
     128
     129                $edit_link = esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => absint( $nav_menu->term_id ) ) ) );
     130                $delete_link = wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'menu' => absint( $nav_menu->term_id ) ) ) );
     131
     132                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $nav_menu->name ) ) . '">' . $nav_menu->name . '</a></strong><br />';
     133
     134                $actions = array();
     135                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
     136                $actions['delete'] = "<a class='delete-menu' href='" . $delete_link . "'>" . __( 'Delete' ) . "</a>";
     137
     138
     139                $actions = apply_filters( 'nave_menu_row_actions', $actions, $nav_menu );
     140
     141                $out .= $this->row_actions( $actions );
     142
     143                return $out;
     144        }
     145
     146        function column_count( $nav_menu ) {
     147                return $nav_menu->count;
     148        }
     149
     150}
     151 No newline at end of file
  • wp-admin/includes/nav-menu.php

     
    8080                }
    8181
    8282                $title = empty( $item->label ) ? $title : $item->label;
     83               
     84                $submenu_text = '';
     85                if (0 == $depth)
     86                        $submenu_text = 'style="display: none;"';
    8387
    8488                ?>
    8589                <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
    8690                        <dl class="menu-item-bar">
    8791                                <dt class="menu-item-handle">
    88                                         <span class="item-title"><?php echo esc_html( $title ); ?></span>
     92                                        <span class="item-title"><?php echo esc_html( $title ); ?> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span>
    8993                                        <span class="item-controls">
    9094                                                <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
    9195                                                <span class="item-order hide-if-js">
     
    382386 **/
    383387function wp_nav_menu_setup() {
    384388        // Register meta boxes
    385         if ( wp_get_nav_menus() )
    386                 add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
    387         add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
    388         wp_nav_menu_post_type_meta_boxes();
    389         wp_nav_menu_taxonomy_meta_boxes();
     389        if ( wp_get_nav_menus() && ! isset( $_POST['menu-name'] ) && ! isset( $_GET['action'] ) || isset( $_GET['_wpnonce'] ) )
     390                add_meta_box( 'nav-menu-theme-locations', __( 'Menus within your theme' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
     391       
     392        $nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
     393       
     394        if ( empty( $nav_menus ) || isset( $_POST['menu-name'] ) || isset( $_GET['action'] ) && ! isset( $_GET['_wpnonce'] ) ) {
     395                wp_nav_menu_post_type_meta_boxes();
     396                add_meta_box( 'add-common-links', __('Common Links'), 'wp_nav_menu_item_common_link_meta_box', 'nav-menus', 'side', 'core' );
     397                add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
     398                wp_nav_menu_taxonomy_meta_boxes();
     399        }
    390400
    391401        // Register advanced menu items (columns)
    392         add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
     402        if ( empty( $nav_menus ) || isset( $_POST['menu-name'] ) || isset( $_GET['action'] ) && ! isset( $_GET['_wpnonce'] ) ) {
     403                add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
     404        }
    393405
    394406        // If first time editing, disable advanced items by default.
    395407        if( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
     
    411423        if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
    412424                return;
    413425
    414         $initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-custom-links', 'add-page', 'add-category' );
     426        $initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-page', 'add-common-links', 'add-custom-links', 'add-category' );
    415427        $hidden_meta_boxes = array();
    416428
    417429        foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
     
    445457                $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
    446458                if ( $post_type ) {
    447459                        $id = $post_type->name;
    448                         add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
     460                        add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'high', $post_type );
    449461                }
    450462        }
    451463}
     
    489501        $menu_locations = get_nav_menu_locations();
    490502        $num_locations = count( array_keys($locations) );
    491503
    492         echo '<p class="howto">' . sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n($num_locations) ) . '</p>';
     504        echo '<p class="howto">' . _n('Select a menu to use within your theme.', 'Select the menus you will use in your theme.', $num_locations ) . '</p>';
    493505
    494506        foreach ( $locations as $location => $description ) {
    495507                ?>
     
    512524        }
    513525        ?>
    514526        <p class="button-controls">
    515                 <?php submit_button( __( 'Save' ), 'primary right', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false ) ); ?>
     527                <?php submit_button( __( 'Save' ), 'primary right', 'nav-menu-locations', false ); ?>
    516528                <span class="spinner"></span>
    517529        </p>
    518530        <?php
    519531}
    520532
    521533/**
     534 * Displays a metabox for the common links menu item.
     535 *
     536 * @since 3.0.0
     537 */
     538function wp_nav_menu_item_common_link_meta_box() {
     539        global $blog_id, $_nav_menu_placeholder, $nav_menu_selected_id;
     540        $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
     541
     542        $removed_args = array(
     543                'action',
     544                'customlink-tab',
     545                'edit-menu-item',
     546                'menu-item',
     547                'page-tab',
     548                '_wpnonce',
     549        );
     550       
     551        $common_links = array(
     552                array(
     553                        'url' => get_site_url(),
     554                        'text' => __('Home')
     555                ),
     556                array(
     557                        'url' => get_site_url($blog_id, '/wp-login.php'),
     558                        'text' => __('Log in')
     559                )
     560        );
     561        ?>
     562        <div class="commonlinkdiv" id="commonlinkdiv">
     563
     564                <div class="common-links">
     565                        <?php foreach ( $common_links as $link ) { ?>
     566                        <label class="menu-item-title"><input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-object-id]" value="<?php echo $link['url']; ?>" title="<?php echo $link['text']; ?>"> <?php echo $link['text']; ?></label>
     567                        <?php } ?>
     568                </div>
     569
     570                <p class="button-controls">
     571                        <span class="add-to-menu">
     572                                <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-common-menu-item" id="submit-commonlinkdiv" />
     573                                <span class="spinner"></span>
     574                        </span>
     575                </p>
     576
     577        </div><!-- /.commonlinkdiv -->
     578        <?php
     579}
     580
     581/**
    522582 * Displays a metabox for the custom links menu item.
    523583 *
    524584 * @since 3.0.0
     
    554614
    555615                        <p id="menu-item-name-wrap">
    556616                                <label class="howto" for="custom-menu-item-name">
    557                                         <span><?php _e('Label'); ?></span>
     617                                        <span><?php _e('Link Text'); ?></span>
    558618                                        <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Menu Item'); ?>" />
    559619                                </label>
    560620                        </p>
     
    10861146                $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
    10871147                $result = '<div id="menu-instructions" class="post-body-plain';
    10881148                $result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
    1089                 $result .= '<p>' . __('Select menu items (pages, categories, links) from the boxes at left to begin building your custom menu.') . '</p>';
     1149                $result .= '<p>' . __('Next, add menu items (i.e. pages, links, categories) from the column on the left.') . '</p>';
    10901150                $result .= '</div>';
    10911151
    10921152                if( empty($menu_items) )
     
    11581218        foreach( (array) $menu_items_to_delete as $menu_item_id )
    11591219                wp_delete_post( $menu_item_id, true );
    11601220}
    1161 
    1162 add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
     1221add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
     1222 No newline at end of file
  • wp-admin/js/nav-menu.js

     
    4646                                this.initSortables();
    4747
    4848                        this.initToggles();
    49 
    50                         this.initTabManager();
     49                       
     50                        this.messageFadeIn();
    5151                },
    5252
    5353                jQueryExtensions : function() {
     
    222222                                }
    223223                        });
    224224                },
     225               
     226                messageFadeIn : function() {
     227                        var messages = $('#message');
     228                       
     229                        // Visual change when users save menus multiple times in a row
     230                        messages.slideDown('slow');
     231                },
    225232
    226233                initToggles : function() {
    227234                        // init postboxes
     
    245252                                menuEdge = api.menuList.offset().left,
    246253                                body = $('body'), maxChildDepth,
    247254                                menuMaxDepth = initialMenuMaxDepth();
     255                               
     256                        if( 0 != $('#menu-to-edit li').length )
     257                                $('.drag-instructions').show();
    248258
    249259                        // Use the right edge if RTL.
    250260                        menuEdge += api.isRTL ? api.menuList.width() : 0;
     
    307317
    308318                                        // Return child elements to the list
    309319                                        children = transport.children().insertAfter(ui.item);
     320                                       
     321                                        // Add "sub menu" description
     322                                        var subMenuTitle = ui.item.find('.item-title .is-submenu');
     323                                        if (0 < currentDepth)
     324                                                subMenuTitle.show();
     325                                        else
     326                                                subMenuTitle.hide();
    310327
    311328                                        // Update depth classes
    312329                                        if( depthChange != 0 ) {
     
    327344                                                ui.item[0].style.left = 'auto';
    328345                                                ui.item[0].style.right = 0;
    329346                                        }
    330 
    331                                         // The width of the tab bar might have changed. Just in case.
    332                                         api.refreshMenuTabs( true );
    333347                                },
    334348                                change: function(e, ui) {
    335349                                        // Make sure the placeholder is inside the menu.
     
    433447                                        $("#submit-customlinkdiv").click();
    434448                                }
    435449                        });
     450                        $('#submit-commonlinkdiv').click(function () {
     451                                api.addCommonLink();
     452                                return false;
     453                        });
    436454                },
    437455
    438456                /**
     
    461479                                if( '' == $t.val() )
    462480                                        $t.addClass( name ).val( $t.data(name) );
    463481                        });
     482                       
     483                        $('.blank-slate .input-with-default-title').focus();
    464484                },
    465485
    466486                attachThemeLocationsListeners : function() {
     
    474494                                loc.find('.spinner').show();
    475495                                $.post( ajaxurl, params, function(r) {
    476496                                        loc.find('.spinner').hide();
     497                                        $('.menu-location-success').slideDown('slow');
    477498                                });
    478499                                return false;
    479500                        });
     
    521542                                api.processQuickSearchQueryResponse(menuMarkup, params, panel);
    522543                        });
    523544                },
     545               
     546                addCommonLink : function() {
     547                       
     548                        $('#commonlinkdiv input[type="checkbox"]:checked').each(function( index ) {
     549                                var url = $(this).val(),
     550                                        linkText = $(this).prop('title'),
     551                                        processMethod = api.addMenuItemToTop;
    524552
     553                                // Show the ajax spinner
     554                                $('.commonlinkdiv .spinner').show();
     555                                api.addLinkToMenu( url, linkText, processMethod, function() {
     556                                        // Remove the ajax spinner
     557                                        $('.commonlinkdiv .spinner').hide();
     558                                });
     559                        });
     560                },
     561
    525562                addCustomLink : function( processMethod ) {
    526563                        var url = $('#custom-menu-item-url').val(),
    527564                                label = $('#custom-menu-item-name').val();
     
    572609                        $.post( ajaxurl, params, function(menuMarkup) {
    573610                                var ins = $('#menu-instructions');
    574611                                processMethod(menuMarkup, params);
     612                                // Make it stand out a bit more visually, by adding a fadeIn
     613                                $('li.pending').hide().fadeIn('slow');
     614                                $('.drag-instructions').show();
    575615                                if( ! ins.hasClass('menu-instructions-inactive') && ins.siblings().length )
    576616                                        ins.addClass('menu-instructions-inactive');
    577617                                callback();
     
    604644                                };
    605645                        } else {
    606646                                // Make the post boxes read-only, as they can't be used yet
    607                                 $('#menu-settings-column').find('input,select').prop('disabled', true).end().find('a').attr('href', '#').unbind('click');
     647                                $('#menu-settings-column').find('input,select').end().find('a').attr('href', '#').unbind('click');
    608648                        }
    609649                },
    610650
     
    688728                        });
    689729                },
    690730
    691                 initTabManager : function() {
    692                         var fixed = $('.nav-tabs-wrapper'),
    693                                 fluid = fixed.children('.nav-tabs'),
    694                                 active = fluid.children('.nav-tab-active'),
    695                                 tabs = fluid.children('.nav-tab'),
    696                                 tabsWidth = 0,
    697                                 fixedRight, fixedLeft,
    698                                 arrowLeft, arrowRight, resizeTimer, css = {},
    699                                 marginFluid = api.isRTL ? 'margin-right' : 'margin-left',
    700                                 marginFixed = api.isRTL ? 'margin-left' : 'margin-right',
    701                                 msPerPx = 2;
    702 
    703                         /**
    704                          * Refreshes the menu tabs.
    705                          * Will show and hide arrows where necessary.
    706                          * Scrolls to the active tab by default.
    707                          *
    708                          * @param savePosition {boolean} Optional. Prevents scrolling so
    709                          *                that the current position is maintained. Default false.
    710                          **/
    711                         api.refreshMenuTabs = function( savePosition ) {
    712                                 var fixedWidth = fixed.width(),
    713                                         margin = 0, css = {};
    714                                 fixedLeft = fixed.offset().left;
    715                                 fixedRight = fixedLeft + fixedWidth;
    716 
    717                                 if( !savePosition )
    718                                         active.makeTabVisible();
    719 
    720                                 // Prevent space from building up next to the last tab if there's more to show
    721                                 if( tabs.last().isTabVisible() ) {
    722                                         margin = fixed.width() - tabsWidth;
    723                                         margin = margin > 0 ? 0 : margin;
    724                                         css[marginFluid] = margin + 'px';
    725                                         fluid.animate( css, 100, "linear" );
    726                                 }
    727 
    728                                 // Show the arrows only when necessary
    729                                 if( fixedWidth > tabsWidth )
    730                                         arrowLeft.add( arrowRight ).hide();
    731                                 else
    732                                         arrowLeft.add( arrowRight ).show();
    733                         }
    734 
    735                         $.fn.extend({
    736                                 makeTabVisible : function() {
    737                                         var t = this.eq(0), left, right, css = {}, shift = 0;
    738 
    739                                         if( ! t.length ) return this;
    740 
    741                                         left = t.offset().left;
    742                                         right = left + t.outerWidth();
    743 
    744                                         if( right > fixedRight )
    745                                                 shift = fixedRight - right;
    746                                         else if ( left < fixedLeft )
    747                                                 shift = fixedLeft - left;
    748 
    749                                         if( ! shift ) return this;
    750 
    751                                         css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px';
    752                                         fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" );
    753                                         return this;
    754                                 },
    755                                 isTabVisible : function() {
    756                                         var t = this.eq(0),
    757                                                 left = t.offset().left,
    758                                                 right = left + t.outerWidth();
    759                                         return ( right <= fixedRight && left >= fixedLeft ) ? true : false;
    760                                 }
    761                         });
    762 
    763                         // Find the width of all tabs
    764                         tabs.each(function(){
    765                                 tabsWidth += $(this).outerWidth(true);
    766                         });
    767 
    768                         // Set up fixed margin for overflow, unset padding
    769                         css['padding'] = 0;
    770                         css[marginFixed] = (-1 * tabsWidth) + 'px';
    771                         fluid.css( css );
    772 
    773                         // Build tab navigation
    774                         arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div>');
    775                         arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div>');
    776                         // Attach to the document
    777                         fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight );
    778 
    779                         // Set the menu tabs
    780                         api.refreshMenuTabs();
    781                         // Make sure the tabs reset on resize
    782                         $(window).resize(function() {
    783                                 if( resizeTimer ) clearTimeout(resizeTimer);
    784                                 resizeTimer = setTimeout( api.refreshMenuTabs, 200);
    785                         });
    786 
    787                         // Build arrow functions
    788                         $.each([{
    789                                         arrow : arrowLeft,
    790                                         next : "next",
    791                                         last : "first",
    792                                         operator : "+="
    793                                 },{
    794                                         arrow : arrowRight,
    795                                         next : "prev",
    796                                         last : "last",
    797                                         operator : "-="
    798                                 }], function(){
    799                                 var that = this;
    800                                 this.arrow.mousedown(function(){
    801                                         var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ),
    802                                                 shift = marginFluidVal,
    803                                                 css = {};
    804 
    805                                         if( "-=" == that.operator )
    806                                                 shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal;
    807 
    808                                         if( ! shift ) return;
    809 
    810                                         css[marginFluid] = that.operator + shift + 'px';
    811                                         fluid.animate( css, shift * msPerPx, "linear" );
    812                                 }).mouseup(function(){
    813                                         var tab, next;
    814                                         fluid.stop(true);
    815                                         tab = tabs[that.last]();
    816                                         while( (next = tab[that.next]()) && next.length && ! next.isTabVisible() ) {
    817                                                 tab = next;
    818                                         }
    819                                         tab.makeTabVisible();
    820                                 });
    821                         });
    822                 },
    823 
    824731                eventOnClickEditLink : function(clickedEl) {
    825732                        var settings, item,
    826733                        matchedSection = /#(.*)$/.exec(clickedEl.href);
     
    945852                                        var ins = $('#menu-instructions');
    946853                                        el.remove();
    947854                                        children.shiftDepthClass(-1).updateParentMenuItemDBId();
    948                                         if( ! ins.siblings().length )
     855                                        if( 0 == $('#menu-to-edit li').length ) {
     856                                                $('.drag-instructions').hide();
    949857                                                ins.removeClass('menu-instructions-inactive');
     858                                        }
    950859                                });
    951860                },
    952861
  • wp-admin/nav-menus.php

     
    2727if ( wp_is_mobile() )
    2828        wp_enqueue_script( 'jquery-touch-punch' );
    2929
     30// prep the table view
     31$wp_list_table = _get_list_table( 'WP_Menus_List_Table' );
     32$pagenum = $wp_list_table->get_pagenum();
     33$wp_list_table->prepare_items();
     34
    3035// Container for any messages displayed to the user
    3136$messages = array();
    3237
     
    367372
    368373                                do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
    369374
    370                                 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title ) . '</p></div>';
     375                                $messages[] = '<div id="message" class="updated"><p>' . sprintf( __('<strong>%s</strong> has been updated. Use this menu to <a href="%s">replace your sites main navigation</a>, or <a href="%s">within a widget</a>.'), $nav_menu_selected_title, admin_url( 'nav-menus.php' ), admin_url( 'widgets.php' ) ) . '</p></div>';
    371376                                unset( $menu_items, $unsorted_menu_items );
    372377                        }
    373378                }
     
    434439if ( ! current_theme_supports( 'menus' ) && ! wp_get_nav_menus() )
    435440        $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>';
    436441
     442add_screen_option( 'per_page', array('label' => _x( 'Menus', 'nav menus per page (screen options)' )) );
     443
    437444get_current_screen()->add_help_tab( array(
    438445'id'            => 'overview',
    439446'title'         => __('Overview'),
     
    460467?>
    461468<div class="wrap">
    462469        <?php screen_icon(); ?>
    463         <h2><?php esc_html_e('Menus'); ?></h2>
     470        <h2 class="nav-tab-wrapper">
     471                <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_POST['menu-name'] ) && ! isset( $_GET['action'] ) || isset( $_GET['_wpnonce'] ) ) echo ' nav-tab-active'; ?>"><?php esc_html_e('Manage Menus'); ?></a>
     472                <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e('Add Menu'); ?></a>
     473        </h2>
    464474        <?php
    465475        foreach( $messages as $message ) :
    466476                echo $message . "\n";
    467477        endforeach;
    468478        ?>
     479        <div class="updated menu-location-success" style="display: none;"><p><?php echo sprintf( __('The menus within your theme have been updated. <a href="%s">Visit your site</a> to preview these changes.'), get_site_url() ); ?></p></div>
    469480        <div id="nav-menus-frame">
    470         <div id="menu-settings-column" class="metabox-holder<?php if ( !$nav_menu_selected_id ) { echo ' metabox-holder-disabled'; } ?>">
     481        <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] || empty( $nav_menus ) ) { echo ' metabox-holder-disabled'; } ?>">
    471482
     483                <?php if ( ! isset( $_POST['menu-name'] ) && ! isset( $_GET['action'] ) || isset( $_GET['_wpnonce'] ) ) : ?>
     484                        <form id="menu-search-form" action="" method="get">
     485                                <?php $wp_list_table->search_box( __( 'Search Menus' ), 'menus' ); ?>
     486                        </form>
     487                <?php endif; ?>
     488
     489                <div class="clear"></div>
     490
    472491                <form id="nav-menu-meta" action="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-menu-meta" method="post" enctype="multipart/form-data">
    473492                        <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
    474493                        <input type="hidden" name="action" value="add-menu-item" />
     
    479498        </div><!-- /#menu-settings-column -->
    480499        <div id="menu-management-liquid">
    481500                <div id="menu-management">
    482                         <div id="select-nav-menu-container" class="hide-if-js">
    483                                 <form id="select-nav-menu" action="">
    484                                         <strong><label for="select-nav-menu"><?php esc_html_e( 'Select Menu:' ); ?></label></strong>
    485                                         <select class="select-nav-menu" name="menu">
    486                                                 <?php foreach( (array) $nav_menus as $_nav_menu ) : ?>
    487                                                         <option value="<?php echo esc_attr($_nav_menu->term_id) ?>" <?php selected($nav_menu_selected_id, $_nav_menu->term_id); ?>>
    488                                                                 <?php echo esc_html( $_nav_menu->truncated_name ); ?>
    489                                                         </option>
    490                                                 <?php endforeach; ?>
    491                                                 <option value="0"><?php esc_html_e('Add New Menu'); ?></option>
    492                                         </select>
    493                                         <input type="hidden" name="action" value="edit" />
    494                                         <?php submit_button( __( 'Select' ), 'secondary', 'select_menu', false ); ?>
     501                        <?php if ( ! isset( $_POST['menu-name'] ) && ! empty( $nav_menus ) && ! isset( $_GET['action'] ) || ( isset( $_GET['_wpnonce'] ) && 0 != count( $nav_menus ) ) ) : ?>
     502
     503                                <form id="menu-list-form" action="" method="get">
     504
     505                                        <?php $wp_list_table->display(); ?>
     506
     507                                        <input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" />
     508                                        <input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" />
     509                                        <input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" />
     510
    495511                                </form>
    496                         </div>
    497                         <div class="nav-tabs-wrapper">
    498                         <div class="nav-tabs">
    499                                 <?php
    500                                 foreach( (array) $nav_menus as $_nav_menu ) :
    501                                         if ( $nav_menu_selected_id == $_nav_menu->term_id ) : ?><span class="nav-tab nav-tab-active">
    502                                                         <?php echo esc_html( $_nav_menu->truncated_name ); ?>
    503                                                 </span><?php else : ?><a href="<?php
    504                                                         echo esc_url(add_query_arg(
    505                                                                 array(
    506                                                                         'action' => 'edit',
    507                                                                         'menu' => $_nav_menu->term_id,
    508                                                                 ),
    509                                                                 admin_url( 'nav-menus.php' )
    510                                                         ));
    511                                                 ?>" class="nav-tab hide-if-no-js">
    512                                                         <?php echo esc_html( $_nav_menu->truncated_name ); ?>
    513                                                 </a><?php endif;
    514                                 endforeach;
    515                                 if ( 0 == $nav_menu_selected_id ) : ?><span class="nav-tab menu-add-new nav-tab-active">
    516                                         <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>
    517                                 </span><?php else : ?><a href="<?php
    518                                         echo esc_url(add_query_arg(
    519                                                 array(
    520                                                         'action' => 'edit',
    521                                                         'menu' => 0,
    522                                                 ),
    523                                                 admin_url( 'nav-menus.php' )
    524                                         ));
    525                                 ?>" class="nav-tab menu-add-new">
    526                                         <?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>
    527                                 </a><?php endif; ?>
    528                         </div>
    529                         </div>
     512
     513
     514                        <?php else : ?>
    530515                        <div class="menu-edit">
    531516                                <form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
    532517                                        <div id="nav-menu-header">
    533518                                                <div id="submitpost" class="submitbox">
    534                                                         <div class="major-publishing-actions">
     519                                                        <div class="major-publishing-actions <?php if ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] || empty( $nav_menus ) ) echo 'blank-slate'; ?>">
    535520                                                                <label class="menu-name-label howto open-label" for="menu-name">
    536521                                                                        <span><?php _e('Menu Name'); ?></span>
    537522                                                                        <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 ); ?>" />
     
    551536                                                                        <label class="howto"><input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" value="1" /> <?php printf( __('Automatically add new top-level pages' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label>
    552537                                                                </div>
    553538                                                                <?php endif; ?>
    554                                                                 <br class="clear" />
    555539                                                                <div class="publishing-action">
    556540                                                                        <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?>
    557541                                                                </div><!-- END .publishing-action -->
    558542
    559                                                                 <?php if ( ! empty( $nav_menu_selected_id ) ) : ?>
    560                                                                 <div class="delete-action">
    561                                                                         <a class="submitdelete deletion menu-delete" href="<?php echo esc_url( wp_nonce_url( admin_url('nav-menus.php?action=delete&amp;menu=' . $nav_menu_selected_id), 'delete-nav_menu-' . $nav_menu_selected_id ) ); ?>"><?php _e('Delete Menu'); ?></a>
    562                                                                 </div><!-- END .delete-action -->
    563                                                                 <?php endif; ?>
    564543                                                        </div><!-- END .major-publishing-actions -->
    565544                                                </div><!-- END #submitpost .submitbox -->
    566545                                                <?php
     
    574553                                        <div id="post-body">
    575554                                                <div id="post-body-content">
    576555                                                        <?php
    577                                                         if ( isset( $edit_markup ) ) {
     556                                                        $drag_instructions = '';
     557                                                        if ( empty( $ordered_menu_items ) )
     558                                                                $drag_instructions = 'style="display: none;"';
     559                                                       
     560                                                        if ( isset( $edit_markup ) ) {                                                         
     561                                                                echo '<div class="drag-instructions post-body-plain" ' . $drag_instructions . '>';
     562                                                                echo '<p>' . __('Drag each item into the order you prefer. Click an item to reveal additional configuration options.') . '</p>';
     563                                                                echo '</div>';
     564                                                               
    578565                                                                if ( ! is_wp_error( $edit_markup ) )
    579566                                                                        echo $edit_markup;
    580567                                                        } else if ( empty( $nav_menu_selected_id ) ) {
    581568                                                                echo '<div class="post-body-plain">';
    582                                                                 echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>';
    583                                                                 echo '<p>' . __('After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.') . '</p>';
    584                                                                 echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>';
     569                                                                echo '<p>' . __('Give your custom menu a name above, then click Create Menu.') . '</p>';
    585570                                                                echo '</div>';
    586571                                                        }
    587572                                                        ?>
     
    599584                                        </div><!-- /#nav-menu-footer -->
    600585                                </form><!-- /#update-nav-menu -->
    601586                        </div><!-- /.menu-edit -->
     587                        <?php endif; ?>
    602588                </div><!-- /#menu-management -->
    603589        </div><!-- /#menu-management-liquid -->
    604590        </div><!-- /#nav-menus-frame -->
  • wp-admin/css/wp-admin.css

     
    24282428.fixed .column-categories,
    24292429.fixed .column-tags,
    24302430.fixed .column-rel,
    2431 .fixed .column-role {
     2431.fixed .column-role,
     2432.fixed .column-count {
    24322433        width: 15%;
    24332434}
    24342435
     
    67506751
    67516752/* nav-menu */
    67526753
     6754.nav-menus-php #message {
     6755        display: none;
     6756}
     6757
     6758.nav-menus-php .nav-tab-wrapper {
     6759        margin-bottom: 20px;
     6760}
     6761
    67536762#nav-menus-frame {
    67546763        margin-left: 300px;
     6764        margin-top: 20px;
    67556765}
    67566766
    67576767#wpbody-content #menu-settings-column {
     
    67606770        margin-left: -300px;
    67616771        clear: both;
    67626772        float: left;
    6763         padding-top: 24px;
     6773        padding-top: 0;
    67646774}
    67656775
    67666776.no-js #wpbody-content #menu-settings-column {
     
    67856795        position: relative;
    67866796}
    67876797
     6798.blank-slate br {
     6799        display: none;
     6800}
     6801
     6802.blank-slate .menu-name {
     6803        height: 2em;
     6804}
     6805
     6806.is-submenu {
     6807        color: #999;
     6808        font-style: italic;
     6809        font-weight: normal;
     6810        margin-left: 4px;
     6811}
     6812
     6813.common-links {
     6814        background: #fff;
     6815        border: 1px solid #dfdfdf;
     6816        line-height: 1.4em;
     6817        min-height: 42px;
     6818        padding: 0.9em;
     6819}
     6820
     6821.common-links label {
     6822        display: block;
     6823        line-height: 19px;
     6824}
     6825
    67886826/* Menu Container */
    67896827#menu-management-liquid {
    67906828        float: left;
    67916829        min-width: 100%;
     6830        margin-top: 3px;
    67926831}
    67936832
    67946833#menu-management {
     
    68026841        margin-bottom: 20px;
    68036842}
    68046843
     6844#menu-settings-column p.search-box {
     6845        margin: 9px 0;
     6846        float: left;
     6847}
     6848
     6849#menu-settings-column #menus-search-input {
     6850        width: 175px;
     6851}
     6852
    68056853.nav-menus-php #post-body {
    68066854        padding: 10px;
    68076855        border-width: 1px 0;
     
    68356883        font-weight:bold;
    68366884}
    68376885
    6838 /* Menu Tabs */
    6839 
    6840 #menu-management .nav-tabs-nav {
    6841         margin: 0 20px;
    6842 }
    6843 
    6844 #menu-management .nav-tabs-arrow {
    6845         width: 10px;
    6846         padding: 0 5px 4px;
    6847         cursor: pointer;
    6848         position: absolute;
    6849         top: 0;
    6850         line-height: 22px;
    6851         font-size: 18px;
    6852         text-shadow: 0 1px 0 #fff;
    6853 }
    6854 
    6855 #menu-management .nav-tabs-arrow-left {
    6856         left: 0;
    6857 }
    6858 
    6859 #menu-management .nav-tabs-arrow-right {
    6860         right: 0;
    6861         text-align: right;
    6862 }
    6863 
    6864 #menu-management .nav-tabs-wrapper {
    6865         width: 100%;
    6866         height: 28px;
    6867         margin-bottom: -1px;
    6868         overflow: hidden;
    6869 }
    6870 
    6871 #menu-management .nav-tabs {
    6872         padding-left: 20px;
    6873         padding-right: 10px;
    6874 }
    6875 
    6876 .js #menu-management .nav-tabs {
    6877         float: left;
    6878         margin-left: 0px;
    6879         margin-right: -400px;
    6880 }
    6881 
    6882 #menu-management .nav-tab {
    6883         margin-bottom: 0;
    6884         font-size: 14px;
    6885 }
    6886 
    68876886#select-nav-menu-container {
    68886887        text-align: right;
    68896888        padding: 0 10px 3px 10px;
     
    70807079}
    70817080
    70827081#menu-to-edit {
    7083         padding: 1em 0;
     7082        padding: 0.1em 0;
    70847083}
    70857084
    70867085.menu ul {
     
    73267325        margin: 5px 0 1px;
    73277326}
    73287327
     7328.nav-menus-php .blank-slate .publishing-action {
     7329        float: left;
     7330        margin: 1px 0 0;
     7331}
     7332
    73297333.nav-menus-php .major-publishing-actions .delete-action {
    73307334        vertical-align: middle;
    73317335        text-align: left;