Changeset 15008 for trunk/wp-admin/includes/nav-menu.php
- Timestamp:
- 05/27/2010 10:22:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/nav-menu.php
r15007 r15008 59 59 $original_title = $original_object->post_title; 60 60 } 61 62 $classes = array( 63 'menu-item menu-item-depth-' . $depth, 64 'menu-item-' . esc_attr( $item->object ), 65 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'), 66 ); 67 68 $title = $item->title; 69 70 if ( isset( $item->post_status ) && 'draft' == $item->post_status ) { 71 $classes[] = 'pending'; 72 /* translators: %s: title of menu item in draft status */ 73 $title = sprintf( __('%s (Pending)'), $item->title ); 74 } 75 61 76 ?> 62 <li id="menu-item-<?php echo $item_id; ?>" class=" menu-item menu-item-depth-<?php echo $depth; ?> menu-item-<?php echo esc_attr( $item->object ); ?> menu-item-edit-<?php echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'; ?>">77 <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> 63 78 <dl class="menu-item-bar"> 64 79 <dt class="menu-item-handle"> 65 <span class="item-title"><?php echo esc_html( $ item->title ); ?></span>80 <span class="item-title"><?php echo esc_html( $title ); ?></span> 66 81 <span class="item-controls"> 67 82 <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> … … 866 881 * @since 3.0.0 867 882 * 868 * @param int $menu_id The menu ID for which to save this item. 883 * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a draft, orphaned menu item. 869 884 * @param array $menu_data The unsanitized posted menu item data. 870 885 * @return array The database IDs of the items saved … … 874 889 $items_saved = array(); 875 890 876 if ( is_nav_menu( $menu_id ) ) {891 if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) { 877 892 878 893 // Loop through all the menu items' POST values … … 883 898 ! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set 884 899 in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default 885 'custom' != $_item_object_data['menu-item-type'] || // or it's not a custom menu item900 ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page) 886 901 ! empty( $_item_object_data['menu-item-db-id'] ) // or it *is* a custom menu item that already exists 887 902 ) … … 999 1014 return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) ); 1000 1015 1016 $some_pending_menu_items = false; 1017 foreach( (array) $menu_items as $menu_item ) { 1018 if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) 1019 $some_pending_menu_items = true; 1020 } 1021 1022 if ( $some_pending_menu_items ) 1023 $result .= '<div class="updated inline"><p>' . __('Click <em>Save Menu</em> to make pending menu items public.') . '</p></div>'; 1024 1001 1025 $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); 1002 1026 return $result; … … 1027 1051 } 1028 1052 1053 /** 1054 * Deletes orphaned draft menu items 1055 * 1056 * @access private 1057 * @since 3.0.0 1058 * 1059 */ 1060 function _wp_delete_orphaned_draft_menu_items() { 1061 global $wpdb; 1062 $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); 1063 1064 // delete orphaned draft menu items 1065 $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) ); 1066 1067 foreach( (array) $menu_items_to_delete as $menu_item_id ) 1068 wp_delete_post( $menu_item_id, true ); 1069 } 1070 1071 add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); 1072 1029 1073 ?>
Note: See TracChangeset
for help on using the changeset viewer.