From fdd5dca174aaed84646347d533b2e3096af28ff9 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 26 Apr 2018 11:31:30 +0300 Subject: [PATCH 01/12] - fixed approving users with "Administrator" role; --- includes/admin/core/class-admin-users.php | 99 +++++++++++------------ 1 file changed, 46 insertions(+), 53 deletions(-) diff --git a/includes/admin/core/class-admin-users.php b/includes/admin/core/class-admin-users.php index e7c2ff9e..fb4b2aa2 100644 --- a/includes/admin/core/class-admin-users.php +++ b/includes/admin/core/class-admin-users.php @@ -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 - * - */ - 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 + * + */ + 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 - * - */ - 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 + * + */ + 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'] ) ) { From 7a72b0012909b6d58a0810f63507b2341ec2ac30 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 26 Apr 2018 14:37:16 +0300 Subject: [PATCH 02/12] - fixed JS hide social links; --- assets/js/um-members.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/um-members.js b/assets/js/um-members.js index ac80292c..32d44c48 100644 --- a/assets/js/um-members.js +++ b/assets/js/um-members.js @@ -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(); } From b93d81bb30a252ba91001fc6496e58b72e5d6719 Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Mon, 30 Apr 2018 16:39:58 +0800 Subject: [PATCH 03/12] update minified script --- assets/js/um-members.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/um-members.min.js b/assets/js/um-members.min.js index f497cad8..58df4dbf 100644 --- a/assets/js/um-members.min.js +++ b/assets/js/um-members.min.js @@ -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})}); \ No newline at end of file +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})}); \ No newline at end of file From cbb9287534a440c69e88ba6c8ca67d8f19c6f3a0 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Mon, 30 Apr 2018 21:07:55 +0300 Subject: [PATCH 04/12] - 2.0.12 release; --- README.md | 4 ++-- assets/css/um-profile.css | 2 +- readme.txt | 10 +++++++++- ultimate-member.php | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c78512ef..d4f28e78 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/assets/css/um-profile.css b/assets/css/um-profile.css index 8ee8dd23..1586807e 100644 --- a/assets/css/um-profile.css +++ b/assets/css/um-profile.css @@ -549,6 +549,6 @@ font-weight: normal; @media (min-width: 880px) { .um-profile-nav-item .um-tip-n { - display: none; + display: none !important; } } \ No newline at end of file diff --git a/readme.txt b/readme.txt index 445ec6c6..59d6914e 100644 --- a/readme.txt +++ b/readme.txt @@ -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.12 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -131,6 +131,14 @@ 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.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: diff --git a/ultimate-member.php b/ultimate-member.php index 5a3cb40a..a083c671 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.0.11 +Version: 2.0.12 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From 1d3351ec5e10774f14e219e79ad6534f1dcff664 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 1 May 2018 00:29:45 +0300 Subject: [PATCH 05/12] - fixed cache users count; --- includes/admin/templates/dashboard/cache.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/includes/admin/templates/dashboard/cache.php b/includes/admin/templates/dashboard/cache.php index 2299e8f5..13121cc1 100644 --- a/includes/admin/templates/dashboard/cache.php +++ b/includes/admin/templates/dashboard/cache.php @@ -1,11 +1,10 @@ - $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_%'" +); ?>

From e49197e5888442a537068b511c7eff3197e10186 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Tue, 1 May 2018 10:21:19 +0300 Subject: [PATCH 06/12] - changes with avatar; --- includes/core/class-permalinks.php | 22 +-- includes/core/um-actions-profile.php | 6 +- includes/core/um-filters-avatars.php | 2 +- includes/um-short-functions.php | 246 +++++++++++++-------------- 4 files changed, 128 insertions(+), 148 deletions(-) diff --git a/includes/core/class-permalinks.php b/includes/core/class-permalinks.php index c852c3ee..56e27224 100644 --- a/includes/core/class-permalinks.php +++ b/includes/core/class-permalinks.php @@ -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 ) ); } diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 072e8901..803a3e88 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -518,11 +518,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(); ?> diff --git a/includes/core/um-filters-avatars.php b/includes/core/um-filters-avatars.php index 715e8aec..f4268af4 100644 --- a/includes/core/um-filters-avatars.php +++ b/includes/core/um-filters-avatars.php @@ -76,7 +76,7 @@ function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_cla $rating = "&r={$rating}"; } - if ( UM()->options()->get('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){ + if ( UM()->options()->get('use_gravatars') && ! um_user('synced_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' ); diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 12011f7b..f0634d82 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -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 \"\";"; @@ -1594,9 +1594,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' ) . '/'; @@ -1706,33 +1704,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; @@ -1749,35 +1737,119 @@ 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 = get_current_user_id(); - return $avatar_uri; + um_fetch_user( $user_id ); + + $data = array( + 'user_id' => $user_id, + 'default' => um_get_default_avatar_uri(), + 'class' => 'func-um_user 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'] ); + $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 { + $data['url'] = add_query_arg( 'd', $gravatar_type, $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 + * + */ + $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 + * + */ + $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']; } @@ -2066,88 +2138,14 @@ 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 - * - */ - $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 - * - */ - $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 '' . $image_alt . ''; + return '' . esc_attr($data['alt']) . ''; break; From 5ab39d0226fafcc1671260b81be4bb7ccbc18343 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Tue, 1 May 2018 10:39:11 +0300 Subject: [PATCH 07/12] fix --- includes/core/um-filters-avatars.php | 59 ---------------------------- includes/um-short-functions.php | 12 +++++- 2 files changed, 10 insertions(+), 61 deletions(-) diff --git a/includes/core/um-filters-avatars.php b/includes/core/um-filters-avatars.php index f4268af4..12aec65c 100644 --- a/includes/core/um-filters-avatars.php +++ b/includes/core/um-filters-avatars.php @@ -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 - * - * @example - * - */ - $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 = "&r={$rating}"; - } - - if ( UM()->options()->get('use_gravatars') && ! um_user('synced_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 = ''.$image_alt.''; - - }else if( empty( $avatar ) ){ - $default_avatar_uri = um_get_default_avatar_uri(); - - $avatar = ''.$image_alt.''; - } - return $avatar; } add_filter( 'get_avatar', 'um_get_avatar', 99999, 5 ); \ No newline at end of file diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index f0634d82..52234e1e 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1773,16 +1773,24 @@ function um_get_user_avatar_data( $user_id = '', $size = '96' ) { $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 ); + $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 { - $data['url'] = add_query_arg( 'd', $gravatar_type, $data['url'] ); + $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'; From 22b60a5a28d55b929c5d51272d10f8a8300c2cd0 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Tue, 1 May 2018 10:53:16 +0300 Subject: [PATCH 08/12] fix --- includes/core/class-rest-api.php | 18 +++++++++--------- includes/um-short-functions.php | 9 +++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/includes/core/class-rest-api.php b/includes/core/class-rest-api.php index bd42c056..8a75f37e 100644 --- a/includes/core/class-rest-api.php +++ b/includes/core/class-rest-api.php @@ -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) ); /** diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 52234e1e..ca1a7f0e 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1752,10 +1752,11 @@ function um_get_default_avatar_uri() { * @return bool|string */ function um_get_user_avatar_data( $user_id = '', $size = '96' ) { - if( empty( $user_id ) ) - $user_id = get_current_user_id(); - - um_fetch_user( $user_id ); + if( empty( $user_id ) ) { + $user_id = um_user( 'ID' ); + } else { + um_fetch_user( $user_id ); + } $data = array( 'user_id' => $user_id, From fa2057cb64ebc88491485176fb26fae45c00bc84 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Tue, 1 May 2018 13:58:15 +0300 Subject: [PATCH 09/12] fix --- includes/um-short-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index ca1a7f0e..6838dff5 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -2153,7 +2153,7 @@ function um_user( $data, $attrs = null ) { src="' . esc_attr($data['url']) . '" class="' . esc_attr($data['class']) . '" width="' . esc_attr($data['size']) . '" - height="' . esc_attr($data['url']) . '" + height="' . esc_attr($data['size']) . '" alt="' . esc_attr($data['alt']) . '" />'; break; From a12bea07f8be1a7885d345a8e828a92969b58a5f Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Tue, 1 May 2018 14:33:47 +0300 Subject: [PATCH 10/12] fix --- includes/um-short-functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 6838dff5..7a787b39 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -2149,12 +2149,12 @@ function um_user( $data, $attrs = null ) { case 'profile_photo': $data = um_get_user_avatar_data( um_user( 'ID' ), $attrs ); - return '' . esc_attr($data['alt']) . ''; + alt="' . esc_attr($data['alt']) . '" + onerror="this.src=\''.esc_attr($data['default']).'\';" />'; //don't move attribute before src break; From f11a62ad30734b4b6af27cd71a54864ec5b1a5d9 Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Tue, 1 May 2018 15:04:55 +0300 Subject: [PATCH 11/12] fix --- assets/js/um-scripts.js | 4 ++++ includes/um-short-functions.php | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/js/um-scripts.js b/assets/js/um-scripts.js index 665643c0..91913505 100644 --- a/assets/js/um-scripts.js +++ b/assets/js/um-scripts.js @@ -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){ diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 7a787b39..d15afc67 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -1761,7 +1761,7 @@ function um_get_user_avatar_data( $user_id = '', $size = '96' ) { $data = array( 'user_id' => $user_id, 'default' => um_get_default_avatar_uri(), - 'class' => 'func-um_user gravatar avatar avatar-' . $size . ' um-avatar', + 'class' => 'gravatar avatar avatar-' . $size . ' um-avatar', 'size' => $size ); @@ -2154,7 +2154,8 @@ function um_user( $data, $attrs = null ) { width="' . esc_attr($data['size']) . '" height="' . esc_attr($data['size']) . '" alt="' . esc_attr($data['alt']) . '" - onerror="this.src=\''.esc_attr($data['default']).'\';" />'; //don't move attribute before src + 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; From 0ba4a8e6b06c056cd9fbe824cdf1677c55dbf7be Mon Sep 17 00:00:00 2001 From: yura_nalivaiko Date: Mon, 7 May 2018 10:23:51 +0300 Subject: [PATCH 12/12] -changes for menu; --- includes/admin/core/packages/2.0-beta1/menus.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/admin/core/packages/2.0-beta1/menus.php b/includes/admin/core/packages/2.0-beta1/menus.php index a1ecb262..80f0ce2a 100644 --- a/includes/admin/core/packages/2.0-beta1/menus.php +++ b/includes/admin/core/packages/2.0-beta1/menus.php @@ -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 ); } \ No newline at end of file