diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/admin-bar.php
--- a/wp/wp-includes/admin-bar.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/admin-bar.php Tue Sep 27 16:37:53 2022 +0200
@@ -8,7 +8,7 @@
*/
/**
- * Instantiate the admin bar object and set it up as a global for access elsewhere.
+ * Instantiates the admin bar object and set it up as a global for access elsewhere.
*
* UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR.
* For that, use show_admin_bar(false) or the {@see 'show_admin_bar'} filter.
@@ -84,13 +84,13 @@
}
/**
- * Load all necessary admin bar items.
+ * Loads all necessary admin bar items.
*
* This is the hook used to add, remove, or manipulate admin bar items.
*
* @since 3.1.0
*
- * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance, passed by reference.
*/
do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
@@ -114,11 +114,11 @@
}
/**
- * Add the WordPress logo menu.
+ * Adds the WordPress logo menu.
*
* @since 3.3.0
*
- * @param WP_Admin_Bar $wp_admin_bar
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_wp_menu( $wp_admin_bar ) {
if ( current_user_can( 'read' ) ) {
@@ -198,11 +198,11 @@
}
/**
- * Add the sidebar toggle button.
+ * Adds the sidebar toggle button.
*
* @since 3.8.0
*
- * @param WP_Admin_Bar $wp_admin_bar
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
if ( is_admin() ) {
@@ -217,11 +217,11 @@
}
/**
- * Add the "My Account" item.
+ * Adds the "My Account" item.
*
* @since 3.3.0
*
- * @param WP_Admin_Bar $wp_admin_bar
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
$user_id = get_current_user_id();
@@ -258,11 +258,11 @@
}
/**
- * Add the "My Account" submenu items.
+ * Adds the "My Account" submenu items.
*
* @since 3.1.0
*
- * @param WP_Admin_Bar $wp_admin_bar
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
@@ -328,11 +328,11 @@
}
/**
- * Add the "Site Name" menu.
+ * Adds the "Site Name" menu.
*
* @since 3.3.0
*
- * @param WP_Admin_Bar $wp_admin_bar
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_site_menu( $wp_admin_bar ) {
// Don't show for logged out users.
@@ -409,16 +409,48 @@
}
/**
+ * Adds the "Edit site" link to the Toolbar.
+ *
+ * @since 5.9.0
+ *
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
+ */
+function wp_admin_bar_edit_site_menu( $wp_admin_bar ) {
+ // 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' => admin_url( 'site-editor.php' ),
+ )
+ );
+}
+
+/**
* Adds the "Customize" link to the Toolbar.
*
* @since 4.3.0
*
- * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
* @global WP_Customize_Manager $wp_customize
*/
function wp_admin_bar_customize_menu( $wp_admin_bar ) {
global $wp_customize;
+ // Don't show if a block theme is activated and no plugins use the customizer.
+ if ( wp_is_block_theme() && ! has_action( 'customize_register' ) ) {
+ return;
+ }
+
// Don't show for users who can't access the customizer or when in the admin.
if ( ! current_user_can( 'customize' ) || is_admin() ) {
return;
@@ -455,11 +487,11 @@
}
/**
- * Add the "My Sites/[Site Name]" menu and all submenus.
+ * Adds the "My Sites/[Site Name]" menu and all submenus.
*
* @since 3.1.0
*
- * @param WP_Admin_Bar $wp_admin_bar
+ * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
// Don't show for logged out users or single site mode.
@@ -579,14 +611,27 @@
)
);
+ /**
+ * Filters whether to show the site icons in toolbar.
+ *
+ * Returning false to this hook is the recommended way to hide site icons in the toolbar.
+ * A truthy return may have negative performance impact on large multisites.
+ *
+ * @since 6.0.0
+ *
+ * @param bool $show_site_icons Whether site icons should be shown in the toolbar. Default true.
+ */
+ $show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );
+
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
switch_to_blog( $blog->userblog_id );
- if ( has_site_icon() ) {
+ if ( true === $show_site_icons && has_site_icon() ) {
$blavatar = sprintf(
- '',
+ '
',
esc_url( get_site_icon_url( 16 ) ),
- esc_url( get_site_icon_url( 32 ) )
+ esc_url( get_site_icon_url( 32 ) ),
+ ( wp_lazy_loading_enabled( 'img', 'site_icon_in_toolbar' ) ? ' loading="lazy"' : '' )
);
} else {
$blavatar = '