Nav Menu Roles - Version 1.7.8

Version Description

  • remove all admin notices
Download this release

Release Info

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

Code changes from version 1.7.7 to 1.7.8

.gitignore DELETED
@@ -1,11 +0,0 @@
1
- *.gitcreds
2
- node_modules/
3
- temp/
4
- build/
5
- svn/
6
- wp-assets/
7
- deploy.sh
8
- sftp-config.json
9
- *.sublime-workspace
10
- *.sublime-project
11
- *.transifexrc
 
 
 
 
 
 
 
 
 
 
 
Gruntfile.js DELETED
@@ -1,208 +0,0 @@
1
- module.exports = function(grunt) {
2
-
3
- // load most all grunt tasks
4
- require('load-grunt-tasks')(grunt);
5
-
6
- // Project configuration.
7
- grunt.initConfig({
8
- pkg: grunt.file.readJSON('package.json'),
9
- uglify: {
10
- options: {
11
- compress: {
12
- global_defs: {
13
- "EO_SCRIPT_DEBUG": false
14
- },
15
- dead_code: true
16
- },
17
- banner: '/*! <%= pkg.name %> <%= pkg.version %> */\n'
18
- },
19
- build: {
20
- files: [{
21
- expand: true, // Enable dynamic expansion.
22
- src: ['js/*.js', '!js/*.min.js'], // Actual pattern(s) to match.
23
- ext: '.min.js', // Dest filepaths will have this extension.
24
- }, ]
25
- }
26
- },
27
- jshint: {
28
- options: {
29
- reporter: require('jshint-stylish'),
30
- globals: {
31
- "EO_SCRIPT_DEBUG": false,
32
- },
33
- '-W020': true, //Read only - error when assigning EO_SCRIPT_DEBUG a value.
34
- },
35
- all: ['js/*.js', '!js/*.min.js']
36
- },
37
-
38
- // Remove the build directory files
39
- clean: {
40
- main: ['build/**']
41
- },
42
-
43
- // Copy the plugin into the build directory
44
- copy: {
45
- main: {
46
- src: [
47
- '**',
48
- '!node_modules/**',
49
- '!build/**',
50
- '!svn/**',
51
- '!wp-assets/**',
52
- '!.git/**',
53
- '!**.md',
54
- '!Gruntfile.js',
55
- '!package.json',
56
- '!gitcreds.json',
57
- '!.gitcreds',
58
- '!.transifexrc',
59
- '!.gitignore',
60
- '!.gitmodules',
61
- '!sftp-config.json',
62
- '!**.sublime-workspace',
63
- '!**.sublime-project',
64
- '!deploy.sh',
65
- '!**/*~'
66
- ],
67
- dest: 'build/'
68
- }
69
- },
70
-
71
- // Generate git readme from readme.txt
72
- wp_readme_to_markdown: {
73
- convert: {
74
- files: {
75
- 'readme.md': 'readme.txt'
76
- },
77
- },
78
- },
79
-
80
- // # Internationalization
81
-
82
- // Add text domain
83
- addtextdomain: {
84
- textdomain: '<%= pkg.name %>',
85
- target: {
86
- files: {
87
- src: ['*.php', '**/*.php', '!node_modules/**', '!build/**']
88
- }
89
- }
90
- },
91
-
92
- // Generate .pot file
93
- makepot: {
94
- target: {
95
- options: {
96
- domainPath: '/languages', // Where to save the POT file.
97
- exclude: ['build/.*', 'svn/.*'], // List of files or directories to ignore.
98
- mainFile: '<%= pkg.name %>.php', // Main project file.
99
- potFilename: '<%= pkg.name %>.pot', // Name of the POT file.
100
- type: 'wp-plugin' // Type of project (wp-plugin or wp-theme).
101
- }
102
- }
103
- },
104
-
105
- transifex: {
106
- 'nav-menu-roles': {
107
- options: {
108
- targetDir: "languages",
109
- mode: "file",
110
- filename : "_resource_-_lang_.po",
111
- }
112
- }
113
- },
114
-
115
- // Create .mo files for existing .po
116
- po2mo: {
117
- files: {
118
- src: 'languages/*.po',
119
- expand: true,
120
- },
121
- },
122
-
123
- // # Check some git repo settings
124
- checkrepo: {
125
- deploy: {
126
- tag: {
127
- eq: '<%= pkg.version %>', // Check if highest repo tag is equal to pkg.version
128
- },
129
- tagged: false, // Check if last repo commit (HEAD) is not tagged
130
- clean: true, // Check if the repo working directory is clean
131
- }
132
- },
133
-
134
- // # Check the plugin, package & readme files have same version
135
- checkwpversion: {
136
- plugin_equals_stable: {
137
- version1: 'plugin',
138
- version2: 'readme',
139
- compare: '==',
140
- },
141
- plugin_equals_package: {
142
- version1: 'plugin',
143
- version2: '<%= pkg.version %>',
144
- compare: '==',
145
- },
146
- },
147
-
148
- // bump version numbers
149
- replace: {
150
- Version: {
151
- src: [
152
- 'readme.txt',
153
- 'readme.md',
154
- '<%= pkg.name %>.php'
155
- ],
156
- overwrite: true,
157
- replacements: [
158
- {
159
- from: /Stable tag:.*$/m,
160
- to: "Stable tag: <%= pkg.version %>"
161
- },
162
- {
163
- from: /Version:.*$/m,
164
- to: "Version: <%= pkg.version %>"
165
- },
166
- {
167
- from: /public \$version = \'.*.'/m,
168
- to: "public $version = '<%= pkg.version %>'"
169
- }
170
- ]
171
- }
172
- },
173
- // # Deploy to WordPress
174
-
175
- wp_deploy: {
176
- deploy: {
177
- options: {
178
- svn_user: '<%= pkg.author %>',
179
- plugin_slug: '<%= pkg.name %>',
180
- build_dir: 'build/',
181
- assets_dir: 'wp-assets/'
182
- },
183
- }
184
- },
185
-
186
- });
187
-
188
- // makepot and addtextdomain tasks
189
- grunt.loadNpmTasks('grunt-wp-i18n');
190
-
191
- // Default task(s).
192
- grunt.registerTask('default', ['jshint', 'uglify']);
193
-
194
- grunt.registerTask('docs', ['wp_readme_to_markdown']);
195
-
196
- grunt.registerTask('test', ['jshint', 'addtextdomain']);
197
-
198
- grunt.registerTask('build', ['test', 'replace', 'newer:uglify', 'makepot', 'newer:po2mo', 'wp_readme_to_markdown', 'clean', 'copy']);
199
-
200
-
201
- // bump version numbers
202
- // grunt release 1.4.1 -> 1.4.2
203
- // grunt release:minor 1.4.1 -> 1.5.0
204
- // grint release:major 1.4.1 -> 2.0.0
205
-
206
- grunt.registerTask('deploy', ['checkbranch:master', 'checkrepo:deploy', 'build', 'release', 'wp_deploy', 'clean']);
207
-
208
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.7.0 */
2
- !function(a){a(".nav_menu_logged_in_out_field").each(function(){{var b=a(this);b.find("input.nav-menu-id").val()}"in"===b.find("input.nav-menu-logged-in-out:checked").val()?b.next(".nav_menu_role_field").show():b.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.7.8 */
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.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the GPL2.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Nav Menu Roles 1.7.7\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nav-menu-roles\n"
7
- "POT-Creation-Date: 2016-02-09 22:49:34+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -163,44 +163,37 @@ msgstr ""
163
  msgid "Nav Menu Roles"
164
  msgstr ""
165
 
166
- #: nav-menu-roles.php:175
167
  msgid ""
168
  "Import %snav menu roles%s and other menu item meta skipped by the default "
169
  "importer"
170
  msgstr ""
171
 
172
- #: nav-menu-roles.php:236
173
- msgid ""
174
- "Nav Menu Roles has detected a possible conflict in the following locations: "
175
- "%1$s. Please direct the author of the conflicting theme or plugin to the "
176
- "%2$sFAQ%3$s for a solution. | %4$sHide Notice%3$s"
177
- msgstr ""
178
-
179
- #: nav-menu-roles.php:278
180
  msgid "FAQ"
181
  msgstr ""
182
 
183
- #: nav-menu-roles.php:279
184
  msgid "Donate"
185
  msgstr ""
186
 
187
- #: nav-menu-roles.php:347
188
  msgid "Display Mode"
189
  msgstr ""
190
 
191
- #: nav-menu-roles.php:355
192
  msgid "Logged In Users"
193
  msgstr ""
194
 
195
- #: nav-menu-roles.php:362
196
  msgid "Logged Out Users"
197
  msgstr ""
198
 
199
- #: nav-menu-roles.php:369
200
  msgid "Everyone"
201
  msgstr ""
202
 
203
- #: nav-menu-roles.php:376
204
  msgid "Restrict menu item to a minimum role"
205
  msgstr ""
206
 
2
  # This file is distributed under the GPL2.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Nav Menu Roles 1.7.8\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/nav-menu-roles\n"
7
+ "POT-Creation-Date: 2016-02-17 15:40:32+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
163
  msgid "Nav Menu Roles"
164
  msgstr ""
165
 
166
+ #: nav-menu-roles.php:168
167
  msgid ""
168
  "Import %snav menu roles%s and other menu item meta skipped by the default "
169
  "importer"
170
  msgstr ""
171
 
172
+ #: nav-menu-roles.php:221
 
 
 
 
 
 
 
173
  msgid "FAQ"
174
  msgstr ""
175
 
176
+ #: nav-menu-roles.php:222
177
  msgid "Donate"
178
  msgstr ""
179
 
180
+ #: nav-menu-roles.php:291
181
  msgid "Display Mode"
182
  msgstr ""
183
 
184
+ #: nav-menu-roles.php:299
185
  msgid "Logged In Users"
186
  msgstr ""
187
 
188
+ #: nav-menu-roles.php:306
189
  msgid "Logged Out Users"
190
  msgstr ""
191
 
192
+ #: nav-menu-roles.php:313
193
  msgid "Everyone"
194
  msgstr ""
195
 
196
+ #: nav-menu-roles.php:320
197
  msgid "Restrict menu item to a minimum role"
198
  msgstr ""
199
 
nav-menu-roles.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nav Menu Roles
4
  Plugin URI: http://www.kathyisawesome.com/449/nav-menu-roles/
5
  Description: Hide custom menu items based on user roles.
6
- Version: 1.7.7
7
  Author: Kathy Darling
8
  Author URI: http://www.kathyisawesome.com
9
  License: GPL2
@@ -105,16 +105,11 @@ class Nav_Menu_Roles {
105
  // load the textdomain
106
  add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
107
 
108
- // add a notice that NMR is conflicting with another plugin
109
- add_action( 'admin_notices', array( $this, 'admin_notice' ) );
110
- add_action( 'activated_plugin', array( $this, 'delete_transient' ) );
111
- add_action( 'deactivated_plugin', array( $this, 'delete_transient' ) );
112
-
113
  // add FAQ and Donate link to plugin
114
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_action_links' ) );
115
 
116
  // switch the admin walker
117
- add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
118
 
119
  // add new fields via hook
120
  add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'custom_fields' ), 10, 4 );
@@ -150,8 +145,6 @@ class Nav_Menu_Roles {
150
  // Register Importer
151
  $this->register_importer();
152
 
153
- // save user notice
154
- $this->nag_ignore();
155
  }
156
 
157
 
@@ -192,80 +185,29 @@ class Nav_Menu_Roles {
192
  /**
193
  * Display a Notice if plugin conflicts with another
194
  * @since 1.5
 
195
  */
196
  public function admin_notice() {
197
- global $pagenow, $wp_filter;
198
-
199
- // quit early if not on the menus page, or if not an admin
200
- if( ! in_array( $pagenow, array( 'nav-menus.php', 'plugins.php' ) ) || ! current_user_can( 'manage_options' ) ){
201
- return;
202
- }
203
-
204
- // Get any existing copy of our transient data
205
- if ( false === ( $conflicts = get_transient( 'nav_menu_roles_conflicts' ) ) ) {
206
-
207
- // It wasn't there, so regenerate the data and save the transient
208
- $filters = self::list_hooks( 'wp_edit_nav_menu_walker' );
209
-
210
- foreach( $filters as $filter ){
211
-
212
- $file = str_replace( WP_CONTENT_DIR, '', $filter['file'] );
213
-
214
- // we expect to see NVR so collect everything else
215
- if( is_array( $filter['function'] ) && $filter['function'][0] == 'Nav_Menu_Roles' ){
216
- continue;
217
- }
218
-
219
- $conflicts[] = sprintf( '<code>%s</code> on line %s', $file, $filter['line'] );;
220
-
221
- }
222
-
223
- set_transient( 'nav_menu_roles_conflicts', $conflicts );
224
-
225
- }
226
-
227
- // Check Transient for conflicts and show error
228
- if ( ! empty ( $conflicts ) ) {
229
- global $current_user ;
230
- $user_id = $current_user->ID;
231
-
232
- if ( ! get_user_meta( $user_id, 'nmr_ignore_notice' ) ) {
233
-
234
- echo '<div class="error">
235
- <p>';
236
- printf ( __( 'Nav Menu Roles has detected a possible conflict in the following locations: %1$s. Please direct the author of the conflicting theme or plugin to the %2$sFAQ%3$s for a solution. | %4$sHide Notice%3$s', 'nav-menu-roles' ),
237
- implode( $conflicts, ', ' ),
238
- '<a href="http://wordpress.org/plugins/nav-menu-roles/faq#conflict" target="_blank">',
239
- '</a>',
240
- '<a href="?nmr_nag_ignore=0">' );
241
- echo '</p>
242
- </div>';
243
-
244
- }
245
-
246
- }
247
-
248
  }
249
 
250
 
251
  /**
252
  * Allow the notice to be dismissable
253
  * @since 1.6
 
254
  */
255
  public function nag_ignore() {
256
- global $current_user;
257
- $user_id = $current_user->ID;
258
- /* If user clicks to ignore the notice, add that to their user meta */
259
- if ( isset($_GET['nmr_nag_ignore']) && '0' == $_GET['nmr_nag_ignore'] ) {
260
- add_user_meta( $user_id, 'nmr_ignore_notice', 'true', true );
261
- }
262
  }
263
 
264
  /**
265
  * Delete the transient when a plugin is activated or deactivated
266
  * @since 1.5
 
267
  */
268
  public function delete_transient() {
 
269
  delete_transient( 'nav_menu_roles_conflicts' );
270
  }
271
 
@@ -274,10 +216,12 @@ class Nav_Menu_Roles {
274
  * Add docu link
275
  * @since 1.7.3
276
  */
277
- public function add_action_links( $links ) {
278
- $links[] = sprintf( '<a href="https://wordpress.org/plugins/nav-menu-roles/faq/#conflict">%s</a>', __( 'FAQ', 'nav-menu-roles' ) );
279
- $links[] = '<a href="' . self::DONATE_URL . '" target="_blank">' . __( 'Donate', 'nav-menu-roles' ) . '</a>';
280
- return $links;
 
 
281
  }
282
 
283
 
@@ -524,55 +468,6 @@ class Nav_Menu_Roles {
524
  }
525
 
526
 
527
- /**
528
- * Even fancier debug info
529
- * @props @Danijel http://stackoverflow.com/a/26680808/383847
530
- * @since 1.7.7
531
- */
532
- public static function list_hooks( $hook = '' ) {
533
- global $wp_filter;
534
-
535
- $hooks = isset( $wp_filter[$hook] ) ? $wp_filter[$hook] : array();
536
- $hooks = call_user_func_array( 'array_merge', $hooks );
537
-
538
- foreach( $hooks as &$item ) {
539
- // function name as string or static class method eg. 'Foo::Bar'
540
- if ( is_string( $item['function'] ) ) {
541
- $ref = strpos( $item['function'], '::' ) ? new ReflectionClass( strstr( $item['function'], '::', true ) ) : new ReflectionFunction( $item['function'] );
542
- $item['file'] = $ref->getFileName();
543
- $item['line'] = get_class( $ref ) == 'ReflectionFunction'
544
- ? $ref->getStartLine()
545
- : $ref->getMethod( substr( $item['function'], strpos( $item['function'], '::' ) + 2 ) )->getStartLine();
546
-
547
- // array( object, method ), array( string object, method ), array( string object, string 'parent::method' )
548
- } elseif ( is_array( $item['function'] ) ) {
549
-
550
- $ref = new ReflectionClass( $item['function'][0] );
551
-
552
- // $item['function'][0] is a reference to existing object
553
- $item['function'] = array(
554
- is_object( $item['function'][0] ) ? get_class( $item['function'][0] ) : $item['function'][0],
555
- $item['function'][1]
556
- );
557
- $item['file'] = $ref->getFileName();
558
- $item['line'] = strpos( $item['function'][1], '::' )
559
- ? $ref->getParentClass()->getMethod( substr( $item['function'][1], strpos( $item['function'][1], '::' ) + 2 ) )->getStartLine()
560
- : $ref->getMethod( $item['function'][1] )->getStartLine();
561
-
562
- // closures
563
- } elseif ( is_callable( $item['function'] ) ) {
564
- $ref = new ReflectionFunction( $item['function'] );
565
- $item['function'] = get_class( $item['function'] );
566
- $item['file'] = $ref->getFileName();
567
- $item['line'] = $ref->getStartLine();
568
-
569
- }
570
- }
571
-
572
- return $hooks;
573
- }
574
-
575
-
576
  /**
577
  * Maybe upgrade
578
  *
@@ -584,7 +479,6 @@ class Nav_Menu_Roles {
584
 
585
  // 1.7.7 upgrade: changed the debug notice so the old transient is invalid
586
  if ( $db_version === false || version_compare( '1.7.7', $db_version, '<' ) ) {
587
- $this->delete_transient();
588
  update_option( 'nav_menu_roles_db_version', self::VERSION );
589
  }
590
  }
3
  Plugin Name: Nav Menu Roles
4
  Plugin URI: http://www.kathyisawesome.com/449/nav-menu-roles/
5
  Description: Hide custom menu items based on user roles.
6
+ Version: 1.7.8
7
  Author: Kathy Darling
8
  Author URI: http://www.kathyisawesome.com
9
  License: GPL2
105
  // load the textdomain
106
  add_action( 'plugins_loaded', array( $this, 'load_text_domain' ) );
107
 
 
 
 
 
 
108
  // add FAQ and Donate link to plugin
109
+ add_filter( 'plugin_row_meta', array( $this, 'add_action_links' ), 10, 4 );
110
 
111
  // switch the admin walker
112
+ add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ), 20 );
113
 
114
  // add new fields via hook
115
  add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'custom_fields' ), 10, 4 );
145
  // Register Importer
146
  $this->register_importer();
147
 
 
 
148
  }
149
 
150
 
185
  /**
186
  * Display a Notice if plugin conflicts with another
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
  * @since 1.6
198
+ * @deprecated will removed in 2.0
199
  */
200
  public function nag_ignore() {
201
+ _deprecated_function( __METHOD__, '1.7.8' );
 
 
 
 
 
202
  }
203
 
204
  /**
205
  * Delete the transient when a plugin is activated or deactivated
206
  * @since 1.5
207
+ * @deprecated will removed in 2.0
208
  */
209
  public function delete_transient() {
210
+ _deprecated_function( __METHOD__, '1.7.8' );
211
  delete_transient( 'nav_menu_roles_conflicts' );
212
  }
213
 
216
  * Add docu link
217
  * @since 1.7.3
218
  */
219
+ public function add_action_links( $plugin_meta, $plugin_file, $plugin_data, $status ) {
220
+ if( $plugin_file == plugin_basename(__FILE__) ){
221
+ $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' ) );
222
+ $plugin_meta[] = '<a class="dashicons-before dashicons-awards" href="' . self::DONATE_URL . '" target="_blank">' . __( 'Donate', 'nav-menu-roles' ) . '</a>';
223
+ }
224
+ return $plugin_meta;
225
  }
226
 
227
 
468
  }
469
 
470
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  /**
472
  * Maybe upgrade
473
  *
479
 
480
  // 1.7.7 upgrade: changed the debug notice so the old transient is invalid
481
  if ( $db_version === false || version_compare( '1.7.7', $db_version, '<' ) ) {
 
482
  update_option( 'nav_menu_roles_db_version', self::VERSION );
483
  }
484
  }
package.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "title": "Nav Menu Roles",
3
- "name": "nav-menu-roles",
4
- "version": "1.7.7",
5
- "description": "Hide menu items based on user roles",
6
- "main": "Gruntfile.js",
7
- "license": "GPL-3.0",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/helgatheviking/nav-menu-roles"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/helgatheviking/nav-menu-roles/issues"
14
- },
15
- "author": "helgatheviking",
16
- "devDependencies": {
17
- "grunt": "~0.4.5",
18
- "grunt-checkbranch": "~1.0.2",
19
- "grunt-checkrepo": "~0.1.0",
20
- "grunt-contrib-clean": "~0.7.0",
21
- "grunt-contrib-copy": "~0.8.2",
22
- "grunt-contrib-jshint": "~0.12.0",
23
- "grunt-contrib-uglify": "~0.11.0",
24
- "grunt-contrib-watch": "~0.6.1",
25
- "grunt-newer": "~1.1.1",
26
- "grunt-po2mo": "~0.1.2",
27
- "grunt-text-replace": "^0.4.0",
28
- "grunt-transifex": "git://github.com/helgatheviking/grunt-transifex",
29
- "grunt-wp-deploy": "~1.1.0",
30
- "grunt-wp-i18n": "~0.5.3",
31
- "grunt-wp-readme-to-markdown": "~1.0.0",
32
- "jshint-stylish": "~2.1.0",
33
- "load-grunt-tasks": "~3.4.0"
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.md DELETED
@@ -1,303 +0,0 @@
1
- # Nav Menu Roles #
2
-
3
- **Contributors:** helgatheviking
4
- **Donate link:** https://www.paypal.me/helgatheviking
5
- **Tags:** menu, menus, nav menu, nav menus
6
- **Requires at least:** 4.4.0
7
- **Tested up to:** 4.4.0
8
- **Stable tag: 1.7.7
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. See the [FAQ](http://wordpress.org/plugins/nav-menu-roles/faq/#new-role).
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. Edit the menu items accordingly. First select whether you'd like to display the item to all logged in users, all logged out users or to customize by role.
27
- **1. If you chose customize by role, 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
- 1. If you choose 'By Role' and don't check any boxes, the item will be visible to everyone like normal.
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
- ![Show the new options for the menu items in the admin menu customizer](http://plugins.svn.wordpress.org/nav-menu-roles/assets/screenshot-1.png)
48
-
49
-
50
- ## Frequently Asked Questions ##
51
-
52
- = <a id="conflict"></a>I don't see the Nav Menu Roles options in the admin menu items? =
53
-
54
- 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.
55
-
56
- 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.
57
-
58
- **A non-exhaustive list of known conflicts:**
59
-
60
- 1. UberMenu 2.x Mega Menus plugin
61
- 2. Add Descendants As Submenu Items plugin
62
- 3. Navception plugin
63
- 4. Suffusion theme
64
- 5. BeTheme
65
- 6. Yith Menu
66
- 7. Jupiter Theme
67
-
68
-
69
- = <a id="compatibility"></a>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
- = <a id="patch"></a>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. **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!**
87
-
88
- 1. Find the class that extends the `Walker_Nav_Menu`. As a hint, it is filtering `wp_edit_nav_menu_walker` and you might even be getting a warning about it from Nav Menu Roles. Example:
89
-
90
- `
91
- add_filter( 'wp_edit_nav_menu_walker', 'sample_edit_nav_menu_walker');
92
- function sample_edit_nav_menu_walker( $walker ) {
93
- return 'Walker_Nav_Menu_Edit_Roles'; // this is the class name
94
- }
95
- `
96
-
97
- 2. Find the file for the extending class. In my plugin this is in a file located at `inc/class.Walker_Nav_Menu_Edit_Roles.php`. I can't know *where* this file is in your plugin/theme. Please don't ask me, but here's what the beginning of that class will look like:
98
-
99
- `class Walker_Nav_Menu_Edit_Roles extends Walker_Nav_Menu {}`
100
-
101
- Note that the class name is the same as the class name you found in step 1.
102
-
103
- 3. Find the `start_el()` method
104
-
105
- In that file you will eventually see a class method that looks like:
106
-
107
- `function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {`
108
-
109
- 4. Paste my action hook somewhere in this method!
110
-
111
- In Nav Menu Roles, I have placed the hook directly after the description, ex:
112
-
113
- `
114
- <p class="field-description description description-wide">
115
- <label for="edit-menu-item-description-<?php echo $item_id; ?>">
116
- <?php _e( 'Description' ); ?><br />
117
- <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>
118
- <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
119
- </label>
120
- </p>
121
-
122
- <?php
123
- // Add this directly after the description paragraph in the start_el() method
124
- do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
125
- // end added section
126
- ?>
127
- `
128
-
129
- ### Workaround #2 ###
130
-
131
- 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.
132
-
133
- ### I'm using XYZ Membership plugin and I don't see its "levels"? ###
134
-
135
- 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.
136
-
137
- 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.
138
-
139
- = <a id="new-role"></a>Adding a new "role" =
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
- ### The menu exploded? Why are all my pages displaying for logged out users? ###
182
-
183
- 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`.
184
-
185
- Therefore, if you have no items to display, WordPress will end up displaying ALL your pages!!
186
-
187
- If you don't want this, you must set the fallback argument to be a null string.
188
-
189
- `
190
- wp_nav_menu( array( 'theme_location' => 'primary-menu', 'fallback_cb' => '' ) );
191
- `
192
-
193
- ### What happened to my menu roles on import/export? ###
194
-
195
- 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.
196
-
197
- 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.
198
-
199
- ### How Do I Use the Custom Importer? ###
200
-
201
- 1. Go to Tools>Export, choose to export All Content and download the Export file
202
- 1. Go to Tools>Import on your new site and perform your normal WordPress import
203
- 1. Return to Tools>Import and this time select the Nav Menu Roles importer.
204
- 1. Use the same .xml file and perform a second import
205
- 1. No duplicate posts will be created but all menu post meta (including your Nav Menu Roles info) will be imported
206
-
207
- ## Changelog ##
208
-
209
- ### 1.7.6 ###
210
- * tweak CSS to initially hide checkboxes on newly added menu items (defaults to "Everyone" so roles should not appear)
211
-
212
- ### 1.7.5 ###
213
- * Update Walker_Nav_Menu_Edit_Roles to mimic Walker_Nav_Menu in WordPress 4.4
214
-
215
- ### 1.7.4 ###
216
- * Change language in metabox to try to explain min caps versus strict role checking
217
- * keep tweaking the FAQ
218
-
219
- ### 1.7.3 ###
220
- * update readme, update error notice, add more links to the FAQ
221
-
222
- ### 1.7.2 ###
223
- * add Italian language. props @sododesign
224
-
225
- ### 1.7.1 ###
226
- * Updated FAQ with patch instructions for conflicting plugins/themes
227
- * add Portugeuse language. props @brunobarros
228
-
229
- ### 1.7.0 ###
230
- * 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)
231
-
232
- ### 1.6.5 ###
233
- * add Guajarati language. props @rohilmistry93
234
-
235
- ### 1.6.4 ###
236
- * more language issues -> sync svn+git version numbers
237
-
238
- ### 1.6.3 ###
239
- * Try again to add languages. Where'd they all go?
240
-
241
- ### 1.6.2 ###
242
- * Add French translation. Props @Philippe Gilles
243
-
244
- ### 1.6.1 ###
245
- * Update list of conflits
246
- * Don't display radio buttons if no roles - allows for granular permissions control
247
-
248
- ### 1.6.0 ###
249
- * Feature: Hiding a parent menu item will automatically hide all its children
250
- * 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.
251
-
252
- ### 1.5.1 ###
253
- * Hopefully fix missing nav-menu-roles.min.js SVN issue
254
-
255
- ### 1.5.0 ###
256
- * Switch to instance of plugin
257
- * Add notice when conflicting plugins are detected
258
- * Remove some extraneous parameters
259
- * Add Spanish translation thanks to @deskarrada
260
-
261
- ### 1.4.1 ###
262
- * update to WP 3.8 version of Walker_Nav_Menu_Edit (prolly not any different from 3.7.1)
263
- * minor CSS adjustment to admin menu items
264
- * checked against WP 3.8
265
-
266
- ### 1.4 ###
267
- * Add to FAQ
268
- * add JS flair to admin menu items
269
- * update to WP 3.7.1 version of Walker_Nav_Menu_Edit
270
-
271
- ### 1.3.5 ###
272
- * Add nav_menu_roles_item_visibility filter to work with plugins that don't use traditional roles
273
-
274
- ### 1.3.4 ###
275
- * Update admin language thanks to @hassanhamm
276
- * Add Arabic translation thanks to @hassanhamm
277
-
278
- ### 1.3.3 ###
279
- * Fix Nav_Menu_Roles_Import not found error
280
-
281
- ### 1.3.2 ###
282
- * Stupid comment error causing save issues
283
-
284
- ### 1.3.1 ###
285
- * SVN failure to include importer files!
286
-
287
- ### 1.3 ###
288
- * Added custom importer
289
-
290
- ### 1.2 ###
291
- * Major fix for theme's that use their own custom Walkers, thanks to Evan Stein @vanpop http://vanpop.com/
292
- * Instead of a custom nav Walker, menu items are controlled through the wp_get_nav_menu_items filter
293
- * Remove the custom nav Walker code
294
-
295
- ### 1.1.1 ###
296
- * Fix link to plugin site
297
- * Fix labels in admin Walker
298
-
299
- ### 1.1 ###
300
- * Clean up debug messages
301
-
302
- ### 1.0 ###
303
- * Initial release