Skip to content

Commit 35df559

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31973 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e5d660e commit 35df559

35 files changed

Lines changed: 156 additions & 82 deletions

src/wp-admin/css/common.css

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ img.emoji {
738738
/* @todo can we combine these into a class or use an existing dashicon one? */
739739
#welcome-panel.welcome-panel .welcome-panel-close:before,
740740
.tagchecklist span a:before,
741-
#bulk-titles div a:before {
741+
#bulk-titles div a:before,
742+
.notice-dismiss:before {
742743
background: none;
743744
color: #bbb;
744745
content: '\f153';
@@ -1288,22 +1289,59 @@ div.error p,
12881289
padding: 2px;
12891290
}
12901291

1292+
.notice.is-dismissible {
1293+
padding-right: 38px;
1294+
position: relative;
1295+
}
1296+
1297+
.notice-dismiss {
1298+
height: 38px;
1299+
width: 38px;
1300+
position: absolute;
1301+
top: 0;
1302+
right: 0;
1303+
border: none;
1304+
margin: 0;
1305+
padding: 11px;
1306+
background: none;
1307+
color: #bbb;
1308+
cursor: pointer;
1309+
}
1310+
1311+
.notice-dismiss:hover:before,
1312+
.notice-dismiss:active:before,
1313+
.notice-dismiss:focus:before {
1314+
color: #c00;
1315+
}
1316+
1317+
.notice-dismiss:active,
1318+
.notice-dismiss:focus {
1319+
outline: none;
1320+
-webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
1321+
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
1322+
color: #c00;
1323+
}
1324+
1325+
.ie8 .notice-dismiss:focus {
1326+
outline: 1px solid #5b9dd9;
1327+
}
1328+
12911329
.notice-success,
12921330
div.updated {
1293-
border-color: #7ad03a;
1331+
border-color: #7ad03a;
12941332
}
12951333

12961334
.notice-warning {
1297-
border-color: #ffba00;
1335+
border-color: #ffba00;
12981336
}
12991337

13001338
.notice-error,
13011339
div.error {
1302-
border-color: #dd3d36;
1340+
border-color: #dd3d36;
13031341
}
13041342

13051343
.notice-info {
1306-
border-color: #00a0d2;
1344+
border-color: #00a0d2;
13071345
}
13081346

13091347
.wrap .notice,
@@ -3122,13 +3160,26 @@ img {
31223160
}
31233161

31243162
/* Feedback Messages */
3125-
.wrap div.updated, .wrap div.error, .media-upload-form div.error {
3163+
.notice,
3164+
.wrap div.updated,
3165+
.wrap div.error,
3166+
.media-upload-form div.error {
31263167
margin: 20px 0 10px 0;
31273168
padding: 5px 10px;
31283169
font-size: 14px;
31293170
line-height: 175%;
31303171
}
31313172

3173+
.notice.is-dismissible {
3174+
padding-right: 46px;
3175+
}
3176+
3177+
.notice-dismiss {
3178+
height: 46px;
3179+
width: 46px;
3180+
padding: 16px;
3181+
}
3182+
31323183
.wrap .icon32 + h2 {
31333184
margin-top: -2px;
31343185
}

src/wp-admin/edit-comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
}
218218
}
219219

220-
echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
220+
echo '<div id="moderated" class="updated notice is-dismissible"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
221221
}
222222
}
223223
?>

src/wp-admin/edit-form-advanced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
<div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice ?></p></div>
411411
<?php endif; ?>
412412
<?php if ( $message ) : ?>
413-
<div id="message" class="updated"><p><?php echo $message; ?></p></div>
413+
<div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
414414
<?php endif; ?>
415415
<div id="lost-connection-notice" class="error hidden">
416416
<p><span class="spinner"></span> <?php _e( '<strong>Connection lost.</strong> Saving has been disabled until you&#8217;re reconnected.' ); ?>

src/wp-admin/edit-link-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a></h2>
7474

7575
<?php if ( isset( $_GET['added'] ) ) : ?>
76-
<div id="message" class="updated"><p><?php _e('Link added.'); ?></p></div>
76+
<div id="message" class="updated notice is-dismissible"><p><?php _e('Link added.'); ?></p></div>
7777
<?php endif; ?>
7878

7979
<form name="<?php echo esc_attr( $form_name ); ?>" id="<?php echo esc_attr( $form_name ); ?>" method="post" action="link.php">

src/wp-admin/edit-tag-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
die('-1');
1212

1313
if ( empty($tag_ID) ) { ?>
14-
<div id="message" class="updated"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
14+
<div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
1515
<?php
1616
return;
1717
}

src/wp-admin/edit-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307
</h2>
308308

309309
<?php if ( $message ) : ?>
310-
<div id="message" class="<?php echo $class; ?>"><p><?php echo $message; ?></p></div>
310+
<div id="message" class="<?php echo $class; ?> notice is-dismissible"><p><?php echo $message; ?></p></div>
311311
<?php $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
312312
endif; ?>
313313
<div id="ajax-response"></div>

src/wp-admin/edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
}
304304

305305
if ( $messages )
306-
echo '<div id="message" class="updated"><p>' . join( ' ', $messages ) . '</p></div>';
306+
echo '<div id="message" class="updated notice is-dismissible"><p>' . join( ' ', $messages ) . '</p></div>';
307307
unset( $messages );
308308

309309
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );

src/wp-admin/includes/misc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,11 @@ function post_form_autocomplete_off() {
854854
function wp_admin_canonical_url() {
855855
$removable_query_args = array(
856856
'message', 'settings-updated', 'saved',
857-
'update', 'updated','activated',
857+
'update', 'updated', 'activated',
858858
'activate', 'deactivate', 'locked',
859859
'deleted', 'trashed', 'untrashed',
860860
'enabled', 'disabled', 'skipped',
861+
'spammed', 'unspammed',
861862
);
862863

863864
/**

src/wp-admin/includes/nav-menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
13171317
/** This action is documented in wp-includes/nav-menu.php */
13181318
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
13191319

1320-
$messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>';
1320+
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>';
13211321
unset( $menu_items, $unsorted_menu_items );
13221322

13231323
return $messages;

src/wp-admin/includes/template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
14831483
$output = '';
14841484
foreach ( $settings_errors as $key => $details ) {
14851485
$css_id = 'setting-error-' . $details['code'];
1486-
$css_class = $details['type'] . ' settings-error';
1486+
$css_class = $details['type'] . ' settings-error notice is-dismissible';
14871487
$output .= "<div id='$css_id' class='$css_class'> \n";
14881488
$output .= "<p><strong>{$details['message']}</strong></p>";
14891489
$output .= "</div> \n";

0 commit comments

Comments
 (0)