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
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
- Scaling
- Constant
- Instructions
- 157–192
- Plugin surface
- 1 hook
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 205.
Third-party callbacks on 'the_title' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 157–172 | wp_nav_menu_disabled_check(), esc_attr(), esc_html(), esc_attr(), esc_attr(), esc_attr(), htmlspecialchars(), esc_url(), esc_attr(), htmlspecialchars(), htmlspecialchars(), htmlspecialchars() |
| always | 162–177 | str_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–177 | 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) | 167–182 | 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) | 172–182 | str_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–187 | str_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–187 | 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() |
empty($menu_item) && isset($menu_item) | 182–192 | str_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 202 | 156–190 | 13 | 3 fewer instructions than PHP 8.5 |
| 8.5 | 205 | 157–192 | 13 | |
| 8.4 | 205 | 157–192 | 13 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 208 | 160–195 | 13 | |
| 8.2 | 208 | 160–195 | 13 | |
| 8.1 | 208 | 160–195 | 13 | 3 fewer instructions than PHP 7.4 |
| 7.4 | 211 | 160–197 | 13 |
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:
Uses · 6
- wp_nav_menu_disabled_check()Check whether to disable the Menu Locations meta box submit button and inputs.
- esc_attr()Escaping for HTML attributes.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- esc_html()Escaping for HTML blocks.
- _post_states()Echoes or returns the post states as HTML.
- esc_url()Checks and cleans a URL.
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.
Signature, return type and hooks compared across 5 parsed releases.
$item to $data_object and $id to $current_object_id to match parent class for PHP 8 named parameter support.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.