WP User Avatar - Version 2.2.5

Version Description

  • Fix: Missing translation strings added.
Download this release

Release Info

Developer Collizo4sky
Plugin Icon 128x128 WP User Avatar
Version 2.2.5
Comparing to
See all releases

Code changes from version 2.1.9 to 2.2.5

includes/class-wp-user-avatar-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  * Core user functions.
4
  *
5
  * @package WP User Avatar
6
- * @version 1.9.13
7
  */
8
 
9
  class WP_User_Avatar_Functions {
@@ -16,12 +16,103 @@ 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
@@ -55,13 +146,13 @@ class WP_User_Avatar_Functions {
55
  * @uses wpua_get_avatar_filter()
56
  */
57
  public function wpua_bp_core_fetch_avatar_url_filter($gravatar,$params){
58
- global $wpua_functions;
59
- if(strpos($gravatar,'gravatar.com',0)>-1){
60
- $avatar = $wpua_functions->wpua_get_avatar_filter($gravatar, ($params['object']=='user') ? $params['item_id'] : '', ($params['object']=='user') ? (($params['type']=='thumb') ? 50 :150) : 50, '', '');
61
- return $avatar;
62
- }
63
- else
64
- return $gravatar;
65
  }
66
 
67
  /**
@@ -137,21 +228,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
  }
3
  * Core user functions.
4
  *
5
  * @package WP User Avatar
6
+ * @version 2.2.4
7
  */
8
 
9
  class WP_User_Avatar_Functions {
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
+
64
+ $has_valid_url = $this->wpua_has_gravatar($id_or_email);
65
+ if(!$has_valid_url){
66
+ $url = $this->wpua_get_default_avatar_url($url, $id_or_email, $args);
67
+ }
68
+
69
+ }
70
+ /**
71
+ * Filter get_avatar_url filter
72
+ * @since 4.1.9
73
+ * @param string $url
74
+ * @param int|string $id_or_email
75
+ * @param array $args
76
+ */
77
+ return apply_filters( 'wpua_get_avatar_filter_url', $url, $id_or_email);
78
+
79
+
80
+ }
81
+
82
+
83
+ function wpua_get_default_avatar_url($url, $id_or_email, $args){
84
+
85
+ global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
86
+
87
+ $default_image_details = array();
88
+
89
+ $size = !empty($args['size'])?$args['size']:96;
90
+
91
+ // Show custom Default Avatar
92
+ if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
93
+ // Get image
94
+ $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
95
+ // Image src
96
+ $url = $wpua_avatar_default_image[0];
97
+ // Add dimensions if numeric size
98
+ } else {
99
+ // Get mustache image based on numeric size comparison
100
+ if($size > get_option('medium_size_w')) {
101
+ $url = $mustache_original;
102
+ } elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')) {
103
+ $url = $mustache_medium;
104
+ } elseif($size <= get_option('thumbnail_size_w') && $size > 96) {
105
+ $url = $mustache_thumbnail;
106
+ } elseif($size <= 96 && $size > 32) {
107
+ $url = $mustache_avatar;
108
+ } elseif($size <= 32) {
109
+ $url = $mustache_admin;
110
+ }
111
+ // Add dimensions if numeric size
112
+ }
113
+
114
+ return $url;
115
+ }
116
 
117
  /**
118
  * Returns WP User Avatar or Gravatar-hosted image if user doesn't have Buddypress-uploaded image
146
  * @uses wpua_get_avatar_filter()
147
  */
148
  public function wpua_bp_core_fetch_avatar_url_filter($gravatar,$params){
149
+ global $wpua_functions;
150
+ if(strpos($gravatar,'gravatar.com',0)>-1){
151
+ $avatar = $this->wpua_get_avatar_url($gravatar, $params['email'], $params);
152
+ return $avatar;
153
+ }
154
+ else
155
+ return $gravatar;
156
  }
157
 
158
  /**
228
  }
229
  else{
230
 
231
+ if(is_array($wpua_hash_gravatar) && !empty($wpua_hash_gravatar)){
232
+
233
+ if (array_key_exists($hash, $wpua_hash_gravatar)){
234
 
235
+ unset($wpua_hash_gravatar[$hash]);
236
+ $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
237
+ update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
238
+ }
239
+ else
240
+ {
241
+ $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
242
+ update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
243
+
244
+ }
245
 
246
  }
247
+
248
+ /*else{
249
  $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
250
  update_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
251
 
252
+ }*/
253
+
254
  }
255
  //end
256
  }
lang/wp-user-avatar-en_US.mo CHANGED
Binary file
lang/wp-user-avatar-en_US.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP USER AVATAR\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2019-02-25 09:44+0530\n"
6
- "PO-Revision-Date: 2019-02-25 09:44+0530\n"
7
  "Last-Translator: Flipper Code <hello@flippercode.com>\n"
8
  "Language-Team: Flipper Code <hello@flippercode.com>\n"
9
  "Language: en_US\n"
@@ -92,7 +92,8 @@ msgstr ""
92
 
93
  #: includes/class-wp-user-avatar-admin.php:324
94
  #: includes/class-wp-user-avatar-admin.php:378
95
- #: includes/class-wp-user-avatar-functions.php:340
 
96
  #: includes/tinymce/window.php:123 includes/wpua-functions.php:79
97
  #: includes/wpua-functions.php:88 includes/wpua-functions.php:93
98
  #: includes/wpua-functions.php:152
2
  msgstr ""
3
  "Project-Id-Version: WP USER AVATAR\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2020-02-20 11:46+0530\n"
6
+ "PO-Revision-Date: 2020-02-20 11:46+0530\n"
7
  "Last-Translator: Flipper Code <hello@flippercode.com>\n"
8
  "Language-Team: Flipper Code <hello@flippercode.com>\n"
9
  "Language: en_US\n"
92
 
93
  #: includes/class-wp-user-avatar-admin.php:324
94
  #: includes/class-wp-user-avatar-admin.php:378
95
+ #: includes/class-wp-user-avatar-functions.php:439
96
+ #: includes/class-wp-user-avatar-functions.php:590
97
  #: includes/tinymce/window.php:123 includes/wpua-functions.php:79
98
  #: includes/wpua-functions.php:88 includes/wpua-functions.php:93
99
  #: includes/wpua-functions.php:152
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP User Avatar ===
2
 
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
10
 
@@ -401,6 +401,23 @@ 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.
1
  === WP User Avatar ===
2
 
3
+ Contributors: properfraction, collizo4sky
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: 4.0
6
+ Tested up to: 5.4
7
+ Stable tag: 2.2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
401
 
402
  == Changelog ==
403
 
404
+ = 2.2.5 =
405
+ * Fix: Missing translation strings added.
406
+
407
+ = 2.2.4 =
408
+ * Fix: Warning Resolved on Avatar images.
409
+
410
+ = 2.2.3 =
411
+ * Fix: Broken Avatar in buddypress resolved.
412
+
413
+ = 2.2.2 =
414
+ * Fix: Broken avatars on comments section.
415
+
416
+ = 2.2.1 =
417
+ * Fix: get_avatar_url filter is defined.
418
+
419
+ = 2.2.0 =
420
+ * Fix: Fatel Error "Cannot use string offset as an array" resolved in PHP7.2.
421
 
422
  = 2.1.9 =
423
  * 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.5
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.5
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.4');
42
  define('WPUA_FOLDER', basename(dirname(__FILE__)));
43
  define('WPUA_DIR', plugin_dir_path(__FILE__));
44
  define('WPUA_INC', WPUA_DIR.'includes'.'/');