Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for WordPress 5.0 and Gutenberg - the new editor #58

Open
bobbingwide opened this issue Apr 26, 2018 · 5 comments
Open

Support for WordPress 5.0 and Gutenberg - the new editor #58

bobbingwide opened this issue Apr 26, 2018 · 5 comments
Assignees
Labels
enhancement Gutenberg WordPress 5.0 block editor

Comments

@bobbingwide
Copy link
Owner

The CPTs registered by oik-shortcodes are not compatible with Gutenberg since they are not REST API enabled. To allow the content to be edited using the block editor we need to add show_in_rest => true to the post type registration.

There are other issues:

  1. The _oik_sc_func field is currently a noderef that produces an enormous select list. We should change the field to make it a user entered string / ID See Rebuilding a component invalidates the oik_shortcodes function reference #52

  2. Since Gutenberg uses the REST API it expands the content during initial editing. This has been shown to produce problems for the oik_shortcodes CPT. See Support for WordPress 5.0 and the new editor - Gutenberg oik#97 (comment)

@bobbingwide bobbingwide added enhancement Gutenberg WordPress 5.0 block editor labels Apr 26, 2018
@bobbingwide bobbingwide self-assigned this Apr 26, 2018
bobbingwide added a commit that referenced this issue Apr 26, 2018
…t WordPress 5.0 and the new block editor
@bobbingwide bobbingwide changed the title Support for WordPress 5.0 and the new editor Support for WordPress 5.0 and Gutenberg - the new editor Nov 27, 2018
@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 27, 2018

With Gutenberg 4.5.1 in herbmiller.me oik-shortcodes appears to prevent dynamic blocks from being processed when the post is being displayed in a single display. The problem does not occur in q.w/hm.

I reconciled the plugin versions and determined that the problem appears to be related to Yoast SEO. When Yoast SEO is deactivated then oik-shortcodes can be reactivated.

The problem has been confirmed to exist with both v8.4 and v9.2.1.
I haven't checked versions earlier than v8.4 nor intermediate versions between v8.4 and v9.2.1.

I tracked the problem down to WordPress/gutenberg#8984 which was developed to fix WordPress/gutenberg#7268.

The workaround would appear to be to delete this line from oik-shortcodes.php

remove_filter( "get_the_excerpt", "wp_trim_excerpt" );

and to change the priority of what was the replacement filter ( from default ( 10 ) to 9 )

add_filter( "get_the_excerpt", "oik_get_the_excerpt", 9);

So it's not really WordPress SEO that's to blame. But if it weren't for WordPress SEO I wouldn't have developed my solution for oik-shortcodes, which subsequently led to the Gutenberg excerpt hack revealing its limitations.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 25, 2019

In oik-plugins.co.uk, after having updated oik-a2z and oik-shortcodes-a2z I found I was unable to edit any oik_shortcode post. Investigation indicated it wasn't a problem with these plugins.
It then appeared that the problem was that I was using WordPress 5.0.3 without Gutenberg.
When I activated Gutenberg (4.9) the problem disappeared.
I was unable to reproduce the problem locally.
The problem was a WSOD. The console log showed that jQuery was not loaded.
load-scripts.php load parameter contained jquery-form but not jquery-load.

I didn't get a screen capture of the log, but basically nothing worked.
It only happened for the oik_shortcode post type. Add new worked, edit didn't.

@bobbingwide
Copy link
Owner Author

I reproduced the problem on oik-plugins.com
image

Again, Gutenberg (4.8) was not activated at the time.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 26, 2019

I've also reproduced the problem locally, in s.b/oikcom.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 26, 2019

The problem is associated with the logic that attempts to generate the programmed example or snippets for a shortcode. This is being executed when the post is being passed through the 'the_content' filter when the post is first opened for editing.
quicktags is unexpectedly enqueued before jquery-core.
The problem is further obfuscated by the fact that the checkboxes may not appear ticked for some instances of the CPT but the logic is being invoked.

Proposed solution

Do not execute the logic when inside the block editor. We might be able to check $current_screen->is_block_editor() at an early stage and avoid doing a lot of unnecessary things. E.g. Disable processing in oiksc_the_content()

The fix also requires changes to be applied in the oik base plugin... where the [bw_code] shortcode already exists in the content. In dependencies_cache::capture_scripts the call to _wp_footer_scripts() causes the problem.

Remember, the problem does not occur when Gutenberg is activated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Gutenberg WordPress 5.0 block editor
Projects
None yet
Development

No branches or pull requests

1 participant