mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Use placeholders in menu strings instead of manual concatenation. fixes #14045.
git-svn-id: http://core.svn.wordpress.org/trunk@23761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f0a60fb9c9
commit
9f26938da3
@ -428,40 +428,36 @@ var wpNavMenu;
|
||||
|
||||
// Where can they move this menu item?
|
||||
if ( 0 !== position ) {
|
||||
var thisLink = menuItem.find( '.menus-move-up' ),
|
||||
thisLinkText = thisLink.text();
|
||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
||||
var thisLink = menuItem.find( '.menus-move-up' );
|
||||
thisLink.prop( 'title', menus.moveUp ).show();
|
||||
}
|
||||
|
||||
if ( 0 !== position && isPrimaryMenuItem ) {
|
||||
var thisLink = menuItem.find( '.menus-move-top' ),
|
||||
thisLinkText = thisLink.text();
|
||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
||||
var thisLink = menuItem.find( '.menus-move-top' );
|
||||
thisLink.prop( 'title', menus.moveToTop ).show();
|
||||
}
|
||||
|
||||
if ( position + 1 !== totalMenuItems && 0 !== position ) {
|
||||
var thisLink = menuItem.find( '.menus-move-down' ),
|
||||
thisLinkText = thisLink.text();
|
||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
||||
var thisLink = menuItem.find( '.menus-move-down' );
|
||||
thisLink.prop( 'title', menus.moveDown ).show();
|
||||
}
|
||||
|
||||
if ( 0 === position && 0 !== hasSameDepthSibling ) {
|
||||
var thisLink = menuItem.find( '.menus-move-down' ),
|
||||
thisLinkText = thisLink.text();
|
||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
||||
var thisLink = menuItem.find( '.menus-move-down' );
|
||||
thisLink.prop( 'title', menus.moveDown ).show();
|
||||
}
|
||||
|
||||
if ( ! isPrimaryMenuItem ) {
|
||||
var thisLink = menuItem.find( '.menus-move-left' ),
|
||||
thisLinkText = menus.outFrom + ' ' + prevItemNameLeft;
|
||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).html(thisLinkText).show();
|
||||
thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft );
|
||||
thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).show();
|
||||
}
|
||||
|
||||
if ( 0 !== position ) {
|
||||
if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) {
|
||||
var thisLink = menuItem.find( '.menus-move-right' ),
|
||||
thisLinkText = menus.under + ' ' + prevItemNameRight;
|
||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).html(thisLinkText).show();
|
||||
thisLinkText = menus.under.replace( '%s', prevItemNameRight );
|
||||
thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,17 +467,16 @@ var wpNavMenu;
|
||||
totalMenuItems = primaryItems.length,
|
||||
|
||||
// String together help text for primary menu items
|
||||
title = itemName + '. ' + menus.menuFocus.replace('%d', itemPosition).replace('%d', totalMenuItems) + '.';
|
||||
title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems );
|
||||
} else {
|
||||
var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(),
|
||||
parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(),
|
||||
parentItemName = parentItem.find( '.menu-item-title' ).text(),
|
||||
subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ),
|
||||
itemPosition = $(subItems.parents('.menu-item').get().reverse()).index( menuItem ) + 1;
|
||||
itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1;
|
||||
|
||||
// String together help text for sub menu items
|
||||
|
||||
title = itemName + '. ' + menus.subMenuFocus.replace('%d', itemPosition) + parentItemName + '.';
|
||||
title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName );
|
||||
}
|
||||
|
||||
$this.prop('title', title).html( title );
|
||||
|
@ -355,12 +355,22 @@ $page_count = wp_count_posts( 'page' );
|
||||
$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
|
||||
|
||||
$l10n = array(
|
||||
"oneThemeLocationNoMenus" => $one_theme_location_no_menus,
|
||||
"move" => __( 'Move' ),
|
||||
"menuFocus" => __( 'Menu item %d of %d' ),
|
||||
"subMenuFocus" => __( 'Sub item number %d under' ),
|
||||
"under" => __( 'Under' ),
|
||||
"outFrom" => __( 'Out from under' )
|
||||
'oneThemeLocationNoMenus' => $one_theme_location_no_menus,
|
||||
'moveUp' => __( 'Move up one' ),
|
||||
'moveDown' => __( 'Move down one' ),
|
||||
'moveToTop' => __( 'Move to the top' ),
|
||||
/* translators: %s: previous item name */
|
||||
'moveUnder' => __( 'Move under %s' ),
|
||||
/* translators: %s: previous item name */
|
||||
'moveOutFrom' => __( 'Move out from under %s' ),
|
||||
/* translators: %s: previous item name */
|
||||
'under' => __( 'Under %s' ),
|
||||
/* translators: %s: previous item name */
|
||||
'outFrom' => __( 'Out from under %s' ),
|
||||
/* translators: 1: item name, 2: item position, 3: total number of items */
|
||||
'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ),
|
||||
/* translators: 1: item name, 2: item position, 3: parent item name */
|
||||
'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ),
|
||||
);
|
||||
wp_localize_script( 'nav-menu', 'menus', $l10n );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user