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

返回介绍

has_custom_logo()

发布于 2017-09-11 字数2294 浏览 907 评论 0

has_custom_logo( int $blog_id )

Determines whether the site has a custom logo.


描述


参数

$blog_id

(int)
(Optional)
ID of the blog in question. Default is the ID of the current blog.


返回值

(bool) Whether the site has a custom logo or not.


源代码

File: wp-includes/general-template.php

function has_custom_logo( $blog_id = 0 ) {
	$switched_blog = false;

	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
		switch_to_blog( $blog_id );
		$switched_blog = true;
	}

	$custom_logo_id = get_theme_mod( 'custom_logo' );

	if ( $switched_blog ) {
		restore_current_blog();
	}

	return (bool) $custom_logo_id;
}

更新日志

Version 描述
4.5.0 Introduced.

相关函数

Uses

  • wp-includes/theme.php:
    get_theme_mod()
  • wp-includes/load.php:
    is_multisite()
  • wp-includes/load.php:
    get_current_blog_id()
  • wp-includes/ms-blogs.php:
    switch_to_blog()
  • wp-includes/ms-blogs.php:
    restore_current_blog()

Used By

  • wp-includes/post-template.php:
    get_body_class()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 1You must log in to vote on the helpfulness of this note

    Contributed by Anthony Hortin

    See Also
    the_custom_logo()
    get_custom_logo()

  2. To get the URL of the custom logo image:

    
    $custom_logo_id = get_theme_mod( 'custom_logo' );
    $image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
    echo $image[0];
    

上一篇:has_custom_header()

下一篇:has_excerpt()

发布评论

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

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