mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +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?
|
// Where can they move this menu item?
|
||||||
if ( 0 !== position ) {
|
if ( 0 !== position ) {
|
||||||
var thisLink = menuItem.find( '.menus-move-up' ),
|
var thisLink = menuItem.find( '.menus-move-up' );
|
||||||
thisLinkText = thisLink.text();
|
thisLink.prop( 'title', menus.moveUp ).show();
|
||||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 !== position && isPrimaryMenuItem ) {
|
if ( 0 !== position && isPrimaryMenuItem ) {
|
||||||
var thisLink = menuItem.find( '.menus-move-top' ),
|
var thisLink = menuItem.find( '.menus-move-top' );
|
||||||
thisLinkText = thisLink.text();
|
thisLink.prop( 'title', menus.moveToTop ).show();
|
||||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( position + 1 !== totalMenuItems && 0 !== position ) {
|
if ( position + 1 !== totalMenuItems && 0 !== position ) {
|
||||||
var thisLink = menuItem.find( '.menus-move-down' ),
|
var thisLink = menuItem.find( '.menus-move-down' );
|
||||||
thisLinkText = thisLink.text();
|
thisLink.prop( 'title', menus.moveDown ).show();
|
||||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 === position && 0 !== hasSameDepthSibling ) {
|
if ( 0 === position && 0 !== hasSameDepthSibling ) {
|
||||||
var thisLink = menuItem.find( '.menus-move-down' ),
|
var thisLink = menuItem.find( '.menus-move-down' );
|
||||||
thisLinkText = thisLink.text();
|
thisLink.prop( 'title', menus.moveDown ).show();
|
||||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isPrimaryMenuItem ) {
|
if ( ! isPrimaryMenuItem ) {
|
||||||
var thisLink = menuItem.find( '.menus-move-left' ),
|
var thisLink = menuItem.find( '.menus-move-left' ),
|
||||||
thisLinkText = menus.outFrom + ' ' + prevItemNameLeft;
|
thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft );
|
||||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).html(thisLinkText).show();
|
thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 !== position ) {
|
if ( 0 !== position ) {
|
||||||
if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) {
|
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' ),
|
var thisLink = menuItem.find( '.menus-move-right' ),
|
||||||
thisLinkText = menus.under + ' ' + prevItemNameRight;
|
thisLinkText = menus.under.replace( '%s', prevItemNameRight );
|
||||||
thisLink.prop('title', menus.move + ' ' + thisLinkText).html(thisLinkText).show();
|
thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +467,7 @@ var wpNavMenu;
|
|||||||
totalMenuItems = primaryItems.length,
|
totalMenuItems = primaryItems.length,
|
||||||
|
|
||||||
// String together help text for primary menu items
|
// 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 {
|
} else {
|
||||||
var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(),
|
var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(),
|
||||||
parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(),
|
parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(),
|
||||||
@ -480,8 +476,7 @@ var wpNavMenu;
|
|||||||
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
|
// String together help text for sub menu items
|
||||||
|
title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName );
|
||||||
title = itemName + '. ' + menus.subMenuFocus.replace('%d', itemPosition) + parentItemName + '.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.prop('title', title).html( title );
|
$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;
|
$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(
|
$l10n = array(
|
||||||
"oneThemeLocationNoMenus" => $one_theme_location_no_menus,
|
'oneThemeLocationNoMenus' => $one_theme_location_no_menus,
|
||||||
"move" => __( 'Move' ),
|
'moveUp' => __( 'Move up one' ),
|
||||||
"menuFocus" => __( 'Menu item %d of %d' ),
|
'moveDown' => __( 'Move down one' ),
|
||||||
"subMenuFocus" => __( 'Sub item number %d under' ),
|
'moveToTop' => __( 'Move to the top' ),
|
||||||
"under" => __( 'Under' ),
|
/* translators: %s: previous item name */
|
||||||
"outFrom" => __( 'Out from under' )
|
'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 );
|
wp_localize_script( 'nav-menu', 'menus', $l10n );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user