WP User Avatar - Version 2.2.8

Version Description

  • Fixed: Notice: Object of class WP_User could not be converted.
  • Replace core Profile Picture in profile edit screen with WP User Avatar.
  • Replace 'Avatar' as a label with 'Profile Picture'.
  • Removed dashboard access restriction feature.
  • Fixed contextual button display showing undo button on page load.
Download this release

Release Info

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

Code changes from version 2.2.7 to 2.2.8

includes/class-wp-user-avatar-admin.php CHANGED
@@ -321,7 +321,7 @@ class WP_User_Avatar_Admin {
321
  * @return array
322
  */
323
  public function wpua_add_column($columns) {
324
- return $columns + array('wp-user-avatar' => __('Avatar','wp-user-avatar'));
325
  }
326
 
327
  /**
@@ -375,7 +375,7 @@ class WP_User_Avatar_Admin {
375
  global $post, $wpua_avatar_default;
376
  $is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
377
  if(!empty($is_wpua)) {
378
- $states[] = __('Avatar','wp-user-avatar');
379
  }
380
  if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)) {
381
  $states[] = __('Default Avatar','wp-user-avatar');
321
  * @return array
322
  */
323
  public function wpua_add_column($columns) {
324
+ return $columns + array('wp-user-avatar' => __('Profile Picture','wp-user-avatar'));
325
  }
326
 
327
  /**
375
  global $post, $wpua_avatar_default;
376
  $is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
377
  if(!empty($is_wpua)) {
378
+ $states[] = __('Profile Picture','wp-user-avatar');
379
  }
380
  if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)) {
381
  $states[] = __('Default Avatar','wp-user-avatar');
includes/class-wp-user-avatar-shortcode.php CHANGED
@@ -199,7 +199,7 @@ class WP_User_Avatar_Shortcode {
199
  $get_user = empty($get_user) ? get_user_by('slug', $user) : $get_user;
200
  $get_user = empty($get_user) ? get_user_by('email', $user) : $get_user;
201
  // Check if current user can edit this user
202
- $valid_user = current_user_can('edit_user', $get_user) ? $get_user : null;
203
  }
204
  // Show form only for valid user
205
  if($valid_user) {
199
  $get_user = empty($get_user) ? get_user_by('slug', $user) : $get_user;
200
  $get_user = empty($get_user) ? get_user_by('email', $user) : $get_user;
201
  // Check if current user can edit this user
202
+ $valid_user = current_user_can('edit_user', $get_user->ID) ? $get_user : null;
203
  }
204
  // Show form only for valid user
205
  if($valid_user) {
includes/class-wp-user-avatar-subscriber.php CHANGED
@@ -17,16 +17,9 @@ class WP_User_Avatar_Subscriber {
17
  * @uses wpua_is_author_or_above()
18
  */
19
  public function __construct() {
20
- global $wp_user_avatar, $wpua_allow_upload;
21
  if((bool) $wpua_allow_upload == 1) {
22
  add_action('user_edit_form_tag', array($this, 'wpua_add_edit_form_multipart_encoding'));
23
- // Only Subscribers lack delete_posts capability
24
- if(!current_user_can('delete_posts') && current_user_can('edit_posts') && !$wp_user_avatar->wpua_is_author_or_above()) {
25
- add_action('admin_menu', array($this, 'wpua_subscriber_remove_menu_pages'));
26
- add_action('wp_before_admin_bar_render', array($this, 'wpua_subscriber_remove_menu_bar_items'));
27
- add_action('wp_dashboard_setup', array($this, 'wpua_subscriber_remove_dashboard_widgets'));
28
- add_action('admin_init', array($this, 'wpua_subscriber_offlimits'));
29
- }
30
  }
31
  add_action('admin_init', array($this, 'wpua_subscriber_capability'));
32
  }
@@ -39,67 +32,6 @@ class WP_User_Avatar_Subscriber {
39
  echo ' enctype="multipart/form-data"';
40
  }
41
 
42
- /**
43
- * Remove menu items
44
- * @since 1.4
45
- * @uses remove_menu_page()
46
- */
47
- public function wpua_subscriber_remove_menu_pages() {
48
- remove_menu_page('edit.php');
49
- remove_menu_page('edit-comments.php');
50
- remove_menu_page('tools.php');
51
- }
52
-
53
- /**
54
- * Remove menu bar items
55
- * @since 1.5.1
56
- * @uses object $wp_admin_bar
57
- * @uses remove_menu()
58
- */
59
- public function wpua_subscriber_remove_menu_bar_items() {
60
- global $wp_admin_bar;
61
- $wp_admin_bar->remove_menu('comments');
62
- $wp_admin_bar->remove_menu('new-content');
63
- }
64
-
65
- /**
66
- * Remove dashboard items
67
- * @since 1.4
68
- * @uses remove_meta_box()
69
- */
70
- public function wpua_subscriber_remove_dashboard_widgets() {
71
- remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
72
- remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
73
- remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
74
- }
75
-
76
- /**
77
- * Restrict access to pages
78
- * @since 1.4
79
- * @uses string $pagenow
80
- * @uses bool $wpua_edit_avatar
81
- * @uses apply_filters()
82
- * @uses do_action()
83
- * @uses wp_die()
84
- */
85
- public function wpua_subscriber_offlimits() {
86
- global $pagenow, $wpua_edit_avatar;
87
- $offlimits = array('edit.php', 'edit-comments.php', 'post-new.php', 'tools.php');
88
- if((bool) $wpua_edit_avatar != 1) {
89
- array_push($offlimits, 'post.php');
90
- }
91
- /**
92
- * Filter restricted pages
93
- * @since 1.9
94
- * @param array $offlimits
95
- */
96
- $offlimits = apply_filters('wpua_subscriber_offlimits', $offlimits);
97
- if(in_array($pagenow, $offlimits)) {
98
- do_action('admin_page_access_denied');
99
- wp_die(__('You do not have sufficient permissions to access this page.','wp-user-avatar'));
100
- }
101
- }
102
-
103
  /**
104
  * Give subscribers edit_posts capability
105
  * @since 1.8.3
17
  * @uses wpua_is_author_or_above()
18
  */
19
  public function __construct() {
20
+ global $wpua_allow_upload;
21
  if((bool) $wpua_allow_upload == 1) {
22
  add_action('user_edit_form_tag', array($this, 'wpua_add_edit_form_multipart_encoding'));
 
 
 
 
 
 
 
23
  }
24
  add_action('admin_init', array($this, 'wpua_subscriber_capability'));
25
  }
32
  echo ' enctype="multipart/form-data"';
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * Give subscribers edit_posts capability
37
  * @since 1.8.3
includes/class-wp-user-avatar.php CHANGED
@@ -26,12 +26,22 @@ class WP_User_Avatar {
26
  // Add WPUA to profile for users with permission
27
  if($this->wpua_is_author_or_above() || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())) {
28
  // Profile functions and scripts
29
- add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
30
  add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
31
- add_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
32
  add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
33
  add_action('user_new_form', array($this, 'wpua_action_show_user_profile'));
34
  add_action('user_register', array($this, 'wpua_action_process_option_update'));
 
 
 
 
 
 
 
 
 
 
35
  // Admin scripts
36
  $pages = array('profile.php', 'options-discussion.php', 'user-edit.php', 'user-new.php');
37
  if(in_array($pagenow, $pages) || $wpua_admin->wpua_is_menu_page()) {
@@ -125,87 +135,102 @@ class WP_User_Avatar {
125
  }
126
  }
127
 
128
- /**
129
- * Add to edit user profile
130
- * @since 1.4
131
- * @param object $user
132
- * @uses int $blog_id
133
- * @uses object $current_user
134
- * @uses bool $show_avatars
135
- * @uses object $wpdb
136
- * @uses object $wp_user_avatar
137
- * @uses bool $wpua_allow_upload
138
- * @uses bool $wpua_edit_avatar
139
- * @uses object $wpua_functions
140
- * @uses string $wpua_upload_size_limit_with_units
141
- * @uses add_query_arg()
142
- * @uses admin_url()
143
- * @uses do_action()
144
- * @uses get_blog_prefix()
145
- * @uses get_user_meta()
146
- * @uses get_wp_user_avatar_src()
147
- * @uses has_wp_user_avatar()
148
- * @uses is_admin()
149
- * @uses wpua_author()
150
- * @uses wpua_get_avatar_original()
151
- * @uses wpua_is_author_or_above()
152
- */
153
- public static function wpua_action_show_user_profile($user) {
154
- global $blog_id, $current_user, $show_avatars, $wpdb, $wp_user_avatar, $wpua_allow_upload, $wpua_edit_avatar, $wpua_functions, $wpua_upload_size_limit_with_units;
155
-
156
- $has_wp_user_avatar = has_wp_user_avatar(@$user->ID);
157
- // Get WPUA attachment ID
158
- $wpua = get_user_meta(@$user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
159
- // Show remove button if WPUA is set
160
- $hide_remove = !$has_wp_user_avatar ? 'wpua-hide' : "";
161
- // Hide image tags if show avatars is off
162
- $hide_images = !$has_wp_user_avatar && (bool) $show_avatars == 0 ? 'wpua-no-avatars' : "";
163
- // If avatars are enabled, get original avatar image or show blank
164
- $avatar_medium_src = (bool) $show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original(@$user->user_email, 'medium') : includes_url().'images/blank.gif';
165
- // Check if user has wp_user_avatar, if not show image from above
166
- $avatar_medium = $has_wp_user_avatar ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
167
- // Check if user has wp_user_avatar, if not show image from above
168
- $avatar_thumbnail = $has_wp_user_avatar ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
169
- $edit_attachment_link = esc_url(add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')));
170
- // Chck if admin page
171
- $is_admin = is_admin() ? '_admin' : "";
172
- ?>
173
- <?php do_action('wpua_before_avatar'.$is_admin); ?>
174
- <input type="hidden" name="wp-user-avatar" id="<?php echo ($user=='add-new-user') ? 'wp-user-avatar' : 'wp-user-avatar-existing'?>" value="<?php echo $wpua; ?>" />
175
- <?php if($wp_user_avatar->wpua_is_author_or_above()) : // Button to launch Media Uploader ?>
176
-
177
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-add-button' : 'wpua-add-button-existing'?>"><button type="button" class="button" id="<?php echo ($user=='add-new-user') ? 'wpua-add' : 'wpua-add-existing'?>" name="<?php echo ($user=='add-new-user') ? 'wpua-add' : 'wpua-add-existing'?>" data-title="<?php _e('Choose Image','wp-user-avatar'); ?>: <?php echo ( ! empty( $user->display_name ) ? $user->display_name:''); ?>"><?php _e('Choose Image','wp-user-avatar'); ?></button></p>
178
 
179
- <?php elseif(!$wp_user_avatar->wpua_is_author_or_above()) : // Upload button ?>
180
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-upload-button' : 'wpua-upload-button-existing'?>">
181
- <input name="wpua-file" id="<?php echo ($user=='add-new-user') ? 'wpua-file' : 'wpua-file-existing'?>" type="file" />
182
- <button type="submit" class="button" id="<?php echo ($user=='add-new-user') ? 'wpua-upload' : 'wpua-upload-existing'?>" name="submit" value="<?php _e('Upload','wp-user-avatar'); ?>"><?php _e('Upload','wp-user-avatar'); ?></button>
183
- </p>
184
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-upload-messages' : 'wpua-upload-messages-existing'?>">
185
- <span id="<?php echo ($user=='add-new-user') ? 'wpua-max-upload' : 'wpua-max-upload-existing'?>" class="description"><?php printf(__('Maximum upload file size: %d%s.','wp-user-avatar'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?></span>
186
- <span id="<?php echo ($user=='add-new-user') ? 'wpua-allowed-files' : 'wpua-allowed-files-existing'?>" class="description"><?php _e('Allowed Files','wp-user-avatar'); ?>: <?php _e('<code>jpg jpeg png gif</code>','wp-user-avatar'); ?></span>
187
- </p>
 
 
 
 
188
  <?php endif; ?>
189
- <div id="<?php echo ($user=='add-new-user') ? 'wpua-images' : 'wpua-images-existing'?>" class="<?php echo $hide_images; ?>">
190
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-preview' : 'wpua-preview-existing'?>">
191
- <img src="<?php echo $avatar_medium; ?>" alt="" />
192
- <span class="description"><?php _e('Original Size','wp-user-avatar'); ?></span>
193
- </p>
194
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-thumbnail' : 'wpua-thumbnail-existing'?>">
195
- <img src="<?php echo $avatar_thumbnail; ?>" alt="" />
196
- <span class="description"><?php _e('Thumbnail','wp-user-avatar'); ?></span>
197
- </p>
198
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-remove-button' : 'wpua-remove-button-existing'?>" class="<?php echo $hide_remove; ?>">
199
- <button type="button" class="button" id="<?php echo ($user=='add-new-user') ? 'wpua-remove' : 'wpua-remove-existing'?>" name="wpua-remove"><?php _e('Remove Image','wp-user-avatar'); ?></button>
200
- <?php if((bool) $wpua_edit_avatar == 1 && !$wp_user_avatar->wpua_is_author_or_above() && has_wp_user_avatar($current_user->ID) && $wp_user_avatar->wpua_author($wpua, $current_user->ID)) : // Edit button ?>
201
- <span id="<?php echo ($user=='add-new-user') ? 'wpua-edit-attachment' : 'wpua-edit-attachment-existing'?>"><a href="<?php echo $edit_attachment_link; ?>" class="edit-attachment" target="_blank"><?php _e('Edit Image','wp-user-avatar'); ?></a></span>
202
- <?php endif; ?>
203
- </p>
204
- <p id="<?php echo ($user=='add-new-user') ? 'wpua-undo-button' : 'wpua-undo-button-existing'?>"><button type="button" class="button" id="<?php echo ($user=='add-new-user') ? 'wpua-undo' : 'wpua-undo-existing'?>" name="wpua-undo"><?php _e('Undo','wp-user-avatar'); ?></button></p>
205
- </div>
206
- <?php do_action('wpua_after_avatar'.$is_admin); ?>
207
- <?php
208
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
  /**
211
  * Add upload error messages
@@ -410,7 +435,7 @@ class WP_User_Avatar {
410
  }
411
  }
412
  }
413
-
414
  }
415
 
416
  /**
@@ -420,7 +445,7 @@ class WP_User_Avatar {
420
  * @param int $user_id
421
  * @param bool $wpua_author
422
  * @uses get_post()
423
- * @return bool
424
  */
425
  private function wpua_author($attachment_id, $user_id, $wpua_author=0) {
426
  $attachment = get_post($attachment_id);
26
  // Add WPUA to profile for users with permission
27
  if($this->wpua_is_author_or_above() || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())) {
28
  // Profile functions and scripts
29
+ //add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
30
  add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
31
+ //add_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
32
  add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
33
  add_action('user_new_form', array($this, 'wpua_action_show_user_profile'));
34
  add_action('user_register', array($this, 'wpua_action_process_option_update'));
35
+
36
+ add_filter('user_profile_picture_description', function ($description, $profileuser) {
37
+ ob_start();
38
+ echo '<style>.user-profile-picture > td > .avatar {display: none;}</style>';
39
+ self::wpua_core_show_user_profile($profileuser);
40
+
41
+ return ob_get_clean();
42
+
43
+ }, 10, 2);
44
+
45
  // Admin scripts
46
  $pages = array('profile.php', 'options-discussion.php', 'user-edit.php', 'user-new.php');
47
  if(in_array($pagenow, $pages) || $wpua_admin->wpua_is_menu_page()) {
135
  }
136
  }
137
 
138
+ public static function wpua_core_show_user_profile($user)
139
+ {
140
+ global $blog_id, $current_user, $show_avatars, $wpdb, $wp_user_avatar, $wpua_edit_avatar, $wpua_functions, $wpua_upload_size_limit_with_units;
141
+
142
+ $has_wp_user_avatar = has_wp_user_avatar(@$user->ID);
143
+ // Get WPUA attachment ID
144
+ $wpua = get_user_meta(@$user->ID, $wpdb->get_blog_prefix($blog_id) . 'user_avatar', true);
145
+ // Show remove button if WPUA is set
146
+ $hide_remove = ! $has_wp_user_avatar ? 'wpua-hide' : "";
147
+ // Hide image tags if show avatars is off
148
+ $hide_images = ! $has_wp_user_avatar && (bool)$show_avatars == 0 ? 'wpua-no-avatars' : "";
149
+ // If avatars are enabled, get original avatar image or show blank
150
+ $avatar_medium_src = (bool)$show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original(@$user->user_email, 'medium') : includes_url() . 'images/blank.gif';
151
+ // Check if user has wp_user_avatar, if not show image from above
152
+ $avatar_medium = $has_wp_user_avatar ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
153
+ // Check if user has wp_user_avatar, if not show image from above
154
+ $avatar_thumbnail = $has_wp_user_avatar ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
155
+ $edit_attachment_link = esc_url(add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')));
156
+ // Chck if admin page
157
+ ?>
158
+ <input type="hidden" name="wp-user-avatar" id="<?php echo ($user == 'add-new-user') ? 'wp-user-avatar' : 'wp-user-avatar-existing' ?>" value="<?php echo $wpua; ?>"/>
159
+ <?php if ($wp_user_avatar->wpua_is_author_or_above()) : // Button to launch Media Uploader ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-add-button' : 'wpua-add-button-existing' ?>">
162
+ <button type="button" class="button" id="<?php echo ($user == 'add-new-user') ? 'wpua-add' : 'wpua-add-existing' ?>" name="<?php echo ($user == 'add-new-user') ? 'wpua-add' : 'wpua-add-existing' ?>" data-title="<?php _e('Choose Image', 'wp-user-avatar'); ?>: <?php echo(! empty($user->display_name) ? $user->display_name : ''); ?>"><?php _e('Choose Image', 'wp-user-avatar'); ?></button>
163
+ </p>
164
+
165
+ <?php elseif ( ! $wp_user_avatar->wpua_is_author_or_above()) : // Upload button ?>
166
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-upload-button' : 'wpua-upload-button-existing' ?>">
167
+ <input name="wpua-file" id="<?php echo ($user == 'add-new-user') ? 'wpua-file' : 'wpua-file-existing' ?>" type="file"/>
168
+ <button type="submit" class="button" id="<?php echo ($user == 'add-new-user') ? 'wpua-upload' : 'wpua-upload-existing' ?>" name="submit" value="<?php _e('Upload', 'wp-user-avatar'); ?>"><?php _e('Upload', 'wp-user-avatar'); ?></button>
169
+ </p>
170
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-upload-messages' : 'wpua-upload-messages-existing' ?>">
171
+ <span id="<?php echo ($user == 'add-new-user') ? 'wpua-max-upload' : 'wpua-max-upload-existing' ?>" class="description"><?php printf(__('Maximum upload file size: %d%s.', 'wp-user-avatar'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?></span>
172
+ <span id="<?php echo ($user == 'add-new-user') ? 'wpua-allowed-files' : 'wpua-allowed-files-existing' ?>" class="description"><?php _e('Allowed Files', 'wp-user-avatar'); ?>: <?php _e('<code>jpg jpeg png gif</code>', 'wp-user-avatar'); ?></span>
173
+ </p>
174
  <?php endif; ?>
175
+ <div id="<?php echo ($user == 'add-new-user') ? 'wpua-images' : 'wpua-images-existing' ?>" class="<?php echo $hide_images; ?>">
176
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-preview' : 'wpua-preview-existing' ?>">
177
+ <img src="<?php echo $avatar_medium; ?>" alt=""/>
178
+ <span class="description"><?php _e('Original Size', 'wp-user-avatar'); ?></span>
179
+ </p>
180
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-thumbnail' : 'wpua-thumbnail-existing' ?>">
181
+ <img src="<?php echo $avatar_thumbnail; ?>" alt=""/>
182
+ <span class="description"><?php _e('Thumbnail', 'wp-user-avatar'); ?></span>
183
+ </p>
184
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-remove-button' : 'wpua-remove-button-existing' ?>" class="<?php echo $hide_remove; ?>">
185
+ <button type="button" class="button" id="<?php echo ($user == 'add-new-user') ? 'wpua-remove' : 'wpua-remove-existing' ?>" name="wpua-remove"><?php _e('Remove Image', 'wp-user-avatar'); ?></button>
186
+ <?php if ((bool)$wpua_edit_avatar == 1 && ! $wp_user_avatar->wpua_is_author_or_above() && has_wp_user_avatar($current_user->ID) && $wp_user_avatar->wpua_author($wpua, $current_user->ID)) : // Edit button ?>
187
+ <span id="<?php echo ($user == 'add-new-user') ? 'wpua-edit-attachment' : 'wpua-edit-attachment-existing' ?>"><a href="<?php echo $edit_attachment_link; ?>" class="edit-attachment" target="_blank"><?php _e('Edit Image', 'wp-user-avatar'); ?></a></span>
188
+ <?php endif; ?>
189
+ </p>
190
+ <p id="<?php echo ($user == 'add-new-user') ? 'wpua-undo-button' : 'wpua-undo-button-existing' ?>">
191
+ <button type="button" class="button" id="<?php echo ($user == 'add-new-user') ? 'wpua-undo' : 'wpua-undo-existing' ?>" name="wpua-undo"><?php _e('Undo', 'wp-user-avatar'); ?></button>
192
+ </p>
193
+ </div>
194
+ <?php
195
+ }
196
+
197
+ /**
198
+ * Add to edit user profile
199
+ *
200
+ * @param object $user
201
+ *
202
+ * @since 1.4
203
+ * @uses int $blog_id
204
+ * @uses object $current_user
205
+ * @uses bool $show_avatars
206
+ * @uses object $wpdb
207
+ * @uses object $wp_user_avatar
208
+ * @uses bool $wpua_edit_avatar
209
+ * @uses object $wpua_functions
210
+ * @uses string $wpua_upload_size_limit_with_units
211
+ * @uses add_query_arg()
212
+ * @uses admin_url()
213
+ * @uses do_action()
214
+ * @uses get_blog_prefix()
215
+ * @uses get_user_meta()
216
+ * @uses get_wp_user_avatar_src()
217
+ * @uses has_wp_user_avatar()
218
+ * @uses is_admin()
219
+ * @uses wpua_author()
220
+ * @uses wpua_get_avatar_original()
221
+ * @uses wpua_is_author_or_above()
222
+ */
223
+ public static function wpua_action_show_user_profile($user)
224
+ {
225
+ $is_admin = is_admin() ? '_admin' : "";
226
+
227
+ do_action('wpua_before_avatar' . $is_admin);
228
+
229
+ self::wpua_core_show_user_profile($user);
230
+
231
+ do_action('wpua_after_avatar' . $is_admin); ?>
232
+ <?php
233
+ }
234
 
235
  /**
236
  * Add upload error messages
435
  }
436
  }
437
  }
438
+
439
  }
440
 
441
  /**
445
  * @param int $user_id
446
  * @param bool $wpua_author
447
  * @uses get_post()
448
+ * @return bool
449
  */
450
  private function wpua_author($attachment_id, $user_id, $wpua_author=0) {
451
  $attachment = get_post($attachment_id);
includes/tinymce/window.php CHANGED
@@ -120,7 +120,7 @@ if(!defined('ABSPATH')) {
120
  <body id="link" class="wp-core-ui" onload="document.body.style.display='';" style="display:none;">
121
  <div id="wpua-tabs">
122
  <ul>
123
- <li><a href="#wpua"><?php _e('Avatar','wp-user-avatar'); ?></a></li>
124
  <li><a href="#wpua-upload"><?php _e('Upload','wp-user-avatar'); ?></a></li>
125
  </ul>
126
  <form name="wpUserAvatar" action="#">
120
  <body id="link" class="wp-core-ui" onload="document.body.style.display='';" style="display:none;">
121
  <div id="wpua-tabs">
122
  <ul>
123
+ <li><a href="#wpua"><?php _e('Profile Picture','wp-user-avatar'); ?></a></li>
124
  <li><a href="#wpua-upload"><?php _e('Upload','wp-user-avatar'); ?></a></li>
125
  </ul>
126
  <form name="wpUserAvatar" action="#">
includes/wpua-functions.php CHANGED
@@ -76,7 +76,7 @@ function wpua_after_avatar() {
76
  * @uses wpuf_has_shortcode()
77
  */
78
  function wpua_do_before_avatar() {
79
- $wpua_profile_title = '<h3>'.__('Avatar','wp-user-avatar').'</h3>';
80
  /**
81
  * Filter profile title
82
  * @since 1.9.4
@@ -85,12 +85,12 @@ function wpua_do_before_avatar() {
85
  $wpua_profile_title = apply_filters('wpua_profile_title', $wpua_profile_title);
86
  ?>
87
  <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
88
- <h2 class="entry-title"><?php _e('Avatar','wp-user-avatar'); ?></h2>
89
  <fieldset class="bbp-form">
90
  <legend><?php _e('Image','wp-user-avatar'); ?></legend>
91
  <?php elseif(class_exists('WPUF_Main') && wpuf_has_shortcode('wpuf_editprofile')) : // Add to WP User Frontend profile with same style ?>
92
  <fieldset>
93
- <legend><?php _e('Avatar','wp-user-avatar') ?></legend>
94
  <table class="wpuf-table">
95
  <tr>
96
  <th><label for="wp_user_avatar"><?php _e('Image','wp-user-avatar'); ?></label></th>
@@ -149,10 +149,9 @@ function wpua_after_avatar_admin() {
149
  */
150
  function wpua_do_before_avatar_admin() {
151
  ?>
152
- <h3><?php _e('Avatar') ?></h3>
153
  <table class="form-table">
154
  <tr>
155
- <th><label for="wp_user_avatar"><?php _e('Image','wp-user-avatar'); ?></label></th>
156
  <td>
157
  <?php
158
  }
76
  * @uses wpuf_has_shortcode()
77
  */
78
  function wpua_do_before_avatar() {
79
+ $wpua_profile_title = '<h3>'.__('Profile Picture','wp-user-avatar').'</h3>';
80
  /**
81
  * Filter profile title
82
  * @since 1.9.4
85
  $wpua_profile_title = apply_filters('wpua_profile_title', $wpua_profile_title);
86
  ?>
87
  <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
88
+ <h2 class="entry-title"><?php _e('Profile Picture','wp-user-avatar'); ?></h2>
89
  <fieldset class="bbp-form">
90
  <legend><?php _e('Image','wp-user-avatar'); ?></legend>
91
  <?php elseif(class_exists('WPUF_Main') && wpuf_has_shortcode('wpuf_editprofile')) : // Add to WP User Frontend profile with same style ?>
92
  <fieldset>
93
+ <legend><?php _e('Profile Picture','wp-user-avatar') ?></legend>
94
  <table class="wpuf-table">
95
  <tr>
96
  <th><label for="wp_user_avatar"><?php _e('Image','wp-user-avatar'); ?></label></th>
149
  */
150
  function wpua_do_before_avatar_admin() {
151
  ?>
 
152
  <table class="form-table">
153
  <tr>
154
+ <th><label for="wp_user_avatar"><?php _e('Profile Picture','wp-user-avatar'); ?></label></th>
155
  <td>
156
  <?php
157
  }
js/wp-user-avatar-user.js CHANGED
@@ -5,6 +5,7 @@ jQuery(function($) {
5
  var wpuaID = $('#wp-user-avatar').val();
6
  // Store WP User Avatar src
7
  var wpuaSrc = $('#wpua-preview').find('img').attr('src');
 
8
  // Remove WP User Avatar
9
  $('body').on('click', '#wpua-remove', function(e) {
10
  e.preventDefault();
5
  var wpuaID = $('#wp-user-avatar').val();
6
  // Store WP User Avatar src
7
  var wpuaSrc = $('#wpua-preview').find('img').attr('src');
8
+ $('#wpua-undo-button-existing').hide();
9
  // Remove WP User Avatar
10
  $('body').on('click', '#wpua-remove', function(e) {
11
  e.preventDefault();
js/wp-user-avatar.js CHANGED
@@ -99,6 +99,7 @@ jQuery(function($) {
99
  $('#your-profile').attr('enctype', 'multipart/form-data');
100
  var a = $('#wp-user-avatar-existing').val();
101
  var b = $('#wpua-preview-existing').find('img').attr('src');
 
102
  $('body').on('click', '#wpua-remove-existing', function(e) {
103
  e.preventDefault();
104
  $('#wpua-original-existing').remove();
99
  $('#your-profile').attr('enctype', 'multipart/form-data');
100
  var a = $('#wp-user-avatar-existing').val();
101
  var b = $('#wpua-preview-existing').find('img').attr('src');
102
+ $('#wpua-undo-button-existing').hide();
103
  $('body').on('click', '#wpua-remove-existing', function(e) {
104
  e.preventDefault();
105
  $('#wpua-original-existing').remove();
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: 2020-04-22 11:23+0100\n"
6
- "PO-Revision-Date: 2020-04-22 11:27+0100\n"
7
  "Last-Translator: ProfilePress <https://profilepress.net/>\n"
8
  "Language-Team: ProfilePress <https://profilepress.net/>\n"
9
  "Language: en_US\n"
@@ -67,7 +67,7 @@ msgid "Retro (Generated)"
67
  msgstr ""
68
 
69
  #: includes/class-wp-user-avatar-admin.php:267
70
- #: includes/class-wp-user-avatar.php:177
71
  msgid "Choose Image"
72
  msgstr ""
73
 
@@ -82,7 +82,7 @@ msgid "Remove"
82
  msgstr ""
83
 
84
  #: includes/class-wp-user-avatar-admin.php:268
85
- #: includes/class-wp-user-avatar.php:204
86
  msgid "Undo"
87
  msgstr ""
88
 
@@ -91,12 +91,14 @@ msgid "Support Forums"
91
  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: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
100
  msgid "Avatar"
101
  msgstr ""
102
 
@@ -171,10 +173,6 @@ msgstr ""
171
  msgid "Update Profile"
172
  msgstr ""
173
 
174
- #: includes/class-wp-user-avatar-subscriber.php:99
175
- msgid "You do not have sufficient permissions to access this page."
176
- msgstr ""
177
-
178
  #: includes/class-wp-user-avatar-widget.php:15
179
  msgid "Insert"
180
  msgstr ""
@@ -195,55 +193,75 @@ msgstr ""
195
  msgid "Automatically add paragraphs"
196
  msgstr ""
197
 
198
- #: includes/class-wp-user-avatar.php:182 includes/tinymce/window.php:124
199
  #: includes/tinymce/window.php:196
200
  msgid "Upload"
201
  msgstr ""
202
 
203
- #: includes/class-wp-user-avatar.php:185 includes/wpua-options-page.php:124
204
  #, php-format
205
  msgid "Maximum upload file size: %d%s."
206
  msgstr ""
207
 
208
- #: includes/class-wp-user-avatar.php:186
209
  msgid "Allowed Files"
210
  msgstr ""
211
 
212
- #: includes/class-wp-user-avatar.php:186
213
  msgid "<code>jpg jpeg png gif</code>"
214
  msgstr ""
215
 
216
- #: includes/class-wp-user-avatar.php:192 includes/tinymce/window.php:142
217
  msgid "Original Size"
218
  msgstr ""
219
 
220
- #: includes/class-wp-user-avatar.php:196 includes/tinymce/window.php:145
221
  msgid "Thumbnail"
222
  msgstr ""
223
 
224
- #: includes/class-wp-user-avatar.php:199
225
  msgid "Remove Image"
226
  msgstr ""
227
 
228
- #: includes/class-wp-user-avatar.php:201
229
  msgid "Edit Image"
230
  msgstr ""
231
 
232
- #: includes/class-wp-user-avatar.php:228
233
  msgid "This file is not an image. Please try another."
234
  msgstr ""
235
 
236
- #: includes/class-wp-user-avatar.php:232 includes/class-wp-user-avatar.php:258
237
  msgid "Memory exceeded. Please try another smaller file."
238
  msgstr ""
239
 
240
- #: includes/class-wp-user-avatar.php:236
241
  #, php-format
242
  msgid ""
243
  "Unable to create directory %s. Is its parent directory writable by the "
244
  "server?"
245
  msgstr ""
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  #: includes/tinymce/window.php:129
248
  msgid "User Name"
249
  msgstr ""
@@ -313,7 +331,6 @@ msgid "Insert into Post"
313
  msgstr ""
314
 
315
  #: includes/wpua-functions.php:90 includes/wpua-functions.php:96
316
- #: includes/wpua-functions.php:155
317
  msgid "Image"
318
  msgstr ""
319
 
2
  msgstr ""
3
  "Project-Id-Version: WP USER AVATAR\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2020-11-23 07:02+0100\n"
6
+ "PO-Revision-Date: 2020-11-23 07:02+0100\n"
7
  "Last-Translator: ProfilePress <https://profilepress.net/>\n"
8
  "Language-Team: ProfilePress <https://profilepress.net/>\n"
9
  "Language: en_US\n"
67
  msgstr ""
68
 
69
  #: includes/class-wp-user-avatar-admin.php:267
70
+ #: includes/class-wp-user-avatar.php:162
71
  msgid "Choose Image"
72
  msgstr ""
73
 
82
  msgstr ""
83
 
84
  #: includes/class-wp-user-avatar-admin.php:268
85
+ #: includes/class-wp-user-avatar.php:191
86
  msgid "Undo"
87
  msgstr ""
88
 
91
  msgstr ""
92
 
93
  #: includes/class-wp-user-avatar-admin.php:324
94
+ #: includes/class-wp-user-avatar-admin.php:378 includes/tinymce/window.php:123
95
+ #: includes/wpua-functions.php:79 includes/wpua-functions.php:88
96
+ #: includes/wpua-functions.php:93 includes/wpua-functions.php:154
97
+ msgid "Profile Picture"
98
+ msgstr ""
99
+
100
  #: includes/class-wp-user-avatar-functions.php:439
101
  #: includes/class-wp-user-avatar-functions.php:590
 
 
 
102
  msgid "Avatar"
103
  msgstr ""
104
 
173
  msgid "Update Profile"
174
  msgstr ""
175
 
 
 
 
 
176
  #: includes/class-wp-user-avatar-widget.php:15
177
  msgid "Insert"
178
  msgstr ""
193
  msgid "Automatically add paragraphs"
194
  msgstr ""
195
 
196
+ #: includes/class-wp-user-avatar.php:168 includes/tinymce/window.php:124
197
  #: includes/tinymce/window.php:196
198
  msgid "Upload"
199
  msgstr ""
200
 
201
+ #: includes/class-wp-user-avatar.php:171 includes/wpua-options-page.php:124
202
  #, php-format
203
  msgid "Maximum upload file size: %d%s."
204
  msgstr ""
205
 
206
+ #: includes/class-wp-user-avatar.php:172
207
  msgid "Allowed Files"
208
  msgstr ""
209
 
210
+ #: includes/class-wp-user-avatar.php:172
211
  msgid "<code>jpg jpeg png gif</code>"
212
  msgstr ""
213
 
214
+ #: includes/class-wp-user-avatar.php:178 includes/tinymce/window.php:142
215
  msgid "Original Size"
216
  msgstr ""
217
 
218
+ #: includes/class-wp-user-avatar.php:182 includes/tinymce/window.php:145
219
  msgid "Thumbnail"
220
  msgstr ""
221
 
222
+ #: includes/class-wp-user-avatar.php:185
223
  msgid "Remove Image"
224
  msgstr ""
225
 
226
+ #: includes/class-wp-user-avatar.php:187
227
  msgid "Edit Image"
228
  msgstr ""
229
 
230
+ #: includes/class-wp-user-avatar.php:253
231
  msgid "This file is not an image. Please try another."
232
  msgstr ""
233
 
234
+ #: includes/class-wp-user-avatar.php:257 includes/class-wp-user-avatar.php:283
235
  msgid "Memory exceeded. Please try another smaller file."
236
  msgstr ""
237
 
238
+ #: includes/class-wp-user-avatar.php:261
239
  #, php-format
240
  msgid ""
241
  "Unable to create directory %s. Is its parent directory writable by the "
242
  "server?"
243
  msgstr ""
244
 
245
+ #: includes/mo-notice.php:60
246
+ #, php-format
247
+ msgid ""
248
+ "Free optin form plugin that will increase revenue, %1$sincrease your email "
249
+ "subscribers%2$s and keep them engaged with %1$sautomated and schedule "
250
+ "newsletters%2$s."
251
+ msgstr ""
252
+
253
+ #: includes/mo-notice.php:69
254
+ msgid "Install MailOptin Now for Free!"
255
+ msgstr ""
256
+
257
+ #: includes/mo-notice.php:74
258
+ msgid "Activate MailOptin Now!"
259
+ msgstr ""
260
+
261
+ #: includes/mo-notice.php:83
262
+ msgid "Dismiss this notice"
263
+ msgstr ""
264
+
265
  #: includes/tinymce/window.php:129
266
  msgid "User Name"
267
  msgstr ""
331
  msgstr ""
332
 
333
  #: includes/wpua-functions.php:90 includes/wpua-functions.php:96
 
334
  msgid "Image"
335
  msgstr ""
336
 
readme.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: properfraction, collizo4sky
4
  Tags: user profile, avatar, gravatar, author image, author photo, author avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo, widget
5
  Requires at least: 4.0
6
- Tested up to: 5.5
7
- Stable tag: 2.2.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -370,6 +370,13 @@ This would output:
370
 
371
  == Changelog ==
372
 
 
 
 
 
 
 
 
373
  = 2.2.7 =
374
  * Removed target blank from dismiss url of admin notice
375
  * Code enhancements and improvements.
3
  Contributors: properfraction, collizo4sky
4
  Tags: user profile, avatar, gravatar, author image, author photo, author avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo, widget
5
  Requires at least: 4.0
6
+ Tested up to: 5.6
7
+ Stable tag: 2.2.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
370
 
371
  == Changelog ==
372
 
373
+ = 2.2.8 =
374
+ * Fixed: Notice: Object of class WP_User could not be converted.
375
+ * Replace core Profile Picture in profile edit screen with WP User Avatar.
376
+ * Replace 'Avatar' as a label with 'Profile Picture'.
377
+ * Removed dashboard access restriction feature.
378
+ * Fixed contextual button display showing undo button on page load.
379
+
380
  = 2.2.7 =
381
  * Removed target blank from dismiss url of admin notice
382
  * Code enhancements and improvements.
wp-user-avatar.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/plugins/wp-user-avatar/
5
  Description: Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.
6
  Author: ProfilePress
7
  Author URI: https://profilepress.net/
8
- Version: 2.2.7
9
  Text Domain: wp-user-avatar
10
  Domain Path: /lang/
11
  */
@@ -33,7 +33,7 @@ class WP_User_Avatar_Setup {
33
  * @since 1.9.2
34
  */
35
  private function _define_constants() {
36
- define('WPUA_VERSION', '2.2.7');
37
  define('WPUA_FOLDER', basename(dirname(__FILE__)));
38
  define('WPUA_DIR', plugin_dir_path(__FILE__));
39
  define('WPUA_INC', WPUA_DIR.'includes'.'/');
5
  Description: Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.
6
  Author: ProfilePress
7
  Author URI: https://profilepress.net/
8
+ Version: 2.2.8
9
  Text Domain: wp-user-avatar
10
  Domain Path: /lang/
11
  */
33
  * @since 1.9.2
34
  */
35
  private function _define_constants() {
36
+ define('WPUA_VERSION', '2.2.8');
37
  define('WPUA_FOLDER', basename(dirname(__FILE__)));
38
  define('WPUA_DIR', plugin_dir_path(__FILE__));
39
  define('WPUA_INC', WPUA_DIR.'includes'.'/');