
WordPress主题开发入门基础教程
is_header_video_active ( No parameters )
is_header_video_active: 如果网站的页眉视频处于活动状态,该函数返回true。头部视频是WordPress的一个功能,允许用户在网站首页的顶部添加一个视频: 这个函数经常被用来根据头条视频是否激活来有条件地显示内容。
检查自定义页眉视频是否有资格在当前页面显示。
function is_header_video_active() { if ( ! get_theme_support( 'custom-header', 'video' ) ) { return false; } $video_active_cb = get_theme_support( 'custom-header', 'video-active-callback' ); if ( empty( $video_active_cb ) || ! is_callable( $video_active_cb ) ) { $show_video = true; } else { $show_video = call_user_func( $video_active_cb ); } /** * Filters whether the custom header video is eligible to show on the current page. * * @since 4.7.0 * * @param bool $show_video Whether the custom header video should be shown. Returns the value * of the theme setting for the `custom-header`'s `video-active-callback`. * If no callback is set, the default value is that of `is_front_page()`. */ return apply_filters( 'is_header_video_active', $show_video ); }