Merge branch 'master' of https://github.com/ultimatemember/ultimatemember into fix/password_field

This commit is contained in:
nikitozzzzzzz
2018-05-14 11:44:28 +03:00
30 changed files with 479 additions and 408 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl
| Latest Version |Requires at least|Stable Tag|
| :------------: |:------------:|:------------:|
| 2.0.10 | WordPress 4.9 or higher| 2.0.10 |
| 2.0.12 | WordPress 4.9 or higher| 2.0.12 |
Features of the plugin include:
@@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version
Releases
====================
[Official Release Version: 2.0.10](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.10).
[Official Release Version: 2.0.12](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.12).
[Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases).
-6
View File
@@ -545,10 +545,4 @@ font-weight: normal;
.um-profile.um-viewing .um-field-checkbox, .um-profile.um-viewing .um-field-radio{
cursor: default !important;
}
@media (min-width: 880px) {
.um-profile-nav-item .um-tip-n {
display: none;
}
}
+8
View File
@@ -6,6 +6,14 @@
display: none;
}
.um-profile-nav-item a.uimob340-show,
.um-profile-nav-item a.uimob500-show,
.um-profile-nav-item a.uimob800-show,
.um-profile-nav-item a.uimob960-show
{
display: none;
}
div.uimob340 .uimob340-show,
div.uimob500 .uimob500-show,
div.uimob800 .uimob800-show,
+1 -1
View File
@@ -4,7 +4,7 @@ jQuery(document).ready(function() {
UM_Member_Grid( jQuery(this) );
});
jQuery('.um-member-connect').each(function(){
jQuery('.um-directory .um-member-connect').each(function(){
if ( jQuery(this).find('a').length == 0 ) {
jQuery(this).remove();
}
+1 -1
View File
@@ -1 +1 @@
jQuery(document).ready(function(){jQuery(".um-members").each(function(){UM_Member_Grid(jQuery(this))}),jQuery(".um-member-connect").each(function(){0==jQuery(this).find("a").length&&jQuery(this).remove()}),jQuery(".um-member-meta-main").each(function(){0==jQuery(this).find(".um-member-metaline").length&&0==jQuery(this).find(".um-member-connect").find("a").length&&jQuery(this).remove()}),jQuery(document).on("click",".um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),m=jQuery(this).parents(".um-members");return r.find(".um-member-more").hide(),r.find(".um-member-meta").slideDown(function(){UM_Member_Grid(m)}),r.find(".um-member-less").fadeIn(),setTimeout(function(){UM_Member_Grid(m)},100),!1}),jQuery(document).on("click",".um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),m=jQuery(this).parents(".um-members");return r.find(".um-member-less").hide(),r.find(".um-member-meta").slideUp(function(){r.find(".um-member-more").fadeIn(),UM_Member_Grid(m)}),!1}),jQuery(document).on("click",".um-do-search",function(e){return e.preventDefault(),jQuery(this).parents("form").find("input").filter(function(e){if(0===this.value.length)return!0}).prop("disabled",!0),jQuery(this).parents("form").find("select").filter(function(e){if(0===this.value.length)return!0}).prop("disabled",!0),jQuery(this).parents("form").submit(),!1})});
jQuery(document).ready(function(){jQuery(".um-members").each(function(){UM_Member_Grid(jQuery(this))}),jQuery(".um-directory .um-member-connect").each(function(){0==jQuery(this).find("a").length&&jQuery(this).remove()}),jQuery(".um-member-meta-main").each(function(){0==jQuery(this).find(".um-member-metaline").length&&0==jQuery(this).find(".um-member-connect").find("a").length&&jQuery(this).remove()}),jQuery(document).on("click",".um-member-more a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),m=jQuery(this).parents(".um-members");return r.find(".um-member-more").hide(),r.find(".um-member-meta").slideDown(function(){UM_Member_Grid(m)}),r.find(".um-member-less").fadeIn(),setTimeout(function(){UM_Member_Grid(m)},100),!1}),jQuery(document).on("click",".um-member-less a",function(e){e.preventDefault();var r=jQuery(this).parents(".um-member"),m=jQuery(this).parents(".um-members");return r.find(".um-member-less").hide(),r.find(".um-member-meta").slideUp(function(){r.find(".um-member-more").fadeIn(),UM_Member_Grid(m)}),!1}),jQuery(document).on("click",".um-do-search",function(e){return e.preventDefault(),jQuery(this).parents("form").find("input").filter(function(e){if(0===this.value.length)return!0}).prop("disabled",!0),jQuery(this).parents("form").find("select").filter(function(e){if(0===this.value.length)return!0}).prop("disabled",!0),jQuery(this).parents("form").submit(),!1})});
+4
View File
@@ -1,3 +1,7 @@
/*jQuery('body').on('error', '.um-avatar', function() {
if( jQuery(this).data('load-error') != undefined ) return;
jQuery(this).data('load-error', '1').attr('src', jQuery(this).data('default'));
});*/
jQuery(document).ready(function() {
jQuery(document).on('click', '.um-dropdown a', function(e){
+25 -2
View File
@@ -38,7 +38,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$this->localize_note();
$this->show_update_messages();
$this->check_wrong_install_folder();
$this->admin_notice_tracking();
//$this->admin_notice_tracking();
$this->need_upgrade();
$this->check_wrong_licenses();
@@ -225,9 +225,32 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
function old_extensions_notice() {
$show = false;
$old_extensions = array(
'bbpress',
'followers',
'friends',
'instagram',
'mailchimp',
'messaging',
'mycred',
'notices',
'notifications',
'online',
'private-content',
'profile-completeness',
'recaptcha',
'reviews',
'social-activity',
'social-login',
'terms-conditions',
'user-tags',
'verified-users',
'woocommerce',
);
$slugs = array_map( function( $item ) {
return 'um-' . $item . '/um-' . $item . '.php';
}, array_keys( UM()->dependencies()->ext_required_version ) );
}, $old_extensions );
$active_plugins = UM()->dependencies()->get_active_plugins();
foreach ( $slugs as $slug ) {
+46 -53
View File
@@ -44,7 +44,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
*/
function user_action_hook( $action ) {
switch ( $action ) {
default:
/**
* UM hook
@@ -74,6 +73,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
case 'um_approve_membership':
case 'um_reenable':
UM()->user()->approve();
break;
@@ -362,8 +362,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
* Bulk user editing actions
*/
function um_bulk_users_edit() {
$admin_err = 0;
// bulk edit users
if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
@@ -377,66 +375,61 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
foreach ( $users as $user_id ) {
UM()->user()->set( $user_id );
if ( ! um_user( 'super_admin' ) ) {
/**
* UM hook
*
* @type action
* @title um_admin_user_action_hook
* @description Action on bulk user action
* @input_vars
* [{"var":"$bulk_action","type":"string","desc":"Bulk Action"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_hook{$action}', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
* function my_admin_user_action( $bulk_action ) {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_hook", $bulk_action );
/**
* UM hook
*
* @type action
* @title um_admin_user_action_hook
* @description Action on bulk user action
* @input_vars
* [{"var":"$bulk_action","type":"string","desc":"Bulk Action"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_hook{$action}', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
* function my_admin_user_action( $bulk_action ) {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_hook", $bulk_action );
/**
* UM hook
*
* @type action
* @title um_admin_user_action_{$bulk_action}_hook
* @description Action on bulk user action
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_{$bulk_action}_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_admin_user_action_{$bulk_action}_hook', 'my_admin_user_action', 10 );
* function my_admin_user_action() {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_{$bulk_action}_hook" );
} else {
$admin_err = 1;
}
/**
* UM hook
*
* @type action
* @title um_admin_user_action_{$bulk_action}_hook
* @description Action on bulk user action
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_{$bulk_action}_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_admin_user_action_{$bulk_action}_hook', 'my_admin_user_action', 10 );
* function my_admin_user_action() {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_{$bulk_action}_hook" );
}
// Finished. redirect now
if ( $admin_err == 0 ) {
//if ( $admin_err == 0 ) {
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
$uri = add_query_arg( 'update', 'users_updated', $uri );
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
$uri = add_query_arg( 'update', 'users_updated', $uri );
wp_redirect( $uri );
wp_redirect( $uri );
exit;
exit;
} else {
/*} else {
wp_redirect( admin_url( 'users.php?update=err_users_updated' ) );
exit;
}
}*/
} else if ( ! empty( $_REQUEST['um_bulkedit'] ) ) {
@@ -18,9 +18,15 @@ $menus = get_posts( array(
foreach ( $menus as $menu ) {
$menu_roles = get_post_meta( $menu->ID, 'menu-item-um_nav_roles', true );
foreach ( $menu_roles as $i => $role_k ) {
$menu_roles[ $i ] = $roles_associations[ $role_k ];
if( !is_array( $menu_roles ) ) {
$menu_roles = array();
}
foreach ( $menu_roles as $i => $role_k ) {
if( $role_k != '' && isset( $roles_associations[ $role_k ] ) ) {
$menu_roles[ $i ] = $roles_associations[ $role_k ];
}
}
update_post_meta( $menu->ID, 'menu-item-um_nav_roles', $menu_roles );
}
+6 -7
View File
@@ -1,11 +1,10 @@
<?php $all_options = wp_load_alloptions();
<?php global $wpdb;
$count = 0;
foreach ( $all_options as $k => $v ) {
if ( strstr( $k, 'um_cache_userdata_' ) !== false ) {
$count++;
}
} ?>
$count = $wpdb->get_var(
"SELECT COUNT( option_id )
FROM {$wpdb->options}
WHERE option_name LIKE 'um_cache_userdata_%'"
); ?>
<p><?php _e( 'Run this task from time to time to keep your DB clean.', 'ultimate-member' ) ?></p>
<p>
@@ -65,7 +65,7 @@
array(
'id' => '_um_login_secondary_btn_word',
'type' => 'text',
'label' => __( 'Primary Button Text', 'ultimate-member' ),
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_login_secondary_btn_word', null, UM()->options()->get( 'login_secondary_btn_word' ) ),
'conditional' => array( '_um_login_secondary_btn', '=', 1 )
@@ -90,7 +90,7 @@
array(
'id' => '_um_profile_secondary_btn_word',
'type' => 'text',
'label' => __( 'Primary Button Text', 'ultimate-member' ),
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_secondary_btn_word', null, UM()->options()->get( 'profile_secondary_btn_word' ) ),
'conditional' => array( '_um_profile_secondary_btn', '=', 1 )
@@ -80,7 +80,7 @@
array(
'id' => '_um_register_secondary_btn_word',
'type' => 'text',
'label' => __( 'Primary Button Text', 'ultimate-member' ),
'label' => __( 'Secondary Button Text', 'ultimate-member' ),
'tooltip' => __( 'Customize the button text', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_register_secondary_btn_word', null, UM()->options()->get( 'register_secondary_btn_word' ) ),
'conditional' => array( '_um_register_secondary_btn', '=', 1 )
+1
View File
@@ -57,6 +57,7 @@ if ( ! class_exists( 'um\Dependencies' ) ) {
'woocommerce' => '2.0.1',
'restrict-content' => '2.0',
'beaver-builder' => '2.0',
'gdpr' => '1.0.0',
);
+2 -42
View File
@@ -30,6 +30,7 @@ if ( ! class_exists( 'UM' ) ) {
* @method UM_Terms_Conditions_API Terms_Conditions_API()
* @method UM_Private_Content_API Private_Content_API()
* @method UM_User_Location_API User_Location_API()
* @method UM_GDPR_API GDPR_API()
*
*/
final class UM extends UM_Functions {
@@ -385,47 +386,6 @@ if ( ! class_exists( 'UM' ) ) {
}
/**
* Show notice for customers with old extension's versions
*/
/*function old_extensions_notice() {
if ( ! is_admin() ) {
return;
}
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
$show = false;
$slugs = array_map( function( $item ) {
return 'um-' . $item . '/um-' . $item . '.php';
}, array_keys( $this->dependencies()->ext_required_version ) );
$active_plugins = $this->dependencies()->get_active_plugins();
foreach ( $slugs as $slug ) {
if ( in_array( $slug, $active_plugins ) ) {
$plugin_data = get_plugin_data( um_path . '..' . DIRECTORY_SEPARATOR . $slug );
if ( version_compare( '2.0', $plugin_data['Version'], '>' ) ) {
$show = true;
break;
}
}
}
if ( ! $show ) {
return;
}
/*global $um_woocommerce;
remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
$um_woocommerce->plugin_inactive = true;*
echo '<div class="error"><p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '</p></div>';
}*/
/**
* Autoload UM classes handler
*
@@ -562,7 +522,7 @@ if ( ! class_exists( 'UM' ) ) {
$this->permalinks();
$this->modal();
$this->cron();
$this->tracking();
//$this->tracking();
$this->mobile();
$this->external_integrations();
}
+5 -3
View File
@@ -524,14 +524,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
*/
function get_post_privacy_settings( $post ) {
//if logged in administrator all pages are visible
if ( current_user_can( 'administrator' ) )
if ( current_user_can( 'administrator' ) ) {
return false;
}
//exlude from privacy UM default pages (except Members list and User(Profile) page)
if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) {
if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) ||
um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) ||
um_is_core_post( $post, 'password-reset' ) )
um_is_core_post( $post, 'password-reset' ) || um_is_core_post( $post, 'user' ) )
return false;
}
@@ -541,7 +542,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] )
if ( ! isset( $restriction['_um_accessible'] ) )
return false;
else
return $restriction;
@@ -624,6 +625,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
//post is private
if ( '0' == $restriction['_um_accessible'] ) {
$this->singular_page = true;
$filtered_posts[] = $post;
continue;
} elseif ( '1' == $restriction['_um_accessible'] ) {
+1 -1
View File
@@ -463,7 +463,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
wp_register_script('um_responsive', um_url . 'assets/js/um-responsive' . $this->suffix . '.js' );
wp_enqueue_script('um_responsive');
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css' );
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css', array( 'um_profile' ) );
wp_enqueue_style('um_responsive');
}
+63 -24
View File
@@ -43,9 +43,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
<div class="um-field um-field-c">
<div class="um-field-area">
<label class="um-field-checkbox active">
<input type="checkbox" name="<?php echo $id; ?>" value="1" checked/><span
class="um-field-checkbox-state"><i
class="um-icon-android-checkbox-outline"></i></span>
<input type="checkbox" name="<?php echo $id; ?>" value="1" checked/>
<span class="um-field-checkbox-state"><i class="um-icon-android-checkbox-outline"></i></span>
<span class="um-field-checkbox-option"> <?php echo $title; ?></span>
</label>
</div>
@@ -800,6 +799,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
return true;
}
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
if ( in_array( $value, $stripslashed ) ) {
return true;
}
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
return true;
}
@@ -1530,10 +1534,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* @param string $key
* @param array $data
* @param boolean $rule
* @param array $args
*
* @return string
*/
function edit_field( $key, $data, $rule = false ) {
function edit_field( $key, $data, $rule = false, $args = array() ) {
global $_um_profile_id;
$output = null;
$disabled = '';
@@ -1567,7 +1572,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* @var boolean $required
* @var string $validate
* @var string $default
* @var string $conditional
* @var string $conditional
*/
extract( $data );
}
@@ -1579,7 +1584,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ($visibility == 'view' && $this->set_mode != 'register') return;
if (( $visibility == 'view' && $this->set_mode == 'register' ) ||
if ( ( $visibility == 'view' && $this->set_mode == 'register' ) ||
( isset( $data['editable'] ) && $data['editable'] == 0 && $this->set_mode == 'profile' )
) {
@@ -1663,7 +1668,47 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
* ?>
*/
$type = apply_filters( "um_hook_for_field_{$type}", $type );
switch ( $type ) {
case 'textarea':
case 'multiselect':
$field_id = $field_name = $key;
$field_value = $this->field_value( $key, $default, $data );
break;
case 'select':
case 'radio':
$form_key = str_replace( 'role_select', 'role', $key );
$field_id = $form_key;
break;
default:
$field_id = '';
break;
}
/**
* UM hook
*
* @type filter
* @title um_completeness_field_id
* @description use for change core id not allowed duplicate
* @input_vars
* [{"var":"$field_id","type":"string","desc":"Field id"},
* {"var":"$data","type":"array","desc":"Field Data"}]
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
* @change_log
* ["Since: 2.0.13"]
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
* @example
* <?php
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
* function function_name( $field_id, $data, $args ) {
* // your code here
* return $field_id;
* }
* ?>
*/
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
/* Begin by field type */
switch ( $type ) {
@@ -1722,8 +1767,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
</div>';
if (!empty( $disabled )) {
$output .= $this->disabled_hidden_field( $field_name, $field_value );
if (!empty( $disabled )) {
$output .= $this->disabled_hidden_field( $field_name, $field_value );
}
if ($this->is_error( $key )) {
@@ -2033,8 +2078,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
$output .= '<div class="um-field-area">';
$field_name = $key;
$field_value = $this->field_value( $key, $default, $data );
if (isset( $data['html'] ) && $data['html'] != 0 && $key != "description") {
@@ -2085,16 +2128,17 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// add the contents of the buffer to the output variable
$output .= ob_get_clean();
} else $output .= '<textarea ' . $disabled . ' style="height: ' . $height . ';" class="' . $this->get_class( $key, $data ) . '" name="' . $key . '" id="' . $key . '" placeholder="' . $placeholder . '">' . $field_value . '</textarea>';
} else {
$output .= '<textarea ' . $disabled . ' style="height: ' . $height . ';" class="' . $this->get_class( $key, $data ) . '" name="' . $field_name . '" id="' . $field_id . '" placeholder="' . $placeholder . '">' . $field_value . '</textarea>';
}
$output .= '
</div>';
$output .= '</div>';
if (!empty( $disabled )) {
if ( ! empty( $disabled ) ) {
$output .= $this->disabled_hidden_field( $field_name, $field_value );
}
if ($this->is_error( $key )) {
if ( $this->is_error( $key ) ) {
$output .= $this->field_error( $this->show_error( $key ) );
}
@@ -2112,7 +2156,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '<div class="um-field-area">';
$output .= '<div class="um-rating um-raty" id="' . $key . '" data-key="' . $key . '" data-number="' . $data['number'] . '" data-score="' . $this->field_value( $key, $default, $data ) . '"></div>';
$output .= '</div>';
$output .= '</div>';
@@ -2314,8 +2357,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Select dropdown */
case 'select':
$form_key = str_replace( 'role_select', 'role', $key );
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
@@ -2435,10 +2476,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
}
if( ! empty( $placeholder ) ) {
$placeholder = strip_tags( $placeholder );
}
$placeholder = strip_tags( $placeholder );
}
$output .= '<select ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . $form_key . '" id="' . $form_key . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . $placeholder . '" ' . $atts_ajax . '>';
$output .= '<select ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . $form_key . '" id="' . $field_id . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . $placeholder . '" ' . $atts_ajax . '>';
/**
* UM hook
@@ -2632,7 +2673,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
}
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . $key . '[]" id="' . $key . '" data-maxsize="' . $max_selections . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . $placeholder . '">';
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . $field_name . '[]" id="' . $field_id . '" data-maxsize="' . $max_selections . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . $placeholder . '">';
if ( isset( $options ) && $options == 'builtin' ) {
@@ -2769,8 +2810,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/* Radio */
case 'radio':
$form_key = str_replace( 'role_radio', 'role', $key );
if ( isset( $options ) ) {
/**
* UM hook
+4 -18
View File
@@ -136,22 +136,15 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
$um_port_forwarding_url = UM()->options()->get( 'um_port_forwarding_url' );
$um_port_forwarding_url = ! empty( $um_port_forwarding_url ) ? $um_port_forwarding_url : '';
$page_url = '';
if ( is_multisite() ) {
$page_url = '';
$blog_id = get_current_blog_id();
$siteurl = get_site_url( $blog_id );
$network_permalink_structure = UM()->options()->get( 'network_permalink_structure' );
if( $network_permalink_structure == "sub-directory" ){
if ( is_ssl() ) {
$page_url = 'https';
} else {
$page_url = 'http';
}
$page_url .= "://";
$page_url .= "//";
$page_url .= $_SERVER[ $server_name_method ];
}else{
$page_url .= $siteurl;
@@ -159,7 +152,6 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
if ( $um_port_forwarding_url == 1 && isset( $_SERVER["SERVER_PORT"] ) ) {
$page_url .= ":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$page_url .= $_SERVER["REQUEST_URI"];
}
@@ -168,13 +160,7 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
if ( !isset( $_SERVER['SERVER_NAME'] ) )
return '';
if ( is_ssl() ) {
$page_url = 'https';
} else {
$page_url = 'http';
}
$page_url .= "://";
$page_url .= "//";
if ( $um_port_forwarding_url == 1 && isset( $_SERVER["SERVER_PORT"] ) ) {
$page_url .= $_SERVER[ $server_name_method ].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
@@ -210,7 +196,7 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
* }
* ?>
*/
return apply_filters( 'um_get_current_page_url', $page_url );
return apply_filters( 'um_get_current_page_url', set_url_scheme( $page_url ) );
}
+9 -9
View File
@@ -524,9 +524,9 @@ if ( ! class_exists( 'um\core\REST_API' ) ) {
$val->first_name = um_user('first_name');
$val->last_name = um_user('last_name');
$val->account_status = um_user('account_status');
$val->profile_pic_original = $this->getsrc( um_user('profile_photo', 'original') );
$val->profile_pic_normal = $this->getsrc( um_user('profile_photo', 200) );
$val->profile_pic_small = $this->getsrc( um_user('profile_photo', 40) );
$val->profile_pic_original = um_get_user_avatar_url('', 'original');
$val->profile_pic_normal = um_get_user_avatar_url('', 200);
$val->profile_pic_small = um_get_user_avatar_url('', 40);
$val->cover_photo = $this->getsrc( um_user('cover_photo', 1000) );
/**
@@ -667,9 +667,9 @@ if ( ! class_exists( 'um\core\REST_API' ) ) {
break;
case 'profile_pic':
$response['profile_pic_original'] = $this->getsrc( um_user('profile_photo', 'original') );
$response['profile_pic_normal'] = $this->getsrc( um_user('profile_photo', 200) );
$response['profile_pic_small'] = $this->getsrc( um_user('profile_photo', 40) );
$response['profile_pic_original'] = um_get_user_avatar_url('', 'original');
$response['profile_pic_normal'] = um_get_user_avatar_url('', 200);
$response['profile_pic_small'] = um_get_user_avatar_url('', 40);
break;
case 'status':
@@ -699,9 +699,9 @@ if ( ! class_exists( 'um\core\REST_API' ) ) {
$val->first_name = um_user('first_name');
$val->last_name = um_user('last_name');
$val->account_status = um_user('account_status');
$val->profile_pic_original = $this->getsrc( um_user('profile_photo', 'original') );
$val->profile_pic_normal = $this->getsrc( um_user('profile_photo', 200) );
$val->profile_pic_small = $this->getsrc( um_user('profile_photo', 40) );
$val->profile_pic_original = um_get_user_avatar_url('', 'original');
$val->profile_pic_normal = um_get_user_avatar_url('', 200);
$val->profile_pic_small = um_get_user_avatar_url('', 40);
$val->cover_photo = $this->getsrc( um_user('cover_photo', 1000) );
/**
+11 -4
View File
@@ -506,13 +506,20 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
* @return mixed|void
*/
function role_data( $roleID ) {
if ( strpos( $roleID, 'um_' ) === 0 )
$roleID = substr( $roleID, 3 );
if ( strpos( $roleID, 'um_' ) === 0 ) {
$role_data = get_option( "um_role_{$roleID}_meta" );
$role_data = get_option( "um_role_{$roleID}_meta" );
if ( ! $role_data ) {
$roleID = substr( $roleID, 3 );
$role_data = get_option( "um_role_{$roleID}_meta" );
}
} else {
$role_data = get_option( "um_role_{$roleID}_meta" );
}
if ( ! $role_data )
if ( ! $role_data ) {
return array();
}
$temp = array();
foreach ( $role_data as $key=>$value ) {
+14
View File
@@ -890,6 +890,20 @@ if ( ! class_exists( 'um\core\User' ) ) {
unset( $submitted['confirm_user_password'] );
}
//remove all password field values from submitted details
$password_fields = array();
foreach ( $submitted as $k => $v ) {
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
$password_fields[] = $k;
$password_fields[] = 'confirm_' . $k;
}
}
foreach ( $password_fields as $pw_field ) {
unset( $submitted[ $pw_field ] );
}
/**
* UM hook
*
+4 -5
View File
@@ -221,6 +221,9 @@ function um_user_edit_profile( $args ) {
foreach ( $fields as $key => $array ) {
/*if ( ! um_can_edit_field( $fields[ $key ] ) )
continue;*/
if ( ! um_can_edit_field( $fields[ $key ] ) && isset( $fields[ $key ]['editable'] ) && ! $fields[ $key ]['editable'] )
continue;
@@ -524,11 +527,7 @@ function um_profile_dynamic_meta_desc() {
$user_id = um_user( 'ID' );
$url = um_user_profile_url();
if (um_profile( 'profile_photo' )) {
$avatar = um_user_uploads_uri() . um_profile( 'profile_photo' );
} else {
$avatar = um_get_default_avatar_uri();
}
$avatar = um_get_user_avatar_url( $user_id, 'original' );
um_reset_user(); ?>
+5 -4
View File
@@ -54,8 +54,9 @@ function um_after_insert_user( $user_id, $args ) {
//clear Users cached queue
UM()->user()->remove_cached_queue();
um_fetch_user( $user_id );
UM()->user()->set_status( um_user('status') );
if ( ! empty( $args['submitted'] ) ) {
um_fetch_user( $user_id );
UM()->user()->set_registration_details( $args['submitted'] );
}
@@ -103,7 +104,7 @@ function um_after_insert_user( $user_id, $args ) {
*/
do_action( 'um_registration_complete', $user_id, $args );
}
add_action( 'um_user_register', 'um_after_insert_user', 10, 2 );
add_action( 'um_user_register', 'um_after_insert_user', 1, 2 );
/**
@@ -118,7 +119,7 @@ function um_send_registration_notification( $user_id, $args ) {
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
if ( um_user( 'status' ) != 'pending' ) {
if ( um_user( 'account_status' ) != 'pending' ) {
UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
} else {
UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
@@ -136,7 +137,7 @@ add_action( 'um_registration_complete', 'um_send_registration_notification', 10,
* @param $args
*/
function um_check_user_status( $user_id, $args ) {
$status = um_user( 'status' );
$status = um_user( 'account_status' );
/**
* UM hook
-59
View File
@@ -27,7 +27,6 @@ add_filter( 'avatar_defaults', 'um_avatar_defaults', 99999 );
* @return string returns avatar in image html elements
*/
function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '' ) {
if ( is_numeric($id_or_email) )
$user_id = (int) $id_or_email;
elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) )
@@ -41,64 +40,6 @@ function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_cla
$avatar = um_user('profile_photo', $size);
/**
* UM hook
*
* @type filter
* @title um_avatar_image_alternate_text
* @description Change avatar image alt
* @input_vars
* [{"var":"$avatar_alt","type":"string","desc":"Image alternate text. Display name by default"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 ); ?>
* @example
* <?php
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
* function my_avatar_image_alternate_text( $avatar_alt ) {
* // your code here
* return $avatar_alt;
* }
* ?>
*/
$image_alt = apply_filters( "um_avatar_image_alternate_text", um_user("display_name") );
if ( ! $avatar && UM()->options()->get( 'use_gravatars' ) ) {
$default = get_option( 'avatar_default', 'mystery' );
if ( $default == 'gravatar_default' ) {
$default = '';
}
$rating = get_option('avatar_rating');
if ( !empty( $rating ) ) {
$rating = "&amp;r={$rating}";
}
if ( UM()->options()->get('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){
$avatar_url = um_get_domain_protocol().'gravatar.com/avatar/'.um_user('synced_gravatar_hashed_id');
$avatar_url = add_query_arg('s',400, $avatar_url);
$gravatar_type = UM()->options()->get( 'use_um_gravatar_default_builtin_image' );
if ( $gravatar_type == 'default' ) {
if ( UM()->options()->get( 'use_um_gravatar_default_image' ) ) {
$avatar_url = add_query_arg('d', um_get_default_avatar_uri(), $avatar_url );
}
} else {
$avatar_url = add_query_arg('d', $gravatar_type, $avatar_url );
}
}
$avatar = '<img src="' .$avatar_url .'?d='. $default . '&amp;s=' . $size . $rating .'" class="func-um_get_avatar gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />';
}else if( empty( $avatar ) ){
$default_avatar_uri = um_get_default_avatar_uri();
$avatar = '<img src="' .$default_avatar_uri .'" class="gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />';
}
return $avatar;
}
add_filter( 'get_avatar', 'um_get_avatar', 99999, 5 );
+62 -10
View File
@@ -367,18 +367,70 @@ add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 );
*/
function um_get_custom_field_array( $array, $fields ) {
if ( isset( $array['conditions'] ) ) {
for ( $a = 0; $a < count( $array['conditions'] ); $a++ ) {
if ( isset( $array['conditional_value'] ) || isset( $array['conditional_value' . $a] ) ) {
foreach ( $array['conditions'] as $key => $value ) {
$condition_metakey = $fields[ $value[1] ]['metakey'];
if ( ! empty( $array['conditions'] ) ) {
foreach ( $array['conditions'] as $key => $value ) {
$condition_metakey = $fields[ $value[1] ]['metakey'];
if ( isset( $_POST[ $condition_metakey ] ) ) {
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
list( $visibility, $parent_key, $op, $parent_value ) = $value;
if ( isset( $_POST[ $condition_metakey ] ) ) {
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
if ( isset( $array['conditional_value'] ) && $cond_value !== $array['conditional_value'] ) {
if ( $visibility == 'hide' ) {
if ( $op == 'empty' ) {
if ( empty( $cond_value ) ) {
$array['required'] = 0;
} elseif ( isset( $array['conditional_value'.$a] ) && $cond_value !== $array['conditional_value'.$a] ) {
}
} elseif ( $op == 'not empty' ) {
if ( ! empty( $cond_value ) ) {
$array['required'] = 0;
}
} elseif ( $op == 'equals to' ) {
if ( $cond_value == $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'not equals' ) {
if ( $cond_value != $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value > $op ) {
$array['required'] = 0;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value < $op ) {
$array['required'] = 0;
}
} elseif ( $op == 'contains' ) {
if ( strstr( $cond_value, $parent_value ) ) {
$array['required'] = 0;
}
}
} elseif ( $visibility == 'show' ) {
if ( $op == 'empty' ) {
if ( ! empty( $cond_value ) ) {
$array['required'] = 0;
}
} elseif ( $op == 'not empty' ) {
if ( empty( $cond_value ) ) {
$array['required'] = 0;
}
} elseif ( $op == 'equals to' ) {
if ( $cond_value != $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'not equals' ) {
if ( $cond_value == $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value <= $op ) {
$array['required'] = 0;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value >= $op ) {
$array['required'] = 0;
}
} elseif ( $op == 'contains' ) {
if ( ! strstr( $cond_value, $parent_value ) ) {
$array['required'] = 0;
}
}
+4 -3
View File
@@ -47,7 +47,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
if ( empty( $_POST['menu-item-db-id'] ) || ! in_array( $menu_item_db_id, $_POST['menu-item-db-id'] ) ) {
return;
}
//var_dump($_POST['menu-item-um_nav_roles']); exit;
foreach ( self::$fields as $_key => $label ) {
$key = sprintf( 'menu-item-%s', $_key );
@@ -55,7 +55,8 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
// Sanitize
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
// Do some checks here...
$value = $_POST[ $key ][ $menu_item_db_id ];
$value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
} else {
$value = null;
}
@@ -165,7 +166,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$html .= "<label $for_attr>
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][]' value='{$k}' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][{$k}]' value='1' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
<span>{$title}</span>
</label>";
}
+172 -147
View File
@@ -442,7 +442,7 @@ function um_js_redirect( $url ) {
if (headers_sent() || empty( $url )) {
//for blank redirects
if ('' == $url) {
$url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$url = set_url_scheme( '//' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] );
}
$funtext = "echo \"<script data-cfasync='false' type='text/javascript'>window.location = '" . $url . "'</script>\";";
@@ -508,10 +508,11 @@ function um_user_submitted_registration( $style = false ) {
$data = um_user( 'submitted' );
if ($style)
if ( $style ) {
$output .= '<div class="um-admin-infobox">';
}
if (isset( $data ) && is_array( $data )) {
if ( isset( $data ) && is_array( $data ) ) {
/**
* UM hook
@@ -535,38 +536,51 @@ function um_user_submitted_registration( $style = false ) {
*/
$data = apply_filters( 'um_email_registration_data', $data );
foreach ($data as $k => $v) {
$pw_fields = array();
foreach ( $data as $k => $v ) {
if (!is_array( $v ) && strstr( $v, 'ultimatemember/temp' )) {
if ( strstr( $k, 'user_pass' ) || in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) ) ) {
continue;
}
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
$pw_fields[] = $k;
$pw_fields[] = 'confirm_' . $k;
continue;
}
if ( ! empty( $pw_fields ) && in_array( $k, $pw_fields ) ) {
continue;
}
if ( ! is_array( $v ) && strstr( $v, 'ultimatemember/temp' ) ) {
$file = basename( $v );
$v = um_user_uploads_uri() . $file;
}
if (!strstr( $k, 'user_pass' ) && !in_array( $k, array( 'g-recaptcha-response', 'request', '_wpnonce', '_wp_http_referer' ) )) {
if (is_array( $v )) {
$v = implode( ',', $v );
}
if ($k == 'timestamp') {
$k = __( 'date submitted', 'ultimate-member' );
$v = date( "d M Y H:i", $v );
}
if ($style) {
if (!$v) $v = __( '(empty)', 'ultimate-member' );
$output .= "<p><label>$k</label><span>$v</span></p>";
} else {
$output .= "$k: $v" . "<br />";
}
if ( is_array( $v ) ) {
$v = implode( ',', $v );
}
if ( $k == 'timestamp' ) {
$k = __( 'date submitted', 'ultimate-member' );
$v = date( "d M Y H:i", $v );
}
if ( $style ) {
if ( ! $v ) {
$v = __( '(empty)', 'ultimate-member' );
}
$output .= "<p><label>$k</label><span>$v</span></p>";
} else {
$output .= "$k: $v" . "<br />";
}
}
}
if ($style)
if ( $style ) {
$output .= '</div>';
}
return $output;
}
@@ -710,6 +724,9 @@ function um_profile_id() {
* @return bool|string
*/
function um_is_temp_upload( $url ) {
if( is_string( $url ) ) {
$url = trim($url);
}
if (filter_var( $url, FILTER_VALIDATE_URL ) === false)
$url = realpath( $url );
@@ -1591,9 +1608,7 @@ function um_youtube_id_from_url( $url ) {
* @return string
*/
function um_user_uploads_uri() {
if (is_ssl()) {
UM()->files()->upload_baseurl = str_replace( "http://", "https://", UM()->files()->upload_baseurl );
}
UM()->files()->upload_baseurl = set_url_scheme( UM()->files()->upload_baseurl );
$uri = UM()->files()->upload_baseurl . um_user( 'ID' ) . '/';
@@ -1703,33 +1718,23 @@ function um_get_avatar_uri( $image, $attrs ) {
*/
$cache_time = apply_filters( 'um_filter_avatar_cache_time', current_time( 'timestamp' ), um_user( 'ID' ) );
if (!empty( $cache_time )) {
$cache_time = "?{$cache_time}";
}
if (file_exists( UM()->files()->upload_basedir . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}" )) {
$uri = um_user_uploads_uri() . "profile_photo-{$attrs}{$ext}{$cache_time}";
if( $attrs == 'original' && file_exists( um_user_uploads_dir() . "profile_photo{$ext}" ) ) {
$uri = um_user_uploads_uri() . "profile_photo{$ext}";
} else if (file_exists( um_user_uploads_dir() . "profile_photo-{$attrs}{$ext}" )) {
$uri = um_user_uploads_uri() . "profile_photo-{$attrs}{$ext}";
} else {
$sizes = UM()->options()->get( 'photo_thumb_sizes' );
if (is_array( $sizes )) $find = um_closest_num( $sizes, $attrs );
if (file_exists( UM()->files()->upload_basedir . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}" )) {
$uri = um_user_uploads_uri() . "profile_photo-{$find}{$ext}{$cache_time}";
} else if (file_exists( UM()->files()->upload_basedir . um_user( 'ID' ) . "/profile_photo{$ext}" )) {
$uri = um_user_uploads_uri() . "profile_photo{$ext}{$cache_time}";
}
if ($attrs == 'original') {
$uri = um_user_uploads_uri() . "profile_photo{$ext}{$cache_time}";
if (file_exists( um_user_uploads_dir() . "profile_photo-{$find}{$ext}" )) {
$uri = um_user_uploads_uri() . "profile_photo-{$find}{$ext}";
} else if (file_exists( um_user_uploads_dir() . "profile_photo{$ext}" )) {
$uri = um_user_uploads_uri() . "profile_photo{$ext}";
}
}
if ( !empty( $cache_time ) ) {
$uri .= "?{$cache_time}";
}
return $uri;
@@ -1746,35 +1751,128 @@ function um_get_default_avatar_uri() {
$uri = !empty( $uri['url'] ) ? $uri['url'] : '';
if ( ! $uri ) {
$uri = um_url . 'assets/img/default_avatar.jpg';
} else {
//http <-> https compatibility default avatar option of SSL was changed
$url_array = parse_url( $uri );
if (is_ssl() && $url_array['scheme'] == 'http') {
$uri = str_replace( 'http://', 'https://', $uri );
} else if (!is_ssl() && $url_array['scheme'] == 'https') {
$uri = str_replace( 'https://', 'http://', $uri );
}
}
return $uri;
return set_url_scheme( $uri );
}
/**
* get user avatar url
*
* @param $user_id
* @param $size
*
* @return bool|string
*/
function um_get_user_avatar_url() {
if (um_profile( 'profile_photo' )) {
$avatar_uri = um_get_avatar_uri( um_profile( 'profile_photo' ), 32 );
} else {
$avatar_uri = um_get_default_avatar_uri();
}
function um_get_user_avatar_data( $user_id = '', $size = '96' ) {
if( empty( $user_id ) ) {
$user_id = um_user( 'ID' );
} else {
um_fetch_user( $user_id );
}
return $avatar_uri;
$data = array(
'user_id' => $user_id,
'default' => um_get_default_avatar_uri(),
'class' => 'gravatar avatar avatar-' . $size . ' um-avatar',
'size' => $size
);
if ( $profile_photo = um_profile( 'profile_photo' ) ) {
$data['url'] = um_get_avatar_uri( $profile_photo, $size );
$data['type'] = 'upload';
$data['class'] .= ' um-avatar-uploaded';
} else if( $synced_profile_photo = um_user( 'synced_profile_photo' ) ) {
$data['url'] = $synced_profile_photo;
$data['type'] = 'sync';
$data['class'] .= ' um-avatar-default';
} else if( UM()->options()->get( 'use_gravatars' ) ) {
$avatar_hash_id = get_user_meta( $user_id, 'synced_gravatar_hashed_id', true );
$data['url'] = set_url_scheme( '//gravatar.com/avatar/' . $avatar_hash_id );
$data['url'] = add_query_arg( 's', 400, $data['url'] );
$rating = get_option('avatar_rating');
if ( !empty( $rating ) ) {
$data['url'] = add_query_arg( 'r', $rating, $data['url'] );
}
$gravatar_type = UM()->options()->get( 'use_um_gravatar_default_builtin_image' );
if ( $gravatar_type == 'default' ) {
if ( UM()->options()->get( 'use_um_gravatar_default_image' ) ) {
$data['url'] = add_query_arg( 'd', $data['default'], $data['url'] );
}
} else {
$default = get_option( 'avatar_default', 'mystery' );
if ( $default == 'gravatar_default' ) {
$default = '';
}
$data['url'] = add_query_arg( 'd', $default, $data['url'] );
}
$data['type'] = 'gravatar';
$data['class'] .= ' um-avatar-gravatar';
} else {
$data['url'] = $data['default'];
$data['type'] = 'default';
$data['class'] .= ' um-avatar-default';
}
/**
* UM hook
*
* @type filter
* @title um_user_avatar_url_filter
* @description Change user avatar URL
* @input_vars
* [{"var":"$avatar_uri","type":"string","desc":"Avatar URL"},
* {"var":"$user_id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_user_avatar_url_filter', 'function_name', 10, 2 );
* @example
* <?php
* add_filter( 'um_user_avatar_url_filter', 'my_user_avatar_url', 10, 2 );
* function my_user_avatar_url( $avatar_uri ) {
* // your code here
* return $avatar_uri;
* }
* ?>
*/
$data['url'] = apply_filters( 'um_user_avatar_url_filter', $data['url'], $user_id, $data );
/**
* UM hook
*
* @type filter
* @title um_avatar_image_alternate_text
* @description Change user display name on um_user function profile photo
* @input_vars
* [{"var":"$display_name","type":"string","desc":"User Display Name"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
* function my_avatar_image_alternate_text( $display_name ) {
* // your code here
* return $display_name;
* }
* ?>
*/
$data['alt'] = apply_filters( "um_avatar_image_alternate_text", um_user( "display_name" ), $data );
return $data;
}
/**
* get user avatar url
*
* @param $user_id
* @param $size
*
* @return bool|string
*/
function um_get_user_avatar_url( $user_id = '', $size = '96' ) {
$data = um_get_user_avatar_data( $user_id, $size );
return $data['url'];
}
@@ -2063,88 +2161,15 @@ function um_user( $data, $attrs = null ) {
break;
case 'profile_photo':
$data = um_get_user_avatar_data( um_user( 'ID' ), $attrs );
$has_profile_photo = false;
$photo_type = 'um-avatar-default';
/**
* UM hook
*
* @type filter
* @title um_avatar_image_alternate_text
* @description Change user display name on um_user function profile photo
* @input_vars
* [{"var":"$display_name","type":"string","desc":"User Display Name"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
* function my_avatar_image_alternate_text( $display_name ) {
* // your code here
* return $display_name;
* }
* ?>
*/
$image_alt = apply_filters( "um_avatar_image_alternate_text", um_user( "display_name" ) );
if (um_profile( 'profile_photo' )) {
$avatar_uri = um_get_avatar_uri( um_profile( 'profile_photo' ), $attrs );
$has_profile_photo = true;
$photo_type = 'um-avatar-uploaded';
} else if (um_user( 'synced_profile_photo' )) {
$avatar_uri = um_user( 'synced_profile_photo' );
} else {
$avatar_uri = um_get_default_avatar_uri();
}
/**
* UM hook
*
* @type filter
* @title um_user_avatar_url_filter
* @description Change user avatar URL
* @input_vars
* [{"var":"$avatar_uri","type":"string","desc":"Avatar URL"},
* {"var":"$user_id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_user_avatar_url_filter', 'function_name', 10, 2 );
* @example
* <?php
* add_filter( 'um_user_avatar_url_filter', 'my_user_avatar_url', 10, 2 );
* function my_user_avatar_url( $avatar_uri ) {
* // your code here
* return $avatar_uri;
* }
* ?>
*/
$avatar_uri = apply_filters( 'um_user_avatar_url_filter', $avatar_uri, um_user( 'ID' ) );
if (!$avatar_uri)
return '';
if ( UM()->options()->get( 'use_gravatars' ) && !um_user( 'synced_profile_photo' ) && !$has_profile_photo) {
$avatar_hash_id = get_user_meta( um_user( 'ID' ), 'synced_gravatar_hashed_id', true );
$avatar_uri = um_get_domain_protocol() . 'gravatar.com/avatar/' . $avatar_hash_id;
$avatar_uri = add_query_arg( 's', 400, $avatar_uri );
$gravatar_type = UM()->options()->get( 'use_um_gravatar_default_builtin_image' );
$photo_type = 'um-avatar-gravatar';
if ( $gravatar_type == 'default' ) {
if ( UM()->options()->get( 'use_um_gravatar_default_image' ) ) {
$avatar_uri = add_query_arg( 'd', um_get_default_avatar_uri(), $avatar_uri );
}
} else {
$avatar_uri = add_query_arg( 'd', $gravatar_type, $avatar_uri );
}
}
$default_avatar = um_get_default_avatar_uri();
return '<img onerror="this.src=\''.esc_attr($default_avatar).'\';" src="' . $avatar_uri . '" class="func-um_user gravatar avatar avatar-' . $attrs . ' um-avatar ' . $photo_type . '" width="' . $attrs . '" height="' . $attrs . '" alt="' . $image_alt . '" />';
return '<img src="' . esc_attr($data['url']) . '"
class="' . esc_attr($data['class']) . '"
width="' . esc_attr($data['size']) . '"
height="' . esc_attr($data['size']) . '"
alt="' . esc_attr($data['alt']) . '"
data-default="' . esc_attr($data['default']) . '"
onerror="if(!this.getAttribute(\'data-load-error\')){this.setAttribute(\'data-load-error\', \'1\');this.setAttribute(\'src\', this.getAttribute(\'data-default\'));}" />'; //don't move attribute before src
break;
+17 -1
View File
@@ -6,7 +6,7 @@ Donate link:
Tags: community, member, membership, user-profile, user-registration
Requires at least: 4.1
Tested up to: 4.9
Stable tag: 2.0.10
Stable tag: 2.0.13
License: GNU Version 2 or Any Later Version
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -131,6 +131,22 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
= Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin =
= 2.0.13: May 2, 2018 =
* Bugfixes:
- Fixed and optimized user avatars
- Fixed Profile Menu on some installs
- Fixed fields IDs duplicates
- Fixed cache users count
= 2.0.12: April 30, 2018 =
* Bugfixes:
- Fixed approving users with "Administrator" role
- Fixed problem with URLs for upload images
- Fixed not UM roles, which start from "um_" symbols
- Fixed content restriction logic
= 2.0.11: April 19, 2018 =
* Bugfixes:
+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.0.11
Version: 2.0.13
Author: Ultimate Member
Author URI: http://ultimatemember.com/
Text Domain: ultimate-member