wp_admin_bar_customize_menu() - WordPress 函数参考中文文档

返回介绍

wp_admin_bar_customize_menu()

发布于 2017-09-11 字数2800 浏览 896 评论 0

wp_admin_bar_customize_menu( WP_Admin_Bar $wp_admin_bar )

Adds the “Customize” link to the Toolbar.


描述


参数

$wp_admin_bar

(WP_Admin_Bar)
(Required)
WP_Admin_Bar instance.


源代码

File: wp-includes/admin-bar.php

function wp_admin_bar_customize_menu( $wp_admin_bar ) {
	global $wp_customize;

	// Don't show for users who can't access the customizer or when in the admin.
	if ( ! current_user_can( 'customize' ) || is_admin() ) {
		return;
	}

	// Don't show if the user cannot edit a given customize_changeset post currently being previewed.
	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() ) ) {
		return;
	}

	$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	if ( is_customize_preview() && $wp_customize->changeset_uuid() ) {
		$current_url = remove_query_arg( 'customize_changeset_uuid', $current_url );
	}

	$customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() );
	if ( is_customize_preview() ) {
		$customize_url = add_query_arg( array( 'changeset_uuid' => $wp_customize->changeset_uuid() ), $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' );
}

更新日志

Version 描述
4.3.0 Introduced.

相关函数

Uses

  • wp-includes/theme.php:
    is_customize_preview()
  • wp-includes/capabilities.php:
    current_user_can()
  • wp-includes/theme.php:
    wp_customize_url()
  • wp-includes/l10n.php:
    __()
  • wp-includes/load.php:
    is_admin()
  • wp-includes/load.php:
    is_ssl()
  • wp-includes/functions.php:
    remove_query_arg()
  • wp-includes/functions.php:
    add_query_arg()
  • wp-includes/class-wp-admin-bar.php:
    WP_Admin_Bar::add_menu()
  • wp-includes/plugin.php:
    add_action()
  • wp-includes/post.php:
    get_post_type_object()
  • Show 6 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!