maratbn / LoginRequirePress

WordPress plugin that allows site administrators to specifically designate arbitrary posts with any public post type as viewable only after user login.
Other
0 stars 0 forks source link

Metabox compatibility error #6

Open carolynzinn opened 4 years ago

carolynzinn commented 4 years ago

It would be great if this worked with the block editor. We are getting an incompatibility error: "This meta box, from the Login Require Press plugin, isn't compatible with the block editor."

maratbn commented 4 years ago

Hello @carolynzinn,

I enabled the error message you are seeing on purpose in the release 1.4, to prevent users from using the Login Require Press meta box with the new WordPress Block Editor.

The commit for this is: https://github.com/maratbn/LoginRequirePress/commit/48e44b3bc9363b4b0b85e62b858e4635b8cc8931

The reason for this change is that the meta box is not compatible with the new Block Editor, so had it been rendered in there, it would not have worked properly.

The meta box still works fine in the WordPress Classic Editor, which can still be enabled on any WordPress site with the Classic Editor Plugin (https://wordpress.org/plugins/classic-editor/) as should be indicated by the notice under the error message that says "Please install the Classic Editor plugin to use this meta box."

When you install this other plugin, it adds the setting "Allow users to switch editors" to the Writing Settings page, allowing you to quickly switch between the new Block Editor and the Classic Editor when editing pages. So for now this problem can be mitigated by switching to the Classic Editor whenever the Login Require Press meta box is needed.

As far as making the meta box compatible with the new Block Editor, I will not have time to get to that any time soon, as I'm currently busy on much higher priority projects. So I recommend that for now you mitigate this problem with the Classic Editor plugin. Of course pull requests are always welcome for thorough code review!

To give you more background on why the meta box is not compatible with the new Block Editor, it is because the Block Editor is based on a completely different UI paradigm from the old Classic Editor. The Classic Editor is based on the classic web UI paradigm, where submitting the user input entries reloads the whole page with the updated data, whereas the Block Editor is based on the more modern single-page-web-app paradigm, in that submitting the user input entries updates server with the data of these entries, but keeps the previously-loaded page that auto-updates with the new updated data.

What this means is that while the classic WordPress meta boxes were rendered, and had their data processed server-side, the new Block Editor meta boxes are completely different beasts that have to be rendered and have their data processed client-side. Therefore, making the meta box work in the new Block Editor will require an entirely new implementation.

This is true for the meta boxes in all WordPress plugins, not only Login Require Press. The WordPress people changed their system completely, but deceptively kept the old name. They also made it so that by default all existing meta boxes would still appear in the new Block Editor, regardless of whether they can properly work there or not.

Making an entirely new implementation will also involve migrating the plugin to the new build system for client-side UI logic currently favored by WordPress to support this new UI paradigm.

Pull requests welcome!!!