Merge pull request #717 from ultimatemember/development/2.1.14

2.1.14 release
This commit is contained in:
Nikita Sinelnikov
2020-12-22 20:32:12 +02:00
committed by GitHub
18 changed files with 105 additions and 45 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ function um_init_datetimepicker() {
function init_tipsy() {
if( typeof(jQuery.fn.tipsy) === "function" ){
if ( typeof( jQuery.fn.tipsy ) === "function" ) {
jQuery('.um-tip-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live', offset: 3 });
jQuery('.um-tip-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live', offset: 3 });
jQuery('.um-tip-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live', offset: 3 });
+1 -1
View File
@@ -898,7 +898,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
continue;
} ?>
<a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
<a href="javascript:void(0);" class="button with-icon" <?php disabled( in_array( $field_key, $form_fields, true ) ) ?> data-silent_action="um_admin_add_field_from_list" data-arg1="<?php echo esc_attr( $field_key ); ?>" data-arg2="<?php echo esc_attr( $arg2 ); ?>" title="<?php echo __( 'Meta Key', 'ultimate-member' ) . ' - ' . esc_attr( $field_key ); ?>"><?php echo um_trim_string( stripslashes( $array['title'] ), 20 ); ?> <small>(<?php echo ucfirst( $array['type'] ); ?>)</small><span class="remove"></span></a>
<?php }
} else {
+2 -2
View File
@@ -173,7 +173,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
*/
function load_role_wrapper() {
wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', array( 'jquery' ), ultimatemember_version, true );
$localize_roles_data = get_option( 'um_roles' );
$localize_roles_data = get_option( 'um_roles', array() );
wp_localize_script( 'um_admin_role_wrapper', 'um_roles', (array) $localize_roles_data );
wp_enqueue_script( 'um_admin_role_wrapper' );
}
@@ -441,7 +441,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
wp_set_script_translations( 'um_block_js', 'ultimate-member' );
$restrict_options = array();
$roles = UM()->roles()->get_roles( false, array( 'administrator' ) );
$roles = UM()->roles()->get_roles( false );
if ( ! empty( $roles ) ) {
foreach ( $roles as $role_key => $title ) {
$restrict_options[] = array(
+4 -3
View File
@@ -40,6 +40,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
function __construct() {
$this->in_edit = false;
$this->edit_mode_value = null;
$this->edit_array = [];
add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9);
@@ -404,7 +405,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
'type' => 'multi_checkbox',
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'options' => UM()->roles()->get_roles( false ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
@@ -558,7 +559,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => $_um_access_roles_value,
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'options' => UM()->roles()->get_roles( false ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
@@ -1233,7 +1234,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
if ( $this->in_edit == true ) { // we're editing a field
$real_attr = substr( $attribute, 1 );
$this->edit_mode_value = (isset( $this->edit_array[ $real_attr ] ) ) ? $this->edit_array[ $real_attr ] : null;
$this->edit_mode_value = isset( $this->edit_array[ $real_attr ] ) ? $this->edit_array[ $real_attr ] : null;
}
switch ( $attribute ) {
@@ -27,7 +27,7 @@ if ( isset( $_GET['action'] ) ) {
um_js_redirect( $redirect );
}
$um_roles = get_option( 'um_roles' );
$um_roles = get_option( 'um_roles', array() );
$um_custom_roles = array();
foreach ( $role_keys as $k => $role_key ) {
@@ -426,7 +426,7 @@ $ListTable->set_sortable_columns( array(
$users_count = count_users();
$roles = array();
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( $role_keys ) {
foreach ( $role_keys as $role_key ) {
@@ -73,7 +73,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => $_um_access_roles_value,
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'options' => UM()->roles()->get_roles( false ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
+1 -1
View File
@@ -117,7 +117,7 @@ if ( ! empty( $_POST['role'] ) ) {
if ( '' == $error ) {
if ( 'add' == sanitize_key( $_GET['tab'] ) ) {
$roles = get_option( 'um_roles' );
$roles = get_option( 'um_roles', array() );
$roles[] = $id;
update_option( 'um_roles', $roles );
+1 -1
View File
@@ -633,7 +633,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
function set_predefined_fields() {
global $wp_roles;
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
+36 -9
View File
@@ -568,7 +568,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
}
$output .= '<label for="' . esc_attr( $key . UM()->form()->form_suffix ) . '">' . __( $label, 'ultimate-member' ) . '</label>';
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
$for_attr = '';
if ( ! in_array( $data['type'], $fields_without_metakey ) ) {
$for_attr = ' for="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
}
$output .= '<label' . $for_attr . '>' . __( $label, 'ultimate-member' ) . '</label>';
if ( ! empty( $data['help'] ) && $this->viewing == false && ! strstr( $key, 'confirm_user_pass' ) ) {
@@ -978,7 +984,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
$field_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( ! empty( $role_keys ) ) {
if ( in_array( $field_value, $role_keys ) ) {
@@ -1125,7 +1131,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ( strstr( $key, 'role_' ) || $key == 'role' ) {
$um_user_value = strtolower( UM()->roles()->get_editable_priority_user_role( um_user( 'ID' ) ) );
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( ! empty( $role_keys ) ) {
if ( in_array( $um_user_value, $role_keys ) ) {
@@ -1443,7 +1449,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$array['conditional'] = null;
}
$array['classes'] .= ' um-field-' . esc_attr( $key );
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
if ( ! in_array( $array['type'], $fields_without_metakey ) ) {
$array['classes'] .= ' um-field-' . esc_attr( $key );
}
$array['classes'] .= ' um-field-' . esc_attr( $array['type'] );
$array['classes'] .= ' um-field-type_' . esc_attr( $array['type'] );
@@ -4059,9 +4069,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$_field_value = $this->field_value( $key, $default, $data );
if ( ! isset( $_field_value ) || $_field_value == '' ) {
if ( ! in_array( $type, $fields_without_metakey ) && ( ! isset( $_field_value ) || $_field_value == '' ) ) {
$output = '';
} else {
$output .= '<div ' . $this->get_atts( $key, $classes, $conditional, $data ) . '>';
if ( isset( $data['label'] ) || ! empty( $data['icon'] ) ) {
@@ -4126,11 +4137,20 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*/
$res = apply_filters( "um_view_field_value_{$type}", $res, $data );
$output .= '<div class="um-field-area">';
$output .= '<div class="um-field-value" id="' . esc_attr( $key . UM()->form()->form_suffix ) . '">' . $res . '</div>';
$output .= '</div>';
$id_attr = '';
if ( ! in_array( $type, $fields_without_metakey ) ) {
$id_attr = ' id="' . esc_attr( $key . UM()->form()->form_suffix ) . '"';
}
$output .= '</div>';
if ( empty( $res ) ) {
$output = '';
} else {
$output .= '<div class="um-field-area">';
$output .= '<div class="um-field-value"' . $id_attr . '>' . $res . '</div>';
$output .= '</div>';
$output .= '</div>';
}
}
break;
@@ -4665,6 +4685,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
)
);
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
if ( in_array( $data['type'], $fields_without_metakey ) ) {
unset( $field_atts['id'] );
unset( $field_atts['data-key'] );
}
if ( ! empty( $field_style ) && is_array( $field_style ) ) {
$arr_inline_style = '';
+4 -1
View File
@@ -385,6 +385,8 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
function show_meta( $array ) {
$output = '';
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey();
if ( ! empty( $array ) ) {
foreach ( $array as $key ) {
if ( $key ) {
@@ -396,8 +398,9 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
$data['in_profile_meta'] = true;
$value = um_filtered_value( $key, $data );
if ( ! $value )
if ( ! $value && ! in_array( $data['type'], $fields_without_metakey ) ) {
continue;
}
if ( ! UM()->options()->get( 'profile_show_metaicon' ) ) {
$icon = '';
+13 -9
View File
@@ -32,7 +32,7 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
function um_on_roles_update( $option, $old_value, $value ) {
global $wp_roles;
if ( isset( $wp_roles->role_key ) && $option == $wp_roles->role_key ) {
if ( is_object( $wp_roles ) && isset( $wp_roles->role_key ) && $option == $wp_roles->role_key ) {
foreach ( $value as $role_key => $role_data ) {
$role_keys = get_option( 'um_roles', array() );
$role_keys = array_map( function( $item ) {
@@ -126,10 +126,11 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
*/
function is_role_custom( $role ) {
// User has roles so look for a UM Role one
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( empty( $role_keys ) )
if ( empty( $role_keys ) ) {
return false;
}
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
@@ -385,7 +386,7 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
return false;
// User has roles so look for a UM Role one
$um_roles_keys = get_option( 'um_roles' );
$um_roles_keys = get_option( 'um_roles', array() );
if ( ! empty( $um_roles_keys ) ) {
$um_roles_keys = array_map( function( $item ) {
@@ -453,7 +454,7 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
return false;
// User has roles so look for a UM Role one
$um_roles_keys = get_option( 'um_roles' );
$um_roles_keys = get_option( 'um_roles', array() );
if ( ! empty( $um_roles_keys ) ) {
$um_roles_keys = array_map( function( $item ) {
@@ -495,15 +496,17 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
*/
function get_um_user_role( $user_id ) {
// User has roles so look for a UM Role one
$um_roles_keys = get_option( 'um_roles' );
$um_roles_keys = get_option( 'um_roles', array() );
if ( empty( $um_roles_keys ) )
if ( empty( $um_roles_keys ) ) {
return false;
}
$user = get_userdata( $user_id );
if ( empty( $user->roles ) )
if ( empty( $user->roles ) ) {
return false;
}
$um_roles_keys = array_map( function( $item ) {
return 'um_' . $item;
@@ -511,8 +514,9 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
$user_um_roles_array = array_intersect( $um_roles_keys, array_values( $user->roles ) );
if ( empty( $user_um_roles_array ) )
if ( empty( $user_um_roles_array ) ) {
return false;
}
return array_shift( $user_um_roles_array );
}
+3 -3
View File
@@ -729,7 +729,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
public function secondary_role_field( $content, $userdata ) {
$roles = array();
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( $role_keys ) {
foreach ( $role_keys as $role_key ) {
$role_meta = get_option( "um_role_{$role_key}_meta" );
@@ -1858,12 +1858,12 @@ if ( ! class_exists( 'um\core\User' ) ) {
//if isset roles argument validate role to properly for security reasons
if ( isset( $args['role'] ) ) {
global $wp_roles;
$um_roles = get_option( 'um_roles' );
$um_roles = get_option( 'um_roles', array() );
if ( ! empty( $um_roles ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
}, $um_roles );
} else {
$role_keys = array();
}
+10 -2
View File
@@ -536,13 +536,21 @@ function um_submit_form_errors_hook_( $args ) {
if ( isset( $array['min_chars'] ) && $array['min_chars'] > 0 ) {
if ( $args[ $key ] && strlen( utf8_decode( $args[ $key ] ) ) < $array['min_chars'] ) {
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) );
if ( empty( $array['label'] ) ) {
UM()->form()->add_error( $key, sprintf( __( 'This field must contain at least %s characters', 'ultimate-member' ), $array['min_chars'] ) );
} else {
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain at least %s characters', 'ultimate-member' ), $array['label'], $array['min_chars'] ) );
}
}
}
if ( isset( $array['max_chars'] ) && $array['max_chars'] > 0 ) {
if ( $args[ $key ] && strlen( utf8_decode( $args[ $key ] ) ) > $array['max_chars'] ) {
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) );
if ( empty( $array['label'] ) ) {
UM()->form()->add_error( $key, sprintf( __( 'This field must contain less than %s characters', 'ultimate-member' ), $array['max_chars'] ) );
} else {
UM()->form()->add_error( $key, sprintf( __( 'Your %s must contain less than %s characters', 'ultimate-member' ), $array['label'], $array['max_chars'] ) );
}
}
}
+4 -4
View File
@@ -380,7 +380,7 @@ function um_user_edit_profile( $args ) {
global $wp_roles;
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
}, get_option( 'um_roles', array() ) );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
if ( ! in_array( $args['submitted']['role'], $exclude_roles ) ) {
@@ -400,7 +400,7 @@ function um_user_edit_profile( $args ) {
global $wp_roles;
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
}, get_option( 'um_roles', array() ) );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
if ( ! in_array( $args['submitted']['role'], $exclude_roles ) ) {
@@ -536,7 +536,7 @@ function um_user_edit_profile( $args ) {
* }
* ?>
*/
do_action( 'um_user_after_updating_profile', $to_update, $user_id );
do_action( 'um_user_after_updating_profile', $to_update, $user_id, $args );
/**
* UM hook
@@ -598,7 +598,7 @@ function um_restore_default_roles( $user_id, $args, $to_update ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
}, get_option( 'um_roles', array() ) );
$leave_roles = array_diff( $args['roles_before_upgrade'], array_merge( $role_keys, array( 'subscriber' ) ) );
+9 -3
View File
@@ -64,8 +64,14 @@ function um_after_insert_user( $user_id, $args ) {
UM()->user()->set_registration_details( $args['submitted'], $args );
}
$status = um_user( 'status' );
if ( empty( $status ) ) {
um_fetch_user( $user_id );
$status = um_user( 'status' );
}
/* save user status */
UM()->user()->set_status( um_user( 'status' ) );
UM()->user()->set_status( $status );
/* create user uploads directory */
UM()->uploader()->get_upload_user_base_dir( $user_id, true );
@@ -400,12 +406,12 @@ function um_submit_form_register( $args ) {
//get user role from field Role dropdown or radio
if ( isset( $args['role'] ) ) {
global $wp_roles;
$um_roles = get_option( 'um_roles' );
$um_roles = get_option( 'um_roles', array() );
if ( ! empty( $um_roles ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
}, $um_roles );
} else {
$role_keys = array();
}
+11
View File
@@ -155,6 +155,17 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
* To learn more about version 2.1 please see this [docs](https://docs.ultimatemember.com/article/1512-upgrade-2-1-0)
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
= 2.1.14: December 21, 2020 =
* Enhancements:
- Added a tooltip with meta key name for fields in a form settings
- Added `Administrator` user role to a restriction setting (to make the content visible only for `Administrator` role)
* Bugfixes:
- Added third parameter $args to the action hook for Profile Tab redirections `um_user_after_updating_profile`
- Fixed issues with fields without metakeys when trying to display them by the hook
- Fixed PHP notices/warnings
= 2.1.13: December 8, 2020 =
* Enhancements:
+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.13
Version: 2.1.14-rc.1
Author: Ultimate Member
Author URI: http://ultimatemember.com/
Text Domain: ultimate-member
+1 -1
View File
@@ -69,7 +69,7 @@ if ( ! empty( $delete_options ) ) {
}
//remove user role meta
$role_keys = get_option( 'um_roles' );
$role_keys = get_option( 'um_roles', array() );
if ( $role_keys ) {
foreach ( $role_keys as $role_key ) {
delete_option( 'um_role_' . $role_key . '_meta' );