WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/01/2015 10:05:17 PM (6 years ago)
Author:
helen
Message:

Admin notices: Make (most) core notices dismissible.

These no longer return upon refreshing the page when JS is on and working, so users should be able to dismiss them. This is particularly important on the post edit screen when DFW is triggered, but pretty much all notices can be dismissed if needed. A post on Make/Core will follow with information on how this can be leveraged in plugins.

props valendesigns, afercia, paulwilde, adamsilverstein, helen.
fixes #31233. see #23367.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/nav-menus.php

    r31951 r31973  
    232232
    233233        if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) )
    234             $messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
     234            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
    235235        break;
    236236
     
    249249
    250250        if ( is_wp_error( $deletion ) )
    251             $messages[] = '<div id="message" class="error"><p>' . $deletion->get_error_message() . '</p></div>';
     251            $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>';
    252252        else
    253             $messages[] = '<div id="message" class="updated"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>';
     253            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>';
    254254        break;
    255255
     
    262262            $deletion = wp_delete_nav_menu( $menu_id_to_delete );
    263263            if ( is_wp_error( $deletion ) ) {
    264                 $messages[] = '<div id="message" class="error"><p>' . $deletion->get_error_message() . '</p></div>';
     264                $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>';
    265265                $deletion_error = true;
    266266            }
     
    268268
    269269        if ( empty( $deletion_error ) )
    270             $messages[] = '<div id="message" class="updated"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>';
     270            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>';
    271271        break;
    272272
     
    297297
    298298                if ( is_wp_error( $_nav_menu_selected_id ) ) {
    299                     $messages[] = '<div id="message" class="error"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
     299                    $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
    300300                } else {
    301301                    $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
     
    328328                }
    329329            } else {
    330                 $messages[] = '<div id="message" class="error"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
     330                $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
    331331            }
    332332
     
    338338            $menu_title = trim( esc_html( $_POST['menu-name'] ) );
    339339            if ( ! $menu_title ) {
    340                 $messages[] = '<div id="message" class="error"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
     340                $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>';
    341341                $menu_title = $_menu_object->name;
    342342            }
     
    346346                if ( is_wp_error( $_nav_menu_selected_id ) ) {
    347347                    $_menu_object = $_nav_menu_selected_id;
    348                     $messages[] = '<div id="message" class="error"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
     348                    $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
    349349                } else {
    350350                    $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
     
    375375            set_theme_mod( 'nav_menu_locations', $menu_locations );
    376376
    377             $messages[] = '<div id="message" class="updated"><p>' . __( 'Menu locations updated.' ) . '</p></div>';
     377            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>';
    378378        }
    379379        break;
Note: See TracChangeset for help on using the changeset viewer.