admin管理员组文章数量:1122832
I have a WordPress plugin containing a dynamic Gutenberg block which returns a div on the front-end:
register_block_type(
PLUGIN_DIR_PATH . 'dist/my-plugin/block.json',
array(
'render_callback' => array( $this, 'render_my_plugin_block' ),
)
PLUGIN_DIR_PATH . 'dist/my-plugin/block.json'
);
Old end result:
<div class="my-plugin-block"></div>
I am targeting this div with React and populating its contents. Now In a new version I am using InnerBlocks on the save function as opposed to returning null.
export default function Save() {
const blockProps = useBlockProps.save();
return (
<div {...blockProps}>
<InnerBlocks.Content />
</div>
);
}
Which produces the following new end result:
<div class="my-plugin-container">
<div class="my-plugin-section-1"></div>
<div class="my-plugin-section-2"></div>
<div class="my-plugin-section-3"></div>
</div>
I have written a deprecation which fixes this on the editor and once a user saves the post. But this only works until the user saves the post. Is there any way to change all those instances to the new HTML markup without relying on a manual save?
So make old become the new end result without relying on a manual save.
本文标签: deprecationWP dynamic blockchange content without saving
版权声明:本文标题:deprecation - WP dynamic block - change content without saving 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311590a1934794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论