wp_admin_bar_customize_menu

Adds the "Customize" link to the Toolbar.

Description

wp_admin_bar_customize_menu( (WP_Admin_Bar) $wp_admin_bar ); 

Parameters (1)

0. $wp_admin_bar (WP_Admin_Bar)
WP_Admin_Bar instance.

Usage

  1. if ( !function_exists( 'wp_admin_bar_customize_menu' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4. // WP_Admin_Bar instance. 
  5. $wp_admin_bar = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_admin_bar_customize_menu($wp_admin_bar); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/admin-bar.php  
  1. function wp_admin_bar_customize_menu( $wp_admin_bar ) { 
  2. global $wp_customize; 
  3.  
  4. // Don't show for users who can't access the customizer or when in the admin. 
  5. if ( ! current_user_can( 'customize' ) || is_admin() ) { 
  6. return; 
  7.  
  8. // Don't show if the user cannot edit a given customize_changeset post currently being previewed. 
  9. if ( is_customize_preview() && $wp_customize->changeset_post_id() && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() ) ) { 
  10. return; 
  11.  
  12. $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
  13. if ( is_customize_preview() && $wp_customize->changeset_uuid() ) { 
  14. $current_url = remove_query_arg( 'customize_changeset_uuid', $current_url ); 
  15.  
  16. $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); 
  17. if ( is_customize_preview() ) { 
  18. $customize_url = add_query_arg( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ), $customize_url ); 
  19.  
  20. $wp_admin_bar->add_menu( array( 
  21. 'id' => 'customize',  
  22. 'title' => __( 'Customize' ),  
  23. 'href' => $customize_url,  
  24. 'meta' => array( 
  25. 'class' => 'hide-if-no-customize',  
  26. ),  
  27. ) );