block_core_image_get_lightbox_settings

函数
block_core_image_get_lightbox_settings ( $block )
参数
  • (array) $block Block data.
    Required:
返回值
  • (array) Filtered block data.
定义位置
相关方法
block_core_image_render_lightboxregister_block_core_site_icon_settingregister_block_core_site_logo_settingblock_core_navigation_get_post_idsblock_core_social_link_services
引入
-
弃用
-

lightboxEnabled  标志添加到区块数据中。该标志用于确定是否应呈现灯箱。

function block_core_image_get_lightbox_settings( $block ) {
	// Get the lightbox setting from the block attributes.
	if ( isset( $block['attrs']['lightbox'] ) ) {
		$lightbox_settings = $block['attrs']['lightbox'];
		// If the lightbox setting is not set in the block attributes,
		// check the legacy lightbox settings that are set using the
		// `gutenberg_should_render_lightbox` filter.
		// We can remove this elseif statement when the legacy lightbox settings are removed.
	} elseif ( isset( $block['legacyLightboxSettings'] ) ) {
		$lightbox_settings = $block['legacyLightboxSettings'];
	}

	if ( ! isset( $lightbox_settings ) ) {
		$lightbox_settings = wp_get_global_settings( array( 'lightbox' ), array( 'block_name' => 'core/image' ) );

		// If not present in global settings, check the top-level global settings.
		//
		// NOTE: If no block-level settings are found, the previous call to
		// `wp_get_global_settings` will return the whole `theme.json`
		// structure in which case we can check if the "lightbox" key is present at
		// the top-level of the global settings and use its value.
		if ( isset( $lightbox_settings['lightbox'] ) ) {
			$lightbox_settings = wp_get_global_settings( array( 'lightbox' ) );
		}
	}

	return $lightbox_settings ?? null;
}

常见问题

FAQs
查看更多 >