wppaste
WordPress

Walker_Nav_Menu_Edit::start_el( string $output, WP_Post $data_object, int $depth = 0, stdClass $args = null, int $current_object_id = 0 )

Since
3.0.0, 5.9.0
Source
wp-admin/includes/class-walker-nav-menu-edit.php:60
Start the element output.

Parameters

$outputstring
Used to append additional content (passed by reference).
$data_objectWP_Post
Menu item data object.
$depthintoptional
Depth of menu item. Used for padding.Default: 0
$argsstdClassoptional
Not used.Default: null
$current_object_idintoptional
ID of the current menu item. Default 0.Default: 0

Hooks fired · 1

One hook fires while Walker_Nav_Menu_Edit::start_el() runs, in this order:

  1. do_action( wp_nav_menu_item_custom_fields )actionline 280 (+220 into the body)

    Fires just before the move buttons of a nav menu item in the menu editor.

Uses · 18

Show all 18
  • admin_url()Retrieves the URL to the admin area for the current site.
  • esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
  • esc_url()Checks and cleans a URL.
  • checked()Outputs the HTML checked attribute.
  • esc_textarea()Escaping for textarea values.
  • do_action()Calls the callback functions that have been added to an action hook.

Source

	public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {		global $_wp_nav_menu_max_depth; 		// Restores the more descriptive, specific name for use within this method.		$menu_item = $data_object; 		$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; 		ob_start();		$item_id      = esc_attr( $menu_item->ID );		$removed_args = array(			'action',			'customlink-tab',			'edit-menu-item',			'menu-item',			'page-tab',			'_wpnonce',		); 		$original_title = false; 		if ( 'taxonomy' === $menu_item->type ) {			$original_object = get_term( (int) $menu_item->object_id, $menu_item->object );			if ( $original_object && ! is_wp_error( $original_object ) ) {				$original_title = $original_object->name;			}		} elseif ( 'post_type' === $menu_item->type ) {			$original_object = get_post( $menu_item->object_id );			if ( $original_object ) {				$original_title = get_the_title( $original_object->ID );			}		} elseif ( 'post_type_archive' === $menu_item->type ) {			$original_object = get_post_type_object( $menu_item->object );			if ( $original_object ) {				$original_title = $original_object->labels->archives;			}		} 		$classes = array(			'menu-item menu-item-depth-' . $depth,			'menu-item-' . esc_attr( $menu_item->object ),			'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),		); 		$title = $menu_item->title; 		if ( ! empty( $menu_item->_invalid ) ) {			$classes[] = 'menu-item-invalid';			/* translators: %s: Title of an invalid menu item. */			$title = sprintf( __( '%s (Invalid)' ), $menu_item->title );		} elseif ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) {			$classes[] = 'pending';			/* translators: %s: Title of a menu item in draft status. */			$title = sprintf( __( '%s (Pending)' ), $menu_item->title );		} 		$title = ( ! isset( $menu_item->label ) || '' === $menu_item->label ) ? $title : $menu_item->label; 		$submenu_text = '';		if ( 0 === $depth ) {			$submenu_text = 'style="display: none;"';		} 		?>		<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode( ' ', $classes ); ?>">			<div class="menu-item-bar">				<div class="menu-item-handle">					<label class="item-title" for="menu-item-checkbox-<?php echo $item_id; ?>">						<input id="menu-item-checkbox-<?php echo $item_id; ?>" type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo $item_id; ?>" disabled="disabled" />						<span class="menu-item-title"><?php echo esc_html( $title ); ?></span>						<span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span>					</label>					<span class="item-controls">						<span class="item-type"><?php echo esc_html( $menu_item->type_label ); ?></span>						<span class="item-order hide-if-js">							<?php							printf(								'<a href="%s" class="item-move-up" aria-label="%s">&#8593;</a>',								wp_nonce_url(									add_query_arg(

History

Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.9.0
Renamed $item to $data_object and $id to $current_object_id to match parent class for PHP 8 named parameter support.from the docblock
3.0.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-admin/includes/class-walker-nav-menu-edit.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.