Merge remote-tracking branch 'remotes/origin/avatar-changes'

This commit is contained in:
nikitozzzzzzz
2018-05-02 12:14:31 +03:00
6 changed files with 150 additions and 215 deletions
+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) );
/**
+1 -5
View File
@@ -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(); ?>
-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 );