gutenbergdocs/contributors/code/deprecations.md
2025-10-22 01:33:45 +08:00

21 KiB
Raw Blame History

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.*
  • 区块 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 中的原始自动补全接口已更新,请改用最新自动补全接口。更多信息请参阅自动补全文档
  • getInserterItemsallowedBlockTypes 参数现为必填项
  • getFrecentInserterItemsallowedBlockTypes 参数现为必填项

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 组件
## 3.6.0

-   已移除 `wp.editor.editorMediaUpload`,请改用 `wp.editor.mediaUpload`
-   已移除 `wp.utils.getMimeTypesArray`
-   已移除 `wp.utils.mediaUpload`,请改用 `wp.editor.mediaUpload`
-   已移除 `wp.utils.preloadImage`
-   区块 API 中的 `supports.wideAlign` 已移除,请改用 `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` 属性已从仅布尔值改为枚举式属性,接受 `"firstElement"`、`"container"` 或 `false`。请将 `<Popover focusOnMount />` 用法转换为 `<Popover focusOnMount="firstElement" />`
-   已移除 `wp.utils.keycodes` 工具,请改用 `wp.keycodes`
-   已移除 `edit` 函数中的区块 `id` 属性,请改用区块 `clientId` 属性
-   已移除 `property` 源,请改用等效的 `text`、`html` 或 `attribute` 源,或注释属性

## 3.3.0

-   已从区块 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`
  • 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 已被移除。
  • 以下编辑器存储操作已被移除:createNoticeremoveNoticecreateSuccessNoticecreateInfoNoticecreateErrorNoticecreateWarningNotice。请使用 @wordpress/notices 模块中同名的等效操作。
  • wp.nux.DotTipid 属性已被移除。请改用 tipId 属性。
  • wp.blocks.isValidBlock 已被移除。请改用 wp.blocks.isValidBlockContent,但请注意参数顺序已更改。
  • wp.dataregistry.registerReducer 已被弃用。请改用 registry.registerStore
  • wp.dataregistry.registerSelectors 已被弃用。请改用 registry.registerStore
  • wp.dataregistry.registerActions 已被弃用。请改用 registry.registerStore
  • wp.dataregistry.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
  • 属性类型强制转换已移除,需省略源以通过序列化注释标记保留类型
  • wp.editor.mediaUploadonFileChange 回调所传对象中的 mediaDetails 已移除,请改用 media_details 属性
  • wp.components.CodeEditor 已移除,请直接使用 wp.codeEditor
  • wp.blocks.setUnknownTypeHandlerName 已移除,请改用 setFreeformContentHandlerNamesetUnregisteredTypeHandlerName
  • wp.blocks.getUnknownTypeHandlerName 已移除,请改用 getFreeformContentHandlerNamegetUnregisteredTypeHandlerName
  • 可重用块数据 API 标记为实验性功能,未来可能变更

4.1.0

  • wp.data.dispatch( 'core/editor' ).checkTemplateValidity 已移除,区块重置时会自动进行有效性验证

4.0.0

  • wp.editor.RichTextProvider 已移除,请改用 wp.data.select( 'core/editor' ) 方法
  • wp.components.Draggable 作为 DOM 节点拖拽处理器的功能已移除,请将 wp.components.Draggable 作为包装组件用于 DOM 节点拖拽处理器
  • wp.i18n.getI18n 已移除,请改用 ___x_n_nx
  • wp.i18n.dcnpgettext 已移除,请改用 ___x_n_nx

3.9.0

  • RichText 的 getSettings 属性已移除,如需继续使用请改用 unstableGetSettings 属性(强烈不建议使用不稳定 API此类 API 可能随时被移除)
  • RichText 的 onSetup 属性已移除,如需继续使用请改用 unstableOnSetup 属性(强烈不建议使用不稳定 API此类 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.withContext 已移除,请改用 wp.element.createContext,参见:https://react.dev/reference/react/createContext
  • wp.coreBlocks.registerCoreBlocks 已移除,请改用 wp.blockLibrary.registerCoreBlocks
  • wp.editor.DocumentTitle 组件已移除
  • getDocumentTitle 选择器(core/editor)已移除

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.restrictPersistencewp.data.setPersistenceStoragewp.data.setupPersistence 已移除,请改用数据持久化插件

已弃用功能

对于Gutenberg插件中包含的功能弃用政策旨在尽可能支持两个次要插件版本的向后兼容性。WordPress稳定版本中包含的功能和代码不在此弃用时间线内而是遵循WordPress项目的版本管理政策。当前已弃用的功能如下所示,并按将完全移除这些功能的版本进行分组。如果您的插件依赖这些行为,则必须在指定版本之前更新至推荐的替代方案。

未发布版本

  • wp.blocks.isValidBlockContent 已被移除。请改用 wp.blocks.validateBlock

11.0.0

  • wp.blocks.registerBlockTypeFromMetadata 方法已被移除。请改用 wp.blocks.registerBlockType 方法。

10.3.0

  • 不再支持向 ActionItem.Slot 组件传递带有 as 属性的组件元组。请改为传递带有 as 属性的组件。示例:
    <ActionItem.Slot
    	名称="my/slot"
    	标签={ __( '我的插槽' ) }
    - 	组件={ [ MenuGroup, MenuItem ] }
    + 	组件={ MenuGroup }
    />
    

9.7.0

  • InterfaceSkeleton 组件中的 leftSidebar 属性已被移除。请改用 secondarySidebar 属性。

8.6.0

  • 更新了与区块上下文的区块API集成。注册区块时请在JavaScript文件中使用 usesContextprovidesContext在PHP文件中使用 uses_contextprovides_context 对,而不是之前的 contextprovidesContext 对。

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 已被移除。