admin管理员组

文章数量:1122846

I wonder if there is the deprecated for blocks.getSaveElement hook?

First, I wrote the code like below.

const addWrapper = (el, type, attributes) => {
    if ('myblock/example' === type.name) {
        return <div className={"example"}>el<div>;
    } else {
        return el
    }
};
addFilter('blocks.getSaveElement', 'block/example', addWrapper);

Then, I want to change the wrapper element, but this hooks still affect to deprecated blocks. I read the document / but, I can not find the solution. Is there an any way to solve it?

I wonder if there is the deprecated for blocks.getSaveElement hook?

First, I wrote the code like below.

const addWrapper = (el, type, attributes) => {
    if ('myblock/example' === type.name) {
        return <div className={"example"}>el<div>;
    } else {
        return el
    }
};
addFilter('blocks.getSaveElement', 'block/example', addWrapper);

Then, I want to change the wrapper element, but this hooks still affect to deprecated blocks. I read the document https://developer.wordpress.org/block-editor/developers/block-api/block-deprecation/ but, I can not find the solution. Is there an any way to solve it?

Share Improve this question asked Jan 19, 2021 at 0:50 naogifynaogify 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I solve this problem by myself. The detail is here. https://github.com/WordPress/gutenberg/issues/28509

本文标签: Deprecated for blocksgetSaveElement