Skip to content

Commit

Permalink
Administration: Use admin notice functions in nav menu admin.
Browse files Browse the repository at this point in the history
Use `wp_get_admin_notice` and `wp_admin_notice` to handle settings notices on the nav menu admin screens.

Props joedolson.
See #57791.

git-svn-id: https://develop.svn.wordpress.org/trunk@56518 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joedolson committed Sep 5, 2023
1 parent 305de43 commit 3384a80
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/wp-admin/includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -1291,15 +1291,21 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
}

if ( $some_pending_menu_items ) {
$result .= '<div class="notice notice-info notice-alt inline"><p>'
. __( 'Click Save Menu to make pending menu items public.' )
. '</p></div>';
$message = __( 'Click Save Menu to make pending menu items public.' );
$notice_args = array(
'type' => 'info',
'additional_classes' => array( 'notice-alt', 'inline' ),
);
$result .= wp_get_admin_notice( $message, $notice_args );
}

if ( $some_invalid_menu_items ) {
$result .= '<div class="notice notice-error notice-alt inline"><p>'
. __( 'There are some invalid menu items. Please check or delete them.' )
. '</p></div>';
$message = __( 'There are some invalid menu items. Please check or delete them.' );
$notice_args = array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline' ),
);
$result .= wp_get_admin_notice( $message, $notice_args );
}

$result .= '<ul class="menu" id="menu-to-edit"> ';
Expand Down Expand Up @@ -1480,12 +1486,15 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
/** This action is documented in wp-includes/nav-menu.php */
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );

$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
sprintf(
/* translators: %s: Nav menu title. */
__( '%s has been updated.' ),
'<strong>' . $nav_menu_selected_title . '</strong>'
) . '</p></div>';
/* translators: %s: Nav menu title. */
$message = sprintf( __( '%s has been updated.' ), '<strong>' . $nav_menu_selected_title . '</strong>' );
$notice_args = array(
'id' => 'message',
'dismissible' => true,
'additional_classes' => array( 'updated' ),
);

$messages[] = wp_get_admin_notice( $message, $notice_args );

unset( $menu_items, $unsorted_menu_items );

Expand Down

0 comments on commit 3384a80

Please sign in to comment.