X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/61343b82c4f0da4c68e4c6373daafff4a81efdd1..78ff9d91a14da1f53bd3f1ffcab1264d92359b72:/wp-admin/includes/nav-menu.php diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index 7e9fe6ad..c98e32fb 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -9,36 +9,47 @@ */ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { /** + * Starts the list before the elements are added. + * * @see Walker_Nav_Menu::start_lvl() + * * @since 3.0.0 * * @param string $output Passed by reference. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. */ function start_lvl( &$output, $depth = 0, $args = array() ) {} /** + * Ends the list of after the elements are added. + * * @see Walker_Nav_Menu::end_lvl() + * * @since 3.0.0 * * @param string $output Passed by reference. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. */ function end_lvl( &$output, $depth = 0, $args = array() ) {} /** - * @see Walker::start_el() + * Start the element output. + * + * @see Walker_Nav_Menu::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. - * @param object $args + * @param object $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. + * @param int $id Not used. */ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $_wp_nav_menu_max_depth; $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; - $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; - ob_start(); $item_id = esc_attr( $item->ID ); $removed_args = array( @@ -57,7 +68,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $original_title = false; } elseif ( 'post_type' == $item->type ) { $original_object = get_post( $item->object_id ); - $original_title = $original_object->post_title; + $original_title = get_the_title( $original_object->ID ); } $classes = array( @@ -214,7 +225,8 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { \n"; } + /** + * Ends the list of after the elements are added. + * + * @see Walker_Nav_Menu::end_lvl() + * + * @since 3.0.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of page. Used for padding. + * @param array $args Not used. + */ function end_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat( "\t", $depth ); $output .= "\n$indent"; } /** - * @see Walker::start_el() + * Start the element output. + * + * @see Walker_Nav_Menu::start_el() + * * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. - * @param object $args + * @param object $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. + * @param int $id Not used. */ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $_nav_menu_placeholder; @@ -261,15 +299,23 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { $output .= $indent . '
  • '; $output .= ''; + $output .= ''; // Menu item hidden fields $output .= ''; @@ -283,7 +329,8 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { $output .= ''; $output .= ''; } -} + +} // Walker_Nav_Menu_Checklist /** * Prints the appropriate response to a menu quick search. @@ -456,6 +503,16 @@ function wp_nav_menu_post_type_meta_boxes() { return; foreach ( $post_types as $post_type ) { + /** + * Filter whether a menu items meta box will be added for the current post type. + * + * If a falsey value is returned instead of a post type object, + * the post type menu items meta box will not be added. + * + * @since 3.0.0 + * + * @param object $post_type The post type object to be used as a meta box. + */ $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); if ( $post_type ) { $id = $post_type->name; @@ -478,6 +535,16 @@ function wp_nav_menu_taxonomy_meta_boxes() { return; foreach ( $taxonomies as $tax ) { + /** + * Filter whether a menu items meta box will be added for the current taxonomy. + * + * If a falsey value is returned instead of a taxonomy object, + * the taxonomy menu items meta box will not be added. + * + * @since 3.0.0 + * + * @param object $tax The taxonomy object to be used as a meta box. + */ $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); if ( $tax ) { $id = $tax->name; @@ -486,51 +553,6 @@ function wp_nav_menu_taxonomy_meta_boxes() { } } -/** - * Displays a metabox for the nav menu theme locations. - * - * @since 3.0.0 - */ -function wp_nav_menu_locations_meta_box() { - global $nav_menu_selected_id; - - if ( ! current_theme_supports( 'menus' ) ) { - // We must only support widgets. Leave a message and bail. - echo '

    ' . __('The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '

    '; - return; - } - - $locations = get_registered_nav_menus(); - $menus = wp_get_nav_menus(); - $menu_locations = get_nav_menu_locations(); - $num_locations = count( array_keys($locations) ); - - echo '

    ' . _n( 'Select a menu to use within your theme.', 'Select the menus you will use in your theme.', $num_locations ) . '

    '; - - foreach ( $locations as $location => $description ) { - ?> -

    - -

    - -

    - - -

    - - class="button-secondary submit-add-to-menu right" value="" name="add-post-type-menu-item" id="" /> + class="button-secondary submit-add-to-menu right" value="" name="add-post-type-menu-item" id="" />

    @@ -998,7 +1035,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) { - class="button-secondary submit-add-to-menu right" value="" name="add-taxonomy-menu-item" id="" /> + class="button-secondary submit-add-to-menu right" value="" name="add-taxonomy-menu-item" id="" />

    @@ -1135,6 +1172,14 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) { if( empty($menu_items) ) return $result . ' '; + /** + * Filter the Walker class used to render a menu formatted for editing. + * + * @since 3.0.0 + * + * @param string $walker_class_name The Walker class used to render a menu formatted for editing. + * @param int $menu_id The ID of the menu being rendered. + */ $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); if ( class_exists( $walker_class_name ) ) @@ -1279,6 +1324,7 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select wp_defer_term_counting( false ); + /** 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 ) . '

    ';