Skip to content

Skip 'all_admin_notices' for Gutenberg pages? #6315

Closed

Description

@jsmoriss

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.

Activity

  1. jsmoriss commented on Apr 20, 2018

    @jsmoriss
    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 );
                                    }
                            }
    
  2. danielbachhuber commented on Jun 27, 2018

    @danielbachhuber
    Member

    Related #5975 #3964

  3. self-assigned this
    on Nov 7, 2018
  4. chrisvanpatten commented on Nov 8, 2018

    @chrisvanpatten
    Contributor

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

  5. aduth commented on Nov 8, 2018

    @aduth
    Member

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

  6. chrisvanpatten commented on Nov 8, 2018

    @chrisvanpatten
    Contributor

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

  7. aduth commented on May 28, 2019

    @aduth
    Member

    #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions