--- a/wp/wp-admin/includes/class-walker-nav-menu-edit.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/class-walker-nav-menu-edit.php Tue Dec 15 13:49:49 2020 +0100
@@ -22,11 +22,11 @@
*
* @since 3.0.0
*
- * @param string $output Passed by reference.
- * @param int $depth Depth of menu item. Used for padding.
- * @param array $args Not used.
+ * @param string $output Passed by reference.
+ * @param int $depth Depth of menu item. Used for padding.
+ * @param stdClass $args Not used.
*/
- public function start_lvl( &$output, $depth = 0, $args = array() ) {}
+ public function start_lvl( &$output, $depth = 0, $args = null ) {}
/**
* Ends the list of after the elements are added.
@@ -35,11 +35,11 @@
*
* @since 3.0.0
*
- * @param string $output Passed by reference.
- * @param int $depth Depth of menu item. Used for padding.
- * @param array $args Not used.
+ * @param string $output Passed by reference.
+ * @param int $depth Depth of menu item. Used for padding.
+ * @param stdClass $args Not used.
*/
- public function end_lvl( &$output, $depth = 0, $args = array() ) {}
+ public function end_lvl( &$output, $depth = 0, $args = null ) {}
/**
* Start the element output.
@@ -49,13 +49,13 @@
*
* @global int $_wp_nav_menu_max_depth
*
- * @param string $output Used to append additional content (passed by reference).
- * @param object $item Menu item data object.
- * @param int $depth Depth of menu item. Used for padding.
- * @param array $args Not used.
- * @param int $id Not used.
+ * @param string $output Used to append additional content (passed by reference).
+ * @param WP_Post $item Menu item data object.
+ * @param int $depth Depth of menu item. Used for padding.
+ * @param stdClass $args Not used.
+ * @param int $id Not used.
*/
- public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
+ public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
@@ -71,15 +71,18 @@
);
$original_title = false;
- if ( 'taxonomy' == $item->type ) {
- $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
- if ( is_wp_error( $original_title ) ) {
- $original_title = false;
+
+ if ( 'taxonomy' === $item->type ) {
+ $original_object = get_term( (int) $item->object_id, $item->object );
+ if ( $original_object && ! is_wp_error( $original_object ) ) {
+ $original_title = $original_object->name;
}
- } elseif ( 'post_type' == $item->type ) {
+ } elseif ( 'post_type' === $item->type ) {
$original_object = get_post( $item->object_id );
- $original_title = get_the_title( $original_object->ID );
- } elseif ( 'post_type_archive' == $item->type ) {
+ if ( $original_object ) {
+ $original_title = get_the_title( $original_object->ID );
+ }
+ } elseif ( 'post_type_archive' === $item->type ) {
$original_object = get_post_type_object( $item->object );
if ( $original_object ) {
$original_title = $original_object->labels->archives;
@@ -96,15 +99,15 @@
if ( ! empty( $item->_invalid ) ) {
$classes[] = 'menu-item-invalid';
- /* translators: %s: title of menu item which is invalid */
+ /* translators: %s: Title of an invalid menu item. */
$title = sprintf( __( '%s (Invalid)' ), $item->title );
- } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
+ } elseif ( isset( $item->post_status ) && 'draft' === $item->post_status ) {
$classes[] = 'pending';
- /* translators: %s: title of menu item in draft status */
+ /* translators: %s: Title of a menu item in draft status. */
$title = sprintf( __( '%s (Pending)' ), $item->title );
}
- $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
+ $title = ( ! isset( $item->label ) || '' === $item->label ) ? $title : $item->label;
$submenu_text = '';
if ( 0 == $depth ) {
@@ -119,9 +122,10 @@
<span class="item-controls">
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
<span class="item-order hide-if-js">
- <a href="
<?php
- echo wp_nonce_url(
+ printf(
+ '<a href="%s" class="item-move-up" aria-label="%s">↑</a>',
+ wp_nonce_url(
add_query_arg(
array(
'action' => 'move-up-menu-item',
@@ -130,13 +134,15 @@
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
- );
+ ),
+ esc_attr__( 'Move up' )
+ );
?>
- " class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ); ?>">↑</a>
|
- <a href="
<?php
- echo wp_nonce_url(
+ printf(
+ '<a href="%s" class="item-move-down" aria-label="%s">↓</a>',
+ wp_nonce_url(
add_query_arg(
array(
'action' => 'move-down-menu-item',
@@ -145,21 +151,37 @@
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
- );
+ ),
+ esc_attr__( 'Move down' )
+ );
?>
- " class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ); ?>">↓</a>
</span>
- <a class="item-edit" id="edit-<?php echo $item_id; ?>" href="
- <?php
- echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
- ?>
- " aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><span class="screen-reader-text"><?php _e( 'Edit' ); ?></span></a>
+ <?php
+ if ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) {
+ $edit_url = admin_url( 'nav-menus.php' );
+ } else {
+ $edit_url = add_query_arg(
+ array(
+ 'edit-menu-item' => $item_id,
+ ),
+ remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) )
+ );
+ }
+
+ printf(
+ '<a class="item-edit" id="edit-%s" href="%s" aria-label="%s"><span class="screen-reader-text">%s</span></a>',
+ $item_id,
+ $edit_url,
+ esc_attr__( 'Edit menu item' ),
+ __( 'Edit' )
+ );
+ ?>
</span>
</div>
</div>
<div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
- <?php if ( 'custom' == $item->type ) : ?>
+ <?php if ( 'custom' === $item->type ) : ?>
<p class="field-url description description-wide">
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
<?php _e( 'URL' ); ?><br />
@@ -205,6 +227,21 @@
</label>
</p>
+ <?php
+ /**
+ * Fires just before the move buttons of a nav menu item in the menu editor.
+ *
+ * @since 5.4.0
+ *
+ * @param int $item_id Menu item ID.
+ * @param WP_Post $item Menu item data object.
+ * @param int $depth Depth of menu item. Used for padding.
+ * @param stdClass $args An object of menu item arguments.
+ * @param int $id Nav menu ID.
+ */
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args, $id );
+ ?>
+
<fieldset class="field-move hide-if-no-js description description-wide">
<span class="field-move-visual-label" aria-hidden="true"><?php _e( 'Move' ); ?></span>
<button type="button" class="button-link menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></button>
@@ -215,40 +252,50 @@
</fieldset>
<div class="menu-item-actions description-wide submitbox">
- <?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
+ <?php if ( 'custom' !== $item->type && false !== $original_title ) : ?>
<p class="link-to-original">
<?php
- /* translators: %s: original title */
+ /* translators: %s: Link to menu item's original object. */
printf( __( 'Original: %s' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' );
?>
</p>
<?php endif; ?>
- <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="
- <?php
- echo wp_nonce_url(
- add_query_arg(
- array(
- 'action' => 'delete-menu-item',
- 'menu-item' => $item_id,
- ),
- admin_url( 'nav-menus.php' )
- ),
- 'delete-menu_item_' . $item_id
- );
- ?>
- "><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="
+
<?php
- echo esc_url(
- add_query_arg(
- array(
- 'edit-menu-item' => $item_id,
- 'cancel' => time(),
+ printf(
+ '<a class="item-delete submitdelete deletion" id="delete-%s" href="%s">%s</a>',
+ $item_id,
+ wp_nonce_url(
+ add_query_arg(
+ array(
+ 'action' => 'delete-menu-item',
+ 'menu-item' => $item_id,
+ ),
+ admin_url( 'nav-menus.php' )
),
- admin_url( 'nav-menus.php' )
- )
+ 'delete-menu_item_' . $item_id
+ ),
+ __( 'Remove' )
);
?>
- #menu-item-settings-<?php echo $item_id; ?>"><?php _e( 'Cancel' ); ?></a>
+ <span class="meta-sep hide-if-no-js"> | </span>
+ <?php
+ printf(
+ '<a class="item-cancel submitcancel hide-if-no-js" id="cancel-%s" href="%s#menu-item-settings-%s">%s</a>',
+ $item_id,
+ esc_url(
+ add_query_arg(
+ array(
+ 'edit-menu-item' => $item_id,
+ 'cancel' => time(),
+ ),
+ admin_url( 'nav-menus.php' )
+ )
+ ),
+ $item_id,
+ __( 'Cancel' )
+ );
+ ?>
</div>
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
@@ -263,4 +310,4 @@
$output .= ob_get_clean();
}
-} // Walker_Nav_Menu_Edit
+}