X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/dc1231b7312fbdca99e9e887cc2bb35a28f85cdc..refs/tags/wordpress-4.4:/wp-admin/includes/nav-menu.php
diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php
index 43a807c8..16b157e7 100644
--- a/wp-admin/includes/nav-menu.php
+++ b/wp-admin/includes/nav-menu.php
@@ -1,343 +1,17 @@
$_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
-
- ob_start();
- $item_id = esc_attr( $item->ID );
- $removed_args = array(
- 'action',
- 'customlink-tab',
- 'edit-menu-item',
- 'menu-item',
- 'page-tab',
- '_wpnonce',
- );
-
- $original_title = '';
- if ( 'taxonomy' == $item->type ) {
- $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
- if ( is_wp_error( $original_title ) )
- $original_title = false;
- } elseif ( 'post_type' == $item->type ) {
- $original_object = get_post( $item->object_id );
- $original_title = get_the_title( $original_object->ID );
- }
-
- $classes = array(
- 'menu-item menu-item-depth-' . $depth,
- 'menu-item-' . esc_attr( $item->object ),
- 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
- );
-
- $title = $item->title;
-
- if ( ! empty( $item->_invalid ) ) {
- $classes[] = 'menu-item-invalid';
- /* translators: %s: title of menu item which is invalid */
- $title = sprintf( __( '%s (Invalid)' ), $item->title );
- } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
- $classes[] = 'pending';
- /* translators: %s: title of menu item in draft status */
- $title = sprintf( __('%s (Pending)'), $item->title );
- }
-
- $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
-
- $submenu_text = '';
- if ( 0 == $depth )
- $submenu_text = 'style="display: none;"';
-
- ?>
-
';
- $output .= '';
-
- // Menu item hidden fields
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- }
+/** Walker_Nav_Menu_Edit class */
+require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );
-} // Walker_Nav_Menu_Checklist
+/** Walker_Nav_Menu_Checklist class */
+require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php' );
/**
* Prints the appropriate response to a menu quick search.
@@ -426,7 +100,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
));
if ( empty( $terms ) || is_wp_error( $terms ) )
return;
- foreach( (array) $terms as $term ) {
+ foreach ( (array) $terms as $term ) {
if ( 'markup' == $response_format ) {
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
} elseif ( 'json' == $response_format ) {
@@ -480,7 +154,7 @@ function wp_initial_nav_menu_meta_boxes() {
if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
return;
- $initial_meta_boxes = array( 'add-page', 'add-post', 'add-custom-links', 'add-category' );
+ $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
$hidden_meta_boxes = array();
foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
@@ -528,7 +202,7 @@ function wp_nav_menu_post_type_meta_boxes() {
$id = $post_type->name;
// Give pages a higher priority.
$priority = ( 'page' == $post_type->name ? 'core' : 'default' );
- add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
+ add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
}
}
}
@@ -819,6 +493,23 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
}
}
+ $post_type = get_post_type_object( $post_type_name );
+ $archive_link = get_post_type_archive_link( $post_type_name );
+ if ( $post_type->has_archive ) {
+ $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
+ array_unshift( $posts, (object) array(
+ 'ID' => 0,
+ 'object_id' => $_nav_menu_placeholder,
+ 'object' => $post_type_name,
+ 'post_content' => '',
+ 'post_excerpt' => '',
+ 'post_title' => $post_type->labels->archives,
+ 'post_type' => 'nav_menu_item',
+ 'type' => 'post_type_archive',
+ 'url' => get_post_type_archive_link( $post_type_name ),
+ ) );
+ }
+
/**
* Filter the posts displayed in the 'View All' tab of the current
* post type's menu items meta box.
@@ -1081,7 +772,7 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
// Loop through all the menu items' POST values.
- foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
+ foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
if (
// Checkbox is not checked.
empty( $_item_object_data['menu-item-object-id'] ) &&
@@ -1208,13 +899,19 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
*/
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
- if ( class_exists( $walker_class_name ) )
+ if ( class_exists( $walker_class_name ) ) {
$walker = new $walker_class_name;
- else
- return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named %s does not exist.'), $walker_class_name ) );
+ } else {
+ return new WP_Error( 'menu_walker_not_exist',
+ /* translators: %s: walker class name */
+ sprintf( __( 'The Walker class named %s does not exist.' ),
+ '' . $walker_class_name . ''
+ )
+ );
+ }
$some_pending_menu_items = $some_invalid_menu_items = false;
- foreach( (array) $menu_items as $menu_item ) {
+ foreach ( (array) $menu_items as $menu_item ) {
if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
$some_pending_menu_items = true;
if ( ! empty( $menu_item->_invalid ) )
@@ -1262,7 +959,7 @@ function wp_nav_menu_manage_columns() {
* @access private
* @since 3.0.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*/
function _wp_delete_orphaned_draft_menu_items() {
global $wpdb;
@@ -1271,7 +968,7 @@ function _wp_delete_orphaned_draft_menu_items() {
// Delete orphaned draft menu items.
$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 ) );
- foreach( (array) $menu_items_to_delete as $menu_item_id )
+ foreach ( (array) $menu_items_to_delete as $menu_item_id )
wp_delete_post( $menu_item_id, true );
}
@@ -1302,7 +999,7 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
wp_defer_term_counting( true );
// Loop through all the menu items' POST variables
if ( ! empty( $_POST['menu-item-db-id'] ) ) {
- foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
+ foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
// Menu item title can't be blank
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
@@ -1352,7 +1049,12 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
/** This action is documented in wp-includes/nav-menu.php */
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
- $messages[] = '' . sprintf( __( '%1$s has been updated.' ), $nav_menu_selected_title ) . '
';
+ $messages[] = '' .
+ /* translators: %s: nav menu title */
+ sprintf( __( '%s has been updated.' ),
+ '' . $nav_menu_selected_title . ''
+ ) . '
';
+
unset( $menu_items, $unsorted_menu_items );
return $messages;