Title: wp_admin_bar_edit_site_menu
Published: February 3, 2022
Last modified: February 24, 2026

---

# wp_admin_bar_edit_site_menu( WP_Admin_Bar $wp_admin_bar )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#wp--skip-link--target)

Adds the “Edit Site” link to the Toolbar.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#parameters)󠁿

 `$wp_admin_bar`[WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
required

The [WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
instance.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#source)󠁿

    ```php
    function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
    	global $_wp_current_template_id;

    	// Don't show if a block theme is not activated.
    	if ( ! wp_is_block_theme() ) {
    		return;
    	}

    	// Don't show for users who can't edit theme options or when in the admin.
    	if ( ! current_user_can( 'edit_theme_options' ) || is_admin() ) {
    		return;
    	}

    	$wp_admin_bar->add_node(
    		array(
    			'id'    => 'site-editor',
    			'title' => __( 'Edit Site' ),
    			'href'  => add_query_arg(
    				array(
    					'postType' => 'wp_template',
    					'postId'   => $_wp_current_template_id,
    					'canvas'   => 'edit',
    				),
    				admin_url( 'site-editor.php' )
    			),
    		)
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/admin-bar.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/admin-bar.php#L462)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/admin-bar.php#L462-L489)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_block_theme()](https://developer.wordpress.org/reference/functions/wp_is_block_theme/)`wp-includes/theme.php` |

Returns whether the active theme is a block-based theme or not.

  | 
| [WP_Admin_Bar::add_node()](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_node/)`wp-includes/class-wp-admin-bar.php` |

Adds a node to the menu.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_admin()](https://developer.wordpress.org/reference/functions/is_admin/)`wp-includes/load.php` |

Determines whether the current request is for an administrative interface page.

  | 
| [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)`wp-includes/functions.php` |

Retrieves a modified URL query string.

  | 
| [admin_url()](https://developer.wordpress.org/reference/functions/admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current site.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Added the `canvas` query arg to the Site Editor link. | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Added `$_wp_current_template_id` global for editing of current template directly from the admin bar. | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_admin_bar_edit_site_menu%2F)
before being able to contribute a note or feedback.