User Menus – Nav Menu Visibility - Version 1.1.2

Version Description

Download this release

Release Info

Developer danieliser
Plugin Icon 128x128 User Menus – Nav Menu Visibility
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

includes/classes/admin/menu-editor.php CHANGED
@@ -17,7 +17,7 @@ class Menu_Editor {
17
  * Init
18
  */
19
  public static function init() {
20
- add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, 'nav_menu_walker' ) );
21
  add_action( 'admin_head-nav-menus.php', array( __CLASS__, 'register_metaboxes' ) );
22
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
23
  }
@@ -28,15 +28,23 @@ class Menu_Editor {
28
  public static function nav_menu_walker( $walker ) {
29
  global $wp_version;
30
 
31
- if ( version_compare( $wp_version, '4.5.0', '>=' ) ) {
32
- require_once \JP_User_Menus::$DIR . 'includes/classes/walker/nav-menu-edit.php';
 
33
 
34
- return '\JP\UM\Walker\Nav_Menu_Edit';
35
- } else {
36
- require_once \JP_User_Menus::$DIR . 'includes/classes/walker/nav-menu-edit-deprecated.php';
37
 
38
- return '\JP\UM\Walker\Nav_Menu_Edit_Deprecated';
 
 
 
 
 
39
  }
 
 
40
  }
41
 
42
 
17
  * Init
18
  */
19
  public static function init() {
20
+ add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, 'nav_menu_walker' ), 999999999 );
21
  add_action( 'admin_head-nav-menus.php', array( __CLASS__, 'register_metaboxes' ) );
22
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
23
  }
28
  public static function nav_menu_walker( $walker ) {
29
  global $wp_version;
30
 
31
+ if ( doing_filter( 'plugins_loaded' ) ) {
32
+ return $walker;
33
+ }
34
 
35
+ if ( $walker == 'Walker_Nav_Menu_Edit_Custom_Fields' ) {
36
+ return $walker;
37
+ }
38
 
39
+ if ( ! class_exists( 'Walker_Nav_Menu_Edit_Custom_Fields' ) ) {
40
+ if ( version_compare( $wp_version, '3.6', '>=' ) ) {
41
+ require_once \JP_User_Menus::$DIR . 'includes/classes/walker/nav-menu-edit-custom-fields.php';
42
+ } else {
43
+ require_once \JP_User_Menus::$DIR . 'includes/classes/walker/nav-menu-edit-custom-fields-deprecated.php';
44
+ }
45
  }
46
+
47
+ return 'Walker_Nav_Menu_Edit_Custom_Fields';
48
  }
49
 
50
 
includes/classes/admin/reviews.php CHANGED
@@ -476,4 +476,3 @@ class Reviews {
476
  }
477
 
478
  Reviews::init();
479
-
476
  }
477
 
478
  Reviews::init();
 
includes/classes/walker/nav-menu-edit-custom-fields-deprecated.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists( 'Walker_Nav_Menu_Edit' ) ) {
4
+ /** Walker_Nav_Menu_Edit class */
5
+ require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
6
+ }
7
+
8
+ /**
9
+ * Custom Walker for Nav Menu Editor
10
+ *
11
+ * Add wp_nav_menu_item_custom_fields hook to the nav menu editor.
12
+ *
13
+ * Credits:
14
+ * @helgatheviking - Initial concept which has made adding settings in the menu editor in a compatible way.
15
+ * @kucrut - preg_replace() method so that we no longer have to translate core strings
16
+ * @danieliser - refactor for less complexity between WP versions & updating versioned classes for proper backward compatibility with the new methods.
17
+ *
18
+ * @since WordPress 3.0.0
19
+ * @uses Walker_Nav_Menu_Edit
20
+ */
21
+ class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
22
+
23
+ /**
24
+ * Start the element output.
25
+ *
26
+ * @see Walker_Nav_Menu_Edit::start_el()
27
+ *
28
+ * @param string $output Passed by reference. Used to append additional content.
29
+ * @param object $item Menu item data object.
30
+ * @param int $depth Depth of menu item.
31
+ * @param array $args
32
+ */
33
+ public function start_el( &$output, $item, $depth = 0, $args = array() ) {
34
+ parent::start_el( $output, $item, $depth, $args );
35
+
36
+ $output = preg_replace( '(<p[^>]+class="[^"]*field-description(.|\n)*?<\/p>)', "$1 \n" . $this->get_custom_fields( $item, $depth, $args ), $output, 1 );
37
+ }
38
+
39
+ /**
40
+ * Get custom fields
41
+ *
42
+ * @uses do_action() Calls 'menu_item_custom_fields' hook
43
+ *
44
+ * @param object $item Menu item data object.
45
+ * @param int $depth Depth of menu item. Used for padding.
46
+ * @param array $args Menu item args.
47
+ *
48
+ * @return string Additional fields or html for the nav menu editor.
49
+ */
50
+ protected function get_custom_fields( $item, $depth, $args = array() ) {
51
+ ob_start();
52
+ $item_id = intval( $item->ID );
53
+ /**
54
+ * Get menu item custom fields from plugins/themes
55
+ *
56
+ * @param int $item_id post ID of menu
57
+ * @param object $item Menu item data object.
58
+ * @param int $depth Depth of menu item. Used for padding.
59
+ * @param array $args Menu item args.
60
+ *
61
+ * @return string Custom fields
62
+ */
63
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
64
+
65
+ return ob_get_clean();
66
+ }
67
+ }
includes/classes/walker/nav-menu-edit-custom-fields.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** Walker_Nav_Menu_Edit class */
4
+ if ( ! class_exists( 'Walker_Nav_Menu_Edit' ) ) {
5
+ global $wp_version;
6
+ if ( version_compare( $wp_version, '4.4', '>=' ) ) {
7
+ require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php';
8
+ } else {
9
+ require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
10
+ }
11
+ }
12
+
13
+ /**
14
+ * Custom Walker for Nav Menu Editor
15
+ *
16
+ * Add wp_nav_menu_item_custom_fields hook to the nav menu editor.
17
+ *
18
+ * Credits:
19
+ * @helgatheviking - Initial concept which has made adding settings in the menu editor in a compatible way.
20
+ * @kucrut - preg_replace() method so that we no longer have to translate core strings
21
+ * @danieliser - refactor for less complexity between WP versions & updating versioned classes for proper backward compatibility with the new methods.
22
+ *
23
+ * @since WordPress 3.6.0
24
+ * @uses Walker_Nav_Menu_Edit
25
+ */
26
+ class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
27
+
28
+ /**
29
+ * Start the element output.
30
+ *
31
+ * @see Walker_Nav_Menu_Edit::start_el()
32
+ *
33
+ * @param string $output Passed by reference. Used to append additional content.
34
+ * @param object $item Menu item data object.
35
+ * @param int $depth Depth of menu item.
36
+ * @param array $args
37
+ * @param int $id
38
+ */
39
+ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
40
+ parent::start_el( $output, $item, $depth, $args, $id = 0 );
41
+
42
+ $output = preg_replace( '(<p[^>]+class="[^"]*field-description(.|\n)*?<\/p>)', "$1 \n" . $this->get_custom_fields( $item, $depth, $args ), $output, 1 );
43
+ }
44
+
45
+
46
+ /**
47
+ * Get custom fields
48
+ *
49
+ * @uses do_action() Calls 'menu_item_custom_fields' hook
50
+ *
51
+ * @param object $item Menu item data object.
52
+ * @param int $depth Depth of menu item. Used for padding.
53
+ * @param array $args Menu item args.
54
+ *
55
+ * @return string Additional fields or html for the nav menu editor.
56
+ */
57
+ protected function get_custom_fields( $item, $depth, $args = array() ) {
58
+ ob_start();
59
+ $item_id = intval( $item->ID );
60
+ /**
61
+ * Get menu item custom fields from plugins/themes
62
+ *
63
+ * @param int $item_id post ID of menu
64
+ * @param object $item Menu item data object.
65
+ * @param int $depth Depth of menu item. Used for padding.
66
+ * @param array $args Menu item args.
67
+ *
68
+ * @return string Custom fields
69
+ */
70
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
71
+
72
+ return ob_get_clean();
73
+ }
74
+ }
includes/classes/walker/nav-menu-edit-deprecated.php DELETED
@@ -1,220 +0,0 @@
1
- <?php
2
-
3
- namespace JP\UM\Walker;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- /**
10
- * Navigation Menu API: (Modifed) Walker_Nav_Menu_Edit class
11
- *
12
- * Copied from Walker_Nav_Menu_Edit class in core /wp-admin/includes/nav-menu.php
13
- *
14
- * @since WordPress 4.4.0
15
- */
16
- class Nav_Menu_Edit_Deprecated extends \Walker_Nav_Menu {
17
-
18
- /**
19
- * Start the element output.
20
- *
21
- * @see Walker_Nav_Menu::start_el()
22
- * @since 3.0.0
23
- *
24
- * @global int $_wp_nav_menu_max_depth
25
- *
26
- * @param string $output Passed by reference. Used to append additional content.
27
- * @param object $item Menu item data object.
28
- * @param int $depth Depth of menu item. Used for padding.
29
- * @param array $args Not used.
30
- * @param int $id Not used.
31
- */
32
- public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
33
- global $_wp_nav_menu_max_depth;
34
- $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
35
-
36
- ob_start();
37
- $item_id = esc_attr( $item->ID );
38
- $removed_args = array(
39
- 'action',
40
- 'customlink-tab',
41
- 'edit-menu-item',
42
- 'menu-item',
43
- 'page-tab',
44
- '_wpnonce',
45
- );
46
-
47
- $original_title = '';
48
- if ( 'taxonomy' == $item->type ) {
49
- $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
50
- if ( is_wp_error( $original_title ) )
51
- $original_title = false;
52
- } elseif ( 'post_type' == $item->type ) {
53
- $original_object = get_post( $item->object_id );
54
- $original_title = get_the_title( $original_object->ID );
55
- } elseif ( 'post_type_archive' == $item->type ) {
56
- $original_object = get_post_type_object( $item->object );
57
- $original_title = $original_object->labels->archives;
58
- }
59
-
60
- $classes = array(
61
- 'menu-item menu-item-depth-' . $depth,
62
- 'menu-item-' . esc_attr( $item->object ),
63
- 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
64
- );
65
-
66
- $title = $item->title;
67
-
68
- if ( ! empty( $item->_invalid ) ) {
69
- $classes[] = 'menu-item-invalid';
70
- /* translators: %s: title of menu item which is invalid */
71
- $title = sprintf( __( '%s (Invalid)' , 'nav-menu-roles' ), $item->title );
72
- } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
73
- $classes[] = 'pending';
74
- /* translators: %s: title of menu item in draft status */
75
- $title = sprintf( __('%s (Pending)', 'nav-menu-roles' ), $item->title );
76
- }
77
-
78
- $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
79
-
80
- $submenu_text = '';
81
- if ( 0 == $depth )
82
- $submenu_text = 'style="display: none;"';
83
-
84
- ?>
85
- <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
86
- <div class="menu-item-bar">
87
- <div class="menu-item-handle">
88
- <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>
89
- <span class="item-controls">
90
- <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
91
- <span class="item-order hide-if-js">
92
- <a href="<?php
93
- echo wp_nonce_url(
94
- add_query_arg(
95
- array(
96
- 'action' => 'move-up-menu-item',
97
- 'menu-item' => $item_id,
98
- ),
99
- remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
100
- ),
101
- 'move-menu_item'
102
- );
103
- ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up', 'nav-menu-roles' ); ?>">&#8593;</abbr></a>
104
- |
105
- <a href="<?php
106
- echo wp_nonce_url(
107
- add_query_arg(
108
- array(
109
- 'action' => 'move-down-menu-item',
110
- 'menu-item' => $item_id,
111
- ),
112
- remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
113
- ),
114
- 'move-menu_item'
115
- );
116
- ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down', 'nav-menu-roles' ); ?>">&#8595;</abbr></a>
117
- </span>
118
- <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php esc_attr_e('Edit Menu Item', 'nav-menu-roles' ); ?>" href="<?php
119
- 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 ) ) );
120
- ?>"><?php _e( 'Edit Menu Item' , 'nav-menu-roles' ); ?></a>
121
- </span>
122
- </div>
123
- </div>
124
-
125
- <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
126
- <?php if ( 'custom' == $item->type ) : ?>
127
- <p class="field-url description description-wide">
128
- <label for="edit-menu-item-url-<?php echo $item_id; ?>">
129
- <?php _e( 'URL' , 'nav-menu-roles' ); ?><br />
130
- <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 ); ?>" />
131
- </label>
132
- </p>
133
- <?php endif; ?>
134
- <p class="description description-wide">
135
- <label for="edit-menu-item-title-<?php echo $item_id; ?>">
136
- <?php _e( 'Navigation Label' , 'nav-menu-roles' ); ?><br />
137
- <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 ); ?>" />
138
- </label>
139
- </p>
140
- <p class="field-title-attribute description description-wide">
141
- <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
142
- <?php _e( 'Title Attribute' , 'nav-menu-roles' ); ?><br />
143
- <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 ); ?>" />
144
- </label>
145
- </p>
146
- <p class="field-link-target description">
147
- <label for="edit-menu-item-target-<?php echo $item_id; ?>">
148
- <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' ); ?> />
149
- <?php _e( 'Open link in a new tab' , 'nav-menu-roles' ); ?>
150
- </label>
151
- </p>
152
- <p class="field-css-classes description description-thin">
153
- <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
154
- <?php _e( 'CSS Classes (optional)' , 'nav-menu-roles' ); ?><br />
155
- <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
156
- </label>
157
- </p>
158
- <p class="field-xfn description description-thin">
159
- <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
160
- <?php _e( 'Link Relationship (XFN)' , 'nav-menu-roles' ); ?><br />
161
- <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
162
- </label>
163
- </p>
164
- <p class="field-description description description-wide">
165
- <label for="edit-menu-item-description-<?php echo $item_id; ?>">
166
- <?php _e( 'Description' , 'nav-menu-roles' ); ?><br />
167
- <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
168
- <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.', 'nav-menu-roles' ); ?></span>
169
- </label>
170
- </p>
171
-
172
- <?php
173
- /**
174
- * This action allows easily extending the admin menu walker class in a useful manner without conflicting with others.
175
- */
176
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args ); ?>
177
-
178
- <p class="field-move hide-if-no-js description description-wide">
179
- <label>
180
- <span><?php _e( 'Move' , 'nav-menu-roles' ); ?></span>
181
- <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' , 'nav-menu-roles' ); ?></a>
182
- <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' , 'nav-menu-roles' ); ?></a>
183
- <a href="#" class="menus-move menus-move-left" data-dir="left"></a>
184
- <a href="#" class="menus-move menus-move-right" data-dir="right"></a>
185
- <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' , 'nav-menu-roles' ); ?></a>
186
- </label>
187
- </p>
188
-
189
- <div class="menu-item-actions description-wide submitbox">
190
- <?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
191
- <p class="link-to-original">
192
- <?php printf( __('Original: %s', 'nav-menu-roles' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
193
- </p>
194
- <?php endif; ?>
195
- <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
196
- echo wp_nonce_url(
197
- add_query_arg(
198
- array(
199
- 'action' => 'delete-menu-item',
200
- 'menu-item' => $item_id,
201
- ),
202
- admin_url( 'nav-menus.php' )
203
- ),
204
- 'delete-menu_item_' . $item_id
205
- ); ?>"><?php _e( 'Remove' , 'nav-menu-roles' ); ?></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() ), admin_url( 'nav-menus.php' ) ) );
206
- ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel', 'nav-menu-roles' ); ?></a>
207
- </div>
208
-
209
- <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
210
- <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
211
- <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
212
- <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
213
- <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
214
- <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
215
- </div><!-- .menu-item-settings-->
216
- <ul class="menu-item-transport"></ul>
217
- <?php
218
- $output .= ob_get_clean();
219
- }
220
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/classes/walker/nav-menu-edit.php DELETED
@@ -1,224 +0,0 @@
1
- <?php
2
-
3
- namespace JP\UM\Walker;
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- /**
10
- * Navigation Menu API: (Modifed) Walker_Nav_Menu_Edit class
11
- *
12
- * Copied from Walker_Nav_Menu_Edit class in core /wp-admin/includes/class-walker-nav-menu-edit.php
13
- *
14
- * @since WordPress 4.5.0
15
- */
16
- class Nav_Menu_Edit extends \Walker_Nav_Menu_Edit {
17
-
18
- /**
19
- * Start the element output.
20
- *
21
- * @see Walker_Nav_Menu::start_el()
22
- * @since 3.0.0
23
- *
24
- * @global int $_wp_nav_menu_max_depth
25
- *
26
- * @param string $output Passed by reference. Used to append additional content.
27
- * @param object $item Menu item data object.
28
- * @param int $depth Depth of menu item. Used for padding.
29
- * @param array $args Not used.
30
- * @param int $id Not used.
31
- */
32
- public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
33
- global $_wp_nav_menu_max_depth;
34
- $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
35
-
36
- ob_start();
37
- $item_id = esc_attr( $item->ID );
38
- $removed_args = array(
39
- 'action',
40
- 'customlink-tab',
41
- 'edit-menu-item',
42
- 'menu-item',
43
- 'page-tab',
44
- '_wpnonce',
45
- );
46
-
47
- $original_title = '';
48
- if ( 'taxonomy' == $item->type ) {
49
- $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
50
- if ( is_wp_error( $original_title ) )
51
- $original_title = false;
52
- } elseif ( 'post_type' == $item->type ) {
53
- $original_object = get_post( $item->object_id );
54
- $original_title = get_the_title( $original_object->ID );
55
- } elseif ( 'post_type_archive' == $item->type ) {
56
- $original_object = get_post_type_object( $item->object );
57
- if ( $original_object ) {
58
- $original_title = $original_object->labels->archives;
59
- }
60
- }
61
-
62
- $classes = array(
63
- 'menu-item menu-item-depth-' . $depth,
64
- 'menu-item-' . esc_attr( $item->object ),
65
- 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
66
- );
67
-
68
- $title = $item->title;
69
-
70
- if ( ! empty( $item->_invalid ) ) {
71
- $classes[] = 'menu-item-invalid';
72
- /* translators: %s: title of menu item which is invalid */
73
- $title = sprintf( __( '%s (Invalid)' ), $item->title );
74
- } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
75
- $classes[] = 'pending';
76
- /* translators: %s: title of menu item in draft status */
77
- $title = sprintf( __('%s (Pending)'), $item->title );
78
- }
79
-
80
- $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
81
-
82
- $submenu_text = '';
83
- if ( 0 == $depth )
84
- $submenu_text = 'style="display: none;"';
85
-
86
- ?>
87
- <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
88
- <div class="menu-item-bar">
89
- <div class="menu-item-handle">
90
- <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' ); ?></span></span>
91
- <span class="item-controls">
92
- <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
93
- <span class="item-order hide-if-js">
94
- <a href="<?php
95
- echo wp_nonce_url(
96
- add_query_arg(
97
- array(
98
- 'action' => 'move-up-menu-item',
99
- 'menu-item' => $item_id,
100
- ),
101
- remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
102
- ),
103
- 'move-menu_item'
104
- );
105
- ?>" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ) ?>">&#8593;</a>
106
- |
107
- <a href="<?php
108
- echo wp_nonce_url(
109
- add_query_arg(
110
- array(
111
- 'action' => 'move-down-menu-item',
112
- 'menu-item' => $item_id,
113
- ),
114
- remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
115
- ),
116
- 'move-menu_item'
117
- );
118
- ?>" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ) ?>">&#8595;</a>
119
- </span>
120
- <a class="item-edit" id="edit-<?php echo $item_id; ?>" href="<?php
121
- 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 ) ) );
122
- ?>" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><?php _e( 'Edit' ); ?></a>
123
- </span>
124
- </div>
125
- </div>
126
-
127
- <div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
128
- <?php if ( 'custom' == $item->type ) : ?>
129
- <p class="field-url description description-wide">
130
- <label for="edit-menu-item-url-<?php echo $item_id; ?>">
131
- <?php _e( 'URL' ); ?><br />
132
- <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 ); ?>" />
133
- </label>
134
- </p>
135
- <?php endif; ?>
136
- <p class="description description-wide">
137
- <label for="edit-menu-item-title-<?php echo $item_id; ?>">
138
- <?php _e( 'Navigation Label' ); ?><br />
139
- <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 ); ?>" />
140
- </label>
141
- </p>
142
-
143
- <?php
144
- /**
145
- * This action allows easily extending the admin menu walker class in a useful manner without conflicting with others.
146
- */
147
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args ); ?>
148
-
149
- <p class="field-title-attribute field-attr-title description description-wide">
150
- <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
151
- <?php _e( 'Title Attribute' ); ?><br />
152
- <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 ); ?>" />
153
- </label>
154
- </p>
155
- <p class="field-link-target description">
156
- <label for="edit-menu-item-target-<?php echo $item_id; ?>">
157
- <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' ); ?> />
158
- <?php _e( 'Open link in a new tab' ); ?>
159
- </label>
160
- </p>
161
- <p class="field-css-classes description description-thin">
162
- <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
163
- <?php _e( 'CSS Classes (optional)' ); ?><br />
164
- <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
165
- </label>
166
- </p>
167
- <p class="field-xfn description description-thin">
168
- <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
169
- <?php _e( 'Link Relationship (XFN)' ); ?><br />
170
- <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
171
- </label>
172
- </p>
173
- <p class="field-description description description-wide">
174
- <label for="edit-menu-item-description-<?php echo $item_id; ?>">
175
- <?php _e( 'Description' ); ?><br />
176
- <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
177
- <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
178
- </label>
179
- </p>
180
-
181
- <p class="field-move hide-if-no-js description description-wide">
182
- <label>
183
- <span><?php _e( 'Move' ); ?></span>
184
- <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></a>
185
- <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></a>
186
- <a href="#" class="menus-move menus-move-left" data-dir="left"></a>
187
- <a href="#" class="menus-move menus-move-right" data-dir="right"></a>
188
- <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></a>
189
- </label>
190
- </p>
191
-
192
- <div class="menu-item-actions description-wide submitbox">
193
- <?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
194
- <p class="link-to-original">
195
- <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
196
- </p>
197
- <?php endif; ?>
198
- <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
199
- echo wp_nonce_url(
200
- add_query_arg(
201
- array(
202
- 'action' => 'delete-menu-item',
203
- 'menu-item' => $item_id,
204
- ),
205
- admin_url( 'nav-menus.php' )
206
- ),
207
- 'delete-menu_item_' . $item_id
208
- ); ?>"><?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() ), admin_url( 'nav-menus.php' ) ) );
209
- ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a>
210
- </div>
211
-
212
- <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
213
- <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
214
- <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
215
- <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
216
- <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
217
- <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
218
- </div><!-- .menu-item-settings-->
219
- <ul class="menu-item-transport"></ul>
220
- <?php
221
- $output .= ob_get_clean();
222
- }
223
-
224
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/user-menus.pot CHANGED
@@ -16,19 +16,19 @@ msgstr ""
16
  "X-Poedit-SearchPathExcluded-0: *.js\n"
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n\n"
18
 
19
- #: includes/classes/admin/menu-editor.php:47
20
  msgid "User Links"
21
  msgstr ""
22
 
23
- #: includes/classes/admin/menu-editor.php:59
24
  msgid "Login"
25
  msgstr ""
26
 
27
- #: includes/classes/admin/menu-editor.php:63
28
  msgid "Logout"
29
  msgstr ""
30
 
31
- #: includes/classes/admin/menu-editor.php:154
32
  msgid "Insert User Menu Codes"
33
  msgstr ""
34
 
16
  "X-Poedit-SearchPathExcluded-0: *.js\n"
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n\n"
18
 
19
+ #: includes/classes/admin/menu-editor.php:55
20
  msgid "User Links"
21
  msgstr ""
22
 
23
+ #: includes/classes/admin/menu-editor.php:67
24
  msgid "Login"
25
  msgstr ""
26
 
27
+ #: includes/classes/admin/menu-editor.php:71
28
  msgid "Logout"
29
  msgstr ""
30
 
31
+ #: includes/classes/admin/menu-editor.php:162
32
  msgid "Insert User Menu Codes"
33
  msgstr ""
34
 
readme.txt CHANGED
@@ -5,8 +5,8 @@ Plugin URI: https://wordpress.org/plugins/user-menus/
5
  Donate link: https://jungleplugins.com/donate/
6
  Tags: menu, menus, user-menu, logout, nav-menu, nav-menus, user, user-role, user-roles
7
  Requires at least: 3.6
8
- Tested up to: 4.7.2
9
- Stable tag: 1.1.1
10
  Minimum PHP: 5.3
11
  License: GNU Version 3 or Any Later Version
12
 
@@ -113,6 +113,9 @@ Bugs can be reported either in our support forum or preferably on the [User Menu
113
 
114
  == Changelog ==
115
 
 
 
 
116
  = v1.1.1 =
117
  * Fix: Forgot to add new files during commit. Correcting this issue.
118
 
5
  Donate link: https://jungleplugins.com/donate/
6
  Tags: menu, menus, user-menu, logout, nav-menu, nav-menus, user, user-role, user-roles
7
  Requires at least: 3.6
8
+ Tested up to: 4.9.4
9
+ Stable tag: 1.1.2
10
  Minimum PHP: 5.3
11
  License: GNU Version 3 or Any Later Version
12
 
113
 
114
  == Changelog ==
115
 
116
+ = v1.1.2 =
117
+ * Improvement: Made changes to the nav menu editor to make it more compatible with other plugins.
118
+
119
  = v1.1.1 =
120
  * Fix: Forgot to add new files during commit. Correcting this issue.
121
 
user-menus.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: User Menus
4
  * Plugin URI: https://wordpress.org/plugins/user-menus/
5
  * Description: Quickly customize & extend your menus with user based functionality.
6
- * Version: 1.1.1
7
  * Author: Jungle Plugins
8
  * Author URI: https://jungleplugins.com/
9
  * Text Domain: user-menus
@@ -37,7 +37,7 @@ class JP_User_Menus {
37
  /**
38
  * @var string
39
  */
40
- public static $VER = '1.1.1';
41
 
42
  /**
43
  * @var string
3
  * Plugin Name: User Menus
4
  * Plugin URI: https://wordpress.org/plugins/user-menus/
5
  * Description: Quickly customize & extend your menus with user based functionality.
6
+ * Version: 1.1.2
7
  * Author: Jungle Plugins
8
  * Author URI: https://jungleplugins.com/
9
  * Text Domain: user-menus
37
  /**
38
  * @var string
39
  */
40
+ public static $VER = '1.1.2';
41
 
42
  /**
43
  * @var string