Version Description
- Fix style issue in WordPress 4.5
Download this release
Release Info
Developer | helgatheviking |
Plugin | Nav Menu Roles |
Version | 1.8.0 |
Comparing to | |
See all releases |
Code changes from version 1.7.9 to 1.8.0
- inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php +248 -0
- languages/nav-menu-roles.pot +38 -10
- nav-menu-roles.php +24 -18
- readme.txt +7 -3
inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Navigation Menu API: (Modifed) Walker_Nav_Menu_Edit class
|
5 |
+
*
|
6 |
+
* Create HTML list of nav menu input items.
|
7 |
+
* Copied from Walker_Nav_Menu_Edit class in core /wp-admin/includes/class-walker-nav-menu-edit.php
|
8 |
+
*
|
9 |
+
* @package nav-menu-roles
|
10 |
+
* @since 1.0
|
11 |
+
* @since WordPress 4.5.0
|
12 |
+
* @uses Walker_Nav_Menu_Edit
|
13 |
+
*/
|
14 |
+
|
15 |
+
class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Starts the list before the elements are added.
|
19 |
+
*
|
20 |
+
* @see Walker_Nav_Menu::start_lvl()
|
21 |
+
*
|
22 |
+
* @since 3.0.0
|
23 |
+
*
|
24 |
+
* @param string $output Passed by reference.
|
25 |
+
* @param int $depth Depth of menu item. Used for padding.
|
26 |
+
* @param array $args Not used.
|
27 |
+
*/
|
28 |
+
public function start_lvl( &$output, $depth = 0, $args = array() ) {}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Ends the list of after the elements are added.
|
32 |
+
*
|
33 |
+
* @see Walker_Nav_Menu::end_lvl()
|
34 |
+
*
|
35 |
+
* @since 3.0.0
|
36 |
+
*
|
37 |
+
* @param string $output Passed by reference.
|
38 |
+
* @param int $depth Depth of menu item. Used for padding.
|
39 |
+
* @param array $args Not used.
|
40 |
+
*/
|
41 |
+
public function end_lvl( &$output, $depth = 0, $args = array() ) {}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Start the element output.
|
45 |
+
*
|
46 |
+
* @see Walker_Nav_Menu::start_el()
|
47 |
+
* @since 3.0.0
|
48 |
+
*
|
49 |
+
* @global int $_wp_nav_menu_max_depth
|
50 |
+
*
|
51 |
+
* @param string $output Passed by reference. Used to append additional content.
|
52 |
+
* @param object $item Menu item data object.
|
53 |
+
* @param int $depth Depth of menu item. Used for padding.
|
54 |
+
* @param array $args Not used.
|
55 |
+
* @param int $id Not used.
|
56 |
+
*/
|
57 |
+
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
58 |
+
global $_wp_nav_menu_max_depth;
|
59 |
+
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
|
60 |
+
|
61 |
+
ob_start();
|
62 |
+
$item_id = esc_attr( $item->ID );
|
63 |
+
$removed_args = array(
|
64 |
+
'action',
|
65 |
+
'customlink-tab',
|
66 |
+
'edit-menu-item',
|
67 |
+
'menu-item',
|
68 |
+
'page-tab',
|
69 |
+
'_wpnonce',
|
70 |
+
);
|
71 |
+
|
72 |
+
$original_title = '';
|
73 |
+
if ( 'taxonomy' == $item->type ) {
|
74 |
+
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
|
75 |
+
if ( is_wp_error( $original_title ) )
|
76 |
+
$original_title = false;
|
77 |
+
} elseif ( 'post_type' == $item->type ) {
|
78 |
+
$original_object = get_post( $item->object_id );
|
79 |
+
$original_title = get_the_title( $original_object->ID );
|
80 |
+
} elseif ( 'post_type_archive' == $item->type ) {
|
81 |
+
$original_object = get_post_type_object( $item->object );
|
82 |
+
if ( $original_object ) {
|
83 |
+
$original_title = $original_object->labels->archives;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
$classes = array(
|
88 |
+
'menu-item menu-item-depth-' . $depth,
|
89 |
+
'menu-item-' . esc_attr( $item->object ),
|
90 |
+
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
|
91 |
+
);
|
92 |
+
|
93 |
+
$title = $item->title;
|
94 |
+
|
95 |
+
if ( ! empty( $item->_invalid ) ) {
|
96 |
+
$classes[] = 'menu-item-invalid';
|
97 |
+
/* translators: %s: title of menu item which is invalid */
|
98 |
+
$title = sprintf( __( '%s (Invalid)', 'nav-menu-roles' ), $item->title );
|
99 |
+
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
|
100 |
+
$classes[] = 'pending';
|
101 |
+
/* translators: %s: title of menu item in draft status */
|
102 |
+
$title = sprintf( __('%s (Pending)', 'nav-menu-roles'), $item->title );
|
103 |
+
}
|
104 |
+
|
105 |
+
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
|
106 |
+
|
107 |
+
$submenu_text = '';
|
108 |
+
if ( 0 == $depth )
|
109 |
+
$submenu_text = 'style="display: none;"';
|
110 |
+
|
111 |
+
?>
|
112 |
+
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
|
113 |
+
<div class="menu-item-bar">
|
114 |
+
<div class="menu-item-handle">
|
115 |
+
<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>
|
116 |
+
<span class="item-controls">
|
117 |
+
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
|
118 |
+
<span class="item-order hide-if-js">
|
119 |
+
<a href="<?php
|
120 |
+
echo wp_nonce_url(
|
121 |
+
add_query_arg(
|
122 |
+
array(
|
123 |
+
'action' => 'move-up-menu-item',
|
124 |
+
'menu-item' => $item_id,
|
125 |
+
),
|
126 |
+
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
|
127 |
+
),
|
128 |
+
'move-menu_item'
|
129 |
+
);
|
130 |
+
?>" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up', 'nav-menu-roles' ) ?>">↑</a>
|
131 |
+
|
|
132 |
+
<a href="<?php
|
133 |
+
echo wp_nonce_url(
|
134 |
+
add_query_arg(
|
135 |
+
array(
|
136 |
+
'action' => 'move-down-menu-item',
|
137 |
+
'menu-item' => $item_id,
|
138 |
+
),
|
139 |
+
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
|
140 |
+
),
|
141 |
+
'move-menu_item'
|
142 |
+
);
|
143 |
+
?>" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down', 'nav-menu-roles' ) ?>">↓</a>
|
144 |
+
</span>
|
145 |
+
<a class="item-edit" id="edit-<?php echo $item_id; ?>" href="<?php
|
146 |
+
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 ) ) );
|
147 |
+
?>" aria-label="<?php esc_attr_e( 'Edit menu item', 'nav-menu-roles' ); ?>"><?php _e( 'Edit', 'nav-menu-roles' ); ?></a>
|
148 |
+
</span>
|
149 |
+
</div>
|
150 |
+
</div>
|
151 |
+
|
152 |
+
<div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
|
153 |
+
<?php if ( 'custom' == $item->type ) : ?>
|
154 |
+
<p class="field-url description description-wide">
|
155 |
+
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
|
156 |
+
<?php _e( 'URL', 'nav-menu-roles' ); ?><br />
|
157 |
+
<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 ); ?>" />
|
158 |
+
</label>
|
159 |
+
</p>
|
160 |
+
<?php endif; ?>
|
161 |
+
<p class="description description-wide">
|
162 |
+
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
|
163 |
+
<?php _e( 'Navigation Label', 'nav-menu-roles' ); ?><br />
|
164 |
+
<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 ); ?>" />
|
165 |
+
</label>
|
166 |
+
</p>
|
167 |
+
<p class="field-title-attribute field-attr-title description description-wide">
|
168 |
+
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
|
169 |
+
<?php _e( 'Title Attribute', 'nav-menu-roles' ); ?><br />
|
170 |
+
<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 ); ?>" />
|
171 |
+
</label>
|
172 |
+
</p>
|
173 |
+
<p class="field-link-target description">
|
174 |
+
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
|
175 |
+
<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' ); ?> />
|
176 |
+
<?php _e( 'Open link in a new tab', 'nav-menu-roles' ); ?>
|
177 |
+
</label>
|
178 |
+
</p>
|
179 |
+
<p class="field-css-classes description description-thin">
|
180 |
+
<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
|
181 |
+
<?php _e( 'CSS Classes (optional)', 'nav-menu-roles' ); ?><br />
|
182 |
+
<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 ) ); ?>" />
|
183 |
+
</label>
|
184 |
+
</p>
|
185 |
+
<p class="field-xfn description description-thin">
|
186 |
+
<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
|
187 |
+
<?php _e( 'Link Relationship (XFN)', 'nav-menu-roles' ); ?><br />
|
188 |
+
<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 ); ?>" />
|
189 |
+
</label>
|
190 |
+
</p>
|
191 |
+
<p class="field-description description description-wide">
|
192 |
+
<label for="edit-menu-item-description-<?php echo $item_id; ?>">
|
193 |
+
<?php _e( 'Description', 'nav-menu-roles' ); ?><br />
|
194 |
+
<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>
|
195 |
+
<span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.', 'nav-menu-roles'); ?></span>
|
196 |
+
</label>
|
197 |
+
</p>
|
198 |
+
|
199 |
+
<?php
|
200 |
+
// This is the added section
|
201 |
+
do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
|
202 |
+
// end added section
|
203 |
+
?>
|
204 |
+
|
205 |
+
<p class="field-move hide-if-no-js description description-wide">
|
206 |
+
<label>
|
207 |
+
<span><?php _e( 'Move', 'nav-menu-roles' ); ?></span>
|
208 |
+
<a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one', 'nav-menu-roles' ); ?></a>
|
209 |
+
<a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one', 'nav-menu-roles' ); ?></a>
|
210 |
+
<a href="#" class="menus-move menus-move-left" data-dir="left"></a>
|
211 |
+
<a href="#" class="menus-move menus-move-right" data-dir="right"></a>
|
212 |
+
<a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top', 'nav-menu-roles' ); ?></a>
|
213 |
+
</label>
|
214 |
+
</p>
|
215 |
+
|
216 |
+
<div class="menu-item-actions description-wide submitbox">
|
217 |
+
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
|
218 |
+
<p class="link-to-original">
|
219 |
+
<?php printf( __('Original: %s', 'nav-menu-roles'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
|
220 |
+
</p>
|
221 |
+
<?php endif; ?>
|
222 |
+
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
|
223 |
+
echo wp_nonce_url(
|
224 |
+
add_query_arg(
|
225 |
+
array(
|
226 |
+
'action' => 'delete-menu-item',
|
227 |
+
'menu-item' => $item_id,
|
228 |
+
),
|
229 |
+
admin_url( 'nav-menus.php' )
|
230 |
+
),
|
231 |
+
'delete-menu_item_' . $item_id
|
232 |
+
); ?>"><?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' ) ) );
|
233 |
+
?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel', 'nav-menu-roles'); ?></a>
|
234 |
+
</div>
|
235 |
+
|
236 |
+
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
|
237 |
+
<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 ); ?>" />
|
238 |
+
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
|
239 |
+
<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 ); ?>" />
|
240 |
+
<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
|
241 |
+
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
|
242 |
+
</div><!-- .menu-item-settings-->
|
243 |
+
<ul class="menu-item-transport"></ul>
|
244 |
+
<?php
|
245 |
+
$output .= ob_get_clean();
|
246 |
+
}
|
247 |
+
|
248 |
+
} // Walker_Nav_Menu_Edit
|
languages/nav-menu-roles.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the GPL2.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Nav Menu Roles 1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nav-menu-roles\n"
|
7 |
-
"POT-Creation-Date: 2016-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -67,24 +67,29 @@ msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
|
|
67 |
msgstr ""
|
68 |
|
69 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:95
|
|
|
70 |
#. translators: %s: title of menu item which is invalid
|
71 |
msgid "%s (Invalid)"
|
72 |
msgstr ""
|
73 |
|
74 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:99
|
|
|
75 |
#. translators: %s: title of menu item in draft status
|
76 |
msgid "%s (Pending)"
|
77 |
msgstr ""
|
78 |
|
79 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:112
|
|
|
80 |
msgid "sub item"
|
81 |
msgstr ""
|
82 |
|
83 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:127
|
|
|
84 |
msgid "Move up"
|
85 |
msgstr ""
|
86 |
|
87 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:140
|
|
|
88 |
msgid "Move down"
|
89 |
msgstr ""
|
90 |
|
@@ -94,67 +99,90 @@ msgid "Edit Menu Item"
|
|
94 |
msgstr ""
|
95 |
|
96 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:153
|
|
|
97 |
msgid "URL"
|
98 |
msgstr ""
|
99 |
|
100 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:160
|
|
|
101 |
msgid "Navigation Label"
|
102 |
msgstr ""
|
103 |
|
104 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:166
|
|
|
105 |
msgid "Title Attribute"
|
106 |
msgstr ""
|
107 |
|
108 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:173
|
|
|
109 |
msgid "Open link in a new tab"
|
110 |
msgstr ""
|
111 |
|
112 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:178
|
|
|
113 |
msgid "CSS Classes (optional)"
|
114 |
msgstr ""
|
115 |
|
116 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:184
|
|
|
117 |
msgid "Link Relationship (XFN)"
|
118 |
msgstr ""
|
119 |
|
120 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:190
|
|
|
121 |
msgid "Description"
|
122 |
msgstr ""
|
123 |
|
124 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:192
|
|
|
125 |
msgid ""
|
126 |
"The description will be displayed in the menu if the current theme supports "
|
127 |
"it."
|
128 |
msgstr ""
|
129 |
|
130 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:204
|
|
|
131 |
msgid "Move"
|
132 |
msgstr ""
|
133 |
|
134 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:205
|
|
|
135 |
msgid "Up one"
|
136 |
msgstr ""
|
137 |
|
138 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:206
|
|
|
139 |
msgid "Down one"
|
140 |
msgstr ""
|
141 |
|
142 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:209
|
|
|
143 |
msgid "To the top"
|
144 |
msgstr ""
|
145 |
|
146 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:216
|
|
|
147 |
msgid "Original: %s"
|
148 |
msgstr ""
|
149 |
|
150 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:229
|
|
|
151 |
msgid "Remove"
|
152 |
msgstr ""
|
153 |
|
154 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:230
|
|
|
155 |
msgid "Cancel"
|
156 |
msgstr ""
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
#: nav-menu-roles.php:82 nav-menu-roles.php:91
|
159 |
msgid "Cheatin’ huh?"
|
160 |
msgstr ""
|
@@ -163,37 +191,37 @@ msgstr ""
|
|
163 |
msgid "Nav Menu Roles"
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: nav-menu-roles.php:
|
167 |
msgid ""
|
168 |
"Import %snav menu roles%s and other menu item meta skipped by the default "
|
169 |
"importer"
|
170 |
msgstr ""
|
171 |
|
172 |
-
#: nav-menu-roles.php:
|
173 |
msgid "FAQ"
|
174 |
msgstr ""
|
175 |
|
176 |
-
#: nav-menu-roles.php:
|
177 |
msgid "Donate"
|
178 |
msgstr ""
|
179 |
|
180 |
-
#: nav-menu-roles.php:
|
181 |
msgid "Display Mode"
|
182 |
msgstr ""
|
183 |
|
184 |
-
#: nav-menu-roles.php:
|
185 |
msgid "Logged In Users"
|
186 |
msgstr ""
|
187 |
|
188 |
-
#: nav-menu-roles.php:
|
189 |
msgid "Logged Out Users"
|
190 |
msgstr ""
|
191 |
|
192 |
-
#: nav-menu-roles.php:
|
193 |
msgid "Everyone"
|
194 |
msgstr ""
|
195 |
|
196 |
-
#: nav-menu-roles.php:
|
197 |
msgid "Restrict menu item to a minimum role"
|
198 |
msgstr ""
|
199 |
|
2 |
# This file is distributed under the GPL2.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Nav Menu Roles 1.8.0\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nav-menu-roles\n"
|
7 |
+
"POT-Creation-Date: 2016-05-04 14:17:56+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
67 |
msgstr ""
|
68 |
|
69 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:95
|
70 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:98
|
71 |
#. translators: %s: title of menu item which is invalid
|
72 |
msgid "%s (Invalid)"
|
73 |
msgstr ""
|
74 |
|
75 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:99
|
76 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:102
|
77 |
#. translators: %s: title of menu item in draft status
|
78 |
msgid "%s (Pending)"
|
79 |
msgstr ""
|
80 |
|
81 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:112
|
82 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:115
|
83 |
msgid "sub item"
|
84 |
msgstr ""
|
85 |
|
86 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:127
|
87 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:130
|
88 |
msgid "Move up"
|
89 |
msgstr ""
|
90 |
|
91 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:140
|
92 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:143
|
93 |
msgid "Move down"
|
94 |
msgstr ""
|
95 |
|
99 |
msgstr ""
|
100 |
|
101 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:153
|
102 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:156
|
103 |
msgid "URL"
|
104 |
msgstr ""
|
105 |
|
106 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:160
|
107 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:163
|
108 |
msgid "Navigation Label"
|
109 |
msgstr ""
|
110 |
|
111 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:166
|
112 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:169
|
113 |
msgid "Title Attribute"
|
114 |
msgstr ""
|
115 |
|
116 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:173
|
117 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:176
|
118 |
msgid "Open link in a new tab"
|
119 |
msgstr ""
|
120 |
|
121 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:178
|
122 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:181
|
123 |
msgid "CSS Classes (optional)"
|
124 |
msgstr ""
|
125 |
|
126 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:184
|
127 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:187
|
128 |
msgid "Link Relationship (XFN)"
|
129 |
msgstr ""
|
130 |
|
131 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:190
|
132 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:193
|
133 |
msgid "Description"
|
134 |
msgstr ""
|
135 |
|
136 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:192
|
137 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:195
|
138 |
msgid ""
|
139 |
"The description will be displayed in the menu if the current theme supports "
|
140 |
"it."
|
141 |
msgstr ""
|
142 |
|
143 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:204
|
144 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:207
|
145 |
msgid "Move"
|
146 |
msgstr ""
|
147 |
|
148 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:205
|
149 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:208
|
150 |
msgid "Up one"
|
151 |
msgstr ""
|
152 |
|
153 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:206
|
154 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:209
|
155 |
msgid "Down one"
|
156 |
msgstr ""
|
157 |
|
158 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:209
|
159 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:212
|
160 |
msgid "To the top"
|
161 |
msgstr ""
|
162 |
|
163 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:216
|
164 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:219
|
165 |
msgid "Original: %s"
|
166 |
msgstr ""
|
167 |
|
168 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:229
|
169 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:232
|
170 |
msgid "Remove"
|
171 |
msgstr ""
|
172 |
|
173 |
#: inc/class.Walker_Nav_Menu_Edit_Roles.php:230
|
174 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:233
|
175 |
msgid "Cancel"
|
176 |
msgstr ""
|
177 |
|
178 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:147
|
179 |
+
msgid "Edit menu item"
|
180 |
+
msgstr ""
|
181 |
+
|
182 |
+
#: inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php:147
|
183 |
+
msgid "Edit"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
#: nav-menu-roles.php:82 nav-menu-roles.php:91
|
187 |
msgid "Cheatin’ huh?"
|
188 |
msgstr ""
|
191 |
msgid "Nav Menu Roles"
|
192 |
msgstr ""
|
193 |
|
194 |
+
#: nav-menu-roles.php:174
|
195 |
msgid ""
|
196 |
"Import %snav menu roles%s and other menu item meta skipped by the default "
|
197 |
"importer"
|
198 |
msgstr ""
|
199 |
|
200 |
+
#: nav-menu-roles.php:227
|
201 |
msgid "FAQ"
|
202 |
msgstr ""
|
203 |
|
204 |
+
#: nav-menu-roles.php:228
|
205 |
msgid "Donate"
|
206 |
msgstr ""
|
207 |
|
208 |
+
#: nav-menu-roles.php:297
|
209 |
msgid "Display Mode"
|
210 |
msgstr ""
|
211 |
|
212 |
+
#: nav-menu-roles.php:305
|
213 |
msgid "Logged In Users"
|
214 |
msgstr ""
|
215 |
|
216 |
+
#: nav-menu-roles.php:312
|
217 |
msgid "Logged Out Users"
|
218 |
msgstr ""
|
219 |
|
220 |
+
#: nav-menu-roles.php:319
|
221 |
msgid "Everyone"
|
222 |
msgstr ""
|
223 |
|
224 |
+
#: nav-menu-roles.php:326
|
225 |
msgid "Restrict menu item to a minimum role"
|
226 |
msgstr ""
|
227 |
|
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.
|
7 |
Author: Kathy Darling
|
8 |
Author URI: http://www.kathyisawesome.com
|
9 |
License: GPL2
|
@@ -54,7 +54,7 @@ class Nav_Menu_Roles {
|
|
54 |
* @constant string version number
|
55 |
* @since 1.7.1
|
56 |
*/
|
57 |
-
CONST VERSION = '1.
|
58 |
|
59 |
/**
|
60 |
* Main Nav Menu Roles Instance
|
@@ -101,11 +101,11 @@ class Nav_Menu_Roles {
|
|
101 |
|
102 |
// Admin functions
|
103 |
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
104 |
-
|
105 |
// load the textdomain
|
106 |
add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
|
107 |
|
108 |
-
// add FAQ and Donate link to plugin
|
109 |
add_filter( 'plugin_row_meta', array( $this, 'add_action_links' ), 10, 4 );
|
110 |
|
111 |
// switch the admin walker
|
@@ -140,7 +140,15 @@ class Nav_Menu_Roles {
|
|
140 |
* @return void
|
141 |
*/
|
142 |
public function admin_init() {
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
// Register Importer
|
146 |
$this->register_importer();
|
@@ -156,12 +164,10 @@ class Nav_Menu_Roles {
|
|
156 |
* @return void
|
157 |
*/
|
158 |
public function register_importer(){
|
159 |
-
|
160 |
-
include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Nav_Menu_Roles_Import.php');
|
161 |
-
|
162 |
// Register the new importer
|
163 |
if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
|
164 |
|
|
|
165 |
// Register the custom importer we've created.
|
166 |
$roles_import = new Nav_Menu_Roles_Import();
|
167 |
|
@@ -237,8 +243,8 @@ class Nav_Menu_Roles {
|
|
237 |
/**
|
238 |
* Add fields to hook added in Walker
|
239 |
* This will allow us to play nicely with any other plugin that is adding the same hook
|
240 |
-
* @params obj $item - the menu item
|
241 |
-
* @params array $args
|
242 |
* @since 1.6.0
|
243 |
*/
|
244 |
public function custom_fields( $item_id, $item, $depth, $args ) {
|
@@ -327,7 +333,7 @@ class Nav_Menu_Roles {
|
|
327 |
|
328 |
/* If the role has been selected, make sure it's checked. */
|
329 |
$checked = checked( true, ( is_array( $checked_roles ) && in_array( $role, $checked_roles ) ), false );
|
330 |
-
|
331 |
?>
|
332 |
|
333 |
<div class="role-input-holder" style="float: left; width: 33.3%; margin: 2px 0;">
|
@@ -341,7 +347,7 @@ class Nav_Menu_Roles {
|
|
341 |
|
342 |
</div>
|
343 |
|
344 |
-
<?php
|
345 |
}
|
346 |
|
347 |
|
@@ -349,7 +355,7 @@ class Nav_Menu_Roles {
|
|
349 |
* Save the roles as menu item meta
|
350 |
* @return null
|
351 |
* @since 1.4
|
352 |
-
*
|
353 |
*/
|
354 |
public function enqueue_scripts( $hook ){
|
355 |
if ( $hook == 'nav-menus.php' ){
|
@@ -383,7 +389,7 @@ class Nav_Menu_Roles {
|
|
383 |
if ( ! empty ( $custom_roles ) ) $saved_data = $custom_roles;
|
384 |
} else if ( isset( $_POST['nav-menu-logged-in-out'][$menu_item_db_id] ) && in_array( $_POST['nav-menu-logged-in-out'][$menu_item_db_id], array( 'in', 'out' ) ) ) {
|
385 |
$saved_data = $_POST['nav-menu-logged-in-out'][$menu_item_db_id];
|
386 |
-
}
|
387 |
|
388 |
if ( $saved_data ) {
|
389 |
update_post_meta( $menu_item_db_id, '_nav_menu_role', $saved_data );
|
@@ -443,7 +449,7 @@ class Nav_Menu_Roles {
|
|
443 |
$visible = false;
|
444 |
if ( is_array( $item->roles ) && ! empty( $item->roles ) ) {
|
445 |
foreach ( $item->roles as $role ) {
|
446 |
-
if ( current_user_can( $role ) )
|
447 |
$visible = true;
|
448 |
}
|
449 |
}
|
@@ -458,7 +464,7 @@ class Nav_Menu_Roles {
|
|
458 |
|
459 |
// unset non-visible item
|
460 |
if ( ! $visible ) {
|
461 |
-
$hide_children_of[] = $item->ID; // store ID of item
|
462 |
unset( $items[$key] ) ;
|
463 |
}
|
464 |
|
@@ -476,11 +482,11 @@ class Nav_Menu_Roles {
|
|
476 |
*/
|
477 |
public function maybe_upgrade() {
|
478 |
$db_version = get_option( 'nav_menu_roles_db_version', false );
|
479 |
-
|
480 |
// 1.7.7 upgrade: changed the debug notice so the old transient is invalid
|
481 |
if ( $db_version === false || version_compare( '1.7.7', $db_version, '<' ) ) {
|
482 |
update_option( 'nav_menu_roles_db_version', self::VERSION );
|
483 |
-
}
|
484 |
}
|
485 |
|
486 |
} // end class
|
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.0
|
7 |
Author: Kathy Darling
|
8 |
Author URI: http://www.kathyisawesome.com
|
9 |
License: GPL2
|
54 |
* @constant string version number
|
55 |
* @since 1.7.1
|
56 |
*/
|
57 |
+
CONST VERSION = '1.8.0';
|
58 |
|
59 |
/**
|
60 |
* Main Nav Menu Roles Instance
|
101 |
|
102 |
// Admin functions
|
103 |
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
104 |
+
|
105 |
// load the textdomain
|
106 |
add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
|
107 |
|
108 |
+
// add FAQ and Donate link to plugin
|
109 |
add_filter( 'plugin_row_meta', array( $this, 'add_action_links' ), 10, 4 );
|
110 |
|
111 |
// switch the admin walker
|
140 |
* @return void
|
141 |
*/
|
142 |
public function admin_init() {
|
143 |
+
|
144 |
+
if( ! class_exists( 'Walker_Nav_Menu_Edit_Roles' ) ){
|
145 |
+
global $wp_version;
|
146 |
+
if ( version_compare( $wp_version, '4.5.0', '>=' ) ){
|
147 |
+
include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php');
|
148 |
+
} else {
|
149 |
+
include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles.php');
|
150 |
+
}
|
151 |
+
}
|
152 |
|
153 |
// Register Importer
|
154 |
$this->register_importer();
|
164 |
* @return void
|
165 |
*/
|
166 |
public function register_importer(){
|
|
|
|
|
|
|
167 |
// Register the new importer
|
168 |
if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
|
169 |
|
170 |
+
include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Nav_Menu_Roles_Import.php');
|
171 |
// Register the custom importer we've created.
|
172 |
$roles_import = new Nav_Menu_Roles_Import();
|
173 |
|
243 |
/**
|
244 |
* Add fields to hook added in Walker
|
245 |
* This will allow us to play nicely with any other plugin that is adding the same hook
|
246 |
+
* @params obj $item - the menu item
|
247 |
+
* @params array $args
|
248 |
* @since 1.6.0
|
249 |
*/
|
250 |
public function custom_fields( $item_id, $item, $depth, $args ) {
|
333 |
|
334 |
/* If the role has been selected, make sure it's checked. */
|
335 |
$checked = checked( true, ( is_array( $checked_roles ) && in_array( $role, $checked_roles ) ), false );
|
336 |
+
|
337 |
?>
|
338 |
|
339 |
<div class="role-input-holder" style="float: left; width: 33.3%; margin: 2px 0;">
|
347 |
|
348 |
</div>
|
349 |
|
350 |
+
<?php
|
351 |
}
|
352 |
|
353 |
|
355 |
* Save the roles as menu item meta
|
356 |
* @return null
|
357 |
* @since 1.4
|
358 |
+
*
|
359 |
*/
|
360 |
public function enqueue_scripts( $hook ){
|
361 |
if ( $hook == 'nav-menus.php' ){
|
389 |
if ( ! empty ( $custom_roles ) ) $saved_data = $custom_roles;
|
390 |
} else if ( isset( $_POST['nav-menu-logged-in-out'][$menu_item_db_id] ) && in_array( $_POST['nav-menu-logged-in-out'][$menu_item_db_id], array( 'in', 'out' ) ) ) {
|
391 |
$saved_data = $_POST['nav-menu-logged-in-out'][$menu_item_db_id];
|
392 |
+
}
|
393 |
|
394 |
if ( $saved_data ) {
|
395 |
update_post_meta( $menu_item_db_id, '_nav_menu_role', $saved_data );
|
449 |
$visible = false;
|
450 |
if ( is_array( $item->roles ) && ! empty( $item->roles ) ) {
|
451 |
foreach ( $item->roles as $role ) {
|
452 |
+
if ( current_user_can( $role ) )
|
453 |
$visible = true;
|
454 |
}
|
455 |
}
|
464 |
|
465 |
// unset non-visible item
|
466 |
if ( ! $visible ) {
|
467 |
+
$hide_children_of[] = $item->ID; // store ID of item
|
468 |
unset( $items[$key] ) ;
|
469 |
}
|
470 |
|
482 |
*/
|
483 |
public function maybe_upgrade() {
|
484 |
$db_version = get_option( 'nav_menu_roles_db_version', false );
|
485 |
+
|
486 |
// 1.7.7 upgrade: changed the debug notice so the old transient is invalid
|
487 |
if ( $db_version === false || version_compare( '1.7.7', $db_version, '<' ) ) {
|
488 |
update_option( 'nav_menu_roles_db_version', self::VERSION );
|
489 |
+
}
|
490 |
}
|
491 |
|
492 |
} // end class
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
Contributors: helgatheviking
|
4 |
Donate link: https://www.paypal.me/helgatheviking
|
5 |
Tags: menu, menus, nav menu, nav menus
|
6 |
-
Requires at least: 4.
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv3
|
10 |
|
11 |
Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
|
@@ -62,6 +62,7 @@ WordPress does not have sufficient hooks in this area of the admin and until the
|
|
62 |
5. BeTheme
|
63 |
6. Yith Menu
|
64 |
7. Jupiter Theme
|
|
|
65 |
|
66 |
|
67 |
= <a id="compatibility"></a>Workaround #1 =
|
@@ -198,6 +199,9 @@ However, the Import plugin only imports certain post meta for menu items. As of
|
|
198 |
|
199 |
== Changelog ==
|
200 |
|
|
|
|
|
|
|
201 |
= 1.7.9 =
|
202 |
* revert priority of walker back to default because themes are not actually using the hook to add their own fields. sadface.
|
203 |
|
3 |
Contributors: helgatheviking
|
4 |
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.5.1
|
8 |
+
Stable tag: 1.8.0
|
9 |
License: GPLv3
|
10 |
|
11 |
Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
|
62 |
5. BeTheme
|
63 |
6. Yith Menu
|
64 |
7. Jupiter Theme
|
65 |
+
8. iMedica
|
66 |
|
67 |
|
68 |
= <a id="compatibility"></a>Workaround #1 =
|
199 |
|
200 |
== Changelog ==
|
201 |
|
202 |
+
= 1.8.0 =
|
203 |
+
* Fix style issue in WordPress 4.5
|
204 |
+
|
205 |
= 1.7.9 =
|
206 |
* revert priority of walker back to default because themes are not actually using the hook to add their own fields. sadface.
|
207 |
|