ID; } else { $user_id = $user; } return get_user_meta( $user_id, AnyCommentSocialAuth::META_SOCIAL_AVATAR, true ); } /** * Get social type. e.g. vkontakte * * @param WP_User|int $user User instance or ID to be checked for. * * @return mixed */ public static function getSocialType( $user ) { if ( $user instanceof WP_User ) { $user_id = $user->ID; } else { $user_id = $user; } if ( empty( $user_id ) ) { return null; } return get_user_meta( $user_id, AnyCommentSocialAuth::META_SOCIAL_TYPE, true ); } /** * Check whether user logged in using social network or not. * * @param WP_User|int $user User instance or ID to be checked for. * * @return bool */ public static function isSocialLogin( $user ) { $socialType = static::getSocialType( $user ); return $socialType !== null && ! empty( $socialType ); } /** * Get social profile URL. * * @param WP_User|int $user User instance or ID to be checked for. * @param bool $html If required to return HTML link * * @return null|string */ public static function get_social_profile_url( $user, $html = false ) { if ( ! static::isSocialLogin( $user ) ) { return null; } $url = get_user_meta( $user, AnyCommentSocialAuth::META_SOCIAL_LINK, true ); if ( empty( $url ) || strpos( $url, 'http' ) !== false ) { $url = null; } if ( empty( $url ) && ( $user_data = get_userdata( $user ) ) !== false ) { $url = $user_data->user_url; } return ! $html ? $url : sprintf( '%s', $url, $url ); } }