Make WordPress Core

Ticket #23770: 23770.3.diff

File 23770.3.diff, 8.1 KB (added by DrewAPicture, 12 years ago)

Doesn't use WP_List_Table, more flexibility and less code.

  • wp-admin/css/wp-admin.css

     
    166166        padding: 0 7px;
    167167}
    168168
     169#col-left-locations {
     170        width: 40%;
     171}
     172
    169173/* utility classes */
    170174.alignleft {
    171175        float: left;
     
    24232427        width: 8%;
    24242428}
    24252429
     2430.fixed .column-posts,
    24262431.fixed .column-date,
    24272432.fixed .column-parent,
    24282433.fixed .column-links,
     
    24392444        width: 15%;
    24402445}
    24412446
     2447.fixed .column-slug {
     2448        width: 25%;
     2449}
     2450
     2451.fixed .column-locations {
     2452        width: 35%;
     2453}
     2454
     2455.fixed .column-menus {
     2456        padding-bottom: 2px;
     2457}
    24422458.fixed .column-comments {
    24432459        width: 4em;
    24442460        padding: 8px 0;
     
    24532469        float: left;
    24542470}
    24552471
    2456 .fixed .column-slug {
    2457         width: 25%;
    2458 }
    2459 
    2460 .fixed .column-posts {
    2461         width: 10%;
    2462 }
    2463 
    24642472.fixed .column-icon {
    24652473        width: 80px;
    24662474}
     
    72237231        filter: alpha(opacity=50);
    72247232}
    72257233
     7234#menu-locations-wrap {
     7235        width: 55%;
     7236}
     7237
    72267238.metabox-holder-disabled .button-controls .select-all {
    72277239        display: none;
    72287240}
     
    73837395        margin-top: -2px;
    73847396}
    73857397
     7398.menu-location-title {
     7399        position: relative;
     7400        top: 10px;
     7401}
     7402
     7403#locations-nav-menu-wrapper {
     7404        padding: 5px 0;
     7405}
     7406
     7407.locations-nav-menu-select select {
     7408        float: left;
     7409        width: 160px;
     7410        margin-right: 5px;
     7411}
     7412
     7413#locations-row-links {
     7414        display: inline-block;
     7415        position: relative;
     7416        top: 3px;
     7417}
     7418
     7419#locations-edit-menu-link,
     7420#locations-add-menu-link {
     7421        margin: 0 2px;
     7422}
     7423
     7424#locations-edit-menu-link {
     7425        width: 15%;
     7426}
     7427
     7428#locations-add-menu-link {
     7429        width: 12%;     
     7430}
     7431
    73867432#wpbody .open-label {
    73877433        display: block;
    73887434        float:left;
  • wp-admin/nav-menus.php

     
    341341                        }
    342342                }
    343343                break;
     344        case 'locations':
     345                // TODO: Nonce this thing
     346
     347                // Get existing menu locations assignments
     348                $locations = get_registered_nav_menus();
     349                $menu_locations = get_nav_menu_locations();
     350
     351                // Merge new and existing menu locations if any new ones are set
     352                if ( isset( $_POST['menu-locations'] ) ) {
     353                        $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
     354                        $menu_locations = array_merge( $menu_locations, $new_menu_locations );
     355                        // Set menu locations
     356                        set_theme_mod( 'nav_menu_locations', $menu_locations );
     357                }
     358                // TODO: Add a message
     359
     360                break;
    344361}
    345362
    346363// Get all nav menus
     
    350367// Are we on the add new screen?
    351368$add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
    352369
     370$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false;
     371
    353372// If we have one theme location, and zero menus, we take them right into editing their first menu
    354373$page_count = wp_count_posts( 'page' );
    355374$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
     
    474493?>
    475494<div class="wrap">
    476495        <?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>
     496        <h2 class="nav-tab-wrapper">
     497                <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>
     498                <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e('Manage Locations'); ?></a>
     499        </h2>
    478500        <?php
    479501        foreach( $messages as $message ) :
    480502                echo $message . "\n";
    481503        endforeach;
    482504        ?>
     505        <?php
     506        if ( $locations_screen ) :
     507                echo '<p>' . __( 'Some explanatory/howto text should probably go here.' ) . '</p>';
     508                ?>
     509        <div id="menu-locations-wrap">
     510                <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>">
     511                        <table class="widefat fixed" cellspacing="0" id="menu-locations-table">
     512                                <thead>
     513                                <tr>
     514                                        <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Locations' ); ?></th>
     515                                        <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menus' ); ?></th>
     516                                </tr>
     517                                </thead>
     518                                <tfoot>
     519                                <tr>
     520                                        <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Locations' ); ?></th>
     521                                        <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menus' ); ?></th>
     522                                </tr>
     523                                </tfoot>
     524                                <tbody class="menu-locations">
     525                                <?php foreach ( $locations as $_location => $_name ) { ?>
     526                                        <tr id="menu-locations-row">
     527                                                <td class="menu-location-title"><strong><?php echo $_name; ?></strong></td>
     528                                                <td class="menu-location-menus">
     529                                                        <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>">
     530                                                                <option value="0"><?php printf( '&mdash; %s &mdash;', esc_html__( 'Select a Menu' ) ); ?></option>
     531                                                                <?php foreach ( $nav_menus as $menu ) : ?>
     532                                                                <option<?php selected( isset( $menu_locations[ $_location ] ) && $menu_locations[ $_location ] == $menu->term_id ); ?>
     533                                                                        value="<?php echo $menu->term_id; ?>">
     534                                                                        <?php $truncated_name = wp_html_excerpt( $menu->name, 40 );
     535                                                                        echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '&hellip;'; ?>
     536                                                                </option>
     537                                                                <?php endforeach; ?>
     538                                                        </select>
     539                                                        <div id="locations-row-links">
     540                                                                <span id="locations-edit-menu-link">
     541                                                                        <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu->term_id ), admin_url( 'nav-menus.php' ) ) ); ?>">
     542                                                                                <?php _ex( 'Edit', 'menu' ); ?>
     543                                                                        </a>
     544                                                                </span>
     545                                                                <span id="locations-add-menu-link">
     546                                                                        <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ); ?>">
     547                                                                                <?php _ex( 'Add New', 'menu' ); ?>
     548                                                                        </a>
     549                                                                </span>
     550                                                        </div><!-- #locations-row-links -->
     551                                                </td><!-- .menu-location-menus -->
     552                                        </tr><!-- #menu-locations-row -->
     553                                <?php } ?>
     554                                </tbody>
     555                        </table>
     556                        <p class="button-controls">
     557                                <?php submit_button( __( 'Save Locations' ), 'primary right', 'nav-menu-locations', false ); ?>
     558                        </p>
     559                        <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
     560                </form>
     561        </div><!-- #menu-locations-wrap -->
     562        <?php else : ?>
    483563        <div class="manage-menus">
    484         <?php if ( $menu_count < 2 ) : ?>
     564                <?php if ( $menu_count < 2 ) : ?>
    485565                <span class="add-edit-menu-action">
    486566                        <?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' ) ) ) ); ?>
    487567                </span><!-- /add-edit-menu-action -->
    488         <?php else : ?>
    489                 <form method="post" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
     568                <?php else : ?>
     569                <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
    490570                        <input type="hidden" name="action" value="edit" />
    491571                        <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
    492572                        <select name="menu" id="menu">
     
    520600                                <?php printf( __( 'or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?>
    521601                        </span><!-- /add-new-menu-action -->
    522602                </form>
    523         <?php endif; ?>
     603                <?php endif; ?>
    524604        </div><!-- /manage-menus -->
    525605        <div id="nav-menus-frame">
    526606        <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>">
     
    633713                </div><!-- /#menu-management -->
    634714        </div><!-- /#menu-management-liquid -->
    635715        </div><!-- /#nav-menus-frame -->
     716        <?php endif; ?>
    636717</div><!-- /.wrap-->
    637718<?php include( './admin-footer.php' ); ?>