wppaste
WordPress

WP_Customize_Nav_Menu_Item_Control::content_template()

Since
4.3.0
Source
wp-includes/customize/class-wp-customize-nav-menu-item-control.php:64
JS/Underscore template for the control UI.

Compatibility

WordPress
since 4.3.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.

Performance profile

How much work a call to WP_Customize_Nav_Menu_Item_Control::content_template() 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
103

Executed per call on PHP 8.5. The body compiles to 103.

Plugin surface
1 hook

Third-party callbacks on 'wp_nav_menu_item_custom_fields_customize_template' 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 callbacksdo_action()called directly

Further down the call graph this can also reach query, option, cache, serialize 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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always103_e(), _e(), __(), printf(), __(), printf(), __(), printf(), __(), printf(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), _e(), do_action(), __(), printf(), _e()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 103 instructions, 103 executed per call, 0 branches. The work does not change between versions.

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 WP_Customize_Nav_Menu_Item_Control::content_template() runs, in this order:

  1. do_action( wp_nav_menu_item_custom_fields_customize_template )actionline 162 (+98 into the body)

    Fires at the end of the form field template for nav menu items in the customizer.

Uses · 3

  • _e()Displays translated text.
  • __()Retrieves the translation of $text.
  • do_action()Calls the callback functions that have been added to an action hook.

Source code

	public function content_template() {		?>		<div class="menu-item-bar">			<div class="menu-item-handle">				<span class="item-type" aria-hidden="true">{{ data.item_type_label }}</span>				<span class="item-title" aria-hidden="true">					<span class="spinner"></span>					<span class="menu-item-title<# if ( ! data.title && ! data.original_title ) { #> no-title<# } #>">{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}</span>					<# if ( 0 === data.depth ) { #>						<span class="is-submenu" style="display: none;"><?php _e( 'sub item' ); ?></span>					<# } else { #>						<span class="is-submenu"><?php _e( 'sub item' ); ?></span>					<# } #>				</span>				<span class="item-controls">					<button type="button" class="button-link item-edit" aria-expanded="false"><span class="screen-reader-text">					<# if ( 0 === data.depth ) { #>						<?php						/* translators: 1: Title of a menu item, 2: Type of a menu item. 3: Item index, 4: Total items. */						printf( __( 'Edit %1$s (%2$s, %3$d of %4$d)' ), '{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}', '', '' );						?>					<# } else if ( 1 === data.depth ) { #>						<?php							/* translators: 1: Title of a menu item, 2: Type of a menu item, 3, Item index, 4, Total items, 5: Item parent. */							printf( __( 'Edit %1$s (%2$s, sub-item %3$d of %4$d under %5$s)' ), '{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}', '', '', '' );						?>					<# } else { #>						<?php							/* translators: 1: Title of a menu item, 2: Type of a menu item, 3, Item index, 4, Total items, 5: Item parent, 6: Item depth. */							printf( __( 'Edit %1$s (%2$s, sub-item %3$d of %4$d under %5$s, level %6$s)' ), '{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}', '', '', '', '{{data.depth}}' );						?>					<# } #>					</span><span class="toggle-indicator" aria-hidden="true"></span></button>					<button type="button" class="button-link item-delete submitdelete deletion"><span class="screen-reader-text">					<?php						/* translators: 1: Title of a menu item, 2: Type of a menu item. */						printf( __( 'Remove Menu Item: %1$s (%2$s)' ), '{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.item_type_label }}' );					?>					</span></button>				</span>			</div>		</div> 		<div class="menu-item-settings" id="menu-item-settings-{{ data.menu_item_id }}">			<# if ( 'custom' === data.item_type ) { #>			<p class="field-url description description-thin">				<label for="edit-menu-item-url-{{ data.menu_item_id }}">					<?php _e( 'URL' ); ?><br />					<input class="widefat code edit-menu-item-url" type="text" id="edit-menu-item-url-{{ data.menu_item_id }}" name="menu-item-url" />				</label>			</p>		<# } #>			<p class="description description-thin">				<label for="edit-menu-item-title-{{ data.menu_item_id }}">					<?php _e( 'Navigation Label' ); ?><br />					<input type="text" id="edit-menu-item-title-{{ data.menu_item_id }}" placeholder="{{ data.original_title }}" class="widefat edit-menu-item-title" name="menu-item-title" />				</label>			</p>			<p class="field-link-target description description-thin">				<label for="edit-menu-item-target-{{ data.menu_item_id }}">					<input type="checkbox" id="edit-menu-item-target-{{ data.menu_item_id }}" class="edit-menu-item-target" value="_blank" name="menu-item-target" />					<?php _e( 'Open link in a new tab' ); ?>				</label>			</p>			<p class="field-title-attribute field-attr-title description description-thin">				<label for="edit-menu-item-attr-title-{{ data.menu_item_id }}">					<?php _e( 'Title Attribute' ); ?><br />					<input type="text" id="edit-menu-item-attr-title-{{ data.menu_item_id }}" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title" />				</label>			</p>			<p class="field-css-classes description description-thin">				<label for="edit-menu-item-classes-{{ data.menu_item_id }}">					<?php _e( 'CSS Classes' ); ?><br />					<input type="text" id="edit-menu-item-classes-{{ data.menu_item_id }}" class="widefat code edit-menu-item-classes" name="menu-item-classes" />				</label>			</p>			<p class="field-xfn description description-thin">				<label for="edit-menu-item-xfn-{{ data.menu_item_id }}">					<?php _e( 'Link Relationship (XFN)' ); ?><br />					<input type="text" id="edit-menu-item-xfn-{{ data.menu_item_id }}" class="widefat code edit-menu-item-xfn" name="menu-item-xfn" />

Changelog

Introduced in 4.3.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.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/customize/class-wp-customize-nav-menu-item-control.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.