WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/01/2015 10:05:17 PM (7 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/users.php

    r31941 r31973  
    395395                $message = _n( '%s user deleted.', '%s users deleted.', $delete_count );
    396396            }
    397             $messages[] = '<div id="message" class="updated"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>';
     397            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>';
    398398            break;
    399399        case 'add':
    400400            if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) {
    401                 $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ),
     401                $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ),
    402402                    esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
    403403                        self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>';
    404404            } else {
    405                 $messages[] = '<div id="message" class="updated"><p>' . __( 'New user created.' ) . '</p></div>';
     405                $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>';
    406406            }
    407407            break;
    408408        case 'promote':
    409             $messages[] = '<div id="message" class="updated"><p>' . __('Changed roles.') . '</p></div>';
     409            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>';
    410410            break;
    411411        case 'err_admin_role':
    412             $messages[] = '<div id="message" class="error"><p>' . __('The current user&#8217;s role must have user editing capabilities.') . '</p></div>';
    413             $messages[] = '<div id="message" class="updated"><p>' . __('Other user roles have been changed.') . '</p></div>';
     412            $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user&#8217;s role must have user editing capabilities.') . '</p></div>';
     413            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>';
    414414            break;
    415415        case 'err_admin_del':
    416             $messages[] = '<div id="message" class="error"><p>' . __('You can&#8217;t delete the current user.') . '</p></div>';
    417             $messages[] = '<div id="message" class="updated"><p>' . __('Other users have been deleted.') . '</p></div>';
     416            $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can&#8217;t delete the current user.') . '</p></div>';
     417            $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>';
    418418            break;
    419419        case 'remove':
    420             $messages[] = '<div id="message" class="updated fade"><p>' . __('User removed from this site.') . '</p></div>';
     420            $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>';
    421421            break;
    422422        case 'err_admin_remove':
    423             $messages[] = '<div id="message" class="error"><p>' . __("You can't remove the current user.") . '</p></div>';
    424             $messages[] = '<div id="message" class="updated fade"><p>' . __('Other users have been removed.') . '</p></div>';
     423            $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>';
     424            $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>';
    425425            break;
    426426        }
Note: See TracChangeset for help on using the changeset viewer.