User Menus – Nav Menu Visibility - Version 1.2.1

Version Description

Download this release

Release Info

Developer danieliser
Plugin Icon 128x128 User Menus – Nav Menu Visibility
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

includes/classes/walker/nav-menu-edit-custom-fields-deprecated.php CHANGED
@@ -11,41 +11,43 @@ if ( ! class_exists( 'Walker_Nav_Menu_Edit' ) ) {
11
  * Add wp_nav_menu_item_custom_fields hook to the nav menu editor.
12
  *
13
  * Credits:
 
14
  * @helgatheviking - Initial concept which has made adding settings in the menu editor in a compatible way.
15
- * @kucrut - preg_replace() method so that we no longer have to translate core strings
16
- * @danieliser - refactor for less complexity between WP versions & updating versioned classes for proper backward compatibility with the new methods.
17
  *
18
- * @since WordPress 3.0.0
19
- * @uses Walker_Nav_Menu_Edit
20
  */
21
  class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
22
 
23
  /**
24
  * Start the element output.
25
  *
26
- * @see Walker_Nav_Menu_Edit::start_el()
27
- *
28
  * @param string $output Passed by reference. Used to append additional content.
29
- * @param object $item Menu item data object.
30
- * @param int $depth Depth of menu item.
31
- * @param array $args
 
 
32
  */
33
  public function start_el( &$output, $item, $depth = 0, $args = array() ) {
34
- parent::start_el( $output, $item, $depth, $args );
35
-
36
- $output = preg_replace( '(<p[^>]+class="[^"]*field-description(.|\n)*?<\/p>)', "$1 \n" . $this->get_custom_fields( $item, $depth, $args ), $output, 1 );
 
37
  }
38
 
39
  /**
40
  * Get custom fields
41
  *
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
  *
48
  * @return string Additional fields or html for the nav menu editor.
 
 
49
  */
50
  protected function get_custom_fields( $item, $depth, $args = array() ) {
51
  ob_start();
@@ -53,10 +55,10 @@ class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
53
  /**
54
  * Get menu item custom fields from plugins/themes
55
  *
56
- * @param int $item_id post ID of menu
57
- * @param object $item Menu item data object.
58
- * @param int $depth Depth of menu item. Used for padding.
59
- * @param array $args Menu item args.
60
  *
61
  * @return string Custom fields
62
  */
11
  * Add wp_nav_menu_item_custom_fields hook to the nav menu editor.
12
  *
13
  * Credits:
14
+ *
15
  * @helgatheviking - Initial concept which has made adding settings in the menu editor in a compatible way.
16
+ * @kucrut - preg_replace() method so that we no longer have to translate core strings
17
+ * @danieliser - refactor for less complexity between WP versions & updating versioned classes for proper backward compatibility with the new methods.
18
  *
19
+ * @since WordPress 3.0.0
20
+ * @uses Walker_Nav_Menu_Edit
21
  */
22
  class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
23
 
24
  /**
25
  * Start the element output.
26
  *
 
 
27
  * @param string $output Passed by reference. Used to append additional content.
28
+ * @param object $item Menu item data object.
29
+ * @param int $depth Depth of menu item.
30
+ * @param array $args
31
+ *
32
+ * @see Walker_Nav_Menu_Edit::start_el()
33
  */
34
  public function start_el( &$output, $item, $depth = 0, $args = array() ) {
35
+ $item_output = '';
36
+ $output .= parent::start_el( $output, $item, $depth, $args );
37
+ // NOTE: Check this regex on major WP version updates!
38
+ $output .= preg_replace( '/(?=<fieldset[^>]+class="[^"]*field-move)/', $this->get_custom_fields( $item, $depth, $args ), $item_output );
39
  }
40
 
41
  /**
42
  * Get custom fields
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
  *
48
  * @return string Additional fields or html for the nav menu editor.
49
+ * @uses do_action() Calls 'menu_item_custom_fields' hook
50
+ *
51
  */
52
  protected function get_custom_fields( $item, $depth, $args = array() ) {
53
  ob_start();
55
  /**
56
  * Get menu item custom fields from plugins/themes
57
  *
58
+ * @param int $item_id post ID of menu
59
+ * @param object $item Menu item data object.
60
+ * @param int $depth Depth of menu item. Used for padding.
61
+ * @param array $args Menu item args.
62
  *
63
  * @return string Custom fields
64
  */
includes/classes/walker/nav-menu-edit-custom-fields.php CHANGED
@@ -16,56 +16,65 @@ if ( ! class_exists( 'Walker_Nav_Menu_Edit' ) ) {
16
  * Add wp_nav_menu_item_custom_fields hook to the nav menu editor.
17
  *
18
  * Credits:
 
19
  * @helgatheviking - Initial concept which has made adding settings in the menu editor in a compatible way.
20
- * @kucrut - preg_replace() method so that we no longer have to translate core strings
21
- * @danieliser - refactor for less complexity between WP versions & updating versioned classes for proper backward compatibility with the new methods.
22
  *
23
- * @since WordPress 3.6.0
24
- * @uses Walker_Nav_Menu_Edit
25
  */
26
  class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
27
 
28
  /**
29
  * Start the element output.
30
  *
 
 
 
 
 
 
31
  * @see Walker_Nav_Menu_Edit::start_el()
32
  *
33
- * @param string $output Passed by reference. Used to append additional content.
34
- * @param object $item Menu item data object.
35
- * @param int $depth Depth of menu item.
36
- * @param array $args
37
- * @param int $id
38
  */
39
  public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
40
- parent::start_el( $output, $item, $depth, $args, $id = 0 );
41
-
42
- $output = preg_replace( '(<p[^>]+class="[^"]*field-description(.|\n)*?<\/p>)', "$1 \n" . $this->get_custom_fields( $item, $depth, $args ), $output, 1 );
 
43
  }
44
 
45
 
46
  /**
47
  * Get custom fields
48
  *
49
- * @uses do_action() Calls 'menu_item_custom_fields' hook
 
 
 
 
 
50
  *
51
- * @param object $item Menu item data object.
52
- * @param int $depth Depth of menu item. Used for padding.
53
- * @param array $args Menu item args.
54
  *
55
- * @return string Additional fields or html for the nav menu editor.
56
  */
57
- protected function get_custom_fields( $item, $depth, $args = array() ) {
58
  ob_start();
59
  $item_id = intval( $item->ID );
60
  /**
61
  * Get menu item custom fields from plugins/themes
62
  *
63
- * @param int $item_id post ID of menu
64
- * @param object $item Menu item data object.
65
- * @param int $depth Depth of menu item. Used for padding.
66
- * @param array $args Menu item args.
67
  *
68
  * @return string Custom fields
 
 
69
  */
70
  do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
71
 
16
  * Add wp_nav_menu_item_custom_fields hook to the nav menu editor.
17
  *
18
  * Credits:
19
+ *
20
  * @helgatheviking - Initial concept which has made adding settings in the menu editor in a compatible way.
21
+ * @kucrut - preg_replace() method so that we no longer have to translate core strings
22
+ * @danieliser - refactor for less complexity between WP versions & updating versioned classes for proper backward compatibility with the new methods.
23
  *
24
+ * @since WordPress 3.6.0
25
+ * @uses Walker_Nav_Menu_Edit
26
  */
27
  class Walker_Nav_Menu_Edit_Custom_Fields extends Walker_Nav_Menu_Edit {
28
 
29
  /**
30
  * Start the element output.
31
  *
32
+ * @param string $output Passed by reference. Used to append additional content.
33
+ * @param object $item Menu item data object.
34
+ * @param int $depth Depth of menu item.
35
+ * @param array $args
36
+ * @param int $id
37
+ *
38
  * @see Walker_Nav_Menu_Edit::start_el()
39
  *
 
 
 
 
 
40
  */
41
  public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
42
+ $item_output = '';
43
+ $output .= parent::start_el( $item_output, $item, $depth, $args, $id );
44
+ // NOTE: Check this regex on major WP version updates!
45
+ $output .= preg_replace( '/(?=<fieldset[^>]+class="[^"]*field-move)/', $this->get_custom_fields( $item, $depth, $args ), $item_output );
46
  }
47
 
48
 
49
  /**
50
  * Get custom fields
51
  *
52
+ * @access protected
53
+ *
54
+ * @param object $item Menu item data object.
55
+ * @param int $depth Depth of menu item. Used for padding.
56
+ * @param array $args Menu item args.
57
+ * @param int $id Nav menu ID.
58
  *
59
+ * @return string Form fields
60
+ * @uses do_action() Calls 'menu_item_custom_fields' hook
 
61
  *
62
+ * @since 0.1.0
63
  */
64
+ protected function get_custom_fields( $item, $depth, $args = array(), $id = 0 ) {
65
  ob_start();
66
  $item_id = intval( $item->ID );
67
  /**
68
  * Get menu item custom fields from plugins/themes
69
  *
70
+ * @param int $item_id post ID of menu
71
+ * @param object $item Menu item data object.
72
+ * @param int $depth Depth of menu item. Used for padding.
73
+ * @param array $args Menu item args.
74
  *
75
  * @return string Custom fields
76
+ * @since 0.1.0
77
+ *
78
  */
79
  do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
80
 
readme.txt CHANGED
@@ -1,11 +1,12 @@
1
- === User Menus - Nav Menu Visibility ===
2
  Contributors: codeatlantic, danieliser
3
- Author URI: https://code-atlantic.com
4
  Plugin URI: https://wordpress.org/plugins/user-menus/
 
5
  Tags: menu, menus, user-menu, logout, nav-menu, nav-menus, user, user-role, user-roles
6
  Requires at least: 4.6
7
- Tested up to: 5.2.3
8
- Stable tag: 1.2.0
9
  Requires PHP: 5.3
10
  License: GPLv3 or Any Later Version
11
 
@@ -114,6 +115,9 @@ Bugs can be reported either in our support forum or preferably on the [User Menu
114
 
115
  == Changelog ==
116
 
 
 
 
117
  = v1.2.0 - 10/10/2019 =
118
  * Feature: Added option to *show* or *hide* the menu item for chosen roles.
119
  * Feature: Added Register user link navigation menu type with optional redirect.
1
+ === User Menus - Nav Menu Visibility ===
2
  Contributors: codeatlantic, danieliser
3
+ Author URI: https://code-atlantic.com/
4
  Plugin URI: https://wordpress.org/plugins/user-menus/
5
+ Donate link: https://code-atlantic.com/donate/
6
  Tags: menu, menus, user-menu, logout, nav-menu, nav-menus, user, user-role, user-roles
7
  Requires at least: 4.6
8
+ Tested up to: 5.3
9
+ Stable tag: 1.2.1
10
  Requires PHP: 5.3
11
  License: GPLv3 or Any Later Version
12
 
115
 
116
  == Changelog ==
117
 
118
+ = v1.2.1 - 10/20/2019 =
119
+ * Fix: Bug in some sites where Menu Editor Description field was not shown.
120
+
121
  = v1.2.0 - 10/10/2019 =
122
  * Feature: Added option to *show* or *hide* the menu item for chosen roles.
123
  * Feature: Added Register user link navigation menu type with optional redirect.
user-menus.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: User Menus
4
  * Plugin URI: https://wordpress.org/plugins/user-menus/
5
  * Description: Quickly customize your menus with a user's name & avatar, or show items based on user role.
6
- * Version: 1.2.0
7
  * Author: Code Atlantic
8
  * Author URI: https://code-atlantic.com/
9
  * License: GPL2 or later
@@ -74,7 +74,7 @@ class JP_User_Menus {
74
  /**
75
  * @var string
76
  */
77
- public static $VER = '1.2.0';
78
 
79
  /**
80
  * @var string
3
  * Plugin Name: User Menus
4
  * Plugin URI: https://wordpress.org/plugins/user-menus/
5
  * Description: Quickly customize your menus with a user's name & avatar, or show items based on user role.
6
+ * Version: 1.2.1
7
  * Author: Code Atlantic
8
  * Author URI: https://code-atlantic.com/
9
  * License: GPL2 or later
74
  /**
75
  * @var string
76
  */
77
+ public static $VER = '1.2.1';
78
 
79
  /**
80
  * @var string