Version Description
- Use new Walker for WP4.7
Download this release
Release Info
Developer | deployer |
Plugin | Nav Menu Roles |
Version | 1.8.5 |
Comparing to | |
See all releases |
Code changes from version 1.8.4 to 1.8.5
- inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php +247 -0
- js/nav-menu-roles.min.js +1 -1
- nav-menu-roles.php +11 -10
- readme.txt +6 -6
inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Navigation Menu API: Walker_Nav_Menu_Edit class
|
4 |
+
*
|
5 |
+
* @package WordPress
|
6 |
+
* @subpackage Administration
|
7 |
+
* @since 4.4.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Create HTML list of nav menu input items.
|
12 |
+
*
|
13 |
+
* @package WordPress
|
14 |
+
* @since 3.0.0
|
15 |
+
* @uses Walker_Nav_Menu
|
16 |
+
*/
|
17 |
+
class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu {
|
18 |
+
/**
|
19 |
+
* Starts the list before the elements are added.
|
20 |
+
*
|
21 |
+
* @see Walker_Nav_Menu::start_lvl()
|
22 |
+
*
|
23 |
+
* @since 3.0.0
|
24 |
+
*
|
25 |
+
* @param string $output Passed by reference.
|
26 |
+
* @param int $depth Depth of menu item. Used for padding.
|
27 |
+
* @param array $args Not used.
|
28 |
+
*/
|
29 |
+
public function start_lvl( &$output, $depth = 0, $args = array() ) {}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Ends the list of after the elements are added.
|
33 |
+
*
|
34 |
+
* @see Walker_Nav_Menu::end_lvl()
|
35 |
+
*
|
36 |
+
* @since 3.0.0
|
37 |
+
*
|
38 |
+
* @param string $output Passed by reference.
|
39 |
+
* @param int $depth Depth of menu item. Used for padding.
|
40 |
+
* @param array $args Not used.
|
41 |
+
*/
|
42 |
+
public function end_lvl( &$output, $depth = 0, $args = array() ) {}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Start the element output.
|
46 |
+
*
|
47 |
+
* @see Walker_Nav_Menu::start_el()
|
48 |
+
* @since 3.0.0
|
49 |
+
*
|
50 |
+
* @global int $_wp_nav_menu_max_depth
|
51 |
+
*
|
52 |
+
* @param string $output Passed by reference. Used to append additional content.
|
53 |
+
* @param object $item Menu item data object.
|
54 |
+
* @param int $depth Depth of menu item. Used for padding.
|
55 |
+
* @param array $args Not used.
|
56 |
+
* @param int $id Not used.
|
57 |
+
*/
|
58 |
+
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
59 |
+
global $_wp_nav_menu_max_depth;
|
60 |
+
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
|
61 |
+
|
62 |
+
ob_start();
|
63 |
+
$item_id = esc_attr( $item->ID );
|
64 |
+
$removed_args = array(
|
65 |
+
'action',
|
66 |
+
'customlink-tab',
|
67 |
+
'edit-menu-item',
|
68 |
+
'menu-item',
|
69 |
+
'page-tab',
|
70 |
+
'_wpnonce',
|
71 |
+
);
|
72 |
+
|
73 |
+
$original_title = false;
|
74 |
+
if ( 'taxonomy' == $item->type ) {
|
75 |
+
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
|
76 |
+
if ( is_wp_error( $original_title ) )
|
77 |
+
$original_title = false;
|
78 |
+
} elseif ( 'post_type' == $item->type ) {
|
79 |
+
$original_object = get_post( $item->object_id );
|
80 |
+
$original_title = get_the_title( $original_object->ID );
|
81 |
+
} elseif ( 'post_type_archive' == $item->type ) {
|
82 |
+
$original_object = get_post_type_object( $item->object );
|
83 |
+
if ( $original_object ) {
|
84 |
+
$original_title = $original_object->labels->archives;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
$classes = array(
|
89 |
+
'menu-item menu-item-depth-' . $depth,
|
90 |
+
'menu-item-' . esc_attr( $item->object ),
|
91 |
+
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
|
92 |
+
);
|
93 |
+
|
94 |
+
$title = $item->title;
|
95 |
+
|
96 |
+
if ( ! empty( $item->_invalid ) ) {
|
97 |
+
$classes[] = 'menu-item-invalid';
|
98 |
+
/* translators: %s: title of menu item which is invalid */
|
99 |
+
$title = sprintf( __( '%s (Invalid)' ), $item->title );
|
100 |
+
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
|
101 |
+
$classes[] = 'pending';
|
102 |
+
/* translators: %s: title of menu item in draft status */
|
103 |
+
$title = sprintf( __('%s (Pending)'), $item->title );
|
104 |
+
}
|
105 |
+
|
106 |
+
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
|
107 |
+
|
108 |
+
$submenu_text = '';
|
109 |
+
if ( 0 == $depth )
|
110 |
+
$submenu_text = 'style="display: none;"';
|
111 |
+
|
112 |
+
?>
|
113 |
+
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
|
114 |
+
<div class="menu-item-bar">
|
115 |
+
<div class="menu-item-handle">
|
116 |
+
<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>
|
117 |
+
<span class="item-controls">
|
118 |
+
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
|
119 |
+
<span class="item-order hide-if-js">
|
120 |
+
<a href="<?php
|
121 |
+
echo wp_nonce_url(
|
122 |
+
add_query_arg(
|
123 |
+
array(
|
124 |
+
'action' => 'move-up-menu-item',
|
125 |
+
'menu-item' => $item_id,
|
126 |
+
),
|
127 |
+
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
|
128 |
+
),
|
129 |
+
'move-menu_item'
|
130 |
+
);
|
131 |
+
?>" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ) ?>">↑</a>
|
132 |
+
|
|
133 |
+
<a href="<?php
|
134 |
+
echo wp_nonce_url(
|
135 |
+
add_query_arg(
|
136 |
+
array(
|
137 |
+
'action' => 'move-down-menu-item',
|
138 |
+
'menu-item' => $item_id,
|
139 |
+
),
|
140 |
+
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
|
141 |
+
),
|
142 |
+
'move-menu_item'
|
143 |
+
);
|
144 |
+
?>" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ) ?>">↓</a>
|
145 |
+
</span>
|
146 |
+
<a class="item-edit" id="edit-<?php echo $item_id; ?>" href="<?php
|
147 |
+
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 ) ) );
|
148 |
+
?>" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><?php _e( 'Edit' ); ?></a>
|
149 |
+
</span>
|
150 |
+
</div>
|
151 |
+
</div>
|
152 |
+
|
153 |
+
<div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
|
154 |
+
<?php if ( 'custom' == $item->type ) : ?>
|
155 |
+
<p class="field-url description description-wide">
|
156 |
+
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
|
157 |
+
<?php _e( 'URL' ); ?><br />
|
158 |
+
<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 ); ?>" />
|
159 |
+
</label>
|
160 |
+
</p>
|
161 |
+
<?php endif; ?>
|
162 |
+
<p class="description description-wide">
|
163 |
+
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
|
164 |
+
<?php _e( 'Navigation Label' ); ?><br />
|
165 |
+
<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 ); ?>" />
|
166 |
+
</label>
|
167 |
+
</p>
|
168 |
+
<p class="field-title-attribute field-attr-title description description-wide">
|
169 |
+
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
|
170 |
+
<?php _e( 'Title Attribute' ); ?><br />
|
171 |
+
<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 ); ?>" />
|
172 |
+
</label>
|
173 |
+
</p>
|
174 |
+
<p class="field-link-target description">
|
175 |
+
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
|
176 |
+
<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' ); ?> />
|
177 |
+
<?php _e( 'Open link in a new tab' ); ?>
|
178 |
+
</label>
|
179 |
+
</p>
|
180 |
+
<p class="field-css-classes description description-thin">
|
181 |
+
<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
|
182 |
+
<?php _e( 'CSS Classes (optional)' ); ?><br />
|
183 |
+
<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 ) ); ?>" />
|
184 |
+
</label>
|
185 |
+
</p>
|
186 |
+
<p class="field-xfn description description-thin">
|
187 |
+
<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
|
188 |
+
<?php _e( 'Link Relationship (XFN)' ); ?><br />
|
189 |
+
<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 ); ?>" />
|
190 |
+
</label>
|
191 |
+
</p>
|
192 |
+
<p class="field-description description description-wide">
|
193 |
+
<label for="edit-menu-item-description-<?php echo $item_id; ?>">
|
194 |
+
<?php _e( 'Description' ); ?><br />
|
195 |
+
<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>
|
196 |
+
<span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
|
197 |
+
</label>
|
198 |
+
</p>
|
199 |
+
|
200 |
+
<?php
|
201 |
+
// This is the added section
|
202 |
+
do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
|
203 |
+
// end added section
|
204 |
+
?>
|
205 |
+
|
206 |
+
<fieldset class="field-move hide-if-no-js description description-wide">
|
207 |
+
<span class="field-move-visual-label" aria-hidden="true"><?php _e( 'Move' ); ?></span>
|
208 |
+
<button type="button" class="button-link menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></button>
|
209 |
+
<button type="button" class="button-link menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></button>
|
210 |
+
<button type="button" class="button-link menus-move menus-move-left" data-dir="left"></button>
|
211 |
+
<button type="button" class="button-link menus-move menus-move-right" data-dir="right"></button>
|
212 |
+
<button type="button" class="button-link menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></button>
|
213 |
+
</fieldset>
|
214 |
+
|
215 |
+
<div class="menu-item-actions description-wide submitbox">
|
216 |
+
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
|
217 |
+
<p class="link-to-original">
|
218 |
+
<?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
|
219 |
+
</p>
|
220 |
+
<?php endif; ?>
|
221 |
+
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
|
222 |
+
echo wp_nonce_url(
|
223 |
+
add_query_arg(
|
224 |
+
array(
|
225 |
+
'action' => 'delete-menu-item',
|
226 |
+
'menu-item' => $item_id,
|
227 |
+
),
|
228 |
+
admin_url( 'nav-menus.php' )
|
229 |
+
),
|
230 |
+
'delete-menu_item_' . $item_id
|
231 |
+
); ?>"><?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' ) ) );
|
232 |
+
?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a>
|
233 |
+
</div>
|
234 |
+
|
235 |
+
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
|
236 |
+
<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 ); ?>" />
|
237 |
+
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
|
238 |
+
<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 ); ?>" />
|
239 |
+
<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
|
240 |
+
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
|
241 |
+
</div><!-- .menu-item-settings-->
|
242 |
+
<ul class="menu-item-transport"></ul>
|
243 |
+
<?php
|
244 |
+
$output .= ob_get_clean();
|
245 |
+
}
|
246 |
+
|
247 |
+
} // Walker_Nav_Menu_Edit
|
js/nav-menu-roles.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
/*! nav-menu-roles 1.
|
2 |
!function(a){a(".nav_menu_logged_in_out_field").each(function(b){var c=a(this);c.find("input.nav-menu-id").val();"in"===c.find("input.nav-menu-logged-in-out:checked").val()?c.next(".nav_menu_role_field").show():c.next(".nav_menu_role_field").hide()}),a("#menu-to-edit").on("change","input.nav-menu-logged-in-out",function(){"in"===a(this).val()?a(this).parentsUntil(".nav_menu_logged_in_out").next(".nav_menu_role_field").slideDown():a(this).parentsUntil(".nav_menu_logged_in_out").next(".nav_menu_role_field").slideUp()})}(jQuery);
|
1 |
+
/*! nav-menu-roles 1.8.5 */
|
2 |
!function(a){a(".nav_menu_logged_in_out_field").each(function(b){var c=a(this);c.find("input.nav-menu-id").val();"in"===c.find("input.nav-menu-logged-in-out:checked").val()?c.next(".nav_menu_role_field").show():c.next(".nav_menu_role_field").hide()}),a("#menu-to-edit").on("change","input.nav-menu-logged-in-out",function(){"in"===a(this).val()?a(this).parentsUntil(".nav_menu_logged_in_out").next(".nav_menu_role_field").slideDown():a(this).parentsUntil(".nav_menu_logged_in_out").next(".nav_menu_role_field").slideUp()})}(jQuery);
|
nav-menu-roles.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Nav Menu Roles
|
4 |
Plugin URI: http://www.kathyisawesome.com/449/nav-menu-roles/
|
5 |
Description: Hide custom menu items based on user roles.
|
6 |
-
Version: 1.8.
|
7 |
Author: Kathy Darling
|
8 |
Author URI: http://www.kathyisawesome.com
|
9 |
License: GPL-3.0
|
@@ -142,15 +142,6 @@ class Nav_Menu_Roles {
|
|
142 |
*/
|
143 |
public function admin_init() {
|
144 |
|
145 |
-
if( ! class_exists( 'Walker_Nav_Menu_Edit_Roles' ) ){
|
146 |
-
global $wp_version;
|
147 |
-
if ( version_compare( $wp_version, '4.5.0', '>=' ) ){
|
148 |
-
include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php');
|
149 |
-
} else {
|
150 |
-
include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles.php');
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
// Register Importer
|
155 |
$this->register_importer();
|
156 |
|
@@ -237,6 +228,16 @@ class Nav_Menu_Roles {
|
|
237 |
* @since 1.0
|
238 |
*/
|
239 |
public function edit_nav_menu_walker( $walker ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
return 'Walker_Nav_Menu_Edit_Roles';
|
241 |
}
|
242 |
|
3 |
Plugin Name: Nav Menu Roles
|
4 |
Plugin URI: http://www.kathyisawesome.com/449/nav-menu-roles/
|
5 |
Description: Hide custom menu items based on user roles.
|
6 |
+
Version: 1.8.5
|
7 |
Author: Kathy Darling
|
8 |
Author URI: http://www.kathyisawesome.com
|
9 |
License: GPL-3.0
|
142 |
*/
|
143 |
public function admin_init() {
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
// Register Importer
|
146 |
$this->register_importer();
|
147 |
|
228 |
* @since 1.0
|
229 |
*/
|
230 |
public function edit_nav_menu_walker( $walker ) {
|
231 |
+
if( ! class_exists( 'Walker_Nav_Menu_Edit_Roles' ) ){
|
232 |
+
global $wp_version;
|
233 |
+
if ( version_compare( $wp_version, '4.7', '>=' ) ){
|
234 |
+
require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php');
|
235 |
+
} else if ( version_compare( $wp_version, '4.5', '>=' ) ){
|
236 |
+
require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php');
|
237 |
+
} else {
|
238 |
+
require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles.php');
|
239 |
+
}
|
240 |
+
}
|
241 |
return 'Walker_Nav_Menu_Edit_Roles';
|
242 |
}
|
243 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.paypal.me/helgatheviking
|
|
5 |
Tags: menu, menus, nav menu, nav menus
|
6 |
Requires at least: 4.5.0
|
7 |
Tested up to: 4.7.0
|
8 |
-
Stable tag: 1.8.
|
9 |
License: GPLv3
|
10 |
|
11 |
Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
|
@@ -14,7 +14,7 @@ Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT S
|
|
14 |
|
15 |
This plugin lets you hide custom menu items based on user roles. So if you have a link in the menu that you only want to show to logged in users, certain types of users, or even only to logged out users, this plugin is for you.
|
16 |
|
17 |
-
Nav Menu Roles is very flexible. In addition to standard user roles, you can customize the functionality by adding your own check boxes with custom labels using the `nav_menu_roles` filter and then using the `nav_menu_roles_item_visibility` filter to check against whatever criteria you need. You can check against any user meta values (like capabilities) and any custom attributes added by other plugins.
|
18 |
|
19 |
= IMPORTANT NOTE =
|
20 |
|
@@ -46,7 +46,7 @@ Please report any bugs, errors, warnings, code problems to [Github](https://gith
|
|
46 |
|
47 |
== Frequently Asked Questions ==
|
48 |
|
49 |
-
=
|
50 |
|
51 |
This is because you have another plugin (or theme) that is also trying to alter the same code that creates the Menu section in the admin.
|
52 |
|
@@ -66,7 +66,7 @@ WordPress does not have sufficient hooks in this area of the admin and until the
|
|
66 |
10. Mega Main Plugin
|
67 |
|
68 |
|
69 |
-
=
|
70 |
[Shazdeh](https://profiles.wordpress.org/shazdeh/) had the genius idea to not wait for a core hook and simply add the hook ourselves. If all plugin and theme authors use the same hook, we can make our plugins play together.
|
71 |
|
72 |
Therefore, as of version 1.6 I am modifying my admin nav menu Walker to *only* adding the following lines (right after the description input):
|
@@ -81,7 +81,7 @@ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
|
|
81 |
|
82 |
**Ask your conflicting plugin/theme's author to add this code to his plugin or theme and our plugins will become compatible.**
|
83 |
|
84 |
-
=
|
85 |
|
86 |
Should you wish to attempt this patch yourself, you can modify your conflicting plugin/theme's admin menu Walker class.
|
87 |
|
@@ -134,7 +134,7 @@ There are apparently a few membership plugins out there that *don't* use traditi
|
|
134 |
|
135 |
Here's an example where I've added a new pseudo role, creatively called "new-role". The first function adds it to the menu item admin screen. The second function is pretty generic and won't actually do anything because you need to supply your own logic based on the plugin you are using. Nav Menu Roles will save the new "role" info and add it to the item in an array to the `$item->roles` variable.
|
136 |
|
137 |
-
=
|
138 |
|
139 |
`
|
140 |
/*
|
5 |
Tags: menu, menus, nav menu, nav menus
|
6 |
Requires at least: 4.5.0
|
7 |
Tested up to: 4.7.0
|
8 |
+
Stable tag: 1.8.6
|
9 |
License: GPLv3
|
10 |
|
11 |
Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
|
14 |
|
15 |
This plugin lets you hide custom menu items based on user roles. So if you have a link in the menu that you only want to show to logged in users, certain types of users, or even only to logged out users, this plugin is for you.
|
16 |
|
17 |
+
Nav Menu Roles is very flexible. In addition to standard user roles, you can customize the functionality by adding your own check boxes with custom labels using the `nav_menu_roles` filter and then using the `nav_menu_roles_item_visibility` filter to check against whatever criteria you need. You can check against any user meta values (like capabilities) and any custom attributes added by other plugins.
|
18 |
|
19 |
= IMPORTANT NOTE =
|
20 |
|
46 |
|
47 |
== Frequently Asked Questions ==
|
48 |
|
49 |
+
= I don't see the Nav Menu Roles options in the admin menu items? =
|
50 |
|
51 |
This is because you have another plugin (or theme) that is also trying to alter the same code that creates the Menu section in the admin.
|
52 |
|
66 |
10. Mega Main Plugin
|
67 |
|
68 |
|
69 |
+
= Workaround #1 =
|
70 |
[Shazdeh](https://profiles.wordpress.org/shazdeh/) had the genius idea to not wait for a core hook and simply add the hook ourselves. If all plugin and theme authors use the same hook, we can make our plugins play together.
|
71 |
|
72 |
Therefore, as of version 1.6 I am modifying my admin nav menu Walker to *only* adding the following lines (right after the description input):
|
81 |
|
82 |
**Ask your conflicting plugin/theme's author to add this code to his plugin or theme and our plugins will become compatible.**
|
83 |
|
84 |
+
= Instructions for Patching Your Plugin/Theme =
|
85 |
|
86 |
Should you wish to attempt this patch yourself, you can modify your conflicting plugin/theme's admin menu Walker class.
|
87 |
|
134 |
|
135 |
Here's an example where I've added a new pseudo role, creatively called "new-role". The first function adds it to the menu item admin screen. The second function is pretty generic and won't actually do anything because you need to supply your own logic based on the plugin you are using. Nav Menu Roles will save the new "role" info and add it to the item in an array to the `$item->roles` variable.
|
136 |
|
137 |
+
= Adding a new "role" =
|
138 |
|
139 |
`
|
140 |
/*
|