Skip to content

Commit

Permalink
update to WordPress 4.4 Walker.
Browse files Browse the repository at this point in the history
  • Loading branch information
helgatheviking committed Dec 7, 2015
1 parent 1f693e4 commit c8f378a
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions inc/class.Walker_Nav_Menu_Edit_Roles.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

/**
* Navigation Menu API: (Modifed) Walker_Nav_Menu_Edit class
*
* Create HTML list of nav menu input items.
* Copied from Walker_Nav_Menu_Edit class in core /wp-admin/includes/nav-menu.php
*
* @package nav-menu-roles
* @since 1.0
* @since WordPress 4.4.0
* @uses Walker_Nav_Menu
*/

Expand All @@ -21,7 +24,7 @@ class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu {
* @param int $depth Depth of menu item. Used for padding.
* @param array $args Not used.
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {}
public function start_lvl( &$output, $depth = 0, $args = array() ) {}

/**
* Ends the list of after the elements are added.
Expand All @@ -34,21 +37,23 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {}
* @param int $depth Depth of menu item. Used for padding.
* @param array $args Not used.
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {}
public function end_lvl( &$output, $depth = 0, $args = array() ) {}

/**
* Start the element output.
*
* @see Walker_Nav_Menu::start_el()
* @since 3.0.0
*
* @global int $_wp_nav_menu_max_depth
*
* @param string $output Passed by reference. Used to append additional content.
* @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.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $item, $depth = 0, $args = array(), $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;

Expand All @@ -71,6 +76,9 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
} 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 ) {
$original_object = get_post_type_object( $item->object );
$original_title = $original_object->labels->archives;
}

$classes = array(
Expand Down Expand Up @@ -99,8 +107,8 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {

?>
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
<dl class="menu-item-bar">
<dt class="menu-item-handle">
<div class="menu-item-bar">
<div class="menu-item-handle">
<span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' , 'nav-menu-roles' ); ?></span></span>
<span class="item-controls">
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
Expand Down Expand Up @@ -135,25 +143,25 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
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 ) ) );
?>"><?php _e( 'Edit Menu Item' , 'nav-menu-roles' ); ?></a>
</span>
</dt>
</dl>
</div>
</div>

<div class="menu-item-settings" 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' , 'nav-menu-roles' ); ?><br />
<input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
</label>
</p>
<?php endif; ?>
<p class="description description-thin">
<p class="description description-wide">
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
<?php _e( 'Navigation Label' , 'nav-menu-roles' ); ?><br />
<input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
</label>
</p>
<p class="description description-thin">
<p class="field-title-attribute description description-wide">
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
<?php _e( 'Title Attribute' , 'nav-menu-roles' ); ?><br />
<input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
Expand All @@ -162,7 +170,7 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
<p class="field-link-target description">
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
<input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> />
<?php _e( 'Open link in a new window/tab' , 'nav-menu-roles' ); ?>
<?php _e( 'Open link in a new tab' , 'nav-menu-roles' ); ?>
</label>
</p>
<p class="field-css-classes description description-thin">
Expand Down Expand Up @@ -194,16 +202,16 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
<p class="field-move hide-if-no-js description description-wide">
<label>
<span><?php _e( 'Move' , 'nav-menu-roles' ); ?></span>
<a href="#" class="menus-move-up"><?php _e( 'Up one' , 'nav-menu-roles' ); ?></a>
<a href="#" class="menus-move-down"><?php _e( 'Down one' , 'nav-menu-roles' ); ?></a>
<a href="#" class="menus-move-left"></a>
<a href="#" class="menus-move-right"></a>
<a href="#" class="menus-move-top"><?php _e( 'To the top' , 'nav-menu-roles' ); ?></a>
<a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' , 'nav-menu-roles' ); ?></a>
<a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' , 'nav-menu-roles' ); ?></a>
<a href="#" class="menus-move menus-move-left" data-dir="left"></a>
<a href="#" class="menus-move menus-move-right" data-dir="right"></a>
<a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' , 'nav-menu-roles' ); ?></a>
</label>
</p>

<div class="menu-item-actions description-wide submitbox">
<?php if( 'custom' != $item->type && $original_title !== false ) : ?>
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
<p class="link-to-original">
<?php printf( __('Original: %s', 'nav-menu-roles' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
</p>
Expand Down Expand Up @@ -234,4 +242,4 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$output .= ob_get_clean();
}

} // Walker_Nav_Menu_Edit
} // Walker_Nav_Menu_Edit

0 comments on commit c8f378a

Please sign in to comment.