forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigation: Add the draft status to the navigation title (WordPress#5…
…1967) * Navigation: Add the draft status to the navigation title * Move the buildNavigationLabel function to the default export
- Loading branch information
1 parent
84e74bd
commit d3a68c3
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...-site/src/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
|
||
// Copied from packages/block-library/src/navigation/edit/navigation-menu-selector.js. | ||
export default function buildNavigationLabel( title, id, status ) { | ||
if ( ! title?.rendered ) { | ||
/* translators: %s is the index of the menu in the list of menus. */ | ||
return sprintf( __( '(no title %s)' ), id ); | ||
} | ||
|
||
if ( status === 'publish' ) { | ||
return decodeEntities( title?.rendered ); | ||
} | ||
|
||
return sprintf( | ||
// translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.). | ||
__( '%1$s (%2$s)' ), | ||
decodeEntities( title?.rendered ), | ||
status | ||
); | ||
} |