wppaste
WordPress

wp_admin_bar_appearance_menu( WP_Admin_Bar $wp_admin_bar )

Since
3.1.0
Source
wp-includes/admin-bar.php:1155
Adds appearance submenu items to the "Site Name" menu.

Compatibility

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

$wp_admin_barWP_Admin_Bar
The WP_Admin_Bar instance.

Performance profile

How much work a call to wp_admin_bar_appearance_menu() 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
13–102

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()one call below wp_admin_bar_appearance_menu()

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 · 50 distinct outcomes

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

WhenInstructionsCalls it makes
!current_user_can()13->add_group(), current_user_can(), current_user_can()
always26->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can()
!current_theme_supports()33->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports()
always42->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
always46->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
always46->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports()
current_user_can() && !current_theme_supports()46->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports()
always48->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
always48->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always55->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
current_user_can()55->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
always57->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
38 further outcomes, up to 102 instructions
always57->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always59->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
current_user_can()59->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
current_user_can()59->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports()
always61->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
always61->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always61->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
always61->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
current_user_can()61->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()61->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always63->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()68->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
always70->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
always70->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
current_user_can()70->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()70->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always72->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()72->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports()
always74->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
always74->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
current_user_can()74->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()74->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
current_user_can()74->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()74->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always76->add_group(), current_user_can(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
always76->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()76->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()83->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()83->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
current_theme_supports()85->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()85->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()87->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()87->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports()
always89->add_group(), current_user_can(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()89->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()89->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can() && current_theme_supports()98->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()
current_user_can()102->add_group(), current_user_can(), __(), admin_url(), appearance(), current_user_can(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), current_theme_supports(), __(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance(), current_theme_supports(), _x(), admin_url(), appearance()

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, 13–102 executed per call, 7 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.

Uses · 5

  • current_user_can()Returns whether the current user has the specified capability.
  • __()Retrieves the translation of $text.
  • admin_url()Retrieves the URL to the admin area for the current site.
  • current_theme_supports()Checks a theme's support for a given feature.
  • _x()Retrieves translated string with gettext context.

Used by · 1

Source code

function wp_admin_bar_appearance_menu( $wp_admin_bar ) {	$wp_admin_bar->add_group(		array(			'parent' => 'site-name',			'id'     => 'appearance',		)	); 	if ( current_user_can( 'switch_themes' ) ) {		$wp_admin_bar->add_node(			array(				'parent' => 'appearance',				'id'     => 'themes',				'title'  => __( 'Themes' ),				'href'   => admin_url( 'themes.php' ),			)		);	} 	if ( ! current_user_can( 'edit_theme_options' ) ) {		return;	} 	if ( current_theme_supports( 'widgets' ) ) {		$wp_admin_bar->add_node(			array(				'parent' => 'appearance',				'id'     => 'widgets',				'title'  => __( 'Widgets' ),				'href'   => admin_url( 'widgets.php' ),			)		);	} 	if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {		$wp_admin_bar->add_node(			array(				'parent' => 'appearance',				'id'     => 'menus',				'title'  => __( 'Menus' ),				'href'   => admin_url( 'nav-menus.php' ),			)		);	} 	if ( current_theme_supports( 'custom-background' ) ) {		$wp_admin_bar->add_node(			array(				'parent' => 'appearance',				'id'     => 'background',				'title'  => _x( 'Background', 'custom background' ),				'href'   => admin_url( 'themes.php?page=custom-background' ),				'meta'   => array(					'class' => 'hide-if-customize',				),			)		);	} 	if ( current_theme_supports( 'custom-header' ) ) {		$wp_admin_bar->add_node(			array(				'parent' => 'appearance',				'id'     => 'header',				'title'  => _x( 'Header', 'custom image header' ),				'href'   => admin_url( 'themes.php?page=custom-header' ),				'meta'   => array(					'class' => 'hide-if-customize',				),			)		);	}}

Changelog

Introduced in 3.1.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.1.0 tag, from src/wp-includes/admin-bar.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.