title: "弃用说明" post_status: publish comment_status: open taxonomy: category: - gutenberg-docs post_tag: - Code - Contributors - Repos
弃用说明
对于 Gutenberg 插件中包含的功能,弃用政策旨在尽可能支持向后兼容两个次要插件版本。WordPress 稳定版本中包含的功能和代码不在此弃用时间线内,而是遵循 WordPress 项目的版本控制政策。当前的弃用项如下所列,并按 它们将被完全移除的版本 分组。如果您的插件依赖这些行为,必须在指定版本前更新至推荐替代方案。
未发布版本
wp.blocks.isValidBlockContent已被移除。请改用wp.blocks.validateBlock。
11.0.0
wp.blocks.registerBlockTypeFromMetadata方法已被移除。请改用wp.blocks.registerBlockType方法。
10.3.0
- 不再支持将带有
as属性的组件元组传递给ActionItem.Slot组件。请改为传递一个带有as属性的组件。示例: ```diff <ActionItem.Slot name="my/slot" label={ __( 'My slot' ) }- as={ [ MenuGroup, MenuItem ] }
- as={ MenuGroup } /> ```
9.7.0
InterfaceSkeleton组件中的leftSidebar属性已被移除。请改用secondarySidebar属性。
8.6.0
- 与区块上下文的区块 API 集成已更新。注册区块时,请在 JavaScript 文件中使用
usesContext和providesContext对,在 PHP 文件中使用uses_context和provides_context对,以替代之前的context和providesContext对。
8.3.0
- PHP 函数
gutenberg_get_post_from_context已被移除。请改用区块上下文。 - 旧的区块模式 API
register_pattern/unregister_pattern已被移除。请改用新函数。
5.5.0
- 已移除 PHP 函数
gutenberg_init。 - 已移除 PHP 函数
is_gutenberg_page。请改用WP_Screen::is_block_editor。 - 已移除 PHP 函数
the_gutenberg_project。 - 已移除 PHP 函数
gutenberg_default_post_format_template。 - 已移除 PHP 函数
gutenberg_get_available_image_sizes。 - 已移除 PHP 函数
gutenberg_get_autosave_newer_than_post_save。 - 已移除 PHP 函数
gutenberg_editor_scripts_and_styles。
5.4.0
- 已移除 PHP 函数
gutenberg_load_plugin_textdomain。 - 已移除 PHP 函数
gutenberg_get_jed_locale_data。 - 已移除 PHP 函数
gutenberg_load_locale_data。
5.3.0
- 已移除 PHP 函数
gutenberg_redirect_to_classic_editor_when_saving_posts。 - 已移除 PHP 函数
gutenberg_revisions_link_to_editor。 - 已移除 PHP 函数
gutenberg_remember_classic_editor_when_saving_posts。 - 已移除 PHP 函数
gutenberg_can_edit_post_type。请改用use_block_editor_for_post_type。 - 已移除 PHP 函数
gutenberg_can_edit_post。请改用use_block_editor_for_post。
5.2.0
- PHP 函数
gutenberg_parse_blocks已被移除。请改用parse_blocks。 - PHP 函数
get_dynamic_blocks_regex已被移除。 - PHP 函数
gutenberg_render_block已被移除。请改用render_block。 - PHP 函数
strip_dynamic_blocks已被移除。如需用于摘要准备,请考虑改用excerpt_remove_blocks。 - PHP 函数
strip_dynamic_blocks_add_filter已被移除。 - PHP 函数
strip_dynamic_blocks_remove_filter已被移除。 - PHP 函数
gutenberg_post_has_blocks已被移除。请改用has_blocks。 - PHP 函数
gutenberg_content_has_blocks已被移除。请改用has_blocks。 - PHP 函数
gutenberg_register_rest_routes已被移除。 - PHP 函数
gutenberg_add_taxonomy_visibility_field已被移除。 - PHP 函数
gutenberg_get_taxonomy_visibility_data已被移除。 - PHP 函数
gutenberg_add_permalink_template_to_posts已被移除。 - PHP 函数
gutenberg_add_block_format_to_post_content已被移除。 - PHP 函数
gutenberg_add_target_schema_to_links已被移除。 - PHP 函数
gutenberg_register_post_prepare_functions已被移除。 - PHP 函数
gutenberg_silence_rest_errors已被移除。 - PHP 函数
gutenberg_filter_post_type_labels已被移除。 - PHP 函数
gutenberg_preload_api_request已被移除。请改用rest_preload_api_request。 - PHP 函数
gutenberg_remove_wpcom_markdown_support已被移除。 - PHP 函数
gutenberg_add_gutenberg_post_state已被移除。 - PHP 函数
gutenberg_bulk_post_updated_messages已被移除。 - PHP 函数
gutenberg_kses_allowedtags已被移除。 - PHP 函数
gutenberg_add_responsive_body_class已被移除。 - PHP 函数
gutenberg_add_edit_link_filters已被移除。 - PHP 函数
gutenberg_add_edit_link已被移除。 - PHP 函数
gutenberg_block_bulk_actions已被移除。 - PHP 函数
gutenberg_replace_default_add_new_button已被移除。 - PHP 函数
gutenberg_content_block_version已被移除。请改用block_version。 - PHP 函数
gutenberg_get_block_categories已被移除。请改用get_block_categories。 - PHP 函数
register_tinymce_scripts已被移除。请改用wp_register_tinymce_scripts。 - PHP 函数
gutenberg_register_post_types已被移除。 gutenberg主题支持选项已被移除。请改用align-wide。- PHP 函数
gutenberg_prepare_blocks_for_js已被移除。请改用get_block_editor_server_block_settings。 - PHP 函数
gutenberg_load_list_reusable_blocks已被移除。 - PHP 函数
_gutenberg_utf8_split已被移除。请改用_mb_substr。 - PHP 函数
gutenberg_disable_editor_settings_wpautop已被移除。 - PHP 函数
gutenberg_add_rest_nonce_to_heartbeat_response_headers已被移除。 - PHP 函数
gutenberg_check_if_classic_needs_warning_about_blocks已被移除。 - PHP 函数
gutenberg_warn_classic_about_blocks已被移除。 - PHP 函数
gutenberg_show_privacy_policy_help_text已被移除。 - PHP 函数
gutenberg_common_scripts_and_styles已被移除。请改用wp_common_block_scripts_and_styles。 - PHP 函数
gutenberg_enqueue_registered_block_scripts_and_styles已被移除。请改用wp_enqueue_registered_block_scripts_and_styles。 - PHP 函数
gutenberg_meta_box_save已被移除。 - PHP 函数
gutenberg_meta_box_save_redirect已被移除。 - PHP 函数
gutenberg_filter_meta_boxes已被移除。 - PHP 函数
gutenberg_intercept_meta_box_render已被移除。 - PHP 函数
gutenberg_override_meta_box_callback已被移除。 - PHP 函数
gutenberg_show_meta_box_warning已被移除。 - PHP 函数
the_gutenberg_metaboxes已被移除。请改用the_block_editor_meta_boxes。 - PHP 函数
gutenberg_meta_box_post_form_hidden_fields已被移除。请改用the_block_editor_meta_box_post_form_hidden_fields。 - PHP 函数
gutenberg_toggle_custom_fields已被移除。 - PHP 函数
gutenberg_collect_meta_box_data已被移除。请改用register_and_do_post_meta_boxes。 window._wpLoadGutenbergEditor已被移除。请改用window._wpLoadBlockEditor。注意:这是一个私有 API,不供公共使用。未来可能会被移除。- PHP 函数
gutenberg_get_script_polyfill已被移除。请改用wp_get_script_polyfill。 - PHP 函数
gutenberg_add_admin_body_class已被移除。如果需要在样式表中限定样式到块编辑器屏幕,请使用.block-editor-page类选择器。
4.5.0
Dropdown.refresh()已被弃用,因为其包含的Popover现在会自动刷新。wp.editor.PostPublishPanelToggle已被弃用,建议使用wp.editor.PostPublishButton。
4.4.0
wp.date.getSettings已被移除。请改用wp.date.__experimentalGetSettings。wp.compose.remountOnPropChange已被移除。- 以下编辑器存储操作已被移除:
createNotice、removeNotice、createSuccessNotice、createInfoNotice、createErrorNotice、createWarningNotice。请使用@wordpress/notices模块中同名的等效操作。 wp.nux.DotTip的 id 属性已被移除。请改用 tipId 属性。wp.blocks.isValidBlock已被移除。请改用wp.blocks.isValidBlockContent,但请注意参数顺序已更改。wp.data的registry.registerReducer已被弃用。请改用registry.registerStore。wp.data的registry.registerSelectors已被弃用。请改用registry.registerStore。wp.data的registry.registerActions已被弃用。请改用registry.registerStore。wp.data的registry.registerResolvers已被弃用。请改用registry.registerStore。moment已从日期模块的公共 API 中移除。
4.3.0
isEditorSidebarPanelOpened选择器 (core/edit-post) 已被移除。请改用isEditorPanelEnabled。toggleGeneralSidebarEditorPanel操作 (core/edit-post) 已被移除。请改用toggleEditorPanelOpened。wp.components.PanelColor组件已被移除。请改用wp.editor.PanelColorSettings。wp.editor.PanelColor组件已被移除。请改用wp.editor.PanelColorSettings。
4.2.0
- 已移除将解析器写作异步生成器的功能。请改用 controls 插件。
- 已移除
wp.components.AccessibleSVG组件。请改用wp.components.SVG。 wp.editor.UnsavedChangesWarning组件不再接受forceIsDirty属性。- 已移除
setActiveMetaBoxLocations操作 (core/edit-post)。 - 已移除
initializeMetaBoxState操作 (core/edit-post)。 wp.editPost.initializeEditor不再返回对象。请使用setActiveMetaBoxLocations操作 (core/edit-post) 来替代原对象的initializeMetaBoxes函数。- 已移除
setMetaBoxSavedData操作 (core/edit-post)。 - 已移除
getMetaBoxes选择器 (core/edit-post)。请改用getActiveMetaBoxLocations选择器 (core/edit-post)。 - 已移除
getMetaBox选择器 (core/edit-post)。请改用isMetaBoxLocationActive选择器 (core/edit-post)。 - 已移除属性类型强制转换。请省略 source 以通过序列化的注释定界符来保留类型。
wp.editor.mediaUpload的onFileChange回调所接收对象中的mediaDetails。请改用media_details属性。- 已移除
wp.components.CodeEditor。请直接使用wp.codeEditor。 - 已移除
wp.blocks.setUnknownTypeHandlerName。请改用setFreeformContentHandlerName和setUnregisteredTypeHandlerName。 - 已移除
wp.blocks.getUnknownTypeHandlerName。请改用getFreeformContentHandlerName和getUnregisteredTypeHandlerName。 - 可重用块数据 API 已标记为实验性,因其未来可能发生变化。
4.1.0
wp.data.dispatch( 'core/editor' ).checkTemplateValidity已被移除。区块重置时会自动验证有效性。
4.0.0
wp.editor.RichTextProvider已被移除。请改用wp.data.select( 'core/editor' )方法。- 作为 DOM 节点拖拽处理器的
wp.components.Draggable已被移除。请将wp.components.Draggable作为包装组件用于你的 DOM 节点拖拽处理器。 wp.i18n.getI18n已被移除。请改用__、_x、_n或_nx。wp.i18n.dcnpgettext已被移除。请改用__、_x、_n或_nx。
3.9.0
- RichText 的
getSettings属性已被移除。如需继续使用,可使用unstableGetSettings属性。强烈不建议使用不稳定 API,它们可能会在未经通知的情况下被移除。 - RichText 的
onSetup属性已被移除。如需继续使用,可使用unstableOnSetup属性。强烈不建议使用不稳定 API,它们可能会在未经通知的情况下被移除。 wp.editor.getColorName已被移除。请改用wp.editor.getColorObjectByColorValue。wp.editor.getColorClass已重命名。请改用wp.editor.getColorClassName。wp.editor.withColors传递的颜色对象中的value属性已被移除。请改用 color 属性。- 副标题区块已被移除。请改用段落区块。
wp.blocks.getDefaultBlockForPostFormat已被移除。
3.8.0
wp.components.withContexthas been removed. Please usewp.element.createContextinstead. See: https://react.dev/reference/react/createContext.wp.coreBlocks.registerCoreBlockshas been removed. Please usewp.blockLibrary.registerCoreBlocksinstead.wp.editor.DocumentTitlecomponent has been removed.getDocumentTitleselector (core/editor) has been removed.
3.7.0
wp.components.withAPIData已被移除。请直接使用核心数据模块或wp.apiFetch。wp.data.dispatch("core").receiveTerms已被弃用。请改用wp.data.dispatch("core").receiveEntityRecords。getCategories解析器已被弃用。请改用getEntityRecords解析器。wp.data.select("core").getTerms已被弃用。请改用wp.data.select("core").getEntityRecords。wp.data.select("core").getCategories已被弃用。请改用wp.data.select("core").getEntityRecords。wp.data.select("core").isRequestingCategories已被弃用。请改用wp.data.select("core/data").isResolving。wp.data.select("core").isRequestingTerms已被弃用。请改用wp.data.select("core").isResolving。wp.data.restrictPersistence、wp.data.setPersistenceStorage和wp.data.setupPersistence已被移除。请改用数据持久化插件。
3.6.0
wp.editor.editorMediaUpload已被移除。请改用wp.editor.mediaUpload。wp.utils.getMimeTypesArray已被移除。wp.utils.mediaUpload已被移除。请改用wp.editor.mediaUpload。wp.utils.preloadImage已被移除。supports.wideAlign已从区块 API 中移除。请改用supports.alignWide。wp.blocks.isSharedBlock已被移除。请改用wp.blocks.isReusableBlock。fetchSharedBlocks操作 (core/editor) 已被移除。请改用fetchReusableBlocks。receiveSharedBlocks操作 (core/editor) 已被移除。请改用receiveReusableBlocks。saveSharedBlock操作 (core/editor) 已被移除。请改用saveReusableBlock。deleteSharedBlock操作 (core/editor) 已被移除。请改用deleteReusableBlock。updateSharedBlockTitle操作 (core/editor) 已被移除。请改用updateReusableBlockTitle。convertBlockToSaved操作 (core/editor) 已被移除。请改用convertBlockToReusable。getSharedBlock选择器 (core/editor) 已被移除。请改用getReusableBlock。isSavingSharedBlock选择器 (core/editor) 已被移除。请改用isSavingReusableBlock。isFetchingSharedBlock选择器 (core/editor) 已被移除。请改用isFetchingReusableBlock。getSharedBlocks选择器 (core/editor) 已被移除。请改用getReusableBlocks。
3.5.0
wp.components.ifCondition已被移除。请改用wp.compose.ifCondition。wp.components.withGlobalEvents已被移除。请改用wp.compose.withGlobalEvents。wp.components.withInstanceId已被移除。请改用wp.compose.withInstanceId。wp.components.withSafeTimeout已被移除。请改用wp.compose.withSafeTimeout。wp.components.withState已被移除。请改用wp.compose.withState。wp.element.pure已被移除。请改用wp.compose.pure。wp.element.compose已被移除。请改用wp.compose.compose。wp.element.createHigherOrderComponent已被移除。请改用wp.compose.createHigherOrderComponent。wp.utils.buildTermsTree已被移除。wp.utils.decodeEntities已被移除。请改用wp.htmlEntities.decodeEntities。- 所有对区块
uid的引用已替换为针对clientId的等效属性和选择器。 wp.editor.MediaPlaceholder组件的onSelectUrl属性已重命名为onSelectURL。wp.editor.UrlInput组件已重命名为wp.editor.URLInput。- 文本列区块已被移除。请改用列区块。
InnerBlocks的分组布局已被移除。请改用中间嵌套的内部区块。请参考列/栏目区块的实现。RichText显式的element格式已被移除。请改用兼容的children格式。
3.4.0
Popover组件中的focusOnMount属性已从仅接受Boolean值更改为枚举式属性,现接受"firstElement"、"container"或false。请将所有<Popover focusOnMount />用法转换为<Popover focusOnMount="firstElement" />。- 移除了
wp.utils.keycodes工具函数。请改用wp.keycodes。 - 移除了
edit函数中的块id属性。请改用块的clientId属性。 - 移除了
property源。请改用等效的text、html或attribute源,或注释属性。
3.3.0
- 已从 Block API 中移除
useOnce: true。请改用supports.multiple: false。 - 使用
componentWillMount生命周期方法序列化组件。请改用构造函数。 - 已移除
blocks.Autocomplete.completers过滤器。请改用editor.Autocomplete.completers。 - 已移除
blocks.BlockEdit过滤器。请改用editor.BlockEdit。 - 已移除
blocks.BlockListBlock过滤器。请改用editor.BlockListBlock。 - 已移除
blocks.MediaUpload过滤器。请改用editor.MediaUpload。
3.2.0
wp.data.withRehydratation已重命名为wp.data.withRehydration。wp.editor.ImagePlaceholder组件已移除。请改用wp.editor.MediaPlaceholder。wp.utils.deprecated函数已移除。请改用wp.deprecated。wp.utils.blob已移除。请改用wp.blob。getInserterItems:移除了allowedBlockTypes参数,并新增了parentUID参数。getFrecentInserterItems选择器已移除。请改用getInserterItems。getSupportedBlocks选择器已移除。请改用canInsertBlockType。
3.1.0
wp.blocks.*中的所有组件已被移除。请改用wp.editor.*。wp.blocks.withEditorSettings已被移除。请使用数据模块访问编辑器设置wp.data.select( "core/editor" ).getEditorSettings()。wp.utils.*中的所有 DOM 工具函数已被移除。请改用wp.dom.*。- Block API 中的
isPrivate: true已被移除。请改用supports.inserter: false。 wp.utils.isExtraSmall函数已被移除。请改用wp.viewport模块。getEditedPostExcerpt选择器(core/editor)已被移除。请改用getEditedPostAttribute( 'excerpt' )。
3.0.0
- 移除了
wp.blocks.registerCoreBlocks函数。请改用wp.coreBlocks.registerCoreBlocks。 RichText的原始 TinyMCE 事件处理器已被弃用。请改用文档化的属性、祖先事件处理器,或通过 onSetup 访问内部编辑器实例的事件中心。
2.8.0
wp.components.Autocomplete中的原始自动补全接口已更新。请改用最新的自动补全接口。更多信息请参阅自动补全。getInserterItems:allowedBlockTypes参数现为必填项。getFrecentInserterItems:allowedBlockTypes参数现为必填项。
2.7.0
- 移除了
wp.element.getWrapperDisplayName函数。请改用wp.element.createHigherOrderComponent。
2.6.0
- 移除了
wp.blocks.getBlockDefaultClassname函数。请改用wp.blocks.getBlockDefaultClassName。 - 移除了
wp.blocks.Editable组件。请改用wp.blocks.RichText组件。
2.5.0
- 不再支持从块
save函数返回原始 HTML。请改用wp.element.RawHTML组件。 - 移除了
wp.data.query高阶组件。请改用wp.data.withSelect。
2.4.0
- 移除了
wp.blocks.BlockDescription组件。请改用description区块属性。 - 移除了
wp.blocks.InspectorControls.*组件。请改用wp.components.*组件。 - 移除了
wp.blocks.source.*匹配器。请改用声明式属性。更多信息请参阅区块属性。 - 移除了
wp.data.select( 'selector', ...args )。请改用wp.data.select( reducerKey' ).*。 - 移除了
wp.blocks.MediaUploadButton组件。请改用wp.blocks.MediaUpload组件。