wp_admin_bar_edit_site_menu()
Adds the "Edit Site" link to the Toolbar.
No Hooks.
Returns
null
. Nothing (null).
Usage
wp_admin_bar_edit_site_menu( $wp_admin_bar );
- $wp_admin_bar(WP_Admin_Bar) (required)
- The WP_Admin_Bar instance.
Notes
- Global. String. $_wp_current_template_id
Changelog
Since 5.9.0 | Introduced. |
Since 6.3.0 | Added $_wp_current_template_id global for editing of current template directly from the admin bar. |
Since 6.6.0 | Added the canvas query arg to the Site Editor link. |
wp_admin_bar_edit_site_menu() wp admin bar edit site menu code WP 6.8.1
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' ) ), ) ); }