has_custom_logo

函式
has_custom_logo ( $blog_id = 0 )
引數
  • (int) $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
    Required:
返回值
  • (bool) Whether the site has a custom logo or not.
定義位置
相關方法
the_custom_logoget_custom_logohas_custom_headeradd_user_to_blogpost_custom
引入
4.5.0
棄用
-

has_custom_logo – 這是一個WordPress函式,用於檢查當前主題是否已經定義了一個自定義的標誌。自定義標識是一個允許使用者上傳自定義圖片或標識作為網站標識的功能。has_custom_logo函式如果在當前主題中已經定義了自定義標誌,則返回true。

決定網站是否有一個自定義的標誌。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function has_custom_logo( $blog_id = 0 ) {
$switched_blog = false;
if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $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;
}
function has_custom_logo( $blog_id = 0 ) { $switched_blog = false; if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $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; }
function has_custom_logo( $blog_id = 0 ) {
	$switched_blog = false;

	if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $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;
}

常見問題

FAQs
檢視更多 >