+/**
+ * Adds the "Customize" link to the Toolbar.
+ *
+ * @since 4.3.0
+ *
+ * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
+ */
+function wp_admin_bar_customize_menu( $wp_admin_bar ) {
+ // Don't show for users who can't access the customizer or when in the admin.
+ if ( ! current_user_can( 'customize' ) || is_admin() ) {
+ return;
+ }
+
+ $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
+
+ $wp_admin_bar->add_menu( array(
+ 'id' => 'customize',
+ 'title' => __( 'Customize' ),
+ 'href' => $customize_url,
+ 'meta' => array(
+ 'class' => 'hide-if-no-customize',
+ ),
+ ) );
+ add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
+}
+