- 2.1.6 pre-release;

This commit is contained in:
nikitasinelnikov
2020-06-01 08:51:46 +03:00
parent 27cf1794b6
commit 1be9e0c24f
4 changed files with 151 additions and 39 deletions
+116 -16
View File
@@ -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' ) );
?>
<div class="um-nav-edit">
<div class="clear"></div>
<h4 style="margin-bottom: 0.6em;"><?php _e( 'Ultimate Member Menu Settings', 'ultimate-member' ) ?></h4>
<p class="description description-wide um-nav-mode">
<label for="edit-menu-item-um_nav_public-<?php echo esc_attr( $item_id ); ?>">
<?php _e( "Who can see this menu link?", 'ultimate-member' ); ?><br/>
<select id="edit-menu-item-um_nav_public-<?php echo esc_attr( $item_id ); ?>" name="menu-item-um_nav_public[<?php echo esc_attr( $item_id ); ?>]" style="width:100%;">
<option value="0" <?php selected( $um_nav_public, 0 ); ?>><?php _e( 'Everyone', 'ultimate-member' ) ?></option>
<option value="1" <?php selected( $um_nav_public, 1 ); ?>><?php _e( 'Logged Out Users', 'ultimate-member' ) ?></option>
<option value="2" <?php selected( $um_nav_public, 2 ); ?>><?php _e( 'Logged In Users', 'ultimate-member' ) ?></option>
</select>
</label>
</p>
<p class="description description-wide um-nav-roles" <?php echo $um_nav_public == 2 ? 'style="display: block;"' : ''; ?>><?php _e( "Select the member roles that can see this link", 'ultimate-member' ) ?><br>
<?php
$i = 0;
$html = '';
$columns = apply_filters( 'wp_nav_menu_item:um_nav_columns', 2, $item_id, $item );
$per_page = ceil( count( $options ) / $columns );
while ( $i < $columns ) {
$section_fields_per_page = array_slice( $options, $i * $per_page, $per_page );
$html .= '<span class="um-form-fields-section" style="width:' . floor( 100 / $columns ) . '% !important;">';
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 .= "<label {$for_attr}> <input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{$item_id}][{$k}]' value='1' {$checked_attr} /> <span>{$title}</span> </label>";
}
$html .= '</span>';
$i++;
}
echo $html;
?>
</p>
<div class="clear"></div>
</div>
<?php
}
/**
*
*/
function wp_nav_menu_item_custom_fields_customize_template() {
?>
<div class="um-nav-edit">
<div class="clear"></div>
<h4 style="margin-bottom: 0.6em;"><?php _e( 'Ultimate Member Menu Settings', 'ultimate-member' ) ?></h4>
<# console.log( data ); #>
<div class="clear"></div>
</div>
<?php
}
/**
*
* Backward compatibility with WP < 5.4
*
*/
/**
* @param $menu_id
* @param $menu_item_db_id
@@ -69,18 +181,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
}
/**
* @param $columns
*
* @return array
*/
function _columns( $columns ) {
$columns = array_merge( $columns, self::$fields );
return $columns;
}
/**
*
*/
+30 -21
View File
@@ -20,6 +20,20 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
*/
function __construct() {
add_action( 'wp_roles_init', array( &$this, 'um_roles_init' ), 99999 );
//add_action( 'update_option', array( &$this, 'update_caps' ), 99999, 3 );
}
function update_caps( $option, $old_value, $value ) {
$role_keys = get_option( 'um_roles', array() );
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, $role_keys );
if ( in_array( $option, $role_keys ) ) {
var_dump('131231231231');
exit;
}
}
@@ -35,35 +49,30 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
foreach ( $wp_roles->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
+4 -1
View File
@@ -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
+1 -1
View File
@@ -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