wppaste
WordPress

Walker_Nav_Menu_Checklist::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-checklist.php:76
Start the element output.

Compatibility

WordPress
since 5.9.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

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

Performance profile

How much work a call to Walker_Nav_Menu_Checklist::start_el() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
157–192

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 205.

Plugin surface
1 hook

Third-party callbacks on 'the_title' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 8 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost Walker_Nav_Menu_Checklist::start_el() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always157–172wp_nav_menu_disabled_check(), esc_attr(), esc_html(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
always162–177str_repeat(), wp_nav_menu_disabled_check(), esc_attr(), esc_html(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
empty($menu_item) && isset($menu_item)167–177wp_nav_menu_disabled_check(), esc_attr(), esc_html(), _post_states(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
empty($menu_item) && isset($menu_item)167–182wp_nav_menu_disabled_check(), esc_attr(), apply_filters(), esc_html(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
empty($menu_item) && isset($menu_item)172–182str_repeat(), wp_nav_menu_disabled_check(), esc_attr(), esc_html(), _post_states(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
empty($menu_item) && isset($menu_item)172–187str_repeat(), wp_nav_menu_disabled_check(), esc_attr(), apply_filters(), esc_html(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
empty($menu_item) && isset($menu_item)177–187wp_nav_menu_disabled_check(), esc_attr(), apply_filters(), esc_html(), _post_states(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()
empty($menu_item) && isset($menu_item)182–192str_repeat(), wp_nav_menu_disabled_check(), esc_attr(), apply_filters(), esc_html(), _post_states(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev202156–190133 fewer instructions than PHP 8.5
8.5205157–19213
8.4205157–192133 fewer instructions than PHP 8.3
8.3208160–19513
8.2208160–19513
8.1208160–195133 fewer instructions than PHP 7.4
7.4211160–19713

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

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

  1. apply_filters( the_title )filterline 102 (+26 into the body)

    Filters the post title.

Uses · 6

Source code

	public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {		global $_nav_menu_placeholder, $nav_menu_selected_id; 		// Restores the more descriptive, specific name for use within this method.		$menu_item = $data_object; 		$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;		$possible_object_id    = isset( $menu_item->post_type ) && 'nav_menu_item' === $menu_item->post_type ? $menu_item->object_id : $_nav_menu_placeholder;		$possible_db_id        = ( ! empty( $menu_item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $menu_item->ID : 0; 		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 		$output .= $indent . '<li>';		$output .= '<label class="menu-item-title">';		$output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox'; 		if ( ! empty( $menu_item->front_or_home ) ) {			$output .= ' add-to-top';		} 		$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $menu_item->object_id ) . '" /> '; 		if ( ! empty( $menu_item->label ) ) {			$title = $menu_item->label;		} elseif ( isset( $menu_item->post_type ) ) {			/** This filter is documented in wp-includes/post-template.php */			$title = apply_filters( 'the_title', $menu_item->post_title, $menu_item->ID );		} 		$output .= isset( $title ) ? esc_html( $title ) : esc_html( $menu_item->title ); 		if ( empty( $menu_item->label ) && isset( $menu_item->post_type ) && 'page' === $menu_item->post_type ) {			// Append post states.			$output .= _post_states( $menu_item, false );		} 		$output .= '</label>'; 		// Menu item hidden fields.		$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';		$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $menu_item->object ) . '" />';		$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $menu_item->menu_item_parent ) . '" />';		$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $menu_item->type ) . '" />';		$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . htmlspecialchars( $menu_item->title, ENT_QUOTES ) . '" />';		$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_url( $menu_item->url ) . '" />';		$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $menu_item->target ) . '" />';		$output .= '<input type="hidden" class="menu-item-attr-title" name="menu-item[' . $possible_object_id . '][menu-item-attr-title]" value="' . htmlspecialchars( $menu_item->attr_title, ENT_QUOTES ) . '" />';		$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . htmlspecialchars( implode( ' ', $menu_item->classes ), ENT_QUOTES ) . '" />';		$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . htmlspecialchars( $menu_item->xfn, ENT_QUOTES ) . '" />';	}

Changelog

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 7.0.4 tag, from src/wp-admin/includes/class-walker-nav-menu-checklist.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.