2

I'm creating a plugin similar to https://www.wpbeaverbuilder.com/ You can drag & drop elements to create layouts, etc.

What would be the best way to store post content in this case? Ideally it shouldn't be lost after disabling the plugin.

Current options are:

  • save to WP_POSTS table as shortcodes
  • create my own table, store there in JSON, and then populate WP_POSTS table with generated HTML

I don't like both, because shortcodes will make it hard to switch as you're bound to generated shortcodes (though you'll have a workaround there). HTML is fine until user needs to make edits.

2

The only reasonably portable option is to store content in post content.

Anything else (be it shortcodes, post meta, or options) will need a custom code to access and display it, either yours or some other if site parts way with your plugin.

The reasonable approach for data portability I've seen is storing a certain amount of generated HTML together with content (which would keep content available and visible by itself) and progressively enhancing it when "builder" code is active and running for full effect.

2
+25

content editing is about the content not about the styling. once you add styling like "hard" positioning and all the other things visual builders like to do, it is not a content anymore but rather a raw html.

You can insert the raw HTML as the post content and have html comments as annotation (just beware, comments can not be nested according to the html standard, no idea if it has any impact in real life) just like Gutenberg is about to do, but forward compatibility really depends on your builder not having to do any processing before content is displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.