Ticket #23770: 23770.2.diff
File 23770.2.diff, 8.7 KB (added by , 12 years ago) |
---|
-
wp-admin/css/wp-admin.css
7413 7413 margin-top: -2px; 7414 7414 } 7415 7415 7416 .select-nav-menu-wrapper { 7417 padding: 5px 0; 7418 } 7419 7420 .select-nav-menu-wrapper select { 7421 float: left; 7422 width: 160px; 7423 margin-right: 5px; 7424 } 7425 7416 7426 #wpbody .open-label { 7417 7427 display: block; 7418 7428 float:left; -
wp-admin/includes/class-wp-menu-locations-list-table.php
1 <?php 2 /** 3 * Nav Menu Locations List Table class 4 * 5 * @package WordPress 6 * @subpackage List_Table 7 * @since 3.6.0 8 * @access private 9 */ 10 11 class WP_Menu_Locations_List_Table extends WP_List_Table { 12 13 function __construct( $args = array() ) { 14 parent::__construct( array( 15 'plural' => 'menu locations', 16 'singular' => 'menu location', 17 'ajax' => true, 18 'screen' => isset( $args['screen'] ) ? $args['screen'] : null 19 ) ); 20 } 21 22 function ajax_user_can() { 23 return current_user_can( 'edit_theme_options' ); 24 } 25 26 function prepare_items() { 27 $columns = $this->get_columns(); 28 $hidden = array(); 29 $sortable = $this->get_sortable_columns(); 30 $this->_column_headers = array( $columns, $hidden, $sortable ); 31 32 $total_items = count( array_keys( get_registered_nav_menus() ) ); 33 34 $per_page = apply_filters( 'menu_locations_per_page', $this->get_items_per_page( 'menu_locations_per_page' ) ); 35 $this->set_pagination_args( array( 36 'total_items' => $total_items, 37 'per_page' => $per_page, 38 'total_pages' => ceil( $total_items / $per_page ) 39 ) ); 40 41 $this->items = get_registered_nav_menus(); 42 } 43 44 function single_row( $location ) { 45 static $row_class = ''; 46 $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); 47 48 echo '<tr id="' . esc_attr( 'location-' . $location ) . '"' . $row_class . '>'; 49 echo $this->single_row_columns( $location ); 50 echo '</tr>'; 51 } 52 53 function get_columns() { 54 $columns = array( 55 'locations' => __( 'Theme Locations' ), 56 'menus' => __( 'Assigned Menus' ) 57 ); 58 return $columns; 59 } 60 61 function get_sortable_columns() { 62 return $sortable_cols = array( 'locations' => array( 'locations', true ) ); 63 } 64 65 function column_locations( $location ) { 66 return sprintf( '<span class="menu-location-title"><strong>%s</strong></span>', $location ); 67 } 68 69 function column_menus( $location ) { 70 $menus = wp_get_nav_menus(); 71 $menu_locations = get_nav_menu_locations(); 72 ?> 73 <div class="select-nav-menu-wrapper"> 74 <span> 75 <select name="menu-locations[<?php echo $location; ?>]" id="locations-<?php echo $location; ?>"> 76 <option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> 77 <?php 78 foreach ( $menus as $menu ) : // TODO: Actually select assigned menu ?> 79 <option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?> value="<?php echo $menu->term_id; ?>"> 80 <?php 81 $truncated_name = wp_html_excerpt( $menu->name, 40 ); 82 echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…'; 83 ?> 84 </option> 85 <?php endforeach; ?> 86 </select> 87 <!-- TODO: Add proper links --> 88 <a href="#"><?php _ex( 'Edit', 'menu' ); ?></a> | 89 <a href="#"><?php _ex( 'Add New', 'menu' ); ?></a> 90 </span> 91 </div><!-- .select-nav-menu-wrapper --> 92 <?php 93 } 94 95 } // WP_Theme_Locations_List_Table -
wp-admin/includes/list-table.php
20 20 function _get_list_table( $class, $args = array() ) { 21 21 $core_classes = array( 22 22 //Site Admin 23 'WP_Posts_List_Table' => 'posts',24 'WP_Media_List_Table' => 'media',25 'WP_Terms_List_Table' => 'terms',26 'WP_Users_List_Table' => 'users',27 'WP_Comments_List_Table' => 'comments',28 'WP_Post_Comments_List_Table' => 'comments',29 'WP_Links_List_Table' => 'links',23 'WP_Posts_List_Table' => 'posts', 24 'WP_Media_List_Table' => 'media', 25 'WP_Terms_List_Table' => 'terms', 26 'WP_Users_List_Table' => 'users', 27 'WP_Comments_List_Table' => 'comments', 28 'WP_Post_Comments_List_Table' => 'comments', 29 'WP_Links_List_Table' => 'links', 30 30 'WP_Plugin_Install_List_Table' => 'plugin-install', 31 'WP_Themes_List_Table' => 'themes', 32 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), 33 'WP_Plugins_List_Table' => 'plugins', 31 'WP_Themes_List_Table' => 'themes', 32 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), 33 'WP_Menu_Locations_List_Table' => 'menu-locations', 34 'WP_Plugins_List_Table' => 'plugins', 34 35 // Network Admin 35 'WP_MS_Sites_List_Table' => 'ms-sites',36 'WP_MS_Users_List_Table' => 'ms-users',37 'WP_MS_Themes_List_Table' => 'ms-themes',36 'WP_MS_Sites_List_Table' => 'ms-sites', 37 'WP_MS_Users_List_Table' => 'ms-users', 38 'WP_MS_Themes_List_Table' => 'ms-themes', 38 39 ); 39 40 40 41 if ( isset( $core_classes[ $class ] ) ) { -
wp-admin/nav-menus.php
341 341 } 342 342 } 343 343 break; 344 case 'locations': 345 346 break; 344 347 } 345 348 346 349 // Get all nav menus … … 350 353 // Are we on the add new screen? 351 354 $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; 352 355 356 $locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false; 357 353 358 // If we have one theme location, and zero menus, we take them right into editing their first menu 354 359 $page_count = wp_count_posts( 'page' ); 355 360 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false; … … 464 469 ?> 465 470 <div class="wrap"> 466 471 <?php screen_icon(); ?> 467 <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> 472 <h2 class="nav-tab-wrapper"> 473 <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> 474 <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> 475 </h2> 468 476 <?php 469 477 foreach( $messages as $message ) : 470 478 echo $message . "\n"; 471 479 endforeach; 472 480 ?> 481 <?php 482 if ( $locations_screen ) : 483 echo '<p>' . __( 'Some explanatory/howto text should probably go here.' ) . '</p>'; 484 $wp_list_table = _get_list_table( 'WP_Menu_Locations_List_Table' ); 485 $wp_list_table->prepare_items(); 486 $wp_list_table->display(); 487 // TODO: Add Save button 488 else : ?> 473 489 <div class="manage-menus"> 474 <?php if ( $menu_count < 2 ) : ?>490 <?php if ( $menu_count < 2 ) : ?> 475 491 <span class="add-edit-menu-action"> 476 492 <?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' ) ) ) ); ?> 477 493 </span><!-- /add-edit-menu-action --> 478 <?php else : ?>494 <?php else : ?> 479 495 <form method="post" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> 480 496 <input type="hidden" name="action" value="edit" /> 481 497 <label for="menu" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> … … 510 526 <?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' ) ) ) ); ?> 511 527 </span><!-- /add-new-menu-action --> 512 528 </form> 513 <?php endif; ?>529 <?php endif; ?> 514 530 </div><!-- /manage-menus --> 515 531 <div id="nav-menus-frame"> 516 532 <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>"> … … 623 639 </div><!-- /#menu-management --> 624 640 </div><!-- /#menu-management-liquid --> 625 641 </div><!-- /#nav-menus-frame --> 642 <?php endif; ?> 626 643 </div><!-- /.wrap--> 627 644 <?php include( './admin-footer.php' ); ?>