检查是否正在使用随机标题图像。
原型
is_random_header_image( string $type = 'any' )
描述
如果用户明确选择外观>标题中的选项,则始终为true。如果主题已注册多个标题图像,则不会选择特定的标题图像,并且主题会使用add_theme_support()打开随机标题,也是如此。
参数
$type
(string)
(Optional)
要使用的随机池。任何|默认|上传
返回值
(bool)
源文件
路径:wp-includes/theme.php
<?php
...
function is_random_header_image( $type = 'any' ) {
$header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
if ( 'any' == $type ) {
if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) )
return true;
} else {
if ( "random-$type-image" == $header_image_mod )
return true;
elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() )
return true;
}
return false;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/is_random_header_image/