Make WordPress Core

Ticket #23770: 23770.9.diff

File 23770.9.diff, 13.6 KB (added by markjaquith, 12 years ago)
  • wp-admin/css/wp-admin-rtl.css

    form.upgrade .hint { 
    697697.fixed .column-comments a {
    698698        float: right;
    699699}
     700.fixed .column-menus {
     701        text-align: right;
     702}
    700703.sorting-indicator {
    701704        margin-left: 0;
    702705        margin-right: 7px;
    body.login { 
    20832086        float: right;
    20842087}
    20852088
     2089.menu-location-menus select {
     2090        float: right;
     2091}
     2092
     2093.locations-row-links {
     2094        float: right;
     2095        margin: 4px 6px 0 0;
     2096}
     2097
     2098.locations-add-menu-link {
     2099        direction: rtl;
     2100}
     2101
     2102.locations-edit-menu-link {
     2103        border-left: 1px solid #CCCCCC;
     2104        border-right: 0;
     2105        padding-left: 6px;
     2106        padding-right: 0;
     2107        float: right;
     2108}
     2109
    20862110/* Menu Container */
    20872111#menu-management-liquid {
    20882112        float: right;
  • wp-admin/css/wp-admin.css

    table.fixed { 
    24232423        width: 8%;
    24242424}
    24252425
     2426.fixed .column-posts,
    24262427.fixed .column-date,
    24272428.fixed .column-parent,
    24282429.fixed .column-links,
    table.fixed { 
    24392440        width: 15%;
    24402441}
    24412442
     2443.fixed .column-slug {
     2444        width: 25%;
     2445}
     2446
     2447.fixed .column-locations {
     2448        width: 35%;
     2449}
     2450
    24422451.fixed .column-comments {
    24432452        width: 4em;
    24442453        padding: 8px 0;
    table.fixed { 
    24532462        float: left;
    24542463}
    24552464
    2456 .fixed .column-slug {
    2457         width: 25%;
    2458 }
    2459 
    2460 .fixed .column-posts {
    2461         width: 10%;
    2462 }
    2463 
    24642465.fixed .column-icon {
    24652466        width: 80px;
    24662467}
    tr.wp-locked .row-actions .trash { 
    25472548        margin-top: 3px;
    25482549}
    25492550
     2551#menu-locations-wrap .widefat {
     2552        width: 60%;
     2553}
     2554
    25502555.widefat th.sortable,
    25512556.widefat th.sorted {
    25522557        padding: 0;
    body.interim-login { 
    73847389
    73857390#nav-menus-frame {
    73867391        margin-left: 300px;
    7387         margin-top: 28px;
     7392        margin-top: 23px;
    73887393}
    73897394
    73907395#wpbody-content #menu-settings-column {
    body.interim-login { 
    74017406        margin: 10px 0 0;
    74027407}
    74037408
    7404 .metabox-holder-disabled .postbox {
     7409.metabox-holder-disabled .postbox,
     7410.metabox-holder-disabled .accordion-section-content  {
    74057411        opacity: 0.5;
    74067412        filter: alpha(opacity=50);
    74077413}
    body.interim-login { 
    74327438}
    74337439
    74347440.manage-menus {
    7435         margin-top: 13px;
     7441        margin-top: 23px;
    74367442        padding: 10px;
    74377443        overflow: hidden;
    74387444        -webkit-border-radius: 3px;
    body.interim-login { 
    75667572        margin-top: -2px;
    75677573}
    75687574
     7575.widefat td.menu-location-menus {
     7576        padding-bottom: 5px;
     7577}
     7578
     7579.menu-location-menus select {
     7580        float: left;
     7581}
     7582
     7583#locations-nav-menu-wrapper {
     7584        padding: 5px 0;
     7585}
     7586
     7587.locations-nav-menu-select select {
     7588        float: left;
     7589        width: 160px;
     7590        margin-right: 5px;
     7591}
     7592
     7593.locations-row-links {
     7594        float: left;
     7595        margin: 6px 0 0 6px;
     7596}
     7597
     7598.locations-edit-menu-link,
     7599.locations-add-menu-link {
     7600        margin: 0 3px;
     7601}
     7602
     7603.locations-edit-menu-link {
     7604        padding-right: 3px;
     7605        border-right: 1px solid #ccc;
     7606}
     7607
    75697608#wpbody .open-label {
    75707609        display: block;
    75717610        float:left;
  • wp-admin/js/nav-menu.js

    var wpNavMenu; 
    4848                        if ( menus.oneThemeLocationNoMenus )
    4949                                $( '#posttype-page' ).addSelectedToMenu( api.addMenuItemToBottom );
    5050
     51                        this.initManageLocations();
     52
    5153                        this.initAccessibility();
    5254
    5355                        this.initToggles();
    var wpNavMenu; 
    735737                        }
    736738                },
    737739
     740                initManageLocations : function () {
     741                        $('.menu-location-menus select').on('change', function () {
     742                                var editLink = $(this).closest('tr').find('.locations-edit-menu-link');
     743                                if ($(this).find('option:selected').data('orig'))
     744                                        editLink.show();
     745                                else
     746                                        editLink.hide();
     747                        });
     748                },
     749
    738750                attachMenuEditListeners : function() {
    739751                        var that = this;
    740752                        $('#update-nav-menu').bind('click', function(e) {
    var wpNavMenu; 
    927939                },
    928940
    929941                attachUnsavedChangesListener : function() {
    930                         $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea').change(function(){
     942                        $('#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select').not('#menu-locations-table select').change(function(){
    931943                                api.registerChange();
    932944                        });
    933945
    934                         if ( 0 != $('#menu-to-edit').length ) {
     946                        if ( 0 != $('#menu-to-edit').length || 0 != $('.menu-location-menus select').length ) {
    935947                                window.onbeforeunload = function(){
    936948                                        if ( api.menusChanged )
    937949                                                return navMenuL10n.saveAlert;
  • wp-admin/nav-menus.php

    $nav_menu_selected_title = ''; 
    3737// The menu id of the current menu being edited
    3838$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
    3939
     40// Get existing menu locations assignments
     41$locations = get_registered_nav_menus();
     42$menu_locations = get_nav_menu_locations();
     43$num_locations = count( array_keys( $locations ) );
     44
    4045// Allowed actions: add, update, delete
    4146$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
    4247
    switch ( $action ) { 
    262267        case 'update':
    263268                check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
    264269
    265                 // Get existing menu locations assignments
    266                 $locations = get_registered_nav_menus();
    267                 $menu_locations = get_nav_menu_locations();
    268 
    269270                // Remove menu locations that have been unchecked
    270271                foreach ( $locations as $location => $description ) {
    271272                        if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id )
    switch ( $action ) { 
    307308                                                }
    308309                                                set_theme_mod( 'nav_menu_locations', $locations );
    309310                                        }
    310                                         $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>';
     311                                        if ( isset( $_REQUEST['use-location'] ) ) {
     312                                                $locations = get_theme_mod( 'nav_menu_locations' );
     313                                                if ( isset( $locations[$_REQUEST['use-location']] ) )
     314                                                        $locations[$_REQUEST['use-location']] = $nav_menu_selected_id;
     315                                                set_theme_mod( 'nav_menu_locations', $locations );
     316                                        }
     317                                        // $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>';
     318                                        wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) );
     319                                        exit();
    311320                                }
    312321                        } else {
    313322                                $messages[] = '<div id="message" class="error"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
    switch ( $action ) { 
    341350                        }
    342351                }
    343352                break;
     353        case 'locations':
     354                add_filter( 'screen_options_show_screen', '__return_false' );
     355
     356                if ( isset( $_POST['menu-locations'] ) ) {
     357                        check_admin_referer( 'save-menu-locations' );
     358
     359                        $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
     360                        $menu_locations = array_merge( $menu_locations, $new_menu_locations );
     361                        // Set menu locations
     362                        set_theme_mod( 'nav_menu_locations', $menu_locations );
     363
     364                        $messages[] = '<div id="message" class="updated"><p>' . __( 'Menu locations updated.' ) . '</p></div>';
     365                }
     366                break;
    344367}
    345368
    346369// Get all nav menus
    $menu_count = count( $nav_menus ); 
    350373// Are we on the add new screen?
    351374$add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
    352375
     376$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false;
     377
    353378// If we have one theme location, and zero menus, we take them right into editing their first menu
    354379$page_count = wp_count_posts( 'page' );
    355380$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
    require_once( './admin-header.php' ); 
    474499?>
    475500<div class="wrap">
    476501        <?php screen_icon(); ?>
    477         <h2><?php _e( 'Menus' ); ?> <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, ), admin_url( 'nav-menus.php' ) ) ); ?>" class="add-new-h2"><?php _ex( 'Add New', 'menu' ); ?></a></h2>
     502        <h2 class="nav-tab-wrapper">
     503                <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
     504                <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a>
     505        </h2>
    478506        <?php
    479507        foreach( $messages as $message ) :
    480508                echo $message . "\n";
    481509        endforeach;
    482510        ?>
     511        <?php
     512        if ( $locations_screen ) :
     513                echo '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu you would like to use below.', 'Your theme supports %s menus. Select a menu to use for each theme location below.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>';
     514        ?>
     515        <div id="menu-locations-wrap">
     516                <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>">
     517                        <table class="widefat fixed" cellspacing="0" id="menu-locations-table">
     518                                <thead>
     519                                <tr>
     520                                        <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th>
     521                                        <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th>
     522                                </tr>
     523                                </thead>
     524                                <!--<tfoot>
     525                                <tr>
     526                                        <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th>
     527                                        <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th>
     528                                </tr>
     529                                </tfoot>-->
     530                                <tbody class="menu-locations">
     531                                <?php foreach ( $locations as $_location => $_name ) { ?>
     532                                        <tr id="menu-locations-row">
     533                                                <td class="menu-location-title"><strong><?php echo $_name; ?></strong></td>
     534                                                <td class="menu-location-menus">
     535                                                        <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>">
     536                                                                <option value="0"><?php printf( '&mdash; %s &mdash;', esc_html__( 'Select a Menu' ) ); ?></option>
     537                                                                <?php foreach ( $nav_menus as $menu ) : ?>
     538                                                                        <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?>
     539                                                                        <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>">
     540                                                                                <?php $truncated_name = wp_html_excerpt( $menu->name, 40 );
     541                                                                                echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '&hellip;'; ?>
     542                                                                        </option>
     543                                                                <?php endforeach; ?>
     544                                                        </select>
     545                                                        <div class="locations-row-links">
     546                                                                <?php if ( isset( $menu_locations[ $_location ] ) && 0 != $menu_locations[ $_location ] ) : ?>
     547                                                                <span class="locations-edit-menu-link">
     548                                                                        <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu_locations[$_location] ), admin_url( 'nav-menus.php' ) ) ); ?>">
     549                                                                                <?php _ex( 'Edit', 'menu' ); ?>
     550                                                                        </a>
     551                                                                </span>
     552                                                                <?php endif; ?>
     553                                                                <span class="locations-add-menu-link">
     554                                                                        <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, 'use-location' => $_location ), admin_url( 'nav-menus.php' ) ) ); ?>">
     555                                                                                <?php _ex( 'Use new menu', 'menu' ); ?>
     556                                                                        </a>
     557                                                                </span>
     558                                                        </div><!-- #locations-row-links -->
     559                                                </td><!-- .menu-location-menus -->
     560                                        </tr><!-- #menu-locations-row -->
     561                                <?php } // foreach ?>
     562                                </tbody>
     563                        </table>
     564                        <p class="button-controls"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p>
     565                        <?php wp_nonce_field( 'save-menu-locations' ); ?>
     566                        <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
     567                </form>
     568        </div><!-- #menu-locations-wrap -->
     569        <?php do_action( 'after_menu_locations_table' ); ?>
     570        <?php else : ?>
    483571        <div class="manage-menus">
    484         <?php if ( $menu_count < 2 ) : ?>
     572                <?php if ( $menu_count < 2 ) : ?>
    485573                <span class="add-edit-menu-action">
    486574                        <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?>
    487575                </span><!-- /add-edit-menu-action -->
    488         <?php else : ?>
    489                 <form method="get" action="">
     576                <?php else : ?>
     577                        <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
    490578                        <input type="hidden" name="action" value="edit" />
    491579                        <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
    492580                        <select name="menu" id="menu">
    require_once( './admin-header.php' ); 
    578666                                                        <?php endif; ?>
    579667                                                        <?php if ( $add_new_screen ) : ?>
    580668                                                                <p class="post-body-plain"><?php _e( 'Give your menu a name above, then click Create Menu.' ); ?></p>
     669                                                                <?php if ( isset( $_GET['use-location'] ) ) : ?>
     670                                                                        <input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" />
     671                                                                <?php endif; ?>
    581672                                                        <?php endif; ?>
    582673                                                        <div class="menu-settings" <?php if ( $one_theme_location_no_menus ) { ?>style="display: none;"<?php } ?>>
    583674                                                                <h3><?php _e( 'Menu Settings' ); ?></h3>
    require_once( './admin-header.php' ); 
    633724                </div><!-- /#menu-management -->
    634725        </div><!-- /#menu-management-liquid -->
    635726        </div><!-- /#nav-menus-frame -->
     727        <?php endif; ?>
    636728</div><!-- /.wrap-->
    637729<?php include( './admin-footer.php' ); ?>