get_legacy_widget_block_editor_settings

函式
get_legacy_widget_block_editor_settings ( No parameters )
返回值
  • (array) Settings to be used with get_block_editor_settings().
定義位置
相關方法
get_default_block_editor_settingsget_block_editor_settingswp_get_code_editor_settingswp_use_widgets_block_editorget_block_editor_server_block_settings
引入
5.8.0
棄用
-

get_legacy_widget_block_editor_settings: 這個函式用來檢索一個小工具的傳統小工具塊編輯器設定: 這是用來確保在區塊編輯器之前建立的小工具仍然可以使用區塊編輯器進行編輯。

返回使用Legacy Widget塊所需的塊編輯器設定,該塊預設未被註冊。

function get_legacy_widget_block_editor_settings() {
	$editor_settings = array();

	/**
	 * Filters the list of widget-type IDs that should **not** be offered by the
	 * Legacy Widget block.
	 *
	 * Returning an empty array will make all widgets available.
	 *
	 * @since 5.8.0
	 *
	 * @param string[] $widgets An array of excluded widget-type IDs.
	 */
	$editor_settings['widgetTypesToHideFromLegacyWidgetBlock'] = apply_filters(
		'widget_types_to_hide_from_legacy_widget_block',
		array(
			'pages',
			'calendar',
			'archives',
			'media_audio',
			'media_image',
			'media_gallery',
			'media_video',
			'search',
			'text',
			'categories',
			'recent-posts',
			'recent-comments',
			'rss',
			'tag_cloud',
			'custom_html',
			'block',
		)
	);

	return $editor_settings;
}

常見問題

FAQs
檢視更多 >