is_header_video_active

函式
is_header_video_active ( No parameters )
返回值
  • (bool) True if the custom header video should be shown. False if not.
定義位置
相關方法
has_header_videoget_header_video_settingsthe_header_video_urlget_header_video_urlhas_header_image
引入
4.7.0
棄用
-

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 );
}

常見問題

FAQs
檢視更多 >