WP User Avatar - Version 2.2.2

Version Description

  • Fix: Broken avatars on comments section.
Download this release

Release Info

Developer flippercode
Plugin Icon 128x128 WP User Avatar
Version 2.2.2
Comparing to
See all releases

Code changes from version 2.1.9 to 2.2.2

includes/class-wp-user-avatar-functions.php CHANGED
@@ -16,12 +16,102 @@ class WP_User_Avatar_Functions {
16
  */
17
  public function __construct() {
18
  add_filter('get_avatar', array($this, 'wpua_get_avatar_filter'), 10, 5);
19
- // Filter to display WP User Avatar at Buddypress
20
- add_filter('bp_core_fetch_avatar', array($this, 'wpua_bp_core_fetch_avatar_filter'), 10, 5);
21
- // Filter to display WP User Avatar by URL at Buddypress
22
- add_filter('bp_core_fetch_avatar_url', array($this, 'wpua_bp_core_fetch_avatar_url_filter'), 10, 5);
 
 
 
23
 
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  /**
27
  * Returns WP User Avatar or Gravatar-hosted image if user doesn't have Buddypress-uploaded image
@@ -137,21 +227,29 @@ class WP_User_Avatar_Functions {
137
  }
138
  else{
139
 
140
- if (array_key_exists($hash, $wpua_hash_gravatar)){
 
 
 
 
 
 
 
 
 
 
 
141
 
142
- unset($wpua_hash_gravatar[$hash]);
143
- $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
144
- update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
145
-
146
 
147
  }
148
- else
149
- {
150
  $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
151
  update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
152
 
153
- }
154
-
155
  }
156
  //end
157
  }
16
  */
17
  public function __construct() {
18
  add_filter('get_avatar', array($this, 'wpua_get_avatar_filter'), 10, 5);
19
+
20
+ add_filter( 'get_avatar_url', array($this,'wpua_get_avatar_url'), 10, 3 );
21
+
22
+ // Filter to display WP User Avatar at Buddypress
23
+ add_filter('bp_core_fetch_avatar', array($this, 'wpua_bp_core_fetch_avatar_filter'), 10, 5);
24
+ // Filter to display WP User Avatar by URL at Buddypress
25
+ add_filter('bp_core_fetch_avatar_url', array($this, 'wpua_bp_core_fetch_avatar_url_filter'), 10, 5);
26
 
27
  }
28
+
29
+
30
+
31
+ function wpua_get_avatar_url($url, $id_or_email, $args){
32
+
33
+
34
+ global $wpua_disable_gravatar;
35
+
36
+ $user_id=null;
37
+ if(is_object($id_or_email)){
38
+ if(!empty($id_or_email->comment_author_email)) {
39
+ $user_id = $id_or_email->user_id;
40
+ }
41
+
42
+ }else{
43
+ if ( is_email( $id_or_email ) ) {
44
+ $user = get_user_by( 'email', $id_or_email );
45
+ if($user){
46
+ $user_id = $user->ID;
47
+ }
48
+ } else {
49
+ $user_id = $id_or_email;
50
+ }
51
+ }
52
+
53
+ // First checking custom avatar.
54
+ if( has_wp_user_avatar( $user_id ) ) {
55
+
56
+ $url = $this->get_wp_user_avatar_src( $user_id );
57
+
58
+ } else if( $wpua_disable_gravatar ) {
59
+
60
+ $url = $this->wpua_get_default_avatar_url($url, $id_or_email, $args);
61
+
62
+ } else {
63
+ $has_valid_url = $this->wpua_has_gravatar($id_or_email);
64
+ if(!$has_valid_url){
65
+ $url = $this->wpua_get_default_avatar_url($url, $id_or_email, $args);
66
+ }
67
+
68
+ }
69
+ /**
70
+ * Filter get_avatar_url filter
71
+ * @since 4.1.9
72
+ * @param string $url
73
+ * @param int|string $id_or_email
74
+ * @param array $args
75
+ */
76
+ return apply_filters( 'wpua_get_avatar_filter_url', $url, $id_or_email);
77
+
78
+
79
+ }
80
+
81
+
82
+ function wpua_get_default_avatar_url($url, $id_or_email, $args){
83
+
84
+ global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
85
+
86
+ $default_image_details = array();
87
+
88
+ $size = !empty($args['size'])?$args['size']:96;
89
+
90
+ // Show custom Default Avatar
91
+ if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
92
+ // Get image
93
+ $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
94
+ // Image src
95
+ $url = $wpua_avatar_default_image[0];
96
+ // Add dimensions if numeric size
97
+ } else {
98
+ // Get mustache image based on numeric size comparison
99
+ if($size > get_option('medium_size_w')) {
100
+ $url = $mustache_original;
101
+ } elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')) {
102
+ $url = $mustache_medium;
103
+ } elseif($size <= get_option('thumbnail_size_w') && $size > 96) {
104
+ $url = $mustache_thumbnail;
105
+ } elseif($size <= 96 && $size > 32) {
106
+ $url = $mustache_avatar;
107
+ } elseif($size <= 32) {
108
+ $url = $mustache_admin;
109
+ }
110
+ // Add dimensions if numeric size
111
+ }
112
+
113
+ return $url;
114
+ }
115
 
116
  /**
117
  * Returns WP User Avatar or Gravatar-hosted image if user doesn't have Buddypress-uploaded image
227
  }
228
  else{
229
 
230
+ if(is_array($wpua_hash_gravatar) && !empty($wpua_hash_gravatar)){
231
+
232
+ if (array_key_exists($hash, $wpua_hash_gravatar)){
233
+
234
+ unset($wpua_hash_gravatar[$hash]);
235
+ $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
236
+ update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
237
+ }
238
+ else
239
+ {
240
+ $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
241
+ update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
242
 
243
+ }
 
 
 
244
 
245
  }
246
+
247
+ /*else{
248
  $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
249
  update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
250
 
251
+ }*/
252
+
253
  }
254
  //end
255
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  Contributors: flippercode
4
  Tags: author image, author photo, author avatar, avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo, widget
5
  Requires at least: 3.6
6
- Tested up to: 5.1.0
7
  Stable tag: 2.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -401,6 +401,14 @@ This would output:
401
 
402
  == Changelog ==
403
 
 
 
 
 
 
 
 
 
404
 
405
  = 2.1.9 =
406
  * New: New filter 'wpua_default_alt_tag' added to modify default image alt tag And warning error resolved on stagging environment.
3
  Contributors: flippercode
4
  Tags: author image, author photo, author avatar, avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo, widget
5
  Requires at least: 3.6
6
+ Tested up to: 5.1.1
7
  Stable tag: 2.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
401
 
402
  == Changelog ==
403
 
404
+ = 2.2.2 =
405
+ * Fix: Broken avatars on comments section.
406
+
407
+ = 2.2.1 =
408
+ * Fix: get_avatar_url filter is defined.
409
+
410
+ = 2.2.0 =
411
+ * Fix: Fatel Error "Cannot use string offset as an array" resolved in PHP7.2.
412
 
413
  = 2.1.9 =
414
  * New: New filter 'wpua_default_alt_tag' added to modify default image alt tag And warning error resolved on stagging environment.
wp-user-avatar.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
- * @version 2.1.9
5
  */
6
 
7
  /*
@@ -10,7 +10,7 @@ Plugin URI: http://wordpress.org/plugins/wp-user-avatar/
10
  Description: Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.
11
  Author: flippercode
12
  Author URI: http://www.flippercode.com/
13
- Version: 2.1.9
14
  Text Domain: wp-user-avatar
15
  Domain Path: /lang/
16
  */
@@ -38,7 +38,7 @@ class WP_User_Avatar_Setup {
38
  * @since 1.9.2
39
  */
40
  private function _define_constants() {
41
- define('WPUA_VERSION', '2.1.9');
42
  define('WPUA_FOLDER', basename(dirname(__FILE__)));
43
  define('WPUA_DIR', plugin_dir_path(__FILE__));
44
  define('WPUA_INC', WPUA_DIR.'includes'.'/');
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 2.2.2
5
  */
6
 
7
  /*
10
  Description: Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.
11
  Author: flippercode
12
  Author URI: http://www.flippercode.com/
13
+ Version: 2.2.2
14
  Text Domain: wp-user-avatar
15
  Domain Path: /lang/
16
  */
38
  * @since 1.9.2
39
  */
40
  private function _define_constants() {
41
+ define('WPUA_VERSION', '2.2.2');
42
  define('WPUA_FOLDER', basename(dirname(__FILE__)));
43
  define('WPUA_DIR', plugin_dir_path(__FILE__));
44
  define('WPUA_INC', WPUA_DIR.'includes'.'/');