diff --git a/includes/admin/core/class-admin-navmenu.php b/includes/admin/core/class-admin-navmenu.php index 9e2a4e17..ebccf0ee 100644 --- a/includes/admin/core/class-admin-navmenu.php +++ b/includes/admin/core/class-admin-navmenu.php @@ -18,20 +18,132 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) { protected static $fields = array(); + /** + * Admin_Navmenu constructor. + */ function __construct() { + global $wp_version; + self::$fields = array( 'um_nav_public' => __( 'Display Mode', 'ultimate-member' ), 'um_nav_roles' => __( 'By Role', 'ultimate-member' ) ); - add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 ); - //add_filter( 'manage_nav-menus_columns', array( &$this, '_columns' ), 99 ); + if ( $wp_version < '5.4' ) { + add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 ); + add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) ); + add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) ); + } else { + add_action( 'load-customize.php', array( &$this, 'enqueue_nav_menus_scripts' ) ); + } - add_action( 'load-nav-menus.php', array( &$this, 'enqueue_nav_menus_scripts' ) ); - add_action( 'admin_footer-nav-menus.php', array( &$this, '_wp_template' ) ); + add_action( 'wp_nav_menu_item_custom_fields', array( $this, 'wp_nav_menu_item_custom_fields' ), 20, 5 ); + //add_action( 'wp_nav_menu_item_custom_fields_customize_template', array( $this, 'wp_nav_menu_item_custom_fields_customize_template' ), 20 ); //waiting wp.org answer } + /** + * Fires just before the move buttons of a nav menu item in the menu editor. + * Adds block "Ultimate Member Menu Settings" + * + * @since WP 5.4.0 + * @hook wp_nav_menu_item_custom_fields + * + * @param int $item_id Menu item ID. + * @param \WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param \stdClass $args An object of menu item arguments. + * @param int $id Nav menu ID. + */ + function wp_nav_menu_item_custom_fields( $item_id, $item, $depth, $args, $id ) { + + $um_nav_public = get_post_meta( $item->ID, 'menu-item-um_nav_public', true ); + $_nav_roles_meta = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true ); + $um_nav_roles = array(); + if ( $_nav_roles_meta ) { + foreach ( $_nav_roles_meta as $key => $value ) { + if ( is_int( $key ) ) { + $um_nav_roles[] = $value; + } + } + } + $options = UM()->roles()->get_roles( false, array( 'administrator' ) ); + ?> +
+
+

+ +

+ +

+ +

>
+ + '; + + foreach ( $section_fields_per_page as $k => $title ) { + $id_attr = ' id="edit-menu-item-um_nav_roles-' . $item_id . '_' . $k . '" '; + $for_attr = ' for="edit-menu-item-um_nav_roles-' . $item_id . '_' . $k . '" '; + $checked_attr = checked( in_array($k,$um_nav_roles), true, false ); + $html .= ""; + } + + $html .= ''; + $i++; + } + echo $html; + ?> +

+
+
+ +
+
+

+ + <# console.log( data ); #> + +
+
+ roles as $roleID => $role_data ) { $role_meta = get_option( "um_role_{$roleID}_meta" ); - if ( ! empty( $role_meta ) ) - $wp_roles->roles[$roleID] = array_merge( $role_data, $role_meta ); + if ( ! empty( $role_meta ) ) { + $wp_roles->roles[ $roleID ] = array_merge( $role_data, $role_meta ); + } } //Add custom UM roles $roles = array(); - $role_keys = get_option( 'um_roles' ); - - if ( $role_keys ) { - - foreach ( $role_keys as $role_key ) { - $role_meta = get_option( "um_role_{$role_key}_meta" ); - if ( $role_meta ) { - //$role_meta['name'] = 'UM ' . $role_meta['name']; - $roles['um_' . $role_key] = $role_meta; - } - } - - foreach ( $roles as $role_id => $details ) { - $capabilities = ! empty( $details['wp_capabilities'] ) ? array_keys( $details['wp_capabilities'] ) : array(); - $details['capabilities'] = array_fill_keys( array_values( $capabilities ), true ); - unset( $details['wp_capabilities'] ); - $wp_roles->roles[$role_id] = $details; - $wp_roles->role_objects[$role_id] = new \WP_Role( $role_id, $details['capabilities'] ); - $wp_roles->role_names[$role_id] = $details['name']; + $role_keys = get_option( 'um_roles', array() ); + foreach ( $role_keys as $role_key ) { + $role_meta = get_option( "um_role_{$role_key}_meta" ); + if ( $role_meta ) { + $roles[ 'um_' . $role_key ] = $role_meta; } + } + foreach ( $roles as $role_id => $details ) { + $capabilities = ! empty( $details['wp_capabilities'] ) ? array_keys( $details['wp_capabilities'] ) : array(); + $details['capabilities'] = array_fill_keys( array_values( $capabilities ), true ); + unset( $details['wp_capabilities'] ); + $wp_roles->roles[ $role_id ] = $details; + $wp_roles->role_objects[ $role_id ] = new \WP_Role( $role_id, $details['capabilities'] ); + $wp_roles->role_names[ $role_id ] = $details['name']; } // Return the modified $wp_roles array diff --git a/readme.txt b/readme.txt index c21b5820..02a7e3c1 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration Requires PHP: 5.6 Requires at least: 5.0 Tested up to: 5.4 -Stable tag: 2.1.5 +Stable tag: 2.1.6 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -149,12 +149,14 @@ The plugin works with popular caching plugins by automatically excluding Ultimat * Enhancements: + - Added The profile page SEO meta tags for OG, Twitter and schema.org - Added filter to the field's privacy option for the 3rd-party integrations 'um_field_privacy_options' - Added layout changes to show email notification description in Settings > Email screen - Added member directory option 'Exclude specific users' - Added filter for the changing redirect after profile edited 'um_update_profile_redirect_after' - Added JS filters for conditional logic - Tweak: apply_shortcodes() function support + - Tweak: nav-menu custom fields using 'wp_nav_menu_item_custom_fields' hook * Bugfixes: @@ -164,6 +166,7 @@ The plugin works with popular caching plugins by automatically excluding Ultimat - Fixed creating user uploads directory on registration - Fixed Role fields validation on registration - Fixed Erase User Data field on the Account page + - Fixed profile privacy - Fixed SkypeID field - Fixed clickable links in the UM forms which are displayed in a modal window - Fixed disabling select and textarea fields in inactive tabs on Account diff --git a/ultimate-member.php b/ultimate-member.php index 8f3edaec..a71e80c0 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.1.6-beta1 +Version: 2.1.6 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member