Nav Menu Roles - Version 1.10.2

Version Description

  • Fix: Strict array typecasting for nav menu classes.
Download this release

Release Info

Developer helgatheviking
Plugin Icon 128x128 Nav Menu Roles
Version 1.10.2
Comparing to
See all releases

Code changes from version 1.10.1 to 1.10.2

inc/class.Nav_Menu_Roles_Import.php CHANGED
@@ -1,308 +1,308 @@
1
- <?php
2
- /**
3
- * Nav Menu Roles Importer - import menu item meta
4
- *
5
- * @author Kathy Darling
6
- * @since 1.3
7
- */
8
-
9
- // Exit if accessed directly
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- exit;
12
- }
13
-
14
- if ( ! defined( 'WP_LOAD_IMPORTERS' ) ){
15
- return;
16
- }
17
-
18
- /** Display verbose errors */
19
- if( ! defined( 'IMPORT_DEBUG' ) ){
20
- define( 'IMPORT_DEBUG', false );
21
- }
22
-
23
- // Load Importer API
24
- require_once ABSPATH . 'wp-admin/includes/import.php';
25
-
26
- if ( ! class_exists( 'WP_Importer' ) ) {
27
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
28
- if ( file_exists( $class_wp_importer ) )
29
- require $class_wp_importer;
30
- }
31
-
32
- if ( class_exists( 'WP_Importer' ) && ! class_exists( 'Nav_Menu_Roles_Import' ) ) {
33
- class Nav_Menu_Roles_Import extends WP_Importer {
34
-
35
- var $max_wxr_version = 1.2; // max. supported WXR version
36
-
37
- var $id; // WXR attachment ID
38
-
39
- // information to import from WXR file
40
- var $version;
41
- var $posts = array();
42
- var $base_url = '';
43
-
44
-
45
- /**
46
- * __construct function.
47
- *
48
- * @access public
49
- * @return void
50
- */
51
- public function __construct() {
52
- $this->import_page = 'woocommerce_tax_rate_csv';
53
- }
54
-
55
- /**
56
- * Registered callback function for the WordPress Importer
57
- *
58
- * Manages the three separate stages of the WXR import process
59
- */
60
- function dispatch() {
61
- $this->header();
62
-
63
- $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
64
- switch ( $step ) {
65
- case 0:
66
- $this->greet();
67
- break;
68
- case 1:
69
- check_admin_referer( 'import-upload' );
70
- if ( $this->handle_upload() ) {
71
- $file = get_attached_file( $this->id );
72
- set_time_limit(0);
73
- $this->import( $file );
74
- }
75
- break;
76
- }
77
-
78
- $this->footer();
79
- }
80
-
81
- /**
82
- * The main controller for the actual import stage.
83
- *
84
- * @param string $file Path to the WXR file for importing
85
- */
86
- function import( $file ) {
87
- add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) );
88
- add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
89
-
90
- $this->import_start( $file );
91
-
92
- wp_suspend_cache_invalidation( true );
93
- $this->process_nav_menu_meta();
94
- wp_suspend_cache_invalidation( false );
95
-
96
- $this->import_end();
97
- }
98
-
99
- /**
100
- * Parses the WXR file and prepares us for the task of processing parsed data
101
- *
102
- * @param string $file Path to the WXR file for importing
103
- */
104
- function import_start( $file ) {
105
- if ( ! is_file($file) ) {
106
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
107
- echo __( 'The file does not exist, please try again.', 'nav-menu-roles' ) . '</p>';
108
- $this->footer();
109
- die();
110
- }
111
-
112
- $import_data = $this->parse( $file );
113
-
114
- if ( is_wp_error( $import_data ) ) {
115
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
116
- echo esc_html( $import_data->get_error_message() ) . '</p>';
117
- $this->footer();
118
- die();
119
- }
120
-
121
- $this->version = $import_data['version'];
122
- $this->posts = $import_data['posts'];
123
- $this->base_url = esc_url( $import_data['base_url'] );
124
-
125
- wp_defer_term_counting( true );
126
- wp_defer_comment_counting( true );
127
-
128
- do_action( 'import_start' );
129
- }
130
-
131
- /**
132
- * Performs post-import cleanup of files and the cache
133
- */
134
- function import_end() {
135
- wp_import_cleanup( $this->id );
136
-
137
- wp_cache_flush();
138
- foreach ( get_taxonomies() as $tax ) {
139
- delete_option( "{$tax}_children" );
140
- _get_term_hierarchy( $tax );
141
- }
142
-
143
- wp_defer_term_counting( false );
144
- wp_defer_comment_counting( false );
145
-
146
- echo '<p>' . __( 'All done.', 'nav-menu-roles' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'nav-menu-roles' ) . '</a>' . '</p>';
147
-
148
- do_action( 'import_end' );
149
- }
150
-
151
- /**
152
- * Handles the WXR upload and initial parsing of the file to prepare for
153
- * displaying author import options
154
- *
155
- * @return bool False if error uploading or invalid file, true otherwise
156
- */
157
- function handle_upload() {
158
- $file = wp_import_handle_upload();
159
-
160
- if ( isset( $file['error'] ) ) {
161
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
162
- echo esc_html( $file['error'] ) . '</p>';
163
- return false;
164
- } else if ( ! file_exists( $file['file'] ) ) {
165
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
166
- printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'nav-menu-roles' ), esc_html( $file['file'] ) );
167
- echo '</p>';
168
- return false;
169
- }
170
-
171
- $this->id = (int) $file['id'];
172
- $import_data = $this->parse( $file['file'] );
173
- if ( is_wp_error( $import_data ) ) {
174
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
175
- echo esc_html( $import_data->get_error_message() ) . '</p>';
176
- return false;
177
- }
178
-
179
- $this->version = $import_data['version'];
180
- if ( $this->version > $this->max_wxr_version ) {
181
- echo '<div class="error"><p><strong>';
182
- printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'nav-menu-roles' ), esc_html($import_data['version']) );
183
- echo '</strong></p></div>';
184
- }
185
-
186
- return true;
187
- }
188
-
189
-
190
-
191
- /**
192
- * Create new posts based on import information
193
- *
194
- * Posts marked as having a parent which doesn't exist will become top level items.
195
- * Doesn't create a new post if: the post type doesn't exist, the given post ID
196
- * is already noted as imported or a post with the same title and date already exists.
197
- * Note that new/updated terms, comments and meta are imported for the last of the above.
198
- */
199
- function process_nav_menu_meta() {
200
- foreach ( $this->posts as $post ) {
201
-
202
- // we only want to deal with the nav_menu_item posts
203
- if ( 'nav_menu_item' != $post['post_type'] || ! empty( $post['post_id'] ) )
204
- continue;
205
-
206
- // ok we've got a nav_menu_item
207
- $post_id = (int) $post['post_id'];
208
-
209
- // add/update post meta
210
- if ( isset( $post['postmeta'] ) ) {
211
- foreach ( $post['postmeta'] as $meta ) {
212
- $key = apply_filters( 'import_post_meta_key', $meta['key'] );
213
- $value = false;
214
-
215
-
216
- if ( $key ) {
217
- // export gets meta straight from the DB so could have a serialized string
218
- if ( ! $value )
219
- $value = maybe_unserialize( $meta['value'] );
220
-
221
- update_post_meta( $post_id, $key, $value );
222
- do_action( 'import_post_meta', $post_id, $key, $value );
223
-
224
- }
225
- }
226
- }
227
- }
228
-
229
- unset( $this->posts );
230
- }
231
-
232
-
233
-
234
-
235
- /**
236
- * Parse a WXR file
237
- *
238
- * @param string $file Path to WXR file for parsing
239
- * @return array Information gathered from the WXR file
240
- */
241
- function parse( $file ) {
242
- $parser = new WXR_Parser();
243
- return $parser->parse( $file );
244
- }
245
-
246
- // Display import page title
247
- function header() {
248
- echo '<div class="wrap">';
249
- echo '<h2>' . __( 'Import Nav Menu Roles', 'nav-menu-roles' ) . '</h2>';
250
-
251
- $updates = get_plugin_updates();
252
- $basename = plugin_basename(__FILE__);
253
- if ( isset( $updates[$basename] ) ) {
254
- $update = $updates[$basename];
255
- echo '<div class="error"><p><strong>';
256
- printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'nav-menu-roles' ), $update->update->new_version );
257
- echo '</strong></p></div>';
258
- }
259
- }
260
-
261
- // Close div.wrap
262
- function footer() {
263
- echo '</div>';
264
- }
265
-
266
- /**
267
- * Display introductory text and file upload form
268
- */
269
- function greet() {
270
- echo '<div class="narrow">';
271
- echo '<p>'.__( 'Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll import the Nav Menu Roles and any other missing post meta for the Nav Menu items.', 'nav-menu-roles' ).'</p>';
272
- echo '<p>'.__( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'nav-menu-roles' ).'</p>';
273
- wp_import_upload_form( 'admin.php?import=nav_menu_roles&amp;step=1' );
274
- echo '</div>';
275
- }
276
-
277
- /**
278
- * Decide if the given meta key maps to information we will want to import
279
- *
280
- * @param string $key The meta key to check
281
- * @return string|bool The key if we do want to import, false if not
282
- */
283
- function is_valid_meta_key( $key ) {
284
- // skip attachment metadata since we'll regenerate it from scratch
285
- // skip _edit_lock as not relevant for import
286
- if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ) ) )
287
- return false;
288
- return $key;
289
- }
290
-
291
-
292
- /**
293
- * Added to http_request_timeout filter to force timeout at 60 seconds during import
294
- * @param int $val
295
- * @return int
296
- */
297
- public function bump_request_timeout( $val ) {
298
- return 60;
299
- }
300
-
301
- // return the difference in length between two strings
302
- function cmpr_strlen( $a, $b ) {
303
- return strlen($b) - strlen($a);
304
- }
305
-
306
-
307
- } // end class
308
  } // end if
1
+ <?php
2
+ /**
3
+ * Nav Menu Roles Importer - import menu item meta
4
+ *
5
+ * @author Kathy Darling
6
+ * @since 1.3
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ if ( ! defined( 'WP_LOAD_IMPORTERS' ) ){
15
+ return;
16
+ }
17
+
18
+ /** Display verbose errors */
19
+ if( ! defined( 'IMPORT_DEBUG' ) ){
20
+ define( 'IMPORT_DEBUG', false );
21
+ }
22
+
23
+ // Load Importer API
24
+ require_once ABSPATH . 'wp-admin/includes/import.php';
25
+
26
+ if ( ! class_exists( 'WP_Importer' ) ) {
27
+ $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
28
+ if ( file_exists( $class_wp_importer ) )
29
+ require $class_wp_importer;
30
+ }
31
+
32
+ if ( class_exists( 'WP_Importer' ) && ! class_exists( 'Nav_Menu_Roles_Import' ) ) {
33
+ class Nav_Menu_Roles_Import extends WP_Importer {
34
+
35
+ var $max_wxr_version = 1.2; // max. supported WXR version
36
+
37
+ var $id; // WXR attachment ID
38
+
39
+ // information to import from WXR file
40
+ var $version;
41
+ var $posts = array();
42
+ var $base_url = '';
43
+
44
+
45
+ /**
46
+ * __construct function.
47
+ *
48
+ * @access public
49
+ * @return void
50
+ */
51
+ public function __construct() {
52
+ $this->import_page = 'woocommerce_tax_rate_csv';
53
+ }
54
+
55
+ /**
56
+ * Registered callback function for the WordPress Importer
57
+ *
58
+ * Manages the three separate stages of the WXR import process
59
+ */
60
+ function dispatch() {
61
+ $this->header();
62
+
63
+ $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
64
+ switch ( $step ) {
65
+ case 0:
66
+ $this->greet();
67
+ break;
68
+ case 1:
69
+ check_admin_referer( 'import-upload' );
70
+ if ( $this->handle_upload() ) {
71
+ $file = get_attached_file( $this->id );
72
+ set_time_limit(0);
73
+ $this->import( $file );
74
+ }
75
+ break;
76
+ }
77
+
78
+ $this->footer();
79
+ }
80
+
81
+ /**
82
+ * The main controller for the actual import stage.
83
+ *
84
+ * @param string $file Path to the WXR file for importing
85
+ */
86
+ function import( $file ) {
87
+ add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) );
88
+ add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
89
+
90
+ $this->import_start( $file );
91
+
92
+ wp_suspend_cache_invalidation( true );
93
+ $this->process_nav_menu_meta();
94
+ wp_suspend_cache_invalidation( false );
95
+
96
+ $this->import_end();
97
+ }
98
+
99
+ /**
100
+ * Parses the WXR file and prepares us for the task of processing parsed data
101
+ *
102
+ * @param string $file Path to the WXR file for importing
103
+ */
104
+ function import_start( $file ) {
105
+ if ( ! is_file($file) ) {
106
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
107
+ echo __( 'The file does not exist, please try again.', 'nav-menu-roles' ) . '</p>';
108
+ $this->footer();
109
+ die();
110
+ }
111
+
112
+ $import_data = $this->parse( $file );
113
+
114
+ if ( is_wp_error( $import_data ) ) {
115
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
116
+ echo esc_html( $import_data->get_error_message() ) . '</p>';
117
+ $this->footer();
118
+ die();
119
+ }
120
+
121
+ $this->version = $import_data['version'];
122
+ $this->posts = $import_data['posts'];
123
+ $this->base_url = esc_url( $import_data['base_url'] );
124
+
125
+ wp_defer_term_counting( true );
126
+ wp_defer_comment_counting( true );
127
+
128
+ do_action( 'import_start' );
129
+ }
130
+
131
+ /**
132
+ * Performs post-import cleanup of files and the cache
133
+ */
134
+ function import_end() {
135
+ wp_import_cleanup( $this->id );
136
+
137
+ wp_cache_flush();
138
+ foreach ( get_taxonomies() as $tax ) {
139
+ delete_option( "{$tax}_children" );
140
+ _get_term_hierarchy( $tax );
141
+ }
142
+
143
+ wp_defer_term_counting( false );
144
+ wp_defer_comment_counting( false );
145
+
146
+ echo '<p>' . __( 'All done.', 'nav-menu-roles' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'nav-menu-roles' ) . '</a>' . '</p>';
147
+
148
+ do_action( 'import_end' );
149
+ }
150
+
151
+ /**
152
+ * Handles the WXR upload and initial parsing of the file to prepare for
153
+ * displaying author import options
154
+ *
155
+ * @return bool False if error uploading or invalid file, true otherwise
156
+ */
157
+ function handle_upload() {
158
+ $file = wp_import_handle_upload();
159
+
160
+ if ( isset( $file['error'] ) ) {
161
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
162
+ echo esc_html( $file['error'] ) . '</p>';
163
+ return false;
164
+ } else if ( ! file_exists( $file['file'] ) ) {
165
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
166
+ printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'nav-menu-roles' ), esc_html( $file['file'] ) );
167
+ echo '</p>';
168
+ return false;
169
+ }
170
+
171
+ $this->id = (int) $file['id'];
172
+ $import_data = $this->parse( $file['file'] );
173
+ if ( is_wp_error( $import_data ) ) {
174
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'nav-menu-roles' ) . '</strong><br />';
175
+ echo esc_html( $import_data->get_error_message() ) . '</p>';
176
+ return false;
177
+ }
178
+
179
+ $this->version = $import_data['version'];
180
+ if ( $this->version > $this->max_wxr_version ) {
181
+ echo '<div class="error"><p><strong>';
182
+ printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'nav-menu-roles' ), esc_html($import_data['version']) );
183
+ echo '</strong></p></div>';
184
+ }
185
+
186
+ return true;
187
+ }
188
+
189
+
190
+
191
+ /**
192
+ * Create new posts based on import information
193
+ *
194
+ * Posts marked as having a parent which doesn't exist will become top level items.
195
+ * Doesn't create a new post if: the post type doesn't exist, the given post ID
196
+ * is already noted as imported or a post with the same title and date already exists.
197
+ * Note that new/updated terms, comments and meta are imported for the last of the above.
198
+ */
199
+ function process_nav_menu_meta() {
200
+ foreach ( $this->posts as $post ) {
201
+
202
+ // we only want to deal with the nav_menu_item posts
203
+ if ( 'nav_menu_item' != $post['post_type'] || ! empty( $post['post_id'] ) )
204
+ continue;
205
+
206
+ // ok we've got a nav_menu_item
207
+ $post_id = (int) $post['post_id'];
208
+
209
+ // add/update post meta
210
+ if ( isset( $post['postmeta'] ) ) {
211
+ foreach ( $post['postmeta'] as $meta ) {
212
+ $key = apply_filters( 'import_post_meta_key', $meta['key'] );
213
+ $value = false;
214
+
215
+
216
+ if ( $key ) {
217
+ // export gets meta straight from the DB so could have a serialized string
218
+ if ( ! $value )
219
+ $value = maybe_unserialize( $meta['value'] );
220
+
221
+ update_post_meta( $post_id, $key, $value );
222
+ do_action( 'import_post_meta', $post_id, $key, $value );
223
+
224
+ }
225
+ }
226
+ }
227
+ }
228
+
229
+ unset( $this->posts );
230
+ }
231
+
232
+
233
+
234
+
235
+ /**
236
+ * Parse a WXR file
237
+ *
238
+ * @param string $file Path to WXR file for parsing
239
+ * @return array Information gathered from the WXR file
240
+ */
241
+ function parse( $file ) {
242
+ $parser = new WXR_Parser();
243
+ return $parser->parse( $file );
244
+ }
245
+
246
+ // Display import page title
247
+ function header() {
248
+ echo '<div class="wrap">';
249
+ echo '<h2>' . __( 'Import Nav Menu Roles', 'nav-menu-roles' ) . '</h2>';
250
+
251
+ $updates = get_plugin_updates();
252
+ $basename = plugin_basename(__FILE__);
253
+ if ( isset( $updates[$basename] ) ) {
254
+ $update = $updates[$basename];
255
+ echo '<div class="error"><p><strong>';
256
+ printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'nav-menu-roles' ), $update->update->new_version );
257
+ echo '</strong></p></div>';
258
+ }
259
+ }
260
+
261
+ // Close div.wrap
262
+ function footer() {
263
+ echo '</div>';
264
+ }
265
+
266
+ /**
267
+ * Display introductory text and file upload form
268
+ */
269
+ function greet() {
270
+ echo '<div class="narrow">';
271
+ echo '<p>'.__( 'Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll import the Nav Menu Roles and any other missing post meta for the Nav Menu items.', 'nav-menu-roles' ).'</p>';
272
+ echo '<p>'.__( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'nav-menu-roles' ).'</p>';
273
+ wp_import_upload_form( 'admin.php?import=nav_menu_roles&amp;step=1' );
274
+ echo '</div>';
275
+ }
276
+
277
+ /**
278
+ * Decide if the given meta key maps to information we will want to import
279
+ *
280
+ * @param string $key The meta key to check
281
+ * @return string|bool The key if we do want to import, false if not
282
+ */
283
+ function is_valid_meta_key( $key ) {
284
+ // skip attachment metadata since we'll regenerate it from scratch
285
+ // skip _edit_lock as not relevant for import
286
+ if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ) ) )
287
+ return false;
288
+ return $key;
289
+ }
290
+
291
+
292
+ /**
293
+ * Added to http_request_timeout filter to force timeout at 60 seconds during import
294
+ * @param int $val
295
+ * @return int
296
+ */
297
+ public function bump_request_timeout( $val ) {
298
+ return 60;
299
+ }
300
+
301
+ // return the difference in length between two strings
302
+ function cmpr_strlen( $a, $b ) {
303
+ return strlen($b) - strlen($a);
304
+ }
305
+
306
+
307
+ } // end class
308
  } // end if
inc/class.Walker_Nav_Menu_Edit_Roles.php CHANGED
@@ -1,245 +1,245 @@
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/nav-menu.php
8
- *
9
- * @package nav-menu-roles
10
- * @since 1.0
11
- * @since WordPress 4.4.0
12
- * @uses Walker_Nav_Menu
13
- */
14
-
15
- class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu {
16
- /**
17
- * Starts the list before the elements are added.
18
- *
19
- * @see Walker_Nav_Menu::start_lvl()
20
- *
21
- * @since 3.0.0
22
- *
23
- * @param string $output Passed by reference.
24
- * @param int $depth Depth of menu item. Used for padding.
25
- * @param array $args Not used.
26
- */
27
- public function start_lvl( &$output, $depth = 0, $args = array() ) {}
28
-
29
- /**
30
- * Ends the list of after the elements are added.
31
- *
32
- * @see Walker_Nav_Menu::end_lvl()
33
- *
34
- * @since 3.0.0
35
- *
36
- * @param string $output Passed by reference.
37
- * @param int $depth Depth of menu item. Used for padding.
38
- * @param array $args Not used.
39
- */
40
- public function end_lvl( &$output, $depth = 0, $args = array() ) {}
41
-
42
- /**
43
- * Start the element output.
44
- *
45
- * @see Walker_Nav_Menu::start_el()
46
- * @since 3.0.0
47
- *
48
- * @global int $_wp_nav_menu_max_depth
49
- *
50
- * @param string $output Passed by reference. Used to append additional content.
51
- * @param object $item Menu item data object.
52
- * @param int $depth Depth of menu item. Used for padding.
53
- * @param array $args Not used.
54
- * @param int $id Not used.
55
- */
56
- public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
57
- global $_wp_nav_menu_max_depth;
58
- $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
59
-
60
- ob_start();
61
- $item_id = esc_attr( $item->ID );
62
- $removed_args = array(
63
- 'action',
64
- 'customlink-tab',
65
- 'edit-menu-item',
66
- 'menu-item',
67
- 'page-tab',
68
- '_wpnonce',
69
- );
70
-
71
- $original_title = '';
72
- if ( 'taxonomy' == $item->type ) {
73
- $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
74
- if ( is_wp_error( $original_title ) )
75
- $original_title = false;
76
- } elseif ( 'post_type' == $item->type ) {
77
- $original_object = get_post( $item->object_id );
78
- $original_title = get_the_title( $original_object->ID );
79
- } elseif ( 'post_type_archive' == $item->type ) {
80
- $original_object = get_post_type_object( $item->object );
81
- $original_title = $original_object->labels->archives;
82
- }
83
-
84
- $classes = array(
85
- 'menu-item menu-item-depth-' . $depth,
86
- 'menu-item-' . esc_attr( $item->object ),
87
- 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
88
- );
89
-
90
- $title = $item->title;
91
-
92
- if ( ! empty( $item->_invalid ) ) {
93
- $classes[] = 'menu-item-invalid';
94
- /* translators: %s: title of menu item which is invalid */
95
- $title = sprintf( __( '%s (Invalid)' , 'nav-menu-roles' ), $item->title );
96
- } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
97
- $classes[] = 'pending';
98
- /* translators: %s: title of menu item in draft status */
99
- $title = sprintf( __('%s (Pending)', 'nav-menu-roles' ), $item->title );
100
- }
101
-
102
- $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
103
-
104
- $submenu_text = '';
105
- if ( 0 == $depth )
106
- $submenu_text = 'style="display: none;"';
107
-
108
- ?>
109
- <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
110
- <div class="menu-item-bar">
111
- <div class="menu-item-handle">
112
- <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>
113
- <span class="item-controls">
114
- <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
115
- <span class="item-order hide-if-js">
116
- <a href="<?php
117
- echo wp_nonce_url(
118
- add_query_arg(
119
- array(
120
- 'action' => 'move-up-menu-item',
121
- 'menu-item' => $item_id,
122
- ),
123
- remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
124
- ),
125
- 'move-menu_item'
126
- );
127
- ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up', 'nav-menu-roles' ); ?>">&#8593;</abbr></a>
128
- |
129
- <a href="<?php
130
- echo wp_nonce_url(
131
- add_query_arg(
132
- array(
133
- 'action' => 'move-down-menu-item',
134
- 'menu-item' => $item_id,
135
- ),
136
- remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
137
- ),
138
- 'move-menu_item'
139
- );
140
- ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down', 'nav-menu-roles' ); ?>">&#8595;</abbr></a>
141
- </span>
142
- <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php esc_attr_e('Edit Menu Item', 'nav-menu-roles' ); ?>" href="<?php
143
- 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 ) ) );
144
- ?>"><?php _e( 'Edit Menu Item' , 'nav-menu-roles' ); ?></a>
145
- </span>
146
- </div>
147
- </div>
148
-
149
- <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
150
- <?php if ( 'custom' == $item->type ) : ?>
151
- <p class="field-url description description-wide">
152
- <label for="edit-menu-item-url-<?php echo $item_id; ?>">
153
- <?php _e( 'URL' , 'nav-menu-roles' ); ?><br />
154
- <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 ); ?>" />
155
- </label>
156
- </p>
157
- <?php endif; ?>
158
- <p class="description description-wide">
159
- <label for="edit-menu-item-title-<?php echo $item_id; ?>">
160
- <?php _e( 'Navigation Label' , 'nav-menu-roles' ); ?><br />
161
- <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 ); ?>" />
162
- </label>
163
- </p>
164
- <p class="field-title-attribute description description-wide">
165
- <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
166
- <?php _e( 'Title Attribute' , 'nav-menu-roles' ); ?><br />
167
- <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 ); ?>" />
168
- </label>
169
- </p>
170
- <p class="field-link-target description">
171
- <label for="edit-menu-item-target-<?php echo $item_id; ?>">
172
- <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' ); ?> />
173
- <?php _e( 'Open link in a new tab' , 'nav-menu-roles' ); ?>
174
- </label>
175
- </p>
176
- <p class="field-css-classes description description-thin">
177
- <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
178
- <?php _e( 'CSS Classes (optional)' , 'nav-menu-roles' ); ?><br />
179
- <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 ) ); ?>" />
180
- </label>
181
- </p>
182
- <p class="field-xfn description description-thin">
183
- <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
184
- <?php _e( 'Link Relationship (XFN)' , 'nav-menu-roles' ); ?><br />
185
- <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 ); ?>" />
186
- </label>
187
- </p>
188
- <p class="field-description description description-wide">
189
- <label for="edit-menu-item-description-<?php echo $item_id; ?>">
190
- <?php _e( 'Description' , 'nav-menu-roles' ); ?><br />
191
- <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>
192
- <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.', 'nav-menu-roles' ); ?></span>
193
- </label>
194
- </p>
195
-
196
- <?php
197
- // This is the added section
198
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
199
- // end added section
200
- ?>
201
-
202
- <p class="field-move hide-if-no-js description description-wide">
203
- <label>
204
- <span><?php _e( 'Move' , 'nav-menu-roles' ); ?></span>
205
- <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' , 'nav-menu-roles' ); ?></a>
206
- <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' , 'nav-menu-roles' ); ?></a>
207
- <a href="#" class="menus-move menus-move-left" data-dir="left"></a>
208
- <a href="#" class="menus-move menus-move-right" data-dir="right"></a>
209
- <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' , 'nav-menu-roles' ); ?></a>
210
- </label>
211
- </p>
212
-
213
- <div class="menu-item-actions description-wide submitbox">
214
- <?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
215
- <p class="link-to-original">
216
- <?php printf( __('Original: %s', 'nav-menu-roles' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
217
- </p>
218
- <?php endif; ?>
219
- <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
220
- echo wp_nonce_url(
221
- add_query_arg(
222
- array(
223
- 'action' => 'delete-menu-item',
224
- 'menu-item' => $item_id,
225
- ),
226
- admin_url( 'nav-menus.php' )
227
- ),
228
- 'delete-menu_item_' . $item_id
229
- ); ?>"><?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' ) ) );
230
- ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel', 'nav-menu-roles' ); ?></a>
231
- </div>
232
-
233
- <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
234
- <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 ); ?>" />
235
- <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
236
- <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 ); ?>" />
237
- <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
238
- <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
239
- </div><!-- .menu-item-settings-->
240
- <ul class="menu-item-transport"></ul>
241
- <?php
242
- $output .= ob_get_clean();
243
- }
244
-
245
- } // Walker_Nav_Menu_Edit
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/nav-menu.php
8
+ *
9
+ * @package nav-menu-roles
10
+ * @since 1.0
11
+ * @since WordPress 4.4.0
12
+ * @uses Walker_Nav_Menu
13
+ */
14
+
15
+ class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu {
16
+ /**
17
+ * Starts the list before the elements are added.
18
+ *
19
+ * @see Walker_Nav_Menu::start_lvl()
20
+ *
21
+ * @since 3.0.0
22
+ *
23
+ * @param string $output Passed by reference.
24
+ * @param int $depth Depth of menu item. Used for padding.
25
+ * @param array $args Not used.
26
+ */
27
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {}
28
+
29
+ /**
30
+ * Ends the list of after the elements are added.
31
+ *
32
+ * @see Walker_Nav_Menu::end_lvl()
33
+ *
34
+ * @since 3.0.0
35
+ *
36
+ * @param string $output Passed by reference.
37
+ * @param int $depth Depth of menu item. Used for padding.
38
+ * @param array $args Not used.
39
+ */
40
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {}
41
+
42
+ /**
43
+ * Start the element output.
44
+ *
45
+ * @see Walker_Nav_Menu::start_el()
46
+ * @since 3.0.0
47
+ *
48
+ * @global int $_wp_nav_menu_max_depth
49
+ *
50
+ * @param string $output Passed by reference. Used to append additional content.
51
+ * @param object $item Menu item data object.
52
+ * @param int $depth Depth of menu item. Used for padding.
53
+ * @param array $args Not used.
54
+ * @param int $id Not used.
55
+ */
56
+ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
57
+ global $_wp_nav_menu_max_depth;
58
+ $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
59
+
60
+ ob_start();
61
+ $item_id = esc_attr( $item->ID );
62
+ $removed_args = array(
63
+ 'action',
64
+ 'customlink-tab',
65
+ 'edit-menu-item',
66
+ 'menu-item',
67
+ 'page-tab',
68
+ '_wpnonce',
69
+ );
70
+
71
+ $original_title = '';
72
+ if ( 'taxonomy' == $item->type ) {
73
+ $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
74
+ if ( is_wp_error( $original_title ) )
75
+ $original_title = false;
76
+ } elseif ( 'post_type' == $item->type ) {
77
+ $original_object = get_post( $item->object_id );
78
+ $original_title = get_the_title( $original_object->ID );
79
+ } elseif ( 'post_type_archive' == $item->type ) {
80
+ $original_object = get_post_type_object( $item->object );
81
+ $original_title = $original_object->labels->archives;
82
+ }
83
+
84
+ $classes = array(
85
+ 'menu-item menu-item-depth-' . $depth,
86
+ 'menu-item-' . esc_attr( $item->object ),
87
+ 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
88
+ );
89
+
90
+ $title = $item->title;
91
+
92
+ if ( ! empty( $item->_invalid ) ) {
93
+ $classes[] = 'menu-item-invalid';
94
+ /* translators: %s: title of menu item which is invalid */
95
+ $title = sprintf( __( '%s (Invalid)' , 'nav-menu-roles' ), $item->title );
96
+ } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
97
+ $classes[] = 'pending';
98
+ /* translators: %s: title of menu item in draft status */
99
+ $title = sprintf( __('%s (Pending)', 'nav-menu-roles' ), $item->title );
100
+ }
101
+
102
+ $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
103
+
104
+ $submenu_text = '';
105
+ if ( 0 == $depth )
106
+ $submenu_text = 'style="display: none;"';
107
+
108
+ ?>
109
+ <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
110
+ <div class="menu-item-bar">
111
+ <div class="menu-item-handle">
112
+ <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>
113
+ <span class="item-controls">
114
+ <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
115
+ <span class="item-order hide-if-js">
116
+ <a href="<?php
117
+ echo wp_nonce_url(
118
+ add_query_arg(
119
+ array(
120
+ 'action' => 'move-up-menu-item',
121
+ 'menu-item' => $item_id,
122
+ ),
123
+ remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
124
+ ),
125
+ 'move-menu_item'
126
+ );
127
+ ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up', 'nav-menu-roles' ); ?>">&#8593;</abbr></a>
128
+ |
129
+ <a href="<?php
130
+ echo wp_nonce_url(
131
+ add_query_arg(
132
+ array(
133
+ 'action' => 'move-down-menu-item',
134
+ 'menu-item' => $item_id,
135
+ ),
136
+ remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
137
+ ),
138
+ 'move-menu_item'
139
+ );
140
+ ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down', 'nav-menu-roles' ); ?>">&#8595;</abbr></a>
141
+ </span>
142
+ <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php esc_attr_e('Edit Menu Item', 'nav-menu-roles' ); ?>" href="<?php
143
+ 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 ) ) );
144
+ ?>"><?php _e( 'Edit Menu Item' , 'nav-menu-roles' ); ?></a>
145
+ </span>
146
+ </div>
147
+ </div>
148
+
149
+ <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
150
+ <?php if ( 'custom' == $item->type ) : ?>
151
+ <p class="field-url description description-wide">
152
+ <label for="edit-menu-item-url-<?php echo $item_id; ?>">
153
+ <?php _e( 'URL' , 'nav-menu-roles' ); ?><br />
154
+ <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 ); ?>" />
155
+ </label>
156
+ </p>
157
+ <?php endif; ?>
158
+ <p class="description description-wide">
159
+ <label for="edit-menu-item-title-<?php echo $item_id; ?>">
160
+ <?php _e( 'Navigation Label' , 'nav-menu-roles' ); ?><br />
161
+ <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 ); ?>" />
162
+ </label>
163
+ </p>
164
+ <p class="field-title-attribute description description-wide">
165
+ <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
166
+ <?php _e( 'Title Attribute' , 'nav-menu-roles' ); ?><br />
167
+ <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 ); ?>" />
168
+ </label>
169
+ </p>
170
+ <p class="field-link-target description">
171
+ <label for="edit-menu-item-target-<?php echo $item_id; ?>">
172
+ <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' ); ?> />
173
+ <?php _e( 'Open link in a new tab' , 'nav-menu-roles' ); ?>
174
+ </label>
175
+ </p>
176
+ <p class="field-css-classes description description-thin">
177
+ <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
178
+ <?php _e( 'CSS Classes (optional)' , 'nav-menu-roles' ); ?><br />
179
+ <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 ) ); ?>" />
180
+ </label>
181
+ </p>
182
+ <p class="field-xfn description description-thin">
183
+ <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
184
+ <?php _e( 'Link Relationship (XFN)' , 'nav-menu-roles' ); ?><br />
185
+ <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 ); ?>" />
186
+ </label>
187
+ </p>
188
+ <p class="field-description description description-wide">
189
+ <label for="edit-menu-item-description-<?php echo $item_id; ?>">
190
+ <?php _e( 'Description' , 'nav-menu-roles' ); ?><br />
191
+ <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>
192
+ <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.', 'nav-menu-roles' ); ?></span>
193
+ </label>
194
+ </p>
195
+
196
+ <?php
197
+ // This is the added section
198
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
199
+ // end added section
200
+ ?>
201
+
202
+ <p class="field-move hide-if-no-js description description-wide">
203
+ <label>
204
+ <span><?php _e( 'Move' , 'nav-menu-roles' ); ?></span>
205
+ <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' , 'nav-menu-roles' ); ?></a>
206
+ <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' , 'nav-menu-roles' ); ?></a>
207
+ <a href="#" class="menus-move menus-move-left" data-dir="left"></a>
208
+ <a href="#" class="menus-move menus-move-right" data-dir="right"></a>
209
+ <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' , 'nav-menu-roles' ); ?></a>
210
+ </label>
211
+ </p>
212
+
213
+ <div class="menu-item-actions description-wide submitbox">
214
+ <?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
215
+ <p class="link-to-original">
216
+ <?php printf( __('Original: %s', 'nav-menu-roles' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
217
+ </p>
218
+ <?php endif; ?>
219
+ <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
220
+ echo wp_nonce_url(
221
+ add_query_arg(
222
+ array(
223
+ 'action' => 'delete-menu-item',
224
+ 'menu-item' => $item_id,
225
+ ),
226
+ admin_url( 'nav-menus.php' )
227
+ ),
228
+ 'delete-menu_item_' . $item_id
229
+ ); ?>"><?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' ) ) );
230
+ ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel', 'nav-menu-roles' ); ?></a>
231
+ </div>
232
+
233
+ <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
234
+ <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 ); ?>" />
235
+ <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
236
+ <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 ); ?>" />
237
+ <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
238
+ <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
239
+ </div><!-- .menu-item-settings-->
240
+ <ul class="menu-item-transport"></ul>
241
+ <?php
242
+ $output .= ob_get_clean();
243
+ }
244
+
245
+ } // Walker_Nav_Menu_Edit
inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php CHANGED
@@ -1,248 +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' ) ?>">&#8593;</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' ) ?>">&#8595;</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
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' ) ?>">&#8593;</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' ) ?>">&#8595;</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
inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
- /**
3
- * Custom Walker for Nav Menu Editor
4
- * Add wp_nav_menu_item_custom_fields hook
5
- * Hat tip to @kucrut and Menu Icons for the preg_replace() idea
6
- * means I no longer have to translate core strings
7
- *
8
- * @package Nav Menu Roles
9
- * @since 1.8.6
10
- * @uses Walker_Nav_Menu_Edit
11
- */
12
- class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu_Edit {
13
-
14
- /**
15
- * Start the element output.
16
- *
17
- * @see Walker_Nav_Menu::start_el()
18
- *
19
- * @param string $output Passed by reference. Used to append additional content.
20
- * @param object $item Menu item data object.
21
- * @param int $depth Depth of menu item. Used for padding.
22
- * @param array $args Not used.
23
- * @param int $id Not used.
24
- */
25
- public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
26
- $item_output = '';
27
- $output .= parent::start_el( $item_output, $item, $depth, $args, $id );
28
- $output .= preg_replace(
29
- // NOTE: Check this regex on major WP version updates!
30
- '/(?=<fieldset[^>]+class="[^"]*field-move)/',
31
- $this->get_custom_fields( $item, $depth, $args ),
32
- $item_output
33
- );
34
- }
35
-
36
-
37
- /**
38
- * Get custom fields
39
- *
40
- * @access protected
41
- * @since 0.1.0
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
- * @param int $id Nav menu ID.
48
- *
49
- * @return string Form fields
50
- */
51
- protected function get_custom_fields( $item, $depth, $args = array(), $id = 0 ) {
52
- ob_start();
53
- $item_id = intval( $item->ID );
54
- /**
55
- * Get menu item custom fields from plugins/themes
56
- *
57
- * @since 0.1.0
58
- *
59
- * @param int $item_id post ID of menu
60
- * @param object $item Menu item data object.
61
- * @param int $depth Depth of menu item. Used for padding.
62
- * @param array $args Menu item args.
63
- *
64
- * @return string Custom fields
65
- */
66
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
67
- return ob_get_clean();
68
- }
69
  } // Walker_Nav_Menu_Edit
1
+ <?php
2
+ /**
3
+ * Custom Walker for Nav Menu Editor
4
+ * Add wp_nav_menu_item_custom_fields hook
5
+ * Hat tip to @kucrut and Menu Icons for the preg_replace() idea
6
+ * means I no longer have to translate core strings
7
+ *
8
+ * @package Nav Menu Roles
9
+ * @since 1.8.6
10
+ * @uses Walker_Nav_Menu_Edit
11
+ */
12
+ class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu_Edit {
13
+
14
+ /**
15
+ * Start the element output.
16
+ *
17
+ * @see Walker_Nav_Menu::start_el()
18
+ *
19
+ * @param string $output Passed by reference. Used to append additional content.
20
+ * @param object $item Menu item data object.
21
+ * @param int $depth Depth of menu item. Used for padding.
22
+ * @param array $args Not used.
23
+ * @param int $id Not used.
24
+ */
25
+ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
26
+ $item_output = '';
27
+ $output .= parent::start_el( $item_output, $item, $depth, $args, $id );
28
+ $output .= preg_replace(
29
+ // NOTE: Check this regex on major WP version updates!
30
+ '/(?=<fieldset[^>]+class="[^"]*field-move)/',
31
+ $this->get_custom_fields( $item, $depth, $args ),
32
+ $item_output
33
+ );
34
+ }
35
+
36
+
37
+ /**
38
+ * Get custom fields
39
+ *
40
+ * @access protected
41
+ * @since 0.1.0
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
+ * @param int $id Nav menu ID.
48
+ *
49
+ * @return string Form fields
50
+ */
51
+ protected function get_custom_fields( $item, $depth, $args = array(), $id = 0 ) {
52
+ ob_start();
53
+ $item_id = intval( $item->ID );
54
+ /**
55
+ * Get menu item custom fields from plugins/themes
56
+ *
57
+ * @since 0.1.0
58
+ *
59
+ * @param int $item_id post ID of menu
60
+ * @param object $item Menu item data object.
61
+ * @param int $depth Depth of menu item. Used for padding.
62
+ * @param array $args Menu item args.
63
+ *
64
+ * @return string Custom fields
65
+ */
66
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
67
+ return ob_get_clean();
68
+ }
69
  } // Walker_Nav_Menu_Edit
js/nav-menu-roles.js CHANGED
@@ -1,27 +1,27 @@
1
- ;(function($) {
2
-
3
- $('.nav_menu_logged_in_out_field').each(function(i){
4
-
5
- var $field = $(this);
6
-
7
- var id = $field.find('input.nav-menu-id').val();
8
-
9
- // if set to display by role (aka is null) then show the roles list, otherwise hide
10
- if( $field.find('input.nav-menu-logged-in-out:checked').val() === 'in' ){
11
- $field.next('.nav_menu_role_field').show();
12
- } else {
13
- $field.next('.nav_menu_role_field').hide();
14
- }
15
- });
16
-
17
- // on in/out/role change, hide/show the roles
18
- $('#menu-to-edit').on('change', 'input.nav-menu-logged-in-out', function() {
19
- if( $(this).val() === 'in' ){
20
- $(this).parentsUntil('.nav_menu_logged_in_out').next('.nav_menu_role_field').slideDown();
21
- } else {
22
- $(this).parentsUntil('.nav_menu_logged_in_out').next('.nav_menu_role_field').slideUp();
23
- }
24
- });
25
-
26
-
27
  })(jQuery);
1
+ ;(function($) {
2
+
3
+ $('.nav_menu_logged_in_out_field').each(function(i){
4
+
5
+ var $field = $(this);
6
+
7
+ var id = $field.find('input.nav-menu-id').val();
8
+
9
+ // if set to display by role (aka is null) then show the roles list, otherwise hide
10
+ if( $field.find('input.nav-menu-logged-in-out:checked').val() === 'in' ){
11
+ $field.next('.nav_menu_role_field').show();
12
+ } else {
13
+ $field.next('.nav_menu_role_field').hide();
14
+ }
15
+ });
16
+
17
+ // on in/out/role change, hide/show the roles
18
+ $('#menu-to-edit').on('change', 'input.nav-menu-logged-in-out', function() {
19
+ if( $(this).val() === 'in' ){
20
+ $(this).parentsUntil('.nav_menu_logged_in_out').next('.nav_menu_role_field').slideDown();
21
+ } else {
22
+ $(this).parentsUntil('.nav_menu_logged_in_out').next('.nav_menu_role_field').slideUp();
23
+ }
24
+ });
25
+
26
+
27
  })(jQuery);
js/nav-menu-roles.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! nav-menu-roles 1.8.6 */
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.6 */
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);
languages/nav-menu-roles-fa.po CHANGED
@@ -1,216 +1,216 @@
1
- # Copyright (C) 2015 Nav Menu Roles
2
- # This file is distributed under the same license as the Nav Menu Roles package.
3
- # Translators:
4
- # Zahed Alfak <tamass4116@gmail.com>, 2015
5
- msgid ""
6
- msgstr ""
7
- "Project-Id-Version: Nav Menu Roles\n"
8
- "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/nav-menu-roles\n"
9
- "POT-Creation-Date: 2015-04-30 07:17:10+00:00\n"
10
- "PO-Revision-Date: 2015-05-07 20:17+0000\n"
11
- "Last-Translator: Zahed Alfak <tamass4116@gmail.com>\n"
12
- "Language-Team: Persian (http://www.transifex.com/projects/p/nav-menu-roles/language/fa/)\n"
13
- "MIME-Version: 1.0\n"
14
- "Content-Type: text/plain; charset=UTF-8\n"
15
- "Content-Transfer-Encoding: 8bit\n"
16
- "Language: fa\n"
17
- "Plural-Forms: nplurals=1; plural=0;\n"
18
-
19
- #: inc/class.Nav_Menu_Roles_Import.php:106
20
- #: inc/class.Nav_Menu_Roles_Import.php:115
21
- #: inc/class.Nav_Menu_Roles_Import.php:161
22
- #: inc/class.Nav_Menu_Roles_Import.php:165
23
- #: inc/class.Nav_Menu_Roles_Import.php:174
24
- msgid "Sorry, there has been an error."
25
- msgstr "با عرض پوزش، خطایی رخ داده است."
26
-
27
- #: inc/class.Nav_Menu_Roles_Import.php:107
28
- msgid "The file does not exist, please try again."
29
- msgstr "فایل وجود ندارد، لطفا دوباره سعی کنید."
30
-
31
- #: inc/class.Nav_Menu_Roles_Import.php:146
32
- msgid "All done."
33
- msgstr "تمام شد."
34
-
35
- #: inc/class.Nav_Menu_Roles_Import.php:146
36
- msgid "Have fun!"
37
- msgstr "خوش بگذره!"
38
-
39
- #: inc/class.Nav_Menu_Roles_Import.php:166
40
- msgid ""
41
- "The export file could not be found at <code>%s</code>. It is likely that "
42
- "this was caused by a permissions problem."
43
- msgstr "ر"
44
-
45
- #: inc/class.Nav_Menu_Roles_Import.php:182
46
- msgid ""
47
- "This WXR file (version %s) may not be supported by this version of the "
48
- "importer. Please consider updating."
49
- msgstr ""
50
-
51
- #: inc/class.Nav_Menu_Roles_Import.php:250
52
- msgid "Import Nav Menu Roles"
53
- msgstr "نقش منوی واردات ناو"
54
-
55
- #: inc/class.Nav_Menu_Roles_Import.php:257
56
- msgid ""
57
- "A new version of this importer is available. Please update to version %s to "
58
- "ensure compatibility with newer export files."
59
- msgstr ""
60
-
61
- #: inc/class.Nav_Menu_Roles_Import.php:272
62
- msgid ""
63
- "Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll "
64
- "import the Nav Menu Roles and any other missing post meta for the Nav Menu "
65
- "items."
66
- msgstr ""
67
-
68
- #: inc/class.Nav_Menu_Roles_Import.php:273
69
- msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
70
- msgstr ""
71
-
72
- #. translators: %s: title of menu item which is invalid
73
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:87
74
- msgid "%s (Invalid)"
75
- msgstr "٪s (نامعتبر)"
76
-
77
- #. translators: %s: title of menu item in draft status
78
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:91
79
- msgid "%s (Pending)"
80
- msgstr "٪s (در انتظار)"
81
-
82
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:104
83
- msgid "sub item"
84
- msgstr "زیرمنو"
85
-
86
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:119
87
- msgid "Move up"
88
- msgstr "حرکت به بالا"
89
-
90
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:132
91
- msgid "Move down"
92
- msgstr "حرکت به پایین"
93
-
94
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:134
95
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:136
96
- msgid "Edit Menu Item"
97
- msgstr "ویرایش آیتم های منو"
98
-
99
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:145
100
- msgid "URL"
101
- msgstr "آدرس"
102
-
103
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:152
104
- msgid "Navigation Label"
105
- msgstr "برچسب ناوبری"
106
-
107
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:158
108
- msgid "Title Attribute"
109
- msgstr "عنوان صفت"
110
-
111
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:165
112
- msgid "Open link in a new window/tab"
113
- msgstr "باز کردن پیوند در پنجره جدید / تب"
114
-
115
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:170
116
- msgid "CSS Classes (optional)"
117
- msgstr "کلاس های سی اس اس (اختیاری)"
118
-
119
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:176
120
- msgid "Link Relationship (XFN)"
121
- msgstr "رابطه لینک (XFN)"
122
-
123
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:182
124
- msgid "Description"
125
- msgstr "توضیحات"
126
-
127
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:184
128
- msgid ""
129
- "The description will be displayed in the menu if the current theme supports "
130
- "it."
131
- msgstr "توضیحات منو داده خواهد شد اگر تم مورد نظر را پشتیبانی کند ."
132
-
133
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:196
134
- msgid "Move"
135
- msgstr "انتقال"
136
-
137
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:197
138
- msgid "Up one"
139
- msgstr "بالا"
140
-
141
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:198
142
- msgid "Down one"
143
- msgstr "پایین"
144
-
145
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:201
146
- msgid "To the top"
147
- msgstr "به بالا"
148
-
149
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:208
150
- msgid "Original: %s"
151
- msgstr "اصلی :"
152
-
153
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:221
154
- msgid "Remove"
155
- msgstr "حذف"
156
-
157
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:222
158
- msgid "Cancel"
159
- msgstr "لغو"
160
-
161
- #: nav-menu-roles.php:76 nav-menu-roles.php:85
162
- msgid "Cheatin&#8217; huh?"
163
- msgstr ""
164
-
165
- #. Plugin Name of the plugin/theme
166
- msgid "Nav Menu Roles"
167
- msgstr "قوانین منوی ناوبری"
168
-
169
- #: nav-menu-roles.php:163
170
- msgid ""
171
- "Import %snav menu roles%s and other menu item meta skipped by the default "
172
- "importer"
173
- msgstr ""
174
-
175
- #: nav-menu-roles.php:219
176
- msgid ""
177
- "Nav Menu Roles has detected a possible conflict with the following functions"
178
- " or classes: %1$s. Please see the %2$sFAQ%3$s for more information and "
179
- "possible resolution. | %4$sHide Notice%3$s"
180
- msgstr ""
181
-
182
- #: nav-menu-roles.php:316
183
- msgid "Display Mode"
184
- msgstr "حالت نمایش"
185
-
186
- #: nav-menu-roles.php:324
187
- msgid "Logged In Users"
188
- msgstr "کاربران وارد شده"
189
-
190
- #: nav-menu-roles.php:331
191
- msgid "Logged Out Users"
192
- msgstr "کاربران از سیستم خارج شده"
193
-
194
- #: nav-menu-roles.php:338
195
- msgid "Everyone"
196
- msgstr "همه"
197
-
198
- #: nav-menu-roles.php:345
199
- msgid "Limit logged in users to specific roles"
200
- msgstr "محدود کردن کاربر به قوانین خاص"
201
-
202
- #. Plugin URI of the plugin/theme
203
- msgid "http://www.kathyisawesome.com/449/nav-menu-roles/"
204
- msgstr "http://www.kathyisawesome.com/449/nav-menu-roles/"
205
-
206
- #. Description of the plugin/theme
207
- msgid "Hide custom menu items based on user roles"
208
- msgstr ""
209
-
210
- #. Author of the plugin/theme
211
- msgid "Kathy Darling"
212
- msgstr "Kathy Darling"
213
-
214
- #. Author URI of the plugin/theme
215
- msgid "http://www.kathyisawesome.com"
216
- msgstr "http://www.kathyisawesome.com"
1
+ # Copyright (C) 2015 Nav Menu Roles
2
+ # This file is distributed under the same license as the Nav Menu Roles package.
3
+ # Translators:
4
+ # Zahed Alfak <tamass4116@gmail.com>, 2015
5
+ msgid ""
6
+ msgstr ""
7
+ "Project-Id-Version: Nav Menu Roles\n"
8
+ "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/nav-menu-roles\n"
9
+ "POT-Creation-Date: 2015-04-30 07:17:10+00:00\n"
10
+ "PO-Revision-Date: 2015-05-07 20:17+0000\n"
11
+ "Last-Translator: Zahed Alfak <tamass4116@gmail.com>\n"
12
+ "Language-Team: Persian (http://www.transifex.com/projects/p/nav-menu-roles/language/fa/)\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "Language: fa\n"
17
+ "Plural-Forms: nplurals=1; plural=0;\n"
18
+
19
+ #: inc/class.Nav_Menu_Roles_Import.php:106
20
+ #: inc/class.Nav_Menu_Roles_Import.php:115
21
+ #: inc/class.Nav_Menu_Roles_Import.php:161
22
+ #: inc/class.Nav_Menu_Roles_Import.php:165
23
+ #: inc/class.Nav_Menu_Roles_Import.php:174
24
+ msgid "Sorry, there has been an error."
25
+ msgstr "با عرض پوزش، خطایی رخ داده است."
26
+
27
+ #: inc/class.Nav_Menu_Roles_Import.php:107
28
+ msgid "The file does not exist, please try again."
29
+ msgstr "فایل وجود ندارد، لطفا دوباره سعی کنید."
30
+
31
+ #: inc/class.Nav_Menu_Roles_Import.php:146
32
+ msgid "All done."
33
+ msgstr "تمام شد."
34
+
35
+ #: inc/class.Nav_Menu_Roles_Import.php:146
36
+ msgid "Have fun!"
37
+ msgstr "خوش بگذره!"
38
+
39
+ #: inc/class.Nav_Menu_Roles_Import.php:166
40
+ msgid ""
41
+ "The export file could not be found at <code>%s</code>. It is likely that "
42
+ "this was caused by a permissions problem."
43
+ msgstr "ر"
44
+
45
+ #: inc/class.Nav_Menu_Roles_Import.php:182
46
+ msgid ""
47
+ "This WXR file (version %s) may not be supported by this version of the "
48
+ "importer. Please consider updating."
49
+ msgstr ""
50
+
51
+ #: inc/class.Nav_Menu_Roles_Import.php:250
52
+ msgid "Import Nav Menu Roles"
53
+ msgstr "نقش منوی واردات ناو"
54
+
55
+ #: inc/class.Nav_Menu_Roles_Import.php:257
56
+ msgid ""
57
+ "A new version of this importer is available. Please update to version %s to "
58
+ "ensure compatibility with newer export files."
59
+ msgstr ""
60
+
61
+ #: inc/class.Nav_Menu_Roles_Import.php:272
62
+ msgid ""
63
+ "Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll "
64
+ "import the Nav Menu Roles and any other missing post meta for the Nav Menu "
65
+ "items."
66
+ msgstr ""
67
+
68
+ #: inc/class.Nav_Menu_Roles_Import.php:273
69
+ msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
70
+ msgstr ""
71
+
72
+ #. translators: %s: title of menu item which is invalid
73
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:87
74
+ msgid "%s (Invalid)"
75
+ msgstr "٪s (نامعتبر)"
76
+
77
+ #. translators: %s: title of menu item in draft status
78
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:91
79
+ msgid "%s (Pending)"
80
+ msgstr "٪s (در انتظار)"
81
+
82
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:104
83
+ msgid "sub item"
84
+ msgstr "زیرمنو"
85
+
86
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:119
87
+ msgid "Move up"
88
+ msgstr "حرکت به بالا"
89
+
90
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:132
91
+ msgid "Move down"
92
+ msgstr "حرکت به پایین"
93
+
94
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:134
95
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:136
96
+ msgid "Edit Menu Item"
97
+ msgstr "ویرایش آیتم های منو"
98
+
99
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:145
100
+ msgid "URL"
101
+ msgstr "آدرس"
102
+
103
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:152
104
+ msgid "Navigation Label"
105
+ msgstr "برچسب ناوبری"
106
+
107
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:158
108
+ msgid "Title Attribute"
109
+ msgstr "عنوان صفت"
110
+
111
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:165
112
+ msgid "Open link in a new window/tab"
113
+ msgstr "باز کردن پیوند در پنجره جدید / تب"
114
+
115
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:170
116
+ msgid "CSS Classes (optional)"
117
+ msgstr "کلاس های سی اس اس (اختیاری)"
118
+
119
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:176
120
+ msgid "Link Relationship (XFN)"
121
+ msgstr "رابطه لینک (XFN)"
122
+
123
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:182
124
+ msgid "Description"
125
+ msgstr "توضیحات"
126
+
127
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:184
128
+ msgid ""
129
+ "The description will be displayed in the menu if the current theme supports "
130
+ "it."
131
+ msgstr "توضیحات منو داده خواهد شد اگر تم مورد نظر را پشتیبانی کند ."
132
+
133
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:196
134
+ msgid "Move"
135
+ msgstr "انتقال"
136
+
137
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:197
138
+ msgid "Up one"
139
+ msgstr "بالا"
140
+
141
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:198
142
+ msgid "Down one"
143
+ msgstr "پایین"
144
+
145
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:201
146
+ msgid "To the top"
147
+ msgstr "به بالا"
148
+
149
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:208
150
+ msgid "Original: %s"
151
+ msgstr "اصلی :"
152
+
153
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:221
154
+ msgid "Remove"
155
+ msgstr "حذف"
156
+
157
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:222
158
+ msgid "Cancel"
159
+ msgstr "لغو"
160
+
161
+ #: nav-menu-roles.php:76 nav-menu-roles.php:85
162
+ msgid "Cheatin&#8217; huh?"
163
+ msgstr ""
164
+
165
+ #. Plugin Name of the plugin/theme
166
+ msgid "Nav Menu Roles"
167
+ msgstr "قوانین منوی ناوبری"
168
+
169
+ #: nav-menu-roles.php:163
170
+ msgid ""
171
+ "Import %snav menu roles%s and other menu item meta skipped by the default "
172
+ "importer"
173
+ msgstr ""
174
+
175
+ #: nav-menu-roles.php:219
176
+ msgid ""
177
+ "Nav Menu Roles has detected a possible conflict with the following functions"
178
+ " or classes: %1$s. Please see the %2$sFAQ%3$s for more information and "
179
+ "possible resolution. | %4$sHide Notice%3$s"
180
+ msgstr ""
181
+
182
+ #: nav-menu-roles.php:316
183
+ msgid "Display Mode"
184
+ msgstr "حالت نمایش"
185
+
186
+ #: nav-menu-roles.php:324
187
+ msgid "Logged In Users"
188
+ msgstr "کاربران وارد شده"
189
+
190
+ #: nav-menu-roles.php:331
191
+ msgid "Logged Out Users"
192
+ msgstr "کاربران از سیستم خارج شده"
193
+
194
+ #: nav-menu-roles.php:338
195
+ msgid "Everyone"
196
+ msgstr "همه"
197
+
198
+ #: nav-menu-roles.php:345
199
+ msgid "Limit logged in users to specific roles"
200
+ msgstr "محدود کردن کاربر به قوانین خاص"
201
+
202
+ #. Plugin URI of the plugin/theme
203
+ msgid "http://www.kathyisawesome.com/449/nav-menu-roles/"
204
+ msgstr "http://www.kathyisawesome.com/449/nav-menu-roles/"
205
+
206
+ #. Description of the plugin/theme
207
+ msgid "Hide custom menu items based on user roles"
208
+ msgstr ""
209
+
210
+ #. Author of the plugin/theme
211
+ msgid "Kathy Darling"
212
+ msgstr "Kathy Darling"
213
+
214
+ #. Author URI of the plugin/theme
215
+ msgid "http://www.kathyisawesome.com"
216
+ msgstr "http://www.kathyisawesome.com"
languages/nav-menu-roles-it.po CHANGED
@@ -1,216 +1,216 @@
1
- # Copyright (C) 2015 Nav Menu Roles
2
- # This file is distributed under the same license as the Nav Menu Roles package.
3
- # Translators:
4
- # Davide Pantè <d.pante@sododesign.it>, 2015
5
- msgid ""
6
- msgstr ""
7
- "Project-Id-Version: Nav Menu Roles\n"
8
- "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/nav-menu-roles\n"
9
- "POT-Creation-Date: 2015-07-31 01:01:52+00:00\n"
10
- "PO-Revision-Date: 2015-08-01 01:01+0000\n"
11
- "Last-Translator: Davide Pantè <d.pante@sododesign.it>\n"
12
- "Language-Team: Italian (http://www.transifex.com/projects/p/nav-menu-roles/language/it/)\n"
13
- "MIME-Version: 1.0\n"
14
- "Content-Type: text/plain; charset=UTF-8\n"
15
- "Content-Transfer-Encoding: 8bit\n"
16
- "Language: it\n"
17
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
-
19
- #: inc/class.Nav_Menu_Roles_Import.php:106
20
- #: inc/class.Nav_Menu_Roles_Import.php:115
21
- #: inc/class.Nav_Menu_Roles_Import.php:161
22
- #: inc/class.Nav_Menu_Roles_Import.php:165
23
- #: inc/class.Nav_Menu_Roles_Import.php:174
24
- msgid "Sorry, there has been an error."
25
- msgstr "Siamo spiacenti, si è verificato un errore."
26
-
27
- #: inc/class.Nav_Menu_Roles_Import.php:107
28
- msgid "The file does not exist, please try again."
29
- msgstr "Il file non esiste, si prega di riprovare."
30
-
31
- #: inc/class.Nav_Menu_Roles_Import.php:146
32
- msgid "All done."
33
- msgstr "Finito."
34
-
35
- #: inc/class.Nav_Menu_Roles_Import.php:146
36
- msgid "Have fun!"
37
- msgstr "Divertirti!"
38
-
39
- #: inc/class.Nav_Menu_Roles_Import.php:166
40
- msgid ""
41
- "The export file could not be found at <code>%s</code>. It is likely that "
42
- "this was caused by a permissions problem."
43
- msgstr "Il file di esportazione non è stato trovato in <code>%s</code>. E' probabile che questo è stato causato da un problema di autorizzazioni."
44
-
45
- #: inc/class.Nav_Menu_Roles_Import.php:182
46
- msgid ""
47
- "This WXR file (version %s) may not be supported by this version of the "
48
- "importer. Please consider updating."
49
- msgstr "Questo file WXR (versione %s) potrebbe non essere supportato da questa versione dell'importatore. Si prega di prendere in considerazione l'aggiornamento."
50
-
51
- #: inc/class.Nav_Menu_Roles_Import.php:250
52
- msgid "Import Nav Menu Roles"
53
- msgstr "Importa Nav Menu Roles"
54
-
55
- #: inc/class.Nav_Menu_Roles_Import.php:257
56
- msgid ""
57
- "A new version of this importer is available. Please update to version %s to "
58
- "ensure compatibility with newer export files."
59
- msgstr "Una nuova versione di questo importatore è disponibile. Si prega di aggiornare alla versione %s per garantire la compatibilità con i file di esportazione più recenti."
60
-
61
- #: inc/class.Nav_Menu_Roles_Import.php:272
62
- msgid ""
63
- "Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll "
64
- "import the Nav Menu Roles and any other missing post meta for the Nav Menu "
65
- "items."
66
- msgstr "Ri-caricare il tuo file normale WordPress eXtended RSS (WXR) e noi&#8217;ll importiamo i ruoli del Nav Menu Roles e qualsiasi altro post meta mancante per le voci del Nav Menu."
67
-
68
- #: inc/class.Nav_Menu_Roles_Import.php:273
69
- msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
70
- msgstr "Scegliere un file WXR (.xml) per caricare, quindi fare clic su Carica file e importa."
71
-
72
- #. translators: %s: title of menu item which is invalid
73
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:87
74
- msgid "%s (Invalid)"
75
- msgstr "%s (Non valido)"
76
-
77
- #. translators: %s: title of menu item in draft status
78
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:91
79
- msgid "%s (Pending)"
80
- msgstr "%s (In attesa)"
81
-
82
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:104
83
- msgid "sub item"
84
- msgstr "elementi secondari"
85
-
86
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:119
87
- msgid "Move up"
88
- msgstr "Sposta su"
89
-
90
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:132
91
- msgid "Move down"
92
- msgstr "Sposta giù"
93
-
94
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:134
95
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:136
96
- msgid "Edit Menu Item"
97
- msgstr "Modifica Elemento Menu"
98
-
99
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:145
100
- msgid "URL"
101
- msgstr "URL"
102
-
103
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:152
104
- msgid "Navigation Label"
105
- msgstr "Etichetta Navigazione"
106
-
107
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:158
108
- msgid "Title Attribute"
109
- msgstr "Attributo Titolo"
110
-
111
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:165
112
- msgid "Open link in a new window/tab"
113
- msgstr "Apri link in una nuova scheda/finestra"
114
-
115
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:170
116
- msgid "CSS Classes (optional)"
117
- msgstr "Classe CSS (opzionale)"
118
-
119
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:176
120
- msgid "Link Relationship (XFN)"
121
- msgstr "Relazioni Link (XFN)"
122
-
123
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:182
124
- msgid "Description"
125
- msgstr "Descrizione"
126
-
127
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:184
128
- msgid ""
129
- "The description will be displayed in the menu if the current theme supports "
130
- "it."
131
- msgstr "La descrizione sarà visualizzata nel menu se il tema corrente la supporta."
132
-
133
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:196
134
- msgid "Move"
135
- msgstr "Muovi"
136
-
137
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:197
138
- msgid "Up one"
139
- msgstr "Su di uno"
140
-
141
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:198
142
- msgid "Down one"
143
- msgstr "Giù di uno"
144
-
145
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:201
146
- msgid "To the top"
147
- msgstr "Verso l'alto"
148
-
149
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:208
150
- msgid "Original: %s"
151
- msgstr "Originale: %s"
152
-
153
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:221
154
- msgid "Remove"
155
- msgstr "Rimuovi"
156
-
157
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:222
158
- msgid "Cancel"
159
- msgstr "Cancella"
160
-
161
- #: nav-menu-roles.php:82 nav-menu-roles.php:91
162
- msgid "Cheatin&#8217; huh?"
163
- msgstr "Cheatin&#8217; huh?"
164
-
165
- #. Plugin Name of the plugin/theme
166
- msgid "Nav Menu Roles"
167
- msgstr "Nav Menu Roles"
168
-
169
- #: nav-menu-roles.php:169
170
- msgid ""
171
- "Import %snav menu roles%s and other menu item meta skipped by the default "
172
- "importer"
173
- msgstr "Importa %sNav Menu Roles%s e altra voce di menu meta ignorato dall'importatore di default"
174
-
175
- #: nav-menu-roles.php:225
176
- msgid ""
177
- "Nav Menu Roles has detected a possible conflict with the following functions"
178
- " or classes: %1$s. Please see the %2$sFAQ%3$s for more information and "
179
- "possible resolution. | %4$sHide Notice%3$s"
180
- msgstr "Nav Menu Roles ha rilevato un possibile conflitto con le seguenti funzioni o classi: %1$s. Si prega di consultare le %2$sFAQ%3$s Per ulteriori informazioni e possibili risoluzioni. | %4$sNascondi Notizia%3$s"
181
-
182
- #: nav-menu-roles.php:322
183
- msgid "Display Mode"
184
- msgstr "Modalità Display"
185
-
186
- #: nav-menu-roles.php:330
187
- msgid "Logged In Users"
188
- msgstr "Utenti connessi"
189
-
190
- #: nav-menu-roles.php:337
191
- msgid "Logged Out Users"
192
- msgstr "Utenti disconnessi"
193
-
194
- #: nav-menu-roles.php:344
195
- msgid "Everyone"
196
- msgstr "Tutti"
197
-
198
- #: nav-menu-roles.php:351
199
- msgid "Limit logged in users to specific roles"
200
- msgstr "Limite a utenti registrato con ruoli specifici"
201
-
202
- #. Plugin URI of the plugin/theme
203
- msgid "http://www.kathyisawesome.com/449/nav-menu-roles/"
204
- msgstr "http://www.kathyisawesome.com/449/nav-menu-roles/"
205
-
206
- #. Description of the plugin/theme
207
- msgid "Hide custom menu items based on user roles"
208
- msgstr "Nascondi le voci di menu personalizzati basati su ruoli utente"
209
-
210
- #. Author of the plugin/theme
211
- msgid "Kathy Darling"
212
- msgstr "Kathy Darling"
213
-
214
- #. Author URI of the plugin/theme
215
- msgid "http://www.kathyisawesome.com"
216
- msgstr "http://www.kathyisawesome.com"
1
+ # Copyright (C) 2015 Nav Menu Roles
2
+ # This file is distributed under the same license as the Nav Menu Roles package.
3
+ # Translators:
4
+ # Davide Pantè <d.pante@sododesign.it>, 2015
5
+ msgid ""
6
+ msgstr ""
7
+ "Project-Id-Version: Nav Menu Roles\n"
8
+ "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/nav-menu-roles\n"
9
+ "POT-Creation-Date: 2015-07-31 01:01:52+00:00\n"
10
+ "PO-Revision-Date: 2015-08-01 01:01+0000\n"
11
+ "Last-Translator: Davide Pantè <d.pante@sododesign.it>\n"
12
+ "Language-Team: Italian (http://www.transifex.com/projects/p/nav-menu-roles/language/it/)\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "Language: it\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+
19
+ #: inc/class.Nav_Menu_Roles_Import.php:106
20
+ #: inc/class.Nav_Menu_Roles_Import.php:115
21
+ #: inc/class.Nav_Menu_Roles_Import.php:161
22
+ #: inc/class.Nav_Menu_Roles_Import.php:165
23
+ #: inc/class.Nav_Menu_Roles_Import.php:174
24
+ msgid "Sorry, there has been an error."
25
+ msgstr "Siamo spiacenti, si è verificato un errore."
26
+
27
+ #: inc/class.Nav_Menu_Roles_Import.php:107
28
+ msgid "The file does not exist, please try again."
29
+ msgstr "Il file non esiste, si prega di riprovare."
30
+
31
+ #: inc/class.Nav_Menu_Roles_Import.php:146
32
+ msgid "All done."
33
+ msgstr "Finito."
34
+
35
+ #: inc/class.Nav_Menu_Roles_Import.php:146
36
+ msgid "Have fun!"
37
+ msgstr "Divertirti!"
38
+
39
+ #: inc/class.Nav_Menu_Roles_Import.php:166
40
+ msgid ""
41
+ "The export file could not be found at <code>%s</code>. It is likely that "
42
+ "this was caused by a permissions problem."
43
+ msgstr "Il file di esportazione non è stato trovato in <code>%s</code>. E' probabile che questo è stato causato da un problema di autorizzazioni."
44
+
45
+ #: inc/class.Nav_Menu_Roles_Import.php:182
46
+ msgid ""
47
+ "This WXR file (version %s) may not be supported by this version of the "
48
+ "importer. Please consider updating."
49
+ msgstr "Questo file WXR (versione %s) potrebbe non essere supportato da questa versione dell'importatore. Si prega di prendere in considerazione l'aggiornamento."
50
+
51
+ #: inc/class.Nav_Menu_Roles_Import.php:250
52
+ msgid "Import Nav Menu Roles"
53
+ msgstr "Importa Nav Menu Roles"
54
+
55
+ #: inc/class.Nav_Menu_Roles_Import.php:257
56
+ msgid ""
57
+ "A new version of this importer is available. Please update to version %s to "
58
+ "ensure compatibility with newer export files."
59
+ msgstr "Una nuova versione di questo importatore è disponibile. Si prega di aggiornare alla versione %s per garantire la compatibilità con i file di esportazione più recenti."
60
+
61
+ #: inc/class.Nav_Menu_Roles_Import.php:272
62
+ msgid ""
63
+ "Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll "
64
+ "import the Nav Menu Roles and any other missing post meta for the Nav Menu "
65
+ "items."
66
+ msgstr "Ri-caricare il tuo file normale WordPress eXtended RSS (WXR) e noi&#8217;ll importiamo i ruoli del Nav Menu Roles e qualsiasi altro post meta mancante per le voci del Nav Menu."
67
+
68
+ #: inc/class.Nav_Menu_Roles_Import.php:273
69
+ msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
70
+ msgstr "Scegliere un file WXR (.xml) per caricare, quindi fare clic su Carica file e importa."
71
+
72
+ #. translators: %s: title of menu item which is invalid
73
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:87
74
+ msgid "%s (Invalid)"
75
+ msgstr "%s (Non valido)"
76
+
77
+ #. translators: %s: title of menu item in draft status
78
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:91
79
+ msgid "%s (Pending)"
80
+ msgstr "%s (In attesa)"
81
+
82
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:104
83
+ msgid "sub item"
84
+ msgstr "elementi secondari"
85
+
86
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:119
87
+ msgid "Move up"
88
+ msgstr "Sposta su"
89
+
90
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:132
91
+ msgid "Move down"
92
+ msgstr "Sposta giù"
93
+
94
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:134
95
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:136
96
+ msgid "Edit Menu Item"
97
+ msgstr "Modifica Elemento Menu"
98
+
99
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:145
100
+ msgid "URL"
101
+ msgstr "URL"
102
+
103
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:152
104
+ msgid "Navigation Label"
105
+ msgstr "Etichetta Navigazione"
106
+
107
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:158
108
+ msgid "Title Attribute"
109
+ msgstr "Attributo Titolo"
110
+
111
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:165
112
+ msgid "Open link in a new window/tab"
113
+ msgstr "Apri link in una nuova scheda/finestra"
114
+
115
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:170
116
+ msgid "CSS Classes (optional)"
117
+ msgstr "Classe CSS (opzionale)"
118
+
119
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:176
120
+ msgid "Link Relationship (XFN)"
121
+ msgstr "Relazioni Link (XFN)"
122
+
123
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:182
124
+ msgid "Description"
125
+ msgstr "Descrizione"
126
+
127
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:184
128
+ msgid ""
129
+ "The description will be displayed in the menu if the current theme supports "
130
+ "it."
131
+ msgstr "La descrizione sarà visualizzata nel menu se il tema corrente la supporta."
132
+
133
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:196
134
+ msgid "Move"
135
+ msgstr "Muovi"
136
+
137
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:197
138
+ msgid "Up one"
139
+ msgstr "Su di uno"
140
+
141
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:198
142
+ msgid "Down one"
143
+ msgstr "Giù di uno"
144
+
145
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:201
146
+ msgid "To the top"
147
+ msgstr "Verso l'alto"
148
+
149
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:208
150
+ msgid "Original: %s"
151
+ msgstr "Originale: %s"
152
+
153
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:221
154
+ msgid "Remove"
155
+ msgstr "Rimuovi"
156
+
157
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:222
158
+ msgid "Cancel"
159
+ msgstr "Cancella"
160
+
161
+ #: nav-menu-roles.php:82 nav-menu-roles.php:91
162
+ msgid "Cheatin&#8217; huh?"
163
+ msgstr "Cheatin&#8217; huh?"
164
+
165
+ #. Plugin Name of the plugin/theme
166
+ msgid "Nav Menu Roles"
167
+ msgstr "Nav Menu Roles"
168
+
169
+ #: nav-menu-roles.php:169
170
+ msgid ""
171
+ "Import %snav menu roles%s and other menu item meta skipped by the default "
172
+ "importer"
173
+ msgstr "Importa %sNav Menu Roles%s e altra voce di menu meta ignorato dall'importatore di default"
174
+
175
+ #: nav-menu-roles.php:225
176
+ msgid ""
177
+ "Nav Menu Roles has detected a possible conflict with the following functions"
178
+ " or classes: %1$s. Please see the %2$sFAQ%3$s for more information and "
179
+ "possible resolution. | %4$sHide Notice%3$s"
180
+ msgstr "Nav Menu Roles ha rilevato un possibile conflitto con le seguenti funzioni o classi: %1$s. Si prega di consultare le %2$sFAQ%3$s Per ulteriori informazioni e possibili risoluzioni. | %4$sNascondi Notizia%3$s"
181
+
182
+ #: nav-menu-roles.php:322
183
+ msgid "Display Mode"
184
+ msgstr "Modalità Display"
185
+
186
+ #: nav-menu-roles.php:330
187
+ msgid "Logged In Users"
188
+ msgstr "Utenti connessi"
189
+
190
+ #: nav-menu-roles.php:337
191
+ msgid "Logged Out Users"
192
+ msgstr "Utenti disconnessi"
193
+
194
+ #: nav-menu-roles.php:344
195
+ msgid "Everyone"
196
+ msgstr "Tutti"
197
+
198
+ #: nav-menu-roles.php:351
199
+ msgid "Limit logged in users to specific roles"
200
+ msgstr "Limite a utenti registrato con ruoli specifici"
201
+
202
+ #. Plugin URI of the plugin/theme
203
+ msgid "http://www.kathyisawesome.com/449/nav-menu-roles/"
204
+ msgstr "http://www.kathyisawesome.com/449/nav-menu-roles/"
205
+
206
+ #. Description of the plugin/theme
207
+ msgid "Hide custom menu items based on user roles"
208
+ msgstr "Nascondi le voci di menu personalizzati basati su ruoli utente"
209
+
210
+ #. Author of the plugin/theme
211
+ msgid "Kathy Darling"
212
+ msgstr "Kathy Darling"
213
+
214
+ #. Author URI of the plugin/theme
215
+ msgid "http://www.kathyisawesome.com"
216
+ msgstr "http://www.kathyisawesome.com"
languages/nav-menu-roles.pot CHANGED
@@ -1,242 +1,242 @@
1
- # Copyright (C) 2016 Kathy Darling
2
- # This file is distributed under the GPL-3.0.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Nav Menu Roles 1.8.6\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nav-menu-roles\n"
7
- "POT-Creation-Date: 2016-12-08 18:08:13+00:00\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=utf-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
- "X-Generator: grunt-wp-i18n 0.5.4\n"
15
-
16
- #: inc/class.Nav_Menu_Roles_Import.php:106
17
- #: inc/class.Nav_Menu_Roles_Import.php:115
18
- #: inc/class.Nav_Menu_Roles_Import.php:161
19
- #: inc/class.Nav_Menu_Roles_Import.php:165
20
- #: inc/class.Nav_Menu_Roles_Import.php:174
21
- msgid "Sorry, there has been an error."
22
- msgstr ""
23
-
24
- #: inc/class.Nav_Menu_Roles_Import.php:107
25
- msgid "The file does not exist, please try again."
26
- msgstr ""
27
-
28
- #: inc/class.Nav_Menu_Roles_Import.php:146
29
- msgid "All done."
30
- msgstr ""
31
-
32
- #: inc/class.Nav_Menu_Roles_Import.php:146
33
- msgid "Have fun!"
34
- msgstr ""
35
-
36
- #: inc/class.Nav_Menu_Roles_Import.php:166
37
- msgid ""
38
- "The export file could not be found at <code>%s</code>. It is likely that "
39
- "this was caused by a permissions problem."
40
- msgstr ""
41
-
42
- #: inc/class.Nav_Menu_Roles_Import.php:182
43
- msgid ""
44
- "This WXR file (version %s) may not be supported by this version of the "
45
- "importer. Please consider updating."
46
- msgstr ""
47
-
48
- #: inc/class.Nav_Menu_Roles_Import.php:249
49
- msgid "Import Nav Menu Roles"
50
- msgstr ""
51
-
52
- #: inc/class.Nav_Menu_Roles_Import.php:256
53
- msgid ""
54
- "A new version of this importer is available. Please update to version %s to "
55
- "ensure compatibility with newer export files."
56
- msgstr ""
57
-
58
- #: inc/class.Nav_Menu_Roles_Import.php:271
59
- msgid ""
60
- "Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll "
61
- "import the Nav Menu Roles and any other missing post meta for the Nav Menu "
62
- "items."
63
- msgstr ""
64
-
65
- #: inc/class.Nav_Menu_Roles_Import.php:272
66
- 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
- #: 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
-
96
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:142
97
- #: inc/class.Walker_Nav_Menu_Edit_Roles.php:144
98
- msgid "Edit Menu Item"
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&#8217; huh?"
188
- msgstr ""
189
-
190
- #. Plugin Name of the plugin/theme
191
- msgid "Nav Menu Roles"
192
- msgstr ""
193
-
194
- #: nav-menu-roles.php:166
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:219
201
- msgid "FAQ"
202
- msgstr ""
203
-
204
- #: nav-menu-roles.php:220
205
- msgid "Donate"
206
- msgstr ""
207
-
208
- #: nav-menu-roles.php:299
209
- msgid "Display Mode"
210
- msgstr ""
211
-
212
- #: nav-menu-roles.php:307
213
- msgid "Logged In Users"
214
- msgstr ""
215
-
216
- #: nav-menu-roles.php:314
217
- msgid "Logged Out Users"
218
- msgstr ""
219
-
220
- #: nav-menu-roles.php:321
221
- msgid "Everyone"
222
- msgstr ""
223
-
224
- #: nav-menu-roles.php:328
225
- msgid "Restrict menu item to a minimum role"
226
- msgstr ""
227
-
228
- #. Plugin URI of the plugin/theme
229
- msgid "http://www.kathyisawesome.com/449/nav-menu-roles/"
230
- msgstr ""
231
-
232
- #. Description of the plugin/theme
233
- msgid "Hide custom menu items based on user roles."
234
- msgstr ""
235
-
236
- #. Author of the plugin/theme
237
- msgid "Kathy Darling"
238
- msgstr ""
239
-
240
- #. Author URI of the plugin/theme
241
- msgid "http://www.kathyisawesome.com"
242
  msgstr ""
1
+ # Copyright (C) 2016 Kathy Darling
2
+ # This file is distributed under the GPL-3.0.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Nav Menu Roles 1.8.6\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nav-menu-roles\n"
7
+ "POT-Creation-Date: 2016-12-08 18:08:13+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+ "X-Generator: grunt-wp-i18n 0.5.4\n"
15
+
16
+ #: inc/class.Nav_Menu_Roles_Import.php:106
17
+ #: inc/class.Nav_Menu_Roles_Import.php:115
18
+ #: inc/class.Nav_Menu_Roles_Import.php:161
19
+ #: inc/class.Nav_Menu_Roles_Import.php:165
20
+ #: inc/class.Nav_Menu_Roles_Import.php:174
21
+ msgid "Sorry, there has been an error."
22
+ msgstr ""
23
+
24
+ #: inc/class.Nav_Menu_Roles_Import.php:107
25
+ msgid "The file does not exist, please try again."
26
+ msgstr ""
27
+
28
+ #: inc/class.Nav_Menu_Roles_Import.php:146
29
+ msgid "All done."
30
+ msgstr ""
31
+
32
+ #: inc/class.Nav_Menu_Roles_Import.php:146
33
+ msgid "Have fun!"
34
+ msgstr ""
35
+
36
+ #: inc/class.Nav_Menu_Roles_Import.php:166
37
+ msgid ""
38
+ "The export file could not be found at <code>%s</code>. It is likely that "
39
+ "this was caused by a permissions problem."
40
+ msgstr ""
41
+
42
+ #: inc/class.Nav_Menu_Roles_Import.php:182
43
+ msgid ""
44
+ "This WXR file (version %s) may not be supported by this version of the "
45
+ "importer. Please consider updating."
46
+ msgstr ""
47
+
48
+ #: inc/class.Nav_Menu_Roles_Import.php:249
49
+ msgid "Import Nav Menu Roles"
50
+ msgstr ""
51
+
52
+ #: inc/class.Nav_Menu_Roles_Import.php:256
53
+ msgid ""
54
+ "A new version of this importer is available. Please update to version %s to "
55
+ "ensure compatibility with newer export files."
56
+ msgstr ""
57
+
58
+ #: inc/class.Nav_Menu_Roles_Import.php:271
59
+ msgid ""
60
+ "Re-Upload your normal WordPress eXtended RSS (WXR) file and we&#8217;ll "
61
+ "import the Nav Menu Roles and any other missing post meta for the Nav Menu "
62
+ "items."
63
+ msgstr ""
64
+
65
+ #: inc/class.Nav_Menu_Roles_Import.php:272
66
+ 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
+ #: 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
+
96
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:142
97
+ #: inc/class.Walker_Nav_Menu_Edit_Roles.php:144
98
+ msgid "Edit Menu Item"
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&#8217; huh?"
188
+ msgstr ""
189
+
190
+ #. Plugin Name of the plugin/theme
191
+ msgid "Nav Menu Roles"
192
+ msgstr ""
193
+
194
+ #: nav-menu-roles.php:166
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:219
201
+ msgid "FAQ"
202
+ msgstr ""
203
+
204
+ #: nav-menu-roles.php:220
205
+ msgid "Donate"
206
+ msgstr ""
207
+
208
+ #: nav-menu-roles.php:299
209
+ msgid "Display Mode"
210
+ msgstr ""
211
+
212
+ #: nav-menu-roles.php:307
213
+ msgid "Logged In Users"
214
+ msgstr ""
215
+
216
+ #: nav-menu-roles.php:314
217
+ msgid "Logged Out Users"
218
+ msgstr ""
219
+
220
+ #: nav-menu-roles.php:321
221
+ msgid "Everyone"
222
+ msgstr ""
223
+
224
+ #: nav-menu-roles.php:328
225
+ msgid "Restrict menu item to a minimum role"
226
+ msgstr ""
227
+
228
+ #. Plugin URI of the plugin/theme
229
+ msgid "http://www.kathyisawesome.com/449/nav-menu-roles/"
230
+ msgstr ""
231
+
232
+ #. Description of the plugin/theme
233
+ msgid "Hide custom menu items based on user roles."
234
+ msgstr ""
235
+
236
+ #. Author of the plugin/theme
237
+ msgid "Kathy Darling"
238
+ msgstr ""
239
+
240
+ #. Author URI of the plugin/theme
241
+ msgid "http://www.kathyisawesome.com"
242
  msgstr ""
nav-menu-roles.php CHANGED
@@ -1,604 +1,604 @@
1
- <?php
2
- /*
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.10.1
7
- Author: Kathy Darling
8
- Author URI: http://www.kathyisawesome.com
9
- License: GPL-3.0
10
- Text Domain: nav-menu-roles
11
-
12
- Copyright 2020 Kathy Darling
13
-
14
- This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License, version 2, as
16
- published by the Free Software Foundation.
17
-
18
- This program is distributed in the hope that it will be useful,
19
- but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
21
- GNU General Public License for more details.
22
-
23
- You should have received a copy of the GNU General Public License
24
- along with this program; if not, write to the Free Software
25
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301USA
26
- */
27
-
28
-
29
- // Don't load directly.
30
- if ( ! function_exists( 'is_admin' ) ) {
31
- header( 'Status: 403 Forbidden' );
32
- header( 'HTTP/1.1 403 Forbidden' );
33
- exit();
34
- }
35
-
36
-
37
- if ( ! class_exists( "Nav_Menu_Roles" ) ) :
38
-
39
- class Nav_Menu_Roles {
40
-
41
- /**
42
- * @var Nav_Menu_Roles The single instance of the class
43
- * @since 1.5
44
- */
45
- protected static $_instance = null;
46
-
47
- /**
48
- * @constant string donate url
49
- * @since 1.9.1
50
- */
51
- CONST DONATE_URL = "https://www.paypal.com/fundraiser/charity/1451316";
52
-
53
- /**
54
- * @constant string version number
55
- * @since 1.7.0
56
- */
57
- CONST VERSION = '1.10.1';
58
-
59
- /**
60
- * Main Nav Menu Roles Instance
61
- *
62
- * Ensures only one instance of Nav Menu Roles is loaded or can be loaded.
63
- *
64
- * @since 1.5
65
- * @static
66
- * @see Nav_Menu_Roles()
67
- * @return Nav_Menu_Roles - Main instance
68
- */
69
- public static function instance() {
70
- if ( is_null( self::$_instance ) ) {
71
- self::$_instance = new self();
72
- }
73
- return self::$_instance;
74
- }
75
-
76
- /**
77
- * Cloning is forbidden.
78
- *
79
- * @since 1.5
80
- */
81
- public function __clone() {
82
- _doing_it_wrong( __FUNCTION__, __( 'Cloning this object is forbidden.' , 'nav-menu-roles' ), '1.5' );
83
- }
84
-
85
- /**
86
- * Unserializing instances of this class is forbidden.
87
- *
88
- * @since 1.5
89
- */
90
- public function __wakeup() {
91
- _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.' , 'nav-menu-roles' ), '1.5' );
92
- }
93
-
94
- /**
95
- * Nav_Menu_Roles Constructor.
96
- * @access public
97
- * @return Nav_Menu_Roles
98
- * @since 1.0
99
- */
100
- public function __construct(){
101
-
102
- // Admin functions.
103
- add_action( 'admin_init', array( $this, 'admin_init' ) );
104
-
105
- // Load the textdomain.
106
- add_action( 'init', 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, 2 );
110
-
111
- // Maybe switch the admin walker.
112
- if( ! self::is_wp_gte( '5.4' ) ) {
113
- add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
114
- }
115
-
116
- // Add new fields via hook.
117
- add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'custom_fields' ), 10, 4 );
118
-
119
- // Add some JS.
120
- add_action( 'admin_enqueue_scripts' , array( $this, 'enqueue_scripts' ) );
121
-
122
- // Save the menu item meta.
123
- add_action( 'wp_update_nav_menu_item', array( $this, 'nav_update'), 10, 2 );
124
-
125
- // Add meta to menu item.
126
- add_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_nav_item' ) );
127
-
128
- // Exclude items via filter instead of via custom Walker.
129
- if ( ! is_admin() ) {
130
- // Because WP_Customize_Nav_Menu_Item_Setting::filter_wp_get_nav_menu_items() runs at 10.
131
- add_filter( 'wp_get_nav_menu_items', array( $this, 'exclude_menu_items' ), 20 );
132
- }
133
-
134
- // Upgrade routine.
135
- add_action( 'plugins_loaded', array( $this, 'maybe_upgrade' ) );
136
-
137
- }
138
-
139
- /**
140
- * Include the custom admin walker
141
- *
142
- * @access public
143
- * @return void
144
- */
145
- public function admin_init() {
146
-
147
- // Register Importer.
148
- $this->register_importer();
149
-
150
- }
151
-
152
-
153
- /**
154
- * Register the Importer
155
- * the regular Importer skips post meta for the menu items
156
- *
157
- * @access private
158
- * @return void
159
- */
160
- public function register_importer(){
161
- // Register the new importer.
162
- if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
163
-
164
- include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Nav_Menu_Roles_Import.php');
165
- // Register the custom importer we've created.
166
- $roles_import = new Nav_Menu_Roles_Import();
167
-
168
- register_importer( 'nav_menu_roles', __( 'Nav Menu Roles', 'nav-menu-roles' ), sprintf( __( 'Import %snav menu roles%s and other menu item meta skipped by the default importer', 'nav-menu-roles' ), '<strong>', '</strong>' ), array( $roles_import, 'dispatch' ) );
169
-
170
- }
171
-
172
- }
173
-
174
- /**
175
- * Make Plugin Translation-ready
176
- *
177
- * @since 1.0
178
- */
179
- public function load_text_domain() {
180
- load_plugin_textdomain( 'nav-menu-roles', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
181
- }
182
-
183
-
184
- /**
185
- * Display a Notice if plugin conflicts with another
186
- *
187
- * @since 1.5
188
- * @deprecated will removed in 2.0
189
- */
190
- public function admin_notice() {
191
- _deprecated_function( __METHOD__, '1.7.8' );
192
- }
193
-
194
-
195
- /**
196
- * Allow the notice to be dismissable
197
- *
198
- * @since 1.6
199
- * @deprecated will removed in 2.0
200
- */
201
- public function nag_ignore() {
202
- _deprecated_function( __METHOD__, '1.7.8' );
203
- }
204
-
205
- /**
206
- * Delete the transient when a plugin is activated or deactivated
207
- *
208
- * @since 1.5
209
- * @deprecated will removed in 2.0
210
- */
211
- public function delete_transient() {
212
- _deprecated_function( __METHOD__, '1.7.8' );
213
- delete_transient( 'nav_menu_roles_conflicts' );
214
- }
215
-
216
-
217
- /**
218
- * Add docu link
219
- *
220
- * @since 1.7.3
221
- * @param array $plugin_meta
222
- * @param string $plugin_file
223
- */
224
- public function add_action_links( $plugin_meta, $plugin_file ) {
225
- if( $plugin_file == plugin_basename(__FILE__) ){
226
- $plugin_meta[] = sprintf( '<a class="dashicons-before dashicons-welcome-learn-more" href="https://wordpress.org/plugins/nav-menu-roles/faq/#conflict">%s</a>', __( 'FAQ', 'nav-menu-roles' ) );
227
- $plugin_meta[] = '<a class="dashicons-before dashicons-admin-generic" href="' . self::DONATE_URL . '" target="_blank">' . __( 'Donate', 'nav-menu-roles' ) . '</a>';
228
- }
229
- return $plugin_meta;
230
- }
231
-
232
-
233
- /**
234
- * Override the Admin Menu Walker
235
- *
236
- * @since 1.0
237
- */
238
- public function edit_nav_menu_walker( $walker ) {
239
- if( ! class_exists( 'Walker_Nav_Menu_Edit_Roles' ) ) {
240
-
241
- if ( self::is_wp_gte( '4.7' ) ) {
242
- require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php' );
243
- } else if ( self::is_wp_gte( '4.5' ) ) {
244
- require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php' );
245
- } else {
246
- require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles.php' );
247
- }
248
- }
249
- return 'Walker_Nav_Menu_Edit_Roles';
250
- }
251
-
252
-
253
- /**
254
- * Add fields to hook added in Walker
255
- * This will allow us to play nicely with any other plugin that is adding the same hook
256
- * @params obj $item - the menu item
257
- * @params array $args
258
- * @since 1.6.0
259
- */
260
- public function custom_fields( $item_id, $item, $depth, $args ) {
261
- global $wp_roles;
262
-
263
- /**
264
- * Pass the menu item to the filter function.
265
- * This change is suggested as it allows the use of information from the menu item (and
266
- * by extension the target object) to further customize what filters appear during menu
267
- * construction.
268
- */
269
- $display_roles = apply_filters( 'nav_menu_roles', $wp_roles->role_names, $item );
270
-
271
- /**
272
- * If no roles are being used, don't display the role selection radio buttons at all.
273
- * Unless something deliberately removes the WordPress roles from this list, nothing will
274
- * be functionally altered to the end user.
275
- * This change is suggested for the benefit of users constructing granular admin permissions
276
- * using extensive custom roles as it is an effective means of stopping admins with partial
277
- * permissions to the menu from accidentally removing all restrictions from a menu item to
278
- * which they do not have access.
279
- */
280
- if( ! $display_roles ) return;
281
-
282
- /* Get the roles saved for the post. */
283
- $roles = get_post_meta( $item->ID, '_nav_menu_role', true );
284
-
285
- // By default nothing is checked (will match "everyone" radio).
286
- $logged_in_out = '';
287
-
288
- // Specific roles are saved as an array, so "in" or an array equals "in" is checked.
289
- if( is_array( $roles ) || $roles == 'in' ){
290
- $logged_in_out = 'in';
291
- } else if ( $roles == 'out' ){
292
- $logged_in_out = 'out';
293
- }
294
-
295
- // The specific roles to check.
296
- $checked_roles = is_array( $roles ) ? $roles : false;
297
-
298
- // Whether to display the role checkboxes.
299
- $hidden = $logged_in_out == 'in' ? '' : 'display: none;';
300
-
301
- ?>
302
-
303
- <input type="hidden" name="nav-menu-role-nonce" value="<?php echo wp_create_nonce( 'nav-menu-nonce-name' ); ?>" />
304
-
305
- <div class="field-nav_menu_role nav_menu_logged_in_out_field description-wide" style="margin: 5px 0;">
306
- <span class="description"><?php _e( "Display Mode", 'nav-menu-roles' ); ?></span>
307
- <br />
308
-
309
- <input type="hidden" class="nav-menu-id" value="<?php echo $item->ID ;?>" />
310
-
311
- <div class="logged-input-holder" style="float: left; width: 35%;">
312
- <input type="radio" class="nav-menu-logged-in-out" name="nav-menu-logged-in-out[<?php echo $item->ID ;?>]" id="nav_menu_logged_in-for-<?php echo $item->ID ;?>" <?php checked( 'in', $logged_in_out ); ?> value="in" />
313
- <label for="nav_menu_logged_in-for-<?php echo $item->ID ;?>">
314
- <?php _e( 'Logged In Users', 'nav-menu-roles'); ?>
315
- </label>
316
- </div>
317
-
318
- <div class="logged-input-holder" style="float: left; width: 35%;">
319
- <input type="radio" class="nav-menu-logged-in-out" name="nav-menu-logged-in-out[<?php echo $item->ID ;?>]" id="nav_menu_logged_out-for-<?php echo $item->ID ;?>" <?php checked( 'out', $logged_in_out ); ?> value="out" />
320
- <label for="nav_menu_logged_out-for-<?php echo $item->ID ;?>">
321
- <?php _e( 'Logged Out Users', 'nav-menu-roles'); ?>
322
- </label>
323
- </div>
324
-
325
- <div class="logged-input-holder" style="float: left; width: 30%;">
326
- <input type="radio" class="nav-menu-logged-in-out" name="nav-menu-logged-in-out[<?php echo $item->ID ;?>]" id="nav_menu_by_role-for-<?php echo $item->ID ;?>" <?php checked( '', $logged_in_out ); ?> value="" />
327
- <label for="nav_menu_by_role-for-<?php echo $item->ID ;?>">
328
- <?php _e( 'Everyone', 'nav-menu-roles'); ?>
329
- </label>
330
- </div>
331
-
332
- </div>
333
-
334
- <div class="field-nav_menu_role nav_menu_role_field description-wide" style="margin: 5px 0; <?php echo $hidden;?>">
335
- <span class="description"><?php _e( "Restrict menu item to a minimum role", 'nav-menu-roles' ); ?></span>
336
- <br />
337
-
338
- <?php
339
-
340
- $i = 1;
341
-
342
- /* Loop through each of the available roles. */
343
- foreach ( $display_roles as $role => $name ) {
344
-
345
- /* If the role has been selected, make sure it's checked. */
346
- $checked = checked( true, ( is_array( $checked_roles ) && in_array( $role, $checked_roles ) ), false );
347
-
348
- ?>
349
-
350
- <div class="role-input-holder" style="margin: 2px 0;">
351
- <input type="checkbox" name="nav-menu-role[<?php echo $item->ID ;?>][<?php echo $i; ?>]" id="nav_menu_role-<?php echo $role; ?>-for-<?php echo $item->ID ;?>" <?php echo $checked; ?> value="<?php echo $role; ?>" />
352
- <label for="nav_menu_role-<?php echo $role; ?>-for-<?php echo $item->ID ;?>">
353
- <?php echo esc_html( $name ); ?>
354
- <?php $i++; ?>
355
- </label>
356
- </div>
357
-
358
- <?php } ?>
359
-
360
- </div>
361
-
362
- <?php
363
- }
364
-
365
-
366
- /**
367
- * Save the roles as menu item meta
368
- *
369
- * @since 1.4
370
- * @return null
371
- */
372
- public function enqueue_scripts( $hook ){
373
- if ( $hook == 'nav-menus.php' ){
374
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
375
- wp_enqueue_script( 'nav-menu-roles', plugins_url( 'js/nav-menu-roles' . $suffix . '.js' , __FILE__ ), array( 'jquery' ), self::VERSION, true );
376
- }
377
- }
378
-
379
- /**
380
- * Save the roles as menu item meta
381
- *
382
- * @since 1.0
383
- * @return string
384
- */
385
- public function nav_update( $menu_id, $menu_item_db_id ) {
386
- global $wp_roles;
387
-
388
- $allowed_roles = apply_filters( 'nav_menu_roles', $wp_roles->role_names );
389
-
390
- // Verify this came from our screen and with proper authorization.
391
- if ( ! isset( $_POST['nav-menu-role-nonce'] ) || ! wp_verify_nonce( $_POST['nav-menu-role-nonce'], 'nav-menu-nonce-name' ) ){
392
- return;
393
- }
394
-
395
- $saved_data = false;
396
-
397
- if ( isset( $_POST['nav-menu-logged-in-out'][$menu_item_db_id] ) && $_POST['nav-menu-logged-in-out'][$menu_item_db_id] == 'in' && ! empty ( $_POST['nav-menu-role'][$menu_item_db_id] ) ) {
398
-
399
- $custom_roles = array();
400
-
401
- // Only save allowed roles.
402
- foreach( (array) $_POST['nav-menu-role'][$menu_item_db_id] as $role ) {
403
- if ( array_key_exists ( $role, $allowed_roles ) ) {
404
- $custom_roles[] = $role;
405
- }
406
- }
407
- if ( ! empty ( $custom_roles ) ) {
408
- $saved_data = $custom_roles;
409
- }
410
- } 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' ) ) ) {
411
- $saved_data = $_POST['nav-menu-logged-in-out'][$menu_item_db_id];
412
- }
413
-
414
- if ( $saved_data ) {
415
- update_post_meta( $menu_item_db_id, '_nav_menu_role', $saved_data );
416
- } else {
417
- delete_post_meta( $menu_item_db_id, '_nav_menu_role' );
418
- }
419
- }
420
-
421
- /**
422
- * Adds value of new field to $item object
423
- * is be passed to Walker_Nav_Menu_Edit_Custom
424
- *
425
- * @since 1.0
426
- */
427
- public function setup_nav_item( $menu_item ) {
428
-
429
- if( is_object( $menu_item ) && isset( $menu_item->ID ) ) {
430
-
431
- $roles = get_post_meta( $menu_item->ID, '_nav_menu_role', true );
432
-
433
- if ( ! empty( $roles ) ) {
434
- $menu_item->roles = $roles;
435
-
436
- // Add the NMR roles as CSS info.
437
- $new_classes = array();
438
-
439
- switch( $roles ) {
440
- case 'in' :
441
- $new_classes[] = 'nmr-logged-in';
442
- break;
443
- case 'out' :
444
- $new_classes[] = 'nmr-logged-out';
445
- break;
446
- default:
447
- if ( is_array( $menu_item->roles ) && ! empty( $menu_item->roles ) ) {
448
- foreach ( $menu_item->roles as $role ) {
449
- $new_classes[] = 'nmr-' . $role;
450
- }
451
- }
452
- break;
453
- }
454
-
455
- // Only apply classes on front-end.
456
- if( ! is_admin() ) {
457
- $menu_item->classes = array_unique( array_merge( $menu_item->classes, $new_classes ) );
458
- }
459
- }
460
- }
461
- return $menu_item;
462
- }
463
-
464
- /**
465
- * Exclude menu items via wp_get_nav_menu_items filter
466
- * this fixes plugin's incompatibility with theme's that use their own custom Walker
467
- * Thanks to Evan Stein @vanpop http://vanpop.com/
468
- *
469
- * @since 1.2
470
- *
471
- * @param WP_Post[] array of Nav Menu Post objects
472
- *
473
- * Multisite compatibility added in 1.9.0
474
- * by @open-dsi https://www.open-dsi.fr/ with props to @fiech
475
- */
476
- public function exclude_menu_items( $items ) {
477
-
478
- $hide_children_of = array();
479
-
480
- if( ! empty( $items ) ) {
481
-
482
- // Iterate over the items to search and destroy.
483
- foreach ( $items as $key => $item ) {
484
-
485
- $visible = true;
486
-
487
- // Hide any item that is the child of a hidden item.
488
- if( isset( $item->menu_item_parent ) && in_array( $item->menu_item_parent, $hide_children_of ) ){
489
- $visible = false;
490
- }
491
-
492
- // Check any item that has NMR roles set.
493
- if( $visible && isset( $item->roles ) ) {
494
-
495
- // Check all logged in, all logged out, or role.
496
- switch( $item->roles ) {
497
- case 'in' :
498
- /**
499
- * Multisite compatibility.
500
- *
501
- * For the logged in condition to work,
502
- * the user has to be a logged in member of the current blog
503
- * or be a logged in super user.
504
- */
505
- $visible = is_user_member_of_blog() || is_super_admin() ? true : false;
506
- break;
507
- case 'out' :
508
- /**
509
- * Multisite compatibility.
510
- *
511
- * For the logged out condition to work,
512
- * the user has to be either logged out
513
- * or not be a member of the current blog.
514
- * But they also may not be a super admin,
515
- * because logged in super admins should see the internal stuff, not the external.
516
- */
517
- $visible = ! is_user_member_of_blog() && ! is_super_admin() ? true : false;
518
- break;
519
- default:
520
- $visible = false;
521
- if ( is_array( $item->roles ) && ! empty( $item->roles ) ) {
522
- foreach ( $item->roles as $role ) {
523
- if ( current_user_can( $role ) ) {
524
- $visible = true;
525
- break;
526
- }
527
- }
528
- }
529
-
530
- break;
531
- }
532
-
533
- }
534
-
535
- /*
536
- * Filter: nav_menu_roles_item_visibility
537
- * Add filter to work with plugins that don't use traditional roles
538
- *
539
- * @param bool $visible
540
- * @param object $item
541
- */
542
- $visible = apply_filters( 'nav_menu_roles_item_visibility', $visible, $item );
543
-
544
- // Unset non-visible item.
545
- if ( ! $visible ) {
546
- if( isset( $item->ID ) ) {
547
- $hide_children_of[] = $item->ID; // Store ID of item to hide it's children.
548
- }
549
- unset( $items[$key] ) ;
550
- }
551
-
552
- }
553
-
554
- }
555
-
556
- return $items;
557
- }
558
-
559
-
560
- /**
561
- * Maybe upgrade
562
- *
563
- * @access public
564
- * @return void
565
- */
566
- public function maybe_upgrade() {
567
- $db_version = get_option( 'nav_menu_roles_db_version', false );
568
-
569
- // 1.7.7 upgrade: changed the debug notice so the old transient is invalid.
570
- if ( $db_version === false || version_compare( '1.7.7', $db_version, '<' ) ) {
571
- update_option( 'nav_menu_roles_db_version', self::VERSION );
572
- }
573
- }
574
-
575
- /**
576
- * Test WordPress version
577
- *
578
- * @access public
579
- * @param string $version - A WordPress version to compare against current version.
580
- * @return boolean
581
- */
582
- public static function is_wp_gte( $version = '5.4' ) {
583
- global $wp_version;
584
- return version_compare( strtolower( $wp_version ), strtolower( $version ), '>=' );
585
- }
586
-
587
- } // end class
588
-
589
- endif; // class_exists check
590
-
591
-
592
- /**
593
- * Launch the whole plugin
594
- * Returns the main instance of Nav Menu Roles to prevent the need to use globals.
595
- *
596
- * @since 1.5
597
- * @return Nav_Menu_Roles
598
- */
599
- function Nav_Menu_Roles() {
600
- return Nav_Menu_Roles::instance();
601
- }
602
-
603
- // Global for backwards compatibility.
604
  $GLOBALS['Nav_Menu_Roles'] = Nav_Menu_Roles();
1
+ <?php
2
+ /*
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.10.2
7
+ Author: Kathy Darling
8
+ Author URI: http://www.kathyisawesome.com
9
+ License: GPL-3.0
10
+ Text Domain: nav-menu-roles
11
+
12
+ Copyright 2020 Kathy Darling
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
+ published by the Free Software Foundation.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301USA
26
+ */
27
+
28
+
29
+ // Don't load directly.
30
+ if ( ! function_exists( 'is_admin' ) ) {
31
+ header( 'Status: 403 Forbidden' );
32
+ header( 'HTTP/1.1 403 Forbidden' );
33
+ exit();
34
+ }
35
+
36
+
37
+ if ( ! class_exists( "Nav_Menu_Roles" ) ) :
38
+
39
+ class Nav_Menu_Roles {
40
+
41
+ /**
42
+ * @var Nav_Menu_Roles The single instance of the class
43
+ * @since 1.5
44
+ */
45
+ protected static $_instance = null;
46
+
47
+ /**
48
+ * @constant string donate url
49
+ * @since 1.9.1
50
+ */
51
+ CONST DONATE_URL = "https://www.paypal.com/fundraiser/charity/1451316";
52
+
53
+ /**
54
+ * @constant string version number
55
+ * @since 1.7.0
56
+ */
57
+ CONST VERSION = '1.10.2';
58
+
59
+ /**
60
+ * Main Nav Menu Roles Instance
61
+ *
62
+ * Ensures only one instance of Nav Menu Roles is loaded or can be loaded.
63
+ *
64
+ * @since 1.5
65
+ * @static
66
+ * @see Nav_Menu_Roles()
67
+ * @return Nav_Menu_Roles - Main instance
68
+ */
69
+ public static function instance() {
70
+ if ( is_null( self::$_instance ) ) {
71
+ self::$_instance = new self();
72
+ }
73
+ return self::$_instance;
74
+ }
75
+
76
+ /**
77
+ * Cloning is forbidden.
78
+ *
79
+ * @since 1.5
80
+ */
81
+ public function __clone() {
82
+ _doing_it_wrong( __FUNCTION__, __( 'Cloning this object is forbidden.' , 'nav-menu-roles' ), '1.5' );
83
+ }
84
+
85
+ /**
86
+ * Unserializing instances of this class is forbidden.
87
+ *
88
+ * @since 1.5
89
+ */
90
+ public function __wakeup() {
91
+ _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.' , 'nav-menu-roles' ), '1.5' );
92
+ }
93
+
94
+ /**
95
+ * Nav_Menu_Roles Constructor.
96
+ * @access public
97
+ * @return Nav_Menu_Roles
98
+ * @since 1.0
99
+ */
100
+ public function __construct(){
101
+
102
+ // Admin functions.
103
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
104
+
105
+ // Load the textdomain.
106
+ add_action( 'init', 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, 2 );
110
+
111
+ // Maybe switch the admin walker.
112
+ if( ! self::is_wp_gte( '5.4' ) ) {
113
+ add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
114
+ }
115
+
116
+ // Add new fields via hook.
117
+ add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'custom_fields' ), 10, 4 );
118
+
119
+ // Add some JS.
120
+ add_action( 'admin_enqueue_scripts' , array( $this, 'enqueue_scripts' ) );
121
+
122
+ // Save the menu item meta.
123
+ add_action( 'wp_update_nav_menu_item', array( $this, 'nav_update'), 10, 2 );
124
+
125
+ // Add meta to menu item.
126
+ add_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_nav_item' ) );
127
+
128
+ // Exclude items via filter instead of via custom Walker.
129
+ if ( ! is_admin() ) {
130
+ // Because WP_Customize_Nav_Menu_Item_Setting::filter_wp_get_nav_menu_items() runs at 10.
131
+ add_filter( 'wp_get_nav_menu_items', array( $this, 'exclude_menu_items' ), 20 );
132
+ }
133
+
134
+ // Upgrade routine.
135
+ add_action( 'plugins_loaded', array( $this, 'maybe_upgrade' ) );
136
+
137
+ }
138
+
139
+ /**
140
+ * Include the custom admin walker
141
+ *
142
+ * @access public
143
+ * @return void
144
+ */
145
+ public function admin_init() {
146
+
147
+ // Register Importer.
148
+ $this->register_importer();
149
+
150
+ }
151
+
152
+
153
+ /**
154
+ * Register the Importer
155
+ * the regular Importer skips post meta for the menu items
156
+ *
157
+ * @access private
158
+ * @return void
159
+ */
160
+ public function register_importer(){
161
+ // Register the new importer.
162
+ if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
163
+
164
+ include_once( plugin_dir_path( __FILE__ ) . 'inc/class.Nav_Menu_Roles_Import.php');
165
+ // Register the custom importer we've created.
166
+ $roles_import = new Nav_Menu_Roles_Import();
167
+
168
+ register_importer( 'nav_menu_roles', __( 'Nav Menu Roles', 'nav-menu-roles' ), sprintf( __( 'Import %snav menu roles%s and other menu item meta skipped by the default importer', 'nav-menu-roles' ), '<strong>', '</strong>' ), array( $roles_import, 'dispatch' ) );
169
+
170
+ }
171
+
172
+ }
173
+
174
+ /**
175
+ * Make Plugin Translation-ready
176
+ *
177
+ * @since 1.0
178
+ */
179
+ public function load_text_domain() {
180
+ load_plugin_textdomain( 'nav-menu-roles', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
181
+ }
182
+
183
+
184
+ /**
185
+ * Display a Notice if plugin conflicts with another
186
+ *
187
+ * @since 1.5
188
+ * @deprecated will removed in 2.0
189
+ */
190
+ public function admin_notice() {
191
+ _deprecated_function( __METHOD__, '1.7.8' );
192
+ }
193
+
194
+
195
+ /**
196
+ * Allow the notice to be dismissable
197
+ *
198
+ * @since 1.6
199
+ * @deprecated will removed in 2.0
200
+ */
201
+ public function nag_ignore() {
202
+ _deprecated_function( __METHOD__, '1.7.8' );
203
+ }
204
+
205
+ /**
206
+ * Delete the transient when a plugin is activated or deactivated
207
+ *
208
+ * @since 1.5
209
+ * @deprecated will removed in 2.0
210
+ */
211
+ public function delete_transient() {
212
+ _deprecated_function( __METHOD__, '1.7.8' );
213
+ delete_transient( 'nav_menu_roles_conflicts' );
214
+ }
215
+
216
+
217
+ /**
218
+ * Add docu link
219
+ *
220
+ * @since 1.7.3
221
+ * @param array $plugin_meta
222
+ * @param string $plugin_file
223
+ */
224
+ public function add_action_links( $plugin_meta, $plugin_file ) {
225
+ if( $plugin_file == plugin_basename(__FILE__) ){
226
+ $plugin_meta[] = sprintf( '<a class="dashicons-before dashicons-welcome-learn-more" href="https://wordpress.org/plugins/nav-menu-roles/faq/#conflict">%s</a>', __( 'FAQ', 'nav-menu-roles' ) );
227
+ $plugin_meta[] = '<a class="dashicons-before dashicons-admin-generic" href="' . self::DONATE_URL . '" target="_blank">' . __( 'Donate', 'nav-menu-roles' ) . '</a>';
228
+ }
229
+ return $plugin_meta;
230
+ }
231
+
232
+
233
+ /**
234
+ * Override the Admin Menu Walker
235
+ *
236
+ * @since 1.0
237
+ */
238
+ public function edit_nav_menu_walker( $walker ) {
239
+ if( ! class_exists( 'Walker_Nav_Menu_Edit_Roles' ) ) {
240
+
241
+ if ( self::is_wp_gte( '4.7' ) ) {
242
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php' );
243
+ } else if ( self::is_wp_gte( '4.5' ) ) {
244
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles_4.5.php' );
245
+ } else {
246
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/class.Walker_Nav_Menu_Edit_Roles.php' );
247
+ }
248
+ }
249
+ return 'Walker_Nav_Menu_Edit_Roles';
250
+ }
251
+
252
+
253
+ /**
254
+ * Add fields to hook added in Walker
255
+ * This will allow us to play nicely with any other plugin that is adding the same hook
256
+ * @params obj $item - the menu item
257
+ * @params array $args
258
+ * @since 1.6.0
259
+ */
260
+ public function custom_fields( $item_id, $item, $depth, $args ) {
261
+ global $wp_roles;
262
+
263
+ /**
264
+ * Pass the menu item to the filter function.
265
+ * This change is suggested as it allows the use of information from the menu item (and
266
+ * by extension the target object) to further customize what filters appear during menu
267
+ * construction.
268
+ */
269
+ $display_roles = apply_filters( 'nav_menu_roles', $wp_roles->role_names, $item );
270
+
271
+ /**
272
+ * If no roles are being used, don't display the role selection radio buttons at all.
273
+ * Unless something deliberately removes the WordPress roles from this list, nothing will
274
+ * be functionally altered to the end user.
275
+ * This change is suggested for the benefit of users constructing granular admin permissions
276
+ * using extensive custom roles as it is an effective means of stopping admins with partial
277
+ * permissions to the menu from accidentally removing all restrictions from a menu item to
278
+ * which they do not have access.
279
+ */
280
+ if( ! $display_roles ) return;
281
+
282
+ /* Get the roles saved for the post. */
283
+ $roles = get_post_meta( $item->ID, '_nav_menu_role', true );
284
+
285
+ // By default nothing is checked (will match "everyone" radio).
286
+ $logged_in_out = '';
287
+
288
+ // Specific roles are saved as an array, so "in" or an array equals "in" is checked.
289
+ if( is_array( $roles ) || $roles == 'in' ){
290
+ $logged_in_out = 'in';
291
+ } else if ( $roles == 'out' ){
292
+ $logged_in_out = 'out';
293
+ }
294
+
295
+ // The specific roles to check.
296
+ $checked_roles = is_array( $roles ) ? $roles : false;
297
+
298
+ // Whether to display the role checkboxes.
299
+ $hidden = $logged_in_out == 'in' ? '' : 'display: none;';
300
+
301
+ ?>
302
+
303
+ <input type="hidden" name="nav-menu-role-nonce" value="<?php echo wp_create_nonce( 'nav-menu-nonce-name' ); ?>" />
304
+
305
+ <div class="field-nav_menu_role nav_menu_logged_in_out_field description-wide" style="margin: 5px 0;">
306
+ <span class="description"><?php _e( "Display Mode", 'nav-menu-roles' ); ?></span>
307
+ <br />
308
+
309
+ <input type="hidden" class="nav-menu-id" value="<?php echo $item->ID ;?>" />
310
+
311
+ <div class="logged-input-holder" style="float: left; width: 35%;">
312
+ <input type="radio" class="nav-menu-logged-in-out" name="nav-menu-logged-in-out[<?php echo $item->ID ;?>]" id="nav_menu_logged_in-for-<?php echo $item->ID ;?>" <?php checked( 'in', $logged_in_out ); ?> value="in" />
313
+ <label for="nav_menu_logged_in-for-<?php echo $item->ID ;?>">
314
+ <?php _e( 'Logged In Users', 'nav-menu-roles'); ?>
315
+ </label>
316
+ </div>
317
+
318
+ <div class="logged-input-holder" style="float: left; width: 35%;">
319
+ <input type="radio" class="nav-menu-logged-in-out" name="nav-menu-logged-in-out[<?php echo $item->ID ;?>]" id="nav_menu_logged_out-for-<?php echo $item->ID ;?>" <?php checked( 'out', $logged_in_out ); ?> value="out" />
320
+ <label for="nav_menu_logged_out-for-<?php echo $item->ID ;?>">
321
+ <?php _e( 'Logged Out Users', 'nav-menu-roles'); ?>
322
+ </label>
323
+ </div>
324
+
325
+ <div class="logged-input-holder" style="float: left; width: 30%;">
326
+ <input type="radio" class="nav-menu-logged-in-out" name="nav-menu-logged-in-out[<?php echo $item->ID ;?>]" id="nav_menu_by_role-for-<?php echo $item->ID ;?>" <?php checked( '', $logged_in_out ); ?> value="" />
327
+ <label for="nav_menu_by_role-for-<?php echo $item->ID ;?>">
328
+ <?php _e( 'Everyone', 'nav-menu-roles'); ?>
329
+ </label>
330
+ </div>
331
+
332
+ </div>
333
+
334
+ <div class="field-nav_menu_role nav_menu_role_field description-wide" style="margin: 5px 0; <?php echo $hidden;?>">
335
+ <span class="description"><?php _e( "Restrict menu item to a minimum role", 'nav-menu-roles' ); ?></span>
336
+ <br />
337
+
338
+ <?php
339
+
340
+ $i = 1;
341
+
342
+ /* Loop through each of the available roles. */
343
+ foreach ( $display_roles as $role => $name ) {
344
+
345
+ /* If the role has been selected, make sure it's checked. */
346
+ $checked = checked( true, ( is_array( $checked_roles ) && in_array( $role, $checked_roles ) ), false );
347
+
348
+ ?>
349
+
350
+ <div class="role-input-holder" style="margin: 2px 0;">
351
+ <input type="checkbox" name="nav-menu-role[<?php echo $item->ID ;?>][<?php echo $i; ?>]" id="nav_menu_role-<?php echo $role; ?>-for-<?php echo $item->ID ;?>" <?php echo $checked; ?> value="<?php echo $role; ?>" />
352
+ <label for="nav_menu_role-<?php echo $role; ?>-for-<?php echo $item->ID ;?>">
353
+ <?php echo esc_html( $name ); ?>
354
+ <?php $i++; ?>
355
+ </label>
356
+ </div>
357
+
358
+ <?php } ?>
359
+
360
+ </div>
361
+
362
+ <?php
363
+ }
364
+
365
+
366
+ /**
367
+ * Save the roles as menu item meta
368
+ *
369
+ * @since 1.4
370
+ * @return null
371
+ */
372
+ public function enqueue_scripts( $hook ){
373
+ if ( $hook == 'nav-menus.php' ){
374
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
375
+ wp_enqueue_script( 'nav-menu-roles', plugins_url( 'js/nav-menu-roles' . $suffix . '.js' , __FILE__ ), array( 'jquery' ), self::VERSION, true );
376
+ }
377
+ }
378
+
379
+ /**
380
+ * Save the roles as menu item meta
381
+ *
382
+ * @since 1.0
383
+ * @return string
384
+ */
385
+ public function nav_update( $menu_id, $menu_item_db_id ) {
386
+ global $wp_roles;
387
+
388
+ $allowed_roles = apply_filters( 'nav_menu_roles', $wp_roles->role_names );
389
+
390
+ // Verify this came from our screen and with proper authorization.
391
+ if ( ! isset( $_POST['nav-menu-role-nonce'] ) || ! wp_verify_nonce( $_POST['nav-menu-role-nonce'], 'nav-menu-nonce-name' ) ){
392
+ return;
393
+ }
394
+
395
+ $saved_data = false;
396
+
397
+ if ( isset( $_POST['nav-menu-logged-in-out'][$menu_item_db_id] ) && $_POST['nav-menu-logged-in-out'][$menu_item_db_id] == 'in' && ! empty ( $_POST['nav-menu-role'][$menu_item_db_id] ) ) {
398
+
399
+ $custom_roles = array();
400
+
401
+ // Only save allowed roles.
402
+ foreach( (array) $_POST['nav-menu-role'][$menu_item_db_id] as $role ) {
403
+ if ( array_key_exists ( $role, $allowed_roles ) ) {
404
+ $custom_roles[] = $role;
405
+ }
406
+ }
407
+ if ( ! empty ( $custom_roles ) ) {
408
+ $saved_data = $custom_roles;
409
+ }
410
+ } 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' ) ) ) {
411
+ $saved_data = $_POST['nav-menu-logged-in-out'][$menu_item_db_id];
412
+ }
413
+
414
+ if ( $saved_data ) {
415
+ update_post_meta( $menu_item_db_id, '_nav_menu_role', $saved_data );
416
+ } else {
417
+ delete_post_meta( $menu_item_db_id, '_nav_menu_role' );
418
+ }
419
+ }
420
+
421
+ /**
422
+ * Adds value of new field to $item object
423
+ * is be passed to Walker_Nav_Menu_Edit_Custom
424
+ *
425
+ * @since 1.0
426
+ */
427
+ public function setup_nav_item( $menu_item ) {
428
+
429
+ if( is_object( $menu_item ) && isset( $menu_item->ID ) ) {
430
+
431
+ $roles = get_post_meta( $menu_item->ID, '_nav_menu_role', true );
432
+
433
+ if ( ! empty( $roles ) ) {
434
+ $menu_item->roles = $roles;
435
+
436
+ // Add the NMR roles as CSS info.
437
+ $new_classes = array();
438
+
439
+ switch( $roles ) {
440
+ case 'in' :
441
+ $new_classes[] = 'nmr-logged-in';
442
+ break;
443
+ case 'out' :
444
+ $new_classes[] = 'nmr-logged-out';
445
+ break;
446
+ default:
447
+ if ( is_array( $menu_item->roles ) && ! empty( $menu_item->roles ) ) {
448
+ foreach ( $menu_item->roles as $role ) {
449
+ $new_classes[] = 'nmr-' . $role;
450
+ }
451
+ }
452
+ break;
453
+ }
454
+
455
+ // Only apply classes on front-end.
456
+ if( ! is_admin() ) {
457
+ $menu_item->classes = array_unique( array_merge( (array) $menu_item->classes, (array) $new_classes ) );
458
+ }
459
+ }
460
+ }
461
+ return $menu_item;
462
+ }
463
+
464
+ /**
465
+ * Exclude menu items via wp_get_nav_menu_items filter
466
+ * this fixes plugin's incompatibility with theme's that use their own custom Walker
467
+ * Thanks to Evan Stein @vanpop http://vanpop.com/
468
+ *
469
+ * @since 1.2
470
+ *
471
+ * @param WP_Post[] array of Nav Menu Post objects
472
+ *
473
+ * Multisite compatibility added in 1.9.0
474
+ * by @open-dsi https://www.open-dsi.fr/ with props to @fiech
475
+ */
476
+ public function exclude_menu_items( $items ) {
477
+
478
+ $hide_children_of = array();
479
+
480
+ if( ! empty( $items ) ) {
481
+
482
+ // Iterate over the items to search and destroy.
483
+ foreach ( $items as $key => $item ) {
484
+
485
+ $visible = true;
486
+
487
+ // Hide any item that is the child of a hidden item.
488
+ if( isset( $item->menu_item_parent ) && in_array( $item->menu_item_parent, $hide_children_of ) ){
489
+ $visible = false;
490
+ }
491
+
492
+ // Check any item that has NMR roles set.
493
+ if( $visible && isset( $item->roles ) ) {
494
+
495
+ // Check all logged in, all logged out, or role.
496
+ switch( $item->roles ) {
497
+ case 'in' :
498
+ /**
499
+ * Multisite compatibility.
500
+ *
501
+ * For the logged in condition to work,
502
+ * the user has to be a logged in member of the current blog
503
+ * or be a logged in super user.
504
+ */
505
+ $visible = is_user_member_of_blog() || is_super_admin() ? true : false;
506
+ break;
507
+ case 'out' :
508
+ /**
509
+ * Multisite compatibility.
510
+ *
511
+ * For the logged out condition to work,
512
+ * the user has to be either logged out
513
+ * or not be a member of the current blog.
514
+ * But they also may not be a super admin,
515
+ * because logged in super admins should see the internal stuff, not the external.
516
+ */
517
+ $visible = ! is_user_member_of_blog() && ! is_super_admin() ? true : false;
518
+ break;
519
+ default:
520
+ $visible = false;
521
+ if ( is_array( $item->roles ) && ! empty( $item->roles ) ) {
522
+ foreach ( $item->roles as $role ) {
523
+ if ( current_user_can( $role ) ) {
524
+ $visible = true;
525
+ break;
526
+ }
527
+ }
528
+ }
529
+
530
+ break;
531
+ }
532
+
533
+ }
534
+
535
+ /*
536
+ * Filter: nav_menu_roles_item_visibility
537
+ * Add filter to work with plugins that don't use traditional roles
538
+ *
539
+ * @param bool $visible
540
+ * @param object $item
541
+ */
542
+ $visible = apply_filters( 'nav_menu_roles_item_visibility', $visible, $item );
543
+
544
+ // Unset non-visible item.
545
+ if ( ! $visible ) {
546
+ if( isset( $item->ID ) ) {
547
+ $hide_children_of[] = $item->ID; // Store ID of item to hide it's children.
548
+ }
549
+ unset( $items[$key] ) ;
550
+ }
551
+
552
+ }
553
+
554
+ }
555
+
556
+ return $items;
557
+ }
558
+
559
+
560
+ /**
561
+ * Maybe upgrade
562
+ *
563
+ * @access public
564
+ * @return void
565
+ */
566
+ public function maybe_upgrade() {
567
+ $db_version = get_option( 'nav_menu_roles_db_version', false );
568
+
569
+ // 1.7.7 upgrade: changed the debug notice so the old transient is invalid.
570
+ if ( $db_version === false || version_compare( '1.7.7', $db_version, '<' ) ) {
571
+ update_option( 'nav_menu_roles_db_version', self::VERSION );
572
+ }
573
+ }
574
+
575
+ /**
576
+ * Test WordPress version
577
+ *
578
+ * @access public
579
+ * @param string $version - A WordPress version to compare against current version.
580
+ * @return boolean
581
+ */
582
+ public static function is_wp_gte( $version = '5.4' ) {
583
+ global $wp_version;
584
+ return version_compare( strtolower( $wp_version ), strtolower( $version ), '>=' );
585
+ }
586
+
587
+ } // end class
588
+
589
+ endif; // class_exists check
590
+
591
+
592
+ /**
593
+ * Launch the whole plugin
594
+ * Returns the main instance of Nav Menu Roles to prevent the need to use globals.
595
+ *
596
+ * @since 1.5
597
+ * @return Nav_Menu_Roles
598
+ */
599
+ function Nav_Menu_Roles() {
600
+ return Nav_Menu_Roles::instance();
601
+ }
602
+
603
+ // Global for backwards compatibility.
604
  $GLOBALS['Nav_Menu_Roles'] = Nav_Menu_Roles();
readme.txt CHANGED
@@ -1,389 +1,394 @@
1
- === Nav Menu Roles ===
2
-
3
- Contributors: helgatheviking
4
- Donate link: https://www.paypal.com/fundraiser/charity/1451316
5
- Tags: menu, menus, nav menu, nav menus
6
- Requires at least: 4.5.0
7
- Tested up to: 5.4.0
8
- Stable tag: 1.10.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.
12
-
13
- == Description ==
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
-
21
- In WordPress menu items and pages are completely separate entities. Nav Menu Roles does not restrict access to content. Nav Menu Roles is *only* for showing/hiding *nav menu* items. If you wish to restrict content then you need to also be using a membership plugin.
22
-
23
- = Usage =
24
-
25
- 1. Go to Appearance > Menus
26
- 1. Set the "Display Mode" to either "logged in users", "logged out users", or "everyone". "Everyone" is the default.
27
- 1. If you wish to customize by role, set the "Display Mode" to "Logged In Users" and under "Restrict menu item to a minimum role" check the boxes next to the desired roles. **Keep in mind that the role doesn't limit the item strictly to that role, but to everyone who has that role's capability.** For example: an item set to "Subscriber" will be visible by Subscribers *and* by admins. Think of this more as a minimum role required to see an item.
28
-
29
- = Support =
30
-
31
- Support is handled in the [WordPress forums](https://wordpress.org/support/plugin/nav-menu-roles). Please note that support is limited and does not cover any custom implementation of the plugin. Before posting, please read the [FAQ](http://wordpress.org/plugins/nav-menu-roles/faq/). Also, please verify the problem with other plugins disabled and while using a default theme.
32
-
33
- Please report any bugs, errors, warnings, code problems to [Github](https://github.com/helgatheviking/nav-menu-roles/issues)
34
-
35
- == Installation ==
36
-
37
- 1. Upload the `plugin` folder to the `/wp-content/plugins/` directory
38
- 1. Activate the plugin through the 'Plugins' menu in WordPress
39
- 1. Go to Appearance > Menus
40
- 1. Edit the menu items accordingly. First select whether you'd like to display the item to Everyone, all logged out users, or all logged in users.
41
- 1. Logged in users can be further limited to specific roles by checking the boxes next to the roles you'd like to restrict visibility to.
42
-
43
- == Screenshots ==
44
-
45
- 1. Show the new options for the menu items in the admin menu customizer
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
-
53
- WordPress does not have sufficient hooks in this area of the admin and until they do plugins are forced to replace everything via custom admin menu Walker, of which there can be only one. There's a [trac ticket](http://core.trac.wordpress.org/ticket/18584) for this, but it has been around a while.
54
-
55
- **A non-exhaustive list of known conflicts:**
56
-
57
- 1. UberMenu 2.x Mega Menus plugin (UberMenu 3.x supports NMR!)
58
- 2. Add Descendants As Submenu Items plugin
59
- 3. Navception plugin
60
- 4. Suffusion theme
61
- 5. BeTheme
62
- 6. Yith Menu
63
- 7. Jupiter Theme
64
- 8. iMedica theme
65
- 9. Prostyler EVO theme
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):
73
-
74
- `
75
- <?php
76
- // Place this in your admin nav menu Walker
77
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
78
- // end added section
79
- ?>
80
- `
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
-
88
- **Reminder: I do not provide support for fixing your plugin/theme. If you aren't comfortable with the following instructions, contact the developer of the conflicting plugin/theme!**
89
-
90
- 1\. Find the class that extends the `Walker_Nav_Menu`. The fastest way to do this is to search your whole plugin/theme folder for `extends Walker_Nav_Menu`. When you find the file that contains this text you willl know which file you need to edit. Once you find it here's what the beginning of that class will look like:
91
-
92
- `class YOUR_THEME_CUSTOM_WALKER extends Walker_Nav_Menu {}`
93
-
94
- 2\. Find the `start_el()` method
95
-
96
- In that file you will eventually see a class method that looks like:
97
-
98
- `function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
99
- // some stuff truncated for brevity
100
- }
101
- `
102
-
103
- 3\. Paste my action hook somewhere in this method!
104
-
105
- In Nav Menu Roles, I have placed the hook directly after the description, like so:
106
-
107
- `
108
- <p class="field-description description description-wide">
109
- <label for="edit-menu-item-description-<?php echo $item_id; ?>">
110
- <?php _e( 'Description' ); ?><br />
111
- <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>
112
- <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
113
- </label>
114
- </p>
115
-
116
- <?php
117
- // Add this directly after the description paragraph in the start_el() method
118
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
119
- // end added section
120
- ?>
121
- `
122
-
123
- = Workaround #2 =
124
-
125
- As a workaround, you can switch to a default theme (or disable the conflicting plugin), edit the Nav Menu Roles, for each menu item, then revert to your original theme/ reenable the conflicting plugin. The front-end functionality of Nav Menu Roles will still work.
126
-
127
- = Workaround #3 =
128
-
129
- Download and install this [tiny plugin](https://gist.github.com/helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c). Activate it when you need to make the NMR options appear and then disable it when you are done editing.
130
-
131
- = I'm using XYZ Membership plugin and I don't see its "levels"? =
132
-
133
- There are apparently a few membership plugins out there that *don't* use traditional WordPress roles/capabilities. My plugin will list any role registered in the traditional WordPress way. If your membership plugin is using some other system, then Nav Menu Roles won't work with it out of the box. Since 1.3.5 I've added a filter called `nav_menu_roles_item_visibility` just before my code decides whether to show/hide a menu item. There's also always been the `nav_menu_roles` filter which lets you modify the roles listed in the admin. Between these two, I believe you have enough to integrate Nav Menu Roles with any membership plugin.
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
- The roles in NMR are filterable distinct from the global `$wp_roles`. This allows for compatibility to be added between plugins that don't use the core roles to determine access, like some membership plugins.
140
-
141
- `
142
- /*
143
- * Add custom roles to Nav Menu Roles menu list
144
- * param: $roles an array of all available roles, by default is global $wp_roles
145
- * return: array
146
- */
147
- function kia_new_roles( $roles ){
148
- $roles['new-role-key'] = 'new-role';
149
- return $roles;
150
- }
151
- add_filter( 'nav_menu_roles', 'kia_new_roles' );
152
- `
153
-
154
- Note, if you want to add a WordPress capability the above is literally all you need. Because Nav Menu Roles checks whether a role has permission to view the menu item using `current_user_can($role) you do not need to right a custom callback for the `nav_menu_roles_item_visibility` filter.
155
-
156
- In case you *do* need to check your visibility status against something very custom, here is how you'd go about it:
157
-
158
- `
159
- /*
160
- * Change visibilty of each menu item
161
- * param: $visible boolean
162
- * param: $item object, the complete menu object. Nav Menu Roles adds its info to $item->roles
163
- * $item->roles can be "in" (all logged in), "out" (all logged out) or an array of specific roles
164
- * return boolean
165
- */
166
- function kia_item_visibility( $visible, $item ){
167
- if( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'new-role-key', $item->roles ) ){
168
- /* if ( // your own custom check on the current user versus 'new-role' status ){
169
- $visible = true;
170
- } else {
171
- $visible = false;
172
- }
173
- */ }
174
- return $visible;
175
- }
176
- add_filter( 'nav_menu_roles_item_visibility', 'kia_item_visibility', 10, 2 );
177
- `
178
-
179
- Note that you have to generate your own if/then logic. I can't provide free support for custom integration with another plugin. You may [contact me](http://kathyisawesome.com/contact) to discuss hiring me, or I would suggest using a plugin that supports WordPress' roles, such as Justin Tadlock's [Members](http://wordpress.org/plugins/members).
180
-
181
-
182
- = Existing Compatibility Plugins =
183
-
184
- 1. [Wishlists Memberships](https://github.com/helgatheviking/nav-menu-roles-wishlists-memberships)
185
- 2. [WooCommerce Memberships](https://github.com/helgatheviking/nav-menu-roles-woocommerce-memberships)
186
-
187
- If your membership plugin is not listed here, you may be able to use the above bridge plugins as a template. Scroll down to the bottom of the main plugin file and you will see a section for "Helper Functions". If you modify the 3 wrapper functions according to your membership plugin's logic, the rest of the plugin should handle the integration with Nav Menu Roles.
188
-
189
- = Sort the roles alphabetically =
190
-
191
- Add the following snippet to your theme's `functions.php` file:
192
-
193
- `
194
- /*
195
- * Sort the NMR roles
196
- * @param: $roles an array of all available roles with ID=>Name
197
- * @return: array
198
- */
199
- function kia_sort_roles( $roles ){
200
- if( is_admin() ) {
201
- $array_lowercase = array_map( 'strtolower', $roles );
202
- array_multisort( $array_lowercase, SORT_ASC, SORT_STRING, $roles );
203
- return $roles;
204
- }
205
- }
206
- add_filter( 'nav_menu_roles', 'kia_sort_roles' );
207
- `
208
-
209
- = The menu exploded? Why are all my pages displaying for logged out users? =
210
-
211
- If every item in your menu is configured to display to logged in users (either all logged in users, or by specific role), then when a logged out visitor comes to your site there are no items in the menu to display. `wp_nav_menu()` will then try check its `fallback_cb` argument... which defaults to `wp_page_menu`.
212
-
213
- Therefore, if you have no items to display, WordPress will end up displaying ALL your pages!!
214
-
215
- If you don't want this, you must set the fallback argument to be a null string.
216
-
217
- `
218
- wp_nav_menu( array( 'theme_location' => 'primary-menu', 'fallback_cb' => '' ) );
219
- `
220
-
221
- = What happened to my menu roles on import/export? =
222
-
223
- The Nav Menu Roles plugin stores 1 piece of post *meta* to every menu item/post. This is exported just fine by the default Export tool.
224
-
225
- However, the Import plugin only imports certain post meta for menu items. As of version 1.3, I've added a custom Importer to Nav Menu Roles as a work around.
226
-
227
- = How Do I Use the Custom Importer? =
228
-
229
- 1. Go to Tools>Export, choose to export All Content and download the Export file
230
- 1. Go to Tools>Import on your new site and perform your normal WordPress import
231
- 1. Return to Tools>Import and this time select the Nav Menu Roles importer.
232
- 1. Use the same .xml file and perform a second import
233
- 1. No duplicate posts will be created but all menu post meta (including your Nav Menu Roles info) will be imported
234
-
235
- = Is Nav Menu Roles compatible with WPML ? =
236
-
237
- Yes, but manually. WPML developers have informed me that the meta data for nav menu items is **not** synced by WPML, meaning that menus copied into a new language will not bring their custom Nav Menu Roles settings. However, if you manually reconfigure the settings, the new language menu will work as expected.
238
-
239
- == Changelog ==
240
-
241
- = 1.10.1 =
242
- * Fix: Only auto-apply classes on front-end. Prevents appending duplicate classes on each save.
243
-
244
- = 1.10.0 =
245
- * Fix: My hook made it into core for WP5.4!! Can finally stop overriding the admin menu Walker.
246
-
247
- = 1.9.5 =
248
- * Fix: PHP Notice: Undefined variable $item
249
-
250
- = 1.9.4 =
251
- * Add the NMR roles as css classes to the menu output
252
- * Improve menu editor role checkbox list UX, by making list items full-width. Props @lkraav
253
-
254
- = 1.9.3 =
255
- * Check all object properties exist before accessing. Resolves PHP notices for custom menu items.
256
-
257
- = 1.9.2 =
258
- * Include a !empty() check on menu $items
259
- * Update donation link
260
-
261
- = 1.9.1 =
262
- * Update donation link
263
- * Update required and tested against versions
264
-
265
- = 1.9.0 =
266
- * Add support for multisite. Props @open-dsi and @fiech.
267
-
268
- = 1.8.5 =
269
- * Use new Walker for WP4.7
270
-
271
- = 1.8.4 =
272
- * Prevent nav menu items edited in the customizer from rendering when they should be excluded
273
-
274
- = 1.8.3 =
275
- * Remove deprecated screen_icon()
276
-
277
- = 1.8.2 =
278
- * Reduce number of parameters passed to `add_action_links` filter
279
-
280
- = 1.8.1 =
281
- * Switch input names to use a counter [nav-menu-role][100][1]. For some reason [nav-menu-role][100][] doesn't post an array and hypenated names [nav-menu-role][100][gold-plan] wreak havoc on the save routine. Shouldn't impact anyone not using hyphenated role names.
282
-
283
- = 1.8.0 =
284
- * Fix style issue in WordPress 4.5
285
-
286
- = 1.7.9 =
287
- * revert priority of walker back to default because themes are not actually using the hook to add their own fields. sadface.
288
-
289
- = 1.7.8 =
290
- * remove all admin notices
291
-
292
- = 1.7.7 =
293
- * add fancy debug messages
294
-
295
- = 1.7.6 =
296
- * tweak CSS to initially hide checkboxes on newly added menu items (defaults to "Everyone" so roles should not appear)
297
-
298
- = 1.7.5 =
299
- * Update Walker_Nav_Menu_Edit_Roles to mimic Walker_Nav_Menu in WordPress 4.4
300
-
301
- = 1.7.4 =
302
- * Change language in metabox to try to explain min caps versus strict role checking
303
- * keep tweaking the FAQ
304
-
305
- = 1.7.3 =
306
- * update readme, update error notice, add more links to the FAQ
307
-
308
- = 1.7.2 =
309
- * add Italian language. props @sododesign
310
-
311
- = 1.7.1 =
312
- * Updated FAQ with patch instructions for conflicting plugins/themes
313
- * add Portugeuse language. props @brunobarros
314
-
315
- = 1.7.0 =
316
- * adjust admin UI to be more user-friendly. Options are now: show to everyone, show to logged out users, and show to logged in users (optionally, logged in users by specific role)
317
-
318
- = 1.6.5 =
319
- * add Guajarati language. props @rohilmistry93
320
-
321
- = 1.6.4 =
322
- * more language issues -> sync svn+git version numbers
323
-
324
- = 1.6.3 =
325
- * Try again to add languages. Where'd they all go?
326
-
327
- = 1.6.2 =
328
- * Add French translation. Props @Philippe Gilles
329
-
330
- = 1.6.1 =
331
- * Update list of conflits
332
- * Don't display radio buttons if no roles - allows for granular permissions control
333
-
334
- = 1.6.0 =
335
- * Feature: Hiding a parent menu item will automatically hide all its children
336
- * Feature: Add compatibility with Menu Item Visibility Control plugin and any plugin/theme that is willing to add its inputs via the `wp_nav_menu_item_custom_fields` hook. See the [FAQ](http://wordpress.org/plugins/nav-menu-roles/faq/#compatibility) to make our plugins compatible.
337
-
338
- = 1.5.1 =
339
- * Hopefully fix missing nav-menu-roles.min.js SVN issue
340
-
341
- = 1.5.0 =
342
- * Switch to instance of plugin
343
- * Add notice when conflicting plugins are detected
344
- * Remove some extraneous parameters
345
- * Add Spanish translation thanks to @deskarrada
346
-
347
- = 1.4.1 =
348
- * update to WP 3.8 version of Walker_Nav_Menu_Edit (prolly not any different from 3.7.1)
349
- * minor CSS adjustment to admin menu items
350
- * checked against WP 3.8
351
-
352
- = 1.4 =
353
- * Add to FAQ
354
- * add JS flair to admin menu items
355
- * update to WP 3.7.1 version of Walker_Nav_Menu_Edit
356
-
357
- = 1.3.5 =
358
- * Add nav_menu_roles_item_visibility filter to work with plugins that don't use traditional roles
359
-
360
- = 1.3.4 =
361
- * Update admin language thanks to @hassanhamm
362
- * Add Arabic translation thanks to @hassanhamm
363
-
364
- = 1.3.3 =
365
- * Fix Nav_Menu_Roles_Import not found error
366
-
367
- = 1.3.2 =
368
- * Stupid comment error causing save issues
369
-
370
- = 1.3.1 =
371
- * SVN failure to include importer files!
372
-
373
- = 1.3 =
374
- * Added custom importer
375
-
376
- = 1.2 =
377
- * Major fix for theme's that use their own custom Walkers, thanks to Evan Stein @vanpop http://vanpop.com/
378
- * Instead of a custom nav Walker, menu items are controlled through the wp_get_nav_menu_items filter
379
- * Remove the custom nav Walker code
380
-
381
- = 1.1.1 =
382
- * Fix link to plugin site
383
- * Fix labels in admin Walker
384
-
385
- = 1.1 =
386
- * Clean up debug messages
387
-
388
- = 1.0 =
389
- * Initial release
 
 
 
 
 
1
+ === Nav Menu Roles ===
2
+
3
+ Contributors: helgatheviking
4
+ Donate link: https://www.paypal.com/fundraiser/charity/1451316
5
+ Tags: menu, menus, nav menu, nav menus
6
+ Requires at least: 4.5.0
7
+ Tested up to: 5.4.0
8
+ Requires PHP: 5.3.2
9
+ Stable tag: 1.10.2
10
+ License: GPLv3
11
+
12
+ Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
13
+
14
+ == Description ==
15
+
16
+ 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.
17
+
18
+ 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.
19
+
20
+ = IMPORTANT NOTE =
21
+
22
+ In WordPress menu items and pages are completely separate entities. Nav Menu Roles does not restrict access to content. Nav Menu Roles is *only* for showing/hiding *nav menu* items. If you wish to restrict content then you need to also be using a membership plugin.
23
+
24
+ = Usage =
25
+
26
+ 1. Go to Appearance > Menus
27
+ 1. Set the "Display Mode" to either "logged in users", "logged out users", or "everyone". "Everyone" is the default.
28
+ 1. If you wish to customize by role, set the "Display Mode" to "Logged In Users" and under "Restrict menu item to a minimum role" check the boxes next to the desired roles. **Keep in mind that the role doesn't limit the item strictly to that role, but to everyone who has that role's capability.** For example: an item set to "Subscriber" will be visible by Subscribers *and* by admins. Think of this more as a minimum role required to see an item.
29
+
30
+ = Support =
31
+
32
+ Support is handled in the [WordPress forums](https://wordpress.org/support/plugin/nav-menu-roles). Please note that support is limited and does not cover any custom implementation of the plugin. Before posting, please read the [FAQ](http://wordpress.org/plugins/nav-menu-roles/faq/). Also, please verify the problem with other plugins disabled and while using a default theme.
33
+
34
+ Please report any bugs, errors, warnings, code problems to [Github](https://github.com/helgatheviking/nav-menu-roles/issues)
35
+
36
+ == Installation ==
37
+
38
+ 1. Upload the `plugin` folder to the `/wp-content/plugins/` directory
39
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
40
+ 1. Go to Appearance > Menus
41
+ 1. Edit the menu items accordingly. First select whether you'd like to display the item to Everyone, all logged out users, or all logged in users.
42
+ 1. Logged in users can be further limited to specific roles by checking the boxes next to the roles you'd like to restrict visibility to.
43
+
44
+ == Screenshots ==
45
+
46
+ 1. Show the new options for the menu items in the admin menu customizer
47
+
48
+ == Frequently Asked Questions ==
49
+
50
+ = I don't see the Nav Menu Roles options in the admin menu items? =
51
+
52
+ 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.
53
+
54
+ WordPress does not have sufficient hooks in this area of the admin and until they do plugins are forced to replace everything via custom admin menu Walker, of which there can be only one. There's a [trac ticket](http://core.trac.wordpress.org/ticket/18584) for this, but it has been around a while.
55
+
56
+ **A non-exhaustive list of known conflicts:**
57
+
58
+ 1. UberMenu 2.x Mega Menus plugin (UberMenu 3.x supports NMR!)
59
+ 2. Add Descendants As Submenu Items plugin
60
+ 3. Navception plugin
61
+ 4. Suffusion theme
62
+ 5. BeTheme
63
+ 6. Yith Menu
64
+ 7. Jupiter Theme
65
+ 8. iMedica theme
66
+ 9. Prostyler EVO theme
67
+ 10. Mega Main Plugin
68
+
69
+
70
+ = Workaround #1 =
71
+ [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.
72
+
73
+ 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):
74
+
75
+ `
76
+ <?php
77
+ // Place this in your admin nav menu Walker
78
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
79
+ // end added section
80
+ ?>
81
+ `
82
+
83
+ **Ask your conflicting plugin/theme's author to add this code to his plugin or theme and our plugins will become compatible.**
84
+
85
+ = Instructions for Patching Your Plugin/Theme =
86
+
87
+ Should you wish to attempt this patch yourself, you can modify your conflicting plugin/theme's admin menu Walker class.
88
+
89
+ **Reminder: I do not provide support for fixing your plugin/theme. If you aren't comfortable with the following instructions, contact the developer of the conflicting plugin/theme!**
90
+
91
+ 1\. Find the class that extends the `Walker_Nav_Menu`. The fastest way to do this is to search your whole plugin/theme folder for `extends Walker_Nav_Menu`. When you find the file that contains this text you willl know which file you need to edit. Once you find it here's what the beginning of that class will look like:
92
+
93
+ `class YOUR_THEME_CUSTOM_WALKER extends Walker_Nav_Menu {}`
94
+
95
+ 2\. Find the `start_el()` method
96
+
97
+ In that file you will eventually see a class method that looks like:
98
+
99
+ `function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
100
+ // some stuff truncated for brevity
101
+ }
102
+ `
103
+
104
+ 3\. Paste my action hook somewhere in this method!
105
+
106
+ In Nav Menu Roles, I have placed the hook directly after the description, like so:
107
+
108
+ `
109
+ <p class="field-description description description-wide">
110
+ <label for="edit-menu-item-description-<?php echo $item_id; ?>">
111
+ <?php _e( 'Description' ); ?><br />
112
+ <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>
113
+ <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
114
+ </label>
115
+ </p>
116
+
117
+ <?php
118
+ // Add this directly after the description paragraph in the start_el() method
119
+ do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
120
+ // end added section
121
+ ?>
122
+ `
123
+
124
+ = Workaround #2 =
125
+
126
+ As a workaround, you can switch to a default theme (or disable the conflicting plugin), edit the Nav Menu Roles, for each menu item, then revert to your original theme/ reenable the conflicting plugin. The front-end functionality of Nav Menu Roles will still work.
127
+
128
+ = Workaround #3 =
129
+
130
+ Download and install this [tiny plugin](https://gist.github.com/helgatheviking/d00f9c033a4b0aab0f69cf50d7dcd89c). Activate it when you need to make the NMR options appear and then disable it when you are done editing.
131
+
132
+ = I'm using XYZ Membership plugin and I don't see its "levels"? =
133
+
134
+ There are apparently a few membership plugins out there that *don't* use traditional WordPress roles/capabilities. My plugin will list any role registered in the traditional WordPress way. If your membership plugin is using some other system, then Nav Menu Roles won't work with it out of the box. Since 1.3.5 I've added a filter called `nav_menu_roles_item_visibility` just before my code decides whether to show/hide a menu item. There's also always been the `nav_menu_roles` filter which lets you modify the roles listed in the admin. Between these two, I believe you have enough to integrate Nav Menu Roles with any membership plugin.
135
+
136
+ 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.
137
+
138
+ = Adding a new "role" =
139
+
140
+ The roles in NMR are filterable distinct from the global `$wp_roles`. This allows for compatibility to be added between plugins that don't use the core roles to determine access, like some membership plugins.
141
+
142
+ `
143
+ /*
144
+ * Add custom roles to Nav Menu Roles menu list
145
+ * param: $roles an array of all available roles, by default is global $wp_roles
146
+ * return: array
147
+ */
148
+ function kia_new_roles( $roles ){
149
+ $roles['new-role-key'] = 'new-role';
150
+ return $roles;
151
+ }
152
+ add_filter( 'nav_menu_roles', 'kia_new_roles' );
153
+ `
154
+
155
+ Note, if you want to add a WordPress capability the above is literally all you need. Because Nav Menu Roles checks whether a role has permission to view the menu item using `current_user_can($role) you do not need to right a custom callback for the `nav_menu_roles_item_visibility` filter.
156
+
157
+ In case you *do* need to check your visibility status against something very custom, here is how you'd go about it:
158
+
159
+ `
160
+ /*
161
+ * Change visibilty of each menu item
162
+ * param: $visible boolean
163
+ * param: $item object, the complete menu object. Nav Menu Roles adds its info to $item->roles
164
+ * $item->roles can be "in" (all logged in), "out" (all logged out) or an array of specific roles
165
+ * return boolean
166
+ */
167
+ function kia_item_visibility( $visible, $item ){
168
+ if( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'new-role-key', $item->roles ) ){
169
+ /* if ( // your own custom check on the current user versus 'new-role' status ){
170
+ $visible = true;
171
+ } else {
172
+ $visible = false;
173
+ }
174
+ */ }
175
+ return $visible;
176
+ }
177
+ add_filter( 'nav_menu_roles_item_visibility', 'kia_item_visibility', 10, 2 );
178
+ `
179
+
180
+ Note that you have to generate your own if/then logic. I can't provide free support for custom integration with another plugin. You may [contact me](http://kathyisawesome.com/contact) to discuss hiring me, or I would suggest using a plugin that supports WordPress' roles, such as Justin Tadlock's [Members](http://wordpress.org/plugins/members).
181
+
182
+
183
+ = Existing Compatibility Plugins =
184
+
185
+ 1. [Wishlists Memberships](https://github.com/helgatheviking/nav-menu-roles-wishlists-memberships)
186
+ 2. [WooCommerce Memberships](https://github.com/helgatheviking/nav-menu-roles-woocommerce-memberships)
187
+
188
+ If your membership plugin is not listed here, you may be able to use the above bridge plugins as a template. Scroll down to the bottom of the main plugin file and you will see a section for "Helper Functions". If you modify the 3 wrapper functions according to your membership plugin's logic, the rest of the plugin should handle the integration with Nav Menu Roles.
189
+
190
+ = Sort the roles alphabetically =
191
+
192
+ Add the following snippet to your theme's `functions.php` file:
193
+
194
+ `
195
+ /*
196
+ * Sort the NMR roles
197
+ * @param: $roles an array of all available roles with ID=>Name
198
+ * @return: array
199
+ */
200
+ function kia_sort_roles( $roles ){
201
+ if( is_admin() ) {
202
+ $array_lowercase = array_map( 'strtolower', $roles );
203
+ array_multisort( $array_lowercase, SORT_ASC, SORT_STRING, $roles );
204
+ return $roles;
205
+ }
206
+ }
207
+ add_filter( 'nav_menu_roles', 'kia_sort_roles' );
208
+ `
209
+
210
+ = The menu exploded? Why are all my pages displaying for logged out users? =
211
+
212
+ If every item in your menu is configured to display to logged in users (either all logged in users, or by specific role), then when a logged out visitor comes to your site there are no items in the menu to display. `wp_nav_menu()` will then try check its `fallback_cb` argument... which defaults to `wp_page_menu`.
213
+
214
+ Therefore, if you have no items to display, WordPress will end up displaying ALL your pages!!
215
+
216
+ If you don't want this, you must set the fallback argument to be a null string.
217
+
218
+ `
219
+ wp_nav_menu( array( 'theme_location' => 'primary-menu', 'fallback_cb' => '' ) );
220
+ `
221
+
222
+ = What happened to my menu roles on import/export? =
223
+
224
+ The Nav Menu Roles plugin stores 1 piece of post *meta* to every menu item/post. This is exported just fine by the default Export tool.
225
+
226
+ However, the Import plugin only imports certain post meta for menu items. As of version 1.3, I've added a custom Importer to Nav Menu Roles as a work around.
227
+
228
+ = How Do I Use the Custom Importer? =
229
+
230
+ 1. Go to Tools>Export, choose to export All Content and download the Export file
231
+ 1. Go to Tools>Import on your new site and perform your normal WordPress import
232
+ 1. Return to Tools>Import and this time select the Nav Menu Roles importer.
233
+ 1. Use the same .xml file and perform a second import
234
+ 1. No duplicate posts will be created but all menu post meta (including your Nav Menu Roles info) will be imported
235
+
236
+ = Is Nav Menu Roles compatible with WPML ? =
237
+
238
+ Yes, but manually. WPML developers have informed me that the meta data for nav menu items is **not** synced by WPML, meaning that menus copied into a new language will not bring their custom Nav Menu Roles settings. However, if you manually reconfigure the settings, the new language menu will work as expected.
239
+
240
+ == Changelog ==
241
+
242
+
243
+ = 1.10.2 =
244
+ * Fix: Strict array typecasting for nav menu classes.
245
+
246
+ = 1.10.1 =
247
+ * Fix: Only auto-apply classes on front-end. Prevents appending duplicate classes on each save.
248
+
249
+ = 1.10.0 =
250
+ * Fix: My hook made it into core for WP5.4!! Can finally stop overriding the admin menu Walker.
251
+
252
+ = 1.9.5 =
253
+ * Fix: PHP Notice: Undefined variable $item
254
+
255
+ = 1.9.4 =
256
+ * Add the NMR roles as css classes to the menu output
257
+ * Improve menu editor role checkbox list UX, by making list items full-width. Props @lkraav
258
+
259
+ = 1.9.3 =
260
+ * Check all object properties exist before accessing. Resolves PHP notices for custom menu items.
261
+
262
+ = 1.9.2 =
263
+ * Include a !empty() check on menu $items
264
+ * Update donation link
265
+
266
+ = 1.9.1 =
267
+ * Update donation link
268
+ * Update required and tested against versions
269
+
270
+ = 1.9.0 =
271
+ * Add support for multisite. Props @open-dsi and @fiech.
272
+
273
+ = 1.8.5 =
274
+ * Use new Walker for WP4.7
275
+
276
+ = 1.8.4 =
277
+ * Prevent nav menu items edited in the customizer from rendering when they should be excluded
278
+
279
+ = 1.8.3 =
280
+ * Remove deprecated screen_icon()
281
+
282
+ = 1.8.2 =
283
+ * Reduce number of parameters passed to `add_action_links` filter
284
+
285
+ = 1.8.1 =
286
+ * Switch input names to use a counter [nav-menu-role][100][1]. For some reason [nav-menu-role][100][] doesn't post an array and hypenated names [nav-menu-role][100][gold-plan] wreak havoc on the save routine. Shouldn't impact anyone not using hyphenated role names.
287
+
288
+ = 1.8.0 =
289
+ * Fix style issue in WordPress 4.5
290
+
291
+ = 1.7.9 =
292
+ * revert priority of walker back to default because themes are not actually using the hook to add their own fields. sadface.
293
+
294
+ = 1.7.8 =
295
+ * remove all admin notices
296
+
297
+ = 1.7.7 =
298
+ * add fancy debug messages
299
+
300
+ = 1.7.6 =
301
+ * tweak CSS to initially hide checkboxes on newly added menu items (defaults to "Everyone" so roles should not appear)
302
+
303
+ = 1.7.5 =
304
+ * Update Walker_Nav_Menu_Edit_Roles to mimic Walker_Nav_Menu in WordPress 4.4
305
+
306
+ = 1.7.4 =
307
+ * Change language in metabox to try to explain min caps versus strict role checking
308
+ * keep tweaking the FAQ
309
+
310
+ = 1.7.3 =
311
+ * update readme, update error notice, add more links to the FAQ
312
+
313
+ = 1.7.2 =
314
+ * add Italian language. props @sododesign
315
+
316
+ = 1.7.1 =
317
+ * Updated FAQ with patch instructions for conflicting plugins/themes
318
+ * add Portugeuse language. props @brunobarros
319
+
320
+ = 1.7.0 =
321
+ * adjust admin UI to be more user-friendly. Options are now: show to everyone, show to logged out users, and show to logged in users (optionally, logged in users by specific role)
322
+
323
+ = 1.6.5 =
324
+ * add Guajarati language. props @rohilmistry93
325
+
326
+ = 1.6.4 =
327
+ * more language issues -> sync svn+git version numbers
328
+
329
+ = 1.6.3 =
330
+ * Try again to add languages. Where'd they all go?
331
+
332
+ = 1.6.2 =
333
+ * Add French translation. Props @Philippe Gilles
334
+
335
+ = 1.6.1 =
336
+ * Update list of conflits
337
+ * Don't display radio buttons if no roles - allows for granular permissions control
338
+
339
+ = 1.6.0 =
340
+ * Feature: Hiding a parent menu item will automatically hide all its children
341
+ * Feature: Add compatibility with Menu Item Visibility Control plugin and any plugin/theme that is willing to add its inputs via the `wp_nav_menu_item_custom_fields` hook. See the [FAQ](http://wordpress.org/plugins/nav-menu-roles/faq/#compatibility) to make our plugins compatible.
342
+
343
+ = 1.5.1 =
344
+ * Hopefully fix missing nav-menu-roles.min.js SVN issue
345
+
346
+ = 1.5.0 =
347
+ * Switch to instance of plugin
348
+ * Add notice when conflicting plugins are detected
349
+ * Remove some extraneous parameters
350
+ * Add Spanish translation thanks to @deskarrada
351
+
352
+ = 1.4.1 =
353
+ * update to WP 3.8 version of Walker_Nav_Menu_Edit (prolly not any different from 3.7.1)
354
+ * minor CSS adjustment to admin menu items
355
+ * checked against WP 3.8
356
+
357
+ = 1.4 =
358
+ * Add to FAQ
359
+ * add JS flair to admin menu items
360
+ * update to WP 3.7.1 version of Walker_Nav_Menu_Edit
361
+
362
+ = 1.3.5 =
363
+ * Add nav_menu_roles_item_visibility filter to work with plugins that don't use traditional roles
364
+
365
+ = 1.3.4 =
366
+ * Update admin language thanks to @hassanhamm
367
+ * Add Arabic translation thanks to @hassanhamm
368
+
369
+ = 1.3.3 =
370
+ * Fix Nav_Menu_Roles_Import not found error
371
+
372
+ = 1.3.2 =
373
+ * Stupid comment error causing save issues
374
+
375
+ = 1.3.1 =
376
+ * SVN failure to include importer files!
377
+
378
+ = 1.3 =
379
+ * Added custom importer
380
+
381
+ = 1.2 =
382
+ * Major fix for theme's that use their own custom Walkers, thanks to Evan Stein @vanpop http://vanpop.com/
383
+ * Instead of a custom nav Walker, menu items are controlled through the wp_get_nav_menu_items filter
384
+ * Remove the custom nav Walker code
385
+
386
+ = 1.1.1 =
387
+ * Fix link to plugin site
388
+ * Fix labels in admin Walker
389
+
390
+ = 1.1 =
391
+ * Clean up debug messages
392
+
393
+ = 1.0 =
394
+ * Initial release