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

Skip 'all_admin_notices' for Gutenberg pages? #6315

Closed
jsmoriss opened this issue Apr 20, 2018 · 6 comments
Closed

Skip 'all_admin_notices' for Gutenberg pages? #6315

jsmoriss opened this issue Apr 20, 2018 · 6 comments
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Developer Documentation Documentation for developers

Comments

@jsmoriss
Copy link

When loading a Gutenberg editing page, the 'all_admin_notices' action is executed.

When saving a Gutenberg post, the 'all_admin_notices' action is executed (with or without metaboxes?).

PHP plugins may create notices, and after these notices are displayed in the 'all_admin_notices' hook, those notices are usually deleted (so they're not displayed again, and again, etc.).

Since Gutenberg hides the 'all_admin_notices' HTML, a jQuery ajax call must be made to fetch notices and display them using Gutenberg functions - unfortunately, since the 'all_admin_notices' action has already been executed (either on page load or when saving a post), those notices may no longer exist and cannot be displayed.

Is it possible to either:

  • Have Gutenberg unregister all hooks from 'all_admin_notices'.

  • Or have somekind of constant, function, etc. available for 'all_admin_notices' action hooks so they can check if this is a Gutenberg page and skip the display + deletion of notices?

Thanks,

js.

@jsmoriss
Copy link
Author

FYI - for now I'm using this:

                        if ( function_exists( 'gutenberg_can_edit_post_type' ) &&
                                gutenberg_can_edit_post_type( $post_obj->post_type ) &&
                                        ! isset( $_REQUEST['classic-editor'] ) ) {

                                if ( ! defined( 'DOING_GUTENBERG' ) ) {
                                        define( 'DOING_GUTENBERG', true );
                                }
                        }

@danielbachhuber danielbachhuber added [Type] Developer Documentation Documentation for developers Backwards Compatibility Issues or PRs that impact backwards compatability labels Jun 27, 2018
@danielbachhuber
Copy link
Member

Related #5975 #3964

@danielbachhuber danielbachhuber added the [Feature] Extensibility The ability to extend blocks or the editing experience label Jun 27, 2018
@gziolo gziolo removed the [Feature] Extensibility The ability to extend blocks or the editing experience label Jul 10, 2018
@danielbachhuber danielbachhuber added the [Feature] Extensibility The ability to extend blocks or the editing experience label Aug 22, 2018
@aduth aduth self-assigned this Nov 7, 2018
@chrisvanpatten
Copy link
Member

Might not need documentation for this if the underlying implementation problem is addressed, but we'll wait and see…

@aduth
Copy link
Member

aduth commented Nov 8, 2018

Related: #11604 will attempt to detect and transparently upgrade all notices output from the server, including from all_admin_notices.

@chrisvanpatten
Copy link
Member

@aduth Thanks sir! We'll close this out when that gets merged; sounds like we won't need back-compat documentation here.

@youknowriad youknowriad removed this from the Documentation & Handbook milestone Mar 18, 2019
@aduth
Copy link
Member

aduth commented May 28, 2019

#11604 was merged, but later (effectively) reverted in #12444. As notices made compatible turned to not be reconcilable with Gutenberg design, they are no longer planned to be inherited. See also Notices data actions for client-side notices documentation.

Or have somekind of constant, function, etc. available for 'all_admin_notices' action hooks so they can check if this is a Gutenberg page and skip the display + deletion of notices?

It should be expected that WP_Screen::is_block_editor can be used for this purpose.

@aduth aduth closed this as completed May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

No branches or pull requests

7 participants