Version Description
- Add the NMR roles as css classes to the menu output
- Improve menu editor role checkbox list UX, by making list items full-width. Props @lkraav
Download this release
Release Info
Developer | helgatheviking |
Plugin | Nav Menu Roles |
Version | 1.9.4 |
Comparing to | |
See all releases |
Code changes from version 1.9.3 to 1.9.4
- nav-menu-roles.php +26 -5
- readme.txt +6 -2
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.9.
|
7 |
Author: Kathy Darling
|
8 |
Author URI: http://www.kathyisawesome.com
|
9 |
License: GPL-3.0
|
@@ -48,13 +48,13 @@ class Nav_Menu_Roles {
|
|
48 |
* @constant string donate url
|
49 |
* @since 1.9.1
|
50 |
*/
|
51 |
-
CONST DONATE_URL = "https://www.paypal.com/fundraiser/
|
52 |
|
53 |
/**
|
54 |
* @constant string version number
|
55 |
* @since 1.7.0
|
56 |
*/
|
57 |
-
CONST VERSION = '1.9.
|
58 |
|
59 |
/**
|
60 |
* Main Nav Menu Roles Instance
|
@@ -222,7 +222,7 @@ class Nav_Menu_Roles {
|
|
222 |
public function add_action_links( $plugin_meta, $plugin_file ) {
|
223 |
if( $plugin_file == plugin_basename(__FILE__) ){
|
224 |
$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' ) );
|
225 |
-
$plugin_meta[] = '<a class="dashicons-before dashicons-
|
226 |
}
|
227 |
return $plugin_meta;
|
228 |
}
|
@@ -345,7 +345,7 @@ class Nav_Menu_Roles {
|
|
345 |
|
346 |
?>
|
347 |
|
348 |
-
<div class="role-input-holder" style="
|
349 |
<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; ?>" />
|
350 |
<label for="nav_menu_role-<?php echo $role; ?>-for-<?php echo $item->ID ;?>">
|
351 |
<?php echo esc_html( $name ); ?>
|
@@ -430,6 +430,27 @@ class Nav_Menu_Roles {
|
|
430 |
|
431 |
if ( ! empty( $roles ) ) {
|
432 |
$menu_item->roles = $roles;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
}
|
434 |
}
|
435 |
return $menu_item;
|
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.9.4
|
7 |
Author: Kathy Darling
|
8 |
Author URI: http://www.kathyisawesome.com
|
9 |
License: GPL-3.0
|
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.9.4';
|
58 |
|
59 |
/**
|
60 |
* Main Nav Menu Roles Instance
|
222 |
public function add_action_links( $plugin_meta, $plugin_file ) {
|
223 |
if( $plugin_file == plugin_basename(__FILE__) ){
|
224 |
$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' ) );
|
225 |
+
$plugin_meta[] = '<a class="dashicons-before dashicons-admin-generic" href="' . self::DONATE_URL . '" target="_blank">' . __( 'Donate', 'nav-menu-roles' ) . '</a>';
|
226 |
}
|
227 |
return $plugin_meta;
|
228 |
}
|
345 |
|
346 |
?>
|
347 |
|
348 |
+
<div class="role-input-holder" style="margin: 2px 0;">
|
349 |
<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; ?>" />
|
350 |
<label for="nav_menu_role-<?php echo $role; ?>-for-<?php echo $item->ID ;?>">
|
351 |
<?php echo esc_html( $name ); ?>
|
430 |
|
431 |
if ( ! empty( $roles ) ) {
|
432 |
$menu_item->roles = $roles;
|
433 |
+
|
434 |
+
// Add the NMR roles as CSS info.
|
435 |
+
$new_classes = array();
|
436 |
+
|
437 |
+
switch( $roles ) {
|
438 |
+
case 'in' :
|
439 |
+
$new_classes[] = 'nmr-logged-in';
|
440 |
+
break;
|
441 |
+
case 'out' :
|
442 |
+
$new_classes[] = 'nmr-logged-out';
|
443 |
+
break;
|
444 |
+
default:
|
445 |
+
if ( is_array( $item->roles ) && ! empty( $item->roles ) ) {
|
446 |
+
foreach ( $item->roles as $role ) {
|
447 |
+
$new_classes[] = 'nmr-' . $role;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
break;
|
451 |
+
}
|
452 |
+
|
453 |
+
$menu_item->classes = array_merge( $menu_item->classes, $new_classes );
|
454 |
}
|
455 |
}
|
456 |
return $menu_item;
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== Nav Menu Roles ===
|
2 |
|
3 |
Contributors: helgatheviking
|
4 |
-
Donate link: https://www.
|
5 |
Tags: menu, menus, nav menu, nav menus
|
6 |
Requires at least: 4.5.0
|
7 |
Tested up to: 5.0.2
|
8 |
-
Stable tag: 1.9.
|
9 |
License: GPLv3
|
10 |
|
11 |
Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
|
@@ -238,6 +238,10 @@ Yes, but manually. WPML developers have informed me that the meta data for nav m
|
|
238 |
|
239 |
== Changelog ==
|
240 |
|
|
|
|
|
|
|
|
|
241 |
= 1.9.3 =
|
242 |
* Check all object properties exist before accessing. Resolves PHP notices for custom menu items.
|
243 |
|
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.0.2
|
8 |
+
Stable tag: 1.9.4
|
9 |
License: GPLv3
|
10 |
|
11 |
Hide custom menu items based on user roles. PLEASE READ THE FAQ IF YOU ARE NOT SEEING THE SETTINGS.
|
238 |
|
239 |
== Changelog ==
|
240 |
|
241 |
+
= 1.9.4 =
|
242 |
+
* Add the NMR roles as css classes to the menu output
|
243 |
+
* Improve menu editor role checkbox list UX, by making list items full-width. Props @lkraav
|
244 |
+
|
245 |
= 1.9.3 =
|
246 |
* Check all object properties exist before accessing. Resolves PHP notices for custom menu items.
|
247 |
|