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 1.9.13 to 2.2.2

css/wp-user-avatar.css CHANGED
@@ -1,11 +1,11 @@
1
#wpua-errors, #wpua-readable-size-error, .wpua-error { color: #c00 !important; font-weight: 700 !important; }
2
#wpua-readable-size-error, #wpua-undo-button { display: none; }
3
- #wpua-preview { margin-right: 10px; }
4
- #wpua-preview, #wpua-thumbnail { display: inline-block; text-align: center; vertical-align: top; }
5
- #wpua-preview img, #wpua-thumbnail img { max-height: 96px; border: 1px solid #dfdfdf; display: block; }
6
- .widget_wp_user_avatar #wpua-preview img, .widget_wp_user_avatar #wpua-thumbnail img { max-height: 64px; }
7
- .defaultavatarpicker #wpua-preview { width: 32px; height: 32px; margin-right: 0; display: inline-block; overflow: hidden; vertical-align: middle; }
8
- .defaultavatarpicker #wpua-preview img { width: 32px; height: auto; border: 0; }
9
#wpua-edit #wpua-remove, #wpua-edit #wpua-undo, #wpua-edit-attachment { margin-left: 10px !important; }
10
#wpua-slider { width: 22.75em; }
11
#wpua-upload-messages span { display: block; }
1
#wpua-errors, #wpua-readable-size-error, .wpua-error { color: #c00 !important; font-weight: 700 !important; }
2
#wpua-readable-size-error, #wpua-undo-button { display: none; }
3
+ #wpua-preview, #wpua-preview-existing { margin-right: 10px; }
4
+ #wpua-preview, #wpua-preview-existing, #wpua-thumbnail, #wpua-thumbnail-existing { display: inline-block; text-align: center; vertical-align: top; }
5
+ #wpua-preview img, #wpua-thumbnail img, #wpua-preview-existing img, #wpua-thumbnail-existing img { max-height: 96px; border: 1px solid #dfdfdf; display: block; }
6
+ .widget_wp_user_avatar #wpua-preview img, .widget_wp_user_avatar #wpua-thumbnail img, .widget_wp_user_avatar #wpua-preview-existing img, .widget_wp_user_avatar #wpua-thumbnail-existing img { max-height: 64px; }
7
+ .defaultavatarpicker #wpua-preview, .defaultavatarpicker #wpua-preview-existing { width: 32px; height: 32px; margin-right: 0; display: inline-block; overflow: hidden; vertical-align: middle; }
8
+ .defaultavatarpicker #wpua-preview img , .defaultavatarpicker #wpua-preview-existing img { width: 32px; height: auto; border: 0; }
9
#wpua-edit #wpua-remove, #wpua-edit #wpua-undo, #wpua-edit-attachment { margin-left: 10px !important; }
10
#wpua-slider { width: 22.75em; }
11
#wpua-upload-messages span { display: block; }
images/mailoptin-banner.png ADDED
Binary file
images/wp-user-avatar-banner.png ADDED
Binary file
includes/class-wp-user-avatar-admin.php CHANGED
@@ -24,7 +24,6 @@ class WP_User_Avatar_Admin {
24
// Settings saved to wp_options
25
add_action('admin_init', array($this, 'wpua_options'));
26
// Remove subscribers edit_posts capability
27
- register_deactivation_hook(WPUA_DIR.'wp-user-avatar.php', array($this, 'wpua_deactivate'));
28
// Translations
29
load_plugin_textdomain('wp-user-avatar', "", WPUA_FOLDER.'/lang');
30
// Admin menu settings
@@ -43,6 +42,7 @@ class WP_User_Avatar_Admin {
43
}
44
// Media states
45
add_filter('display_media_states', array($this, 'wpua_add_media_state'), 10, 1);
46
}
47
48
/**
@@ -51,6 +51,7 @@ class WP_User_Avatar_Admin {
51
* @uses add_option()
52
*/
53
public function wpua_options() {
54
add_option('avatar_default_wp_user_avatar', "");
55
add_option('wp_user_avatar_allow_upload', '0');
56
add_option('wp_user_avatar_disable_gravatar', '0');
@@ -60,7 +61,24 @@ class WP_User_Avatar_Admin {
60
add_option('wp_user_avatar_resize_upload', '0');
61
add_option('wp_user_avatar_resize_w', '96');
62
add_option('wp_user_avatar_tinymce', '1');
63
- add_option('wp_user_avatar_upload_size_limit', '0');
64
}
65
66
/**
@@ -82,6 +100,7 @@ class WP_User_Avatar_Admin {
82
update_option($wp_user_roles, $user_roles);
83
// Reset all default avatars to Mystery Man
84
update_option('avatar_default', 'mystery');
85
}
86
87
/**
@@ -91,9 +110,9 @@ class WP_User_Avatar_Admin {
91
* @uses add_submenu_page()
92
*/
93
public function wpua_admin() {
94
- add_menu_page(__('WP User Avatar', 'wp-user-avatar'), __('Avatars'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'), WPUA_URL.'images/wpua-icon.png');
95
- add_submenu_page('wp-user-avatar', __('Settings'), __('Settings'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'));
96
- $hook = add_submenu_page('wp-user-avatar', __('Library'), __('Library'), 'manage_options', 'wp-user-avatar-library', array($this, 'wpua_media_page'));
97
add_action("load-$hook", array($this, 'wpua_media_screen_option'));
98
add_filter('set-screen-option', array($this, 'wpua_set_media_screen_option'), 10, 3);
99
}
@@ -126,7 +145,7 @@ class WP_User_Avatar_Admin {
126
public function wpua_media_screen_option() {
127
$option = 'per_page';
128
$args = array(
129
- 'label' => __('Avatars'),
130
'default' => 10,
131
'option' => 'upload_per_page'
132
);
@@ -207,13 +226,13 @@ class WP_User_Avatar_Admin {
207
$avatar_list = "";
208
// Set avatar defaults
209
$avatar_defaults = array(
210
- 'mystery' => __('Mystery Man'),
211
- 'blank' => __('Blank'),
212
- 'gravatar_default' => __('Gravatar Logo'),
213
- 'identicon' => __('Identicon (Generated)'),
214
- 'wavatar' => __('Wavatar (Generated)'),
215
- 'monsterid' => __('MonsterID (Generated)'),
216
- 'retro' => __('Retro (Generated)')
217
);
218
// No Default Avatar, set to Mystery Man
219
if(empty($avatar_default)) {
@@ -245,14 +264,14 @@ class WP_User_Avatar_Admin {
245
$wpua_list = "\n\t<label><input type='radio' name='avatar_default' id='wp_user_avatar_radio' value='wp_user_avatar'$selected_avatar /> ";
246
$wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
247
$wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
248
- $wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add" data-avatar_default="true" data-title="'._('Choose Image').': '._('Default Avatar').'">'.__('Choose Image').'</button>';
249
- $wpua_list .= '<span id="wpua-remove-button"'.$hide_remove.'><a href="#" id="wpua-remove">'.__('Remove').'</a></span><span id="wpua-undo-button"><a href="#" id="wpua-undo">'.__('Undo').'</a></span></p>';
250
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
251
$wpua_list .= '<div id="wpua-modal"></div>';
252
if((bool) $wpua_disable_gravatar != 1) {
253
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
254
} else {
255
- return $wpua_list;
256
}
257
}
258
@@ -276,7 +295,7 @@ class WP_User_Avatar_Admin {
276
*/
277
public function wpua_action_links($links, $file) {
278
if(basename(dirname($file)) == 'wp-user-avatar') {
279
- $links[] = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('admin.php')).'">'.__('Settings').'</a>';
280
}
281
return $links;
282
}
@@ -290,8 +309,7 @@ class WP_User_Avatar_Admin {
290
*/
291
public function wpua_row_meta($links, $file) {
292
if(basename(dirname($file)) == 'wp-user-avatar') {
293
- $links[] = '<a href="http://wordpress.org/support/plugin/wp-user-avatar" target="_blank">'.__('Support Forums').'</a>';
294
- $links[] = '<a href="http://siboliban.org/donate" target="_blank">'.__('Donate', 'wp-user-avatar').'</a>';
295
}
296
return $links;
297
}
@@ -303,7 +321,7 @@ class WP_User_Avatar_Admin {
303
* @return array
304
*/
305
public function wpua_add_column($columns) {
306
- return $columns + array('wp-user-avatar' => __('Avatar'));
307
}
308
309
/**
@@ -357,10 +375,10 @@ class WP_User_Avatar_Admin {
357
global $post, $wpua_avatar_default;
358
$is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
359
if(!empty($is_wpua)) {
360
- $states[] = __('Avatar');
361
}
362
if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)) {
363
- $states[] = __('Default Avatar');
364
}
365
/**
366
* Filter media states
@@ -369,6 +387,7 @@ class WP_User_Avatar_Admin {
369
*/
370
return apply_filters('wpua_add_media_state', $states);
371
}
372
}
373
374
/**
24
// Settings saved to wp_options
25
add_action('admin_init', array($this, 'wpua_options'));
26
// Remove subscribers edit_posts capability
27
// Translations
28
load_plugin_textdomain('wp-user-avatar', "", WPUA_FOLDER.'/lang');
29
// Admin menu settings
42
}
43
// Media states
44
add_filter('display_media_states', array($this, 'wpua_add_media_state'), 10, 1);
45
+
46
}
47
48
/**
51
* @uses add_option()
52
*/
53
public function wpua_options() {
54
+
55
add_option('avatar_default_wp_user_avatar', "");
56
add_option('wp_user_avatar_allow_upload', '0');
57
add_option('wp_user_avatar_disable_gravatar', '0');
61
add_option('wp_user_avatar_resize_upload', '0');
62
add_option('wp_user_avatar_resize_w', '96');
63
add_option('wp_user_avatar_tinymce', '1');
64
+ add_option('wp_user_avatar_upload_size_limit', '0');
65
+
66
+ if(wp_next_scheduled( 'wpua_has_gravatar_cron_hook' )){
67
+ $cron=get_option('cron');
68
+ $new_cron='';
69
+ foreach($cron as $key=>$value)
70
+ {
71
+ if(is_array($value))
72
+ {
73
+ if(array_key_exists('wpua_has_gravatar_cron_hook',$value))
74
+ unset($cron[$key]);
75
+ }
76
+ }
77
+ update_option('cron',$cron);
78
+ }
79
+
80
+
81
+
82
}
83
84
/**
100
update_option($wp_user_roles, $user_roles);
101
// Reset all default avatars to Mystery Man
102
update_option('avatar_default', 'mystery');
103
+
104
}
105
106
/**
110
* @uses add_submenu_page()
111
*/
112
public function wpua_admin() {
113
+ add_menu_page(__('WP User Avatar', 'wp-user-avatar'), __('Avatars', 'wp-user-avatar'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'), WPUA_URL.'images/wpua-icon.png');
114
+ add_submenu_page('wp-user-avatar', __('Settings' , 'wp-user-avatar'), __('Settings' , 'wp-user-avatar'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'));
115
+ $hook = add_submenu_page('wp-user-avatar', __('Library','wp-user-avatar'), __('Library', 'wp-user-avatar'), 'manage_options', 'wp-user-avatar-library', array($this, 'wpua_media_page'));
116
add_action("load-$hook", array($this, 'wpua_media_screen_option'));
117
add_filter('set-screen-option', array($this, 'wpua_set_media_screen_option'), 10, 3);
118
}
145
public function wpua_media_screen_option() {
146
$option = 'per_page';
147
$args = array(
148
+ 'label' => __('Avatars','wp-user-avatar'),
149
'default' => 10,
150
'option' => 'upload_per_page'
151
);
226
$avatar_list = "";
227
// Set avatar defaults
228
$avatar_defaults = array(
229
+ 'mystery' => __('Mystery Man','wp-user-avatar'),
230
+ 'blank' => __('Blank','wp-user-avatar'),
231
+ 'gravatar_default' => __('Gravatar Logo','wp-user-avatar'),
232
+ 'identicon' => __('Identicon (Generated)','wp-user-avatar'),
233
+ 'wavatar' => __('Wavatar (Generated)','wp-user-avatar'),
234
+ 'monsterid' => __('MonsterID (Generated)','wp-user-avatar'),
235
+ 'retro' => __('Retro (Generated)','wp-user-avatar')
236
);
237
// No Default Avatar, set to Mystery Man
238
if(empty($avatar_default)) {
264
$wpua_list = "\n\t<label><input type='radio' name='avatar_default' id='wp_user_avatar_radio' value='wp_user_avatar'$selected_avatar /> ";
265
$wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
266
$wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
267
+ $wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add" data-avatar_default="true" data-title="'.__('Choose Image').': '.__('Default Avatar').'">'.__('Choose Image','wp-user-avatar').'</button>';
268
+ $wpua_list .= '<span id="wpua-remove-button"'.$hide_remove.'><a href="#" id="wpua-remove">'.__('Remove','wp-user-avatar').'</a></span><span id="wpua-undo-button"><a href="#" id="wpua-undo">'.__('Undo','wp-user-avatar').'</a></span></p>';
269
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
270
$wpua_list .= '<div id="wpua-modal"></div>';
271
if((bool) $wpua_disable_gravatar != 1) {
272
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
273
} else {
274
+ return $wpua_list.'<div id="wp-avatars" style="display:none;">'.$avatar_list.'</div>';
275
}
276
}
277
295
*/
296
public function wpua_action_links($links, $file) {
297
if(basename(dirname($file)) == 'wp-user-avatar') {
298
+ $links[] = '<a href="'.esc_url(add_query_arg(array('page' => 'wp-user-avatar'), admin_url('admin.php'))).'">'.__('Settings','wp-user-avatar').'</a>';
299
}
300
return $links;
301
}
309
*/
310
public function wpua_row_meta($links, $file) {
311
if(basename(dirname($file)) == 'wp-user-avatar') {
312
+ $links[] = '<a href="http://wordpress.org/support/plugin/wp-user-avatar" target="_blank">'.__('Support Forums','wp-user-avatar').'</a>';
313
}
314
return $links;
315
}
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
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');
382
}
383
/**
384
* Filter media states
387
*/
388
return apply_filters('wpua_add_media_state', $states);
389
}
390
+
391
}
392
393
/**
includes/class-wp-user-avatar-functions.php CHANGED
@@ -11,11 +11,149 @@ class WP_User_Avatar_Functions {
11
* Constructor
12
* @since 1.8
13
* @uses add_filter()
14
*/
15
public function __construct() {
16
add_filter('get_avatar', array($this, 'wpua_get_avatar_filter'), 10, 5);
17
}
18
19
/**
20
* Returns true if user has Gravatar-hosted image
21
* @since 1.4
@@ -31,25 +169,101 @@ class WP_User_Avatar_Functions {
31
* @return bool $has_gravatar
32
*/
33
public function wpua_has_gravatar($id_or_email="", $has_gravatar=0, $user="", $email="") {
34
if(!is_object($id_or_email) && !empty($id_or_email)) {
35
// Find user by ID or e-mail address
36
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
37
// Get registered user e-mail address
38
$email = !empty($user) ? $user->user_email : "";
39
}
40
- // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
41
- $hash = md5(strtolower(trim($email)));
42
- $gravatar = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
43
- $data = wp_cache_get($hash);
44
- if(false === $data) {
45
- $response = wp_remote_head($gravatar);
46
- $data = is_wp_error($response) ? 'not200' : $response['response']['code'];
47
- wp_cache_set($hash, $data, $group="", $expire=60*5);
48
}
49
- $has_gravatar = ($data == '200') ? true : false;
50
return (bool) $has_gravatar;
51
}
52
53
/**
54
* Check if local image
55
* @since 1.9.2
@@ -136,19 +350,58 @@ class WP_User_Avatar_Functions {
136
* @return bool
137
*/
138
public function has_wp_user_avatar($id_or_email="", $has_wpua=0, $user="", $user_id="") {
139
- global $blog_id, $wpdb, $wpua_avatar_default, $wpua_functions;
140
if(!is_object($id_or_email) && !empty($id_or_email)) {
141
// Find user by ID or e-mail address
142
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
143
// Get registered user ID
144
- $user_id = !empty($user) ? $user->ID : "";
145
}
146
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
147
// Check if avatar is same as default avatar or on excluded list
148
- $has_wpua = !empty($wpua) && ($wpua != $wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua) ? true : false;
149
return (bool) $has_wpua;
150
}
151
152
/**
153
* Replace get_avatar only in get_wp_user_avatar
154
* @since 1.4
@@ -177,12 +430,21 @@ class WP_User_Avatar_Functions {
177
* @return string $avatar
178
*/
179
public function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt="") {
180
global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
181
// User has WPUA
182
if(is_object($id_or_email)) {
183
if(!empty($id_or_email->comment_author_email)) {
184
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
185
} else {
186
$avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
187
}
188
} else {
@@ -190,36 +452,27 @@ class WP_User_Avatar_Functions {
190
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
191
// User has Gravatar and Gravatar is not disabled
192
} elseif((bool) $wpua_disable_gravatar != 1 && $wpua_functions->wpua_has_gravatar($id_or_email)) {
193
- $avatar = $avatar;
194
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
195
} elseif($avatar_default == 'wp_user_avatar') {
196
- // Show custom Default Avatar
197
- if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
198
- // Get image
199
- $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
200
- // Image src
201
- $default = $wpua_avatar_default_image[0];
202
- // Add dimensions if numeric size
203
- $dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
204
- } else {
205
- // Get mustache image based on numeric size comparison
206
- if($size > get_option('medium_size_w')) {
207
- $default = $mustache_original;
208
- } elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')) {
209
- $default = $mustache_medium;
210
- } elseif($size <= get_option('thumbnail_size_w') && $size > 96) {
211
- $default = $mustache_thumbnail;
212
- } elseif($size <= 96 && $size > 32) {
213
- $default = $mustache_avatar;
214
- } elseif($size <= 32) {
215
- $default = $mustache_admin;
216
- }
217
- // Add dimensions if numeric size
218
- $dimensions = ' width="'.$size.'" height="'.$size.'"';
219
- }
220
- // Construct the img tag
221
- $avatar = '<img src="'.$default.'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.' photo avatar-default" />';
222
- }
223
}
224
/**
225
* Filter get_avatar filter
@@ -263,7 +516,10 @@ class WP_User_Avatar_Functions {
263
if(!$wpua_functions->wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar') {
264
// Show custom Default Avatar
265
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
266
- $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
267
$default = $wpua_avatar_default_image[0];
268
} else {
269
$default = $mustache_avatar;
@@ -277,7 +533,10 @@ class WP_User_Avatar_Functions {
277
}
278
} else {
279
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
280
- $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
281
$default = $wpua_avatar_default_image[0];
282
} else {
283
$default = $mustache_avatar;
@@ -293,6 +552,7 @@ class WP_User_Avatar_Functions {
293
return apply_filters('wpua_get_avatar_original', $default);
294
}
295
296
/**
297
* Find WPUA, show get_avatar if empty
298
* @since 1.0
@@ -323,7 +583,12 @@ class WP_User_Avatar_Functions {
323
public function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt="") {
324
global $all_sizes, $avatar_default, $blog_id, $post, $wpdb, $wpua_avatar_default, $wpua_functions, $_wp_additional_image_sizes;
325
$email='unknown@gravatar.com';
326
- // Checks if comment
327
if(is_object($id_or_email)) {
328
// Checks if comment author is registered user by user ID
329
if($id_or_email->user_id != 0) {
@@ -391,7 +656,7 @@ class WP_User_Avatar_Functions {
391
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
392
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
393
}
394
- $replace = array('wp-user-avatar ', 'wp-user-avatar-'.$get_size.' ', 'wp-user-avatar-'.$size.' ', 'avatar-'.$get_size, 'photo');
395
$replacements = array("", "", "", 'avatar-'.$size, 'wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo');
396
$avatar = str_replace($replace, $replacements, $avatar);
397
}
11
* Constructor
12
* @since 1.8
13
* @uses add_filter()
14
+ * @uses register_activation_hook()
15
+ * @uses register_deactivation_hook()
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
118
+ * @param string $avatar
119
+ * @param array $params
120
+ * @param int $item_id
121
+ * @param string $avatar_dir
122
+ * @param string $css_id
123
+ * @param int $html_width
124
+ * @param int $html_height
125
+ * @param string $avatar_folder_url
126
+ * @param string $avatar_folder_dir
127
+ * @uses object $wpua_functions
128
+ * @uses wpua_get_avatar_filter()
129
+ */
130
+ public function wpua_bp_core_fetch_avatar_filter($gravatar,$params,$item_id='', $avatar_dir='', $css_id='', $html_width='', $html_height='', $avatar_folder_url='', $avatar_folder_dir=''){
131
+ global $wpua_functions;
132
+ if(strpos($gravatar,'gravatar.com',0)>-1){
133
+ $avatar = $wpua_functions->wpua_get_avatar_filter($gravatar, ($params['object']=='user') ? $params['item_id'] : '', ($params['object']=='user') ? (($params['type']=='thumb') ? 50 :150) : 50, '', '');
134
+ return $avatar;
135
+ }
136
+ else
137
+ return $gravatar;
138
+ }
139
+
140
+ /**
141
+ * Returns WP user default local avatar URL or Gravatar-hosted image URL if user doesn't have Buddypress-uploaded image
142
+ * @param string $avatar
143
+ * @param array $params
144
+ * @uses object $wpua_functions
145
+ * @uses wpua_get_avatar_filter()
146
+ */
147
+ public function wpua_bp_core_fetch_avatar_url_filter($gravatar,$params){
148
+ global $wpua_functions;
149
+ if(strpos($gravatar,'gravatar.com',0)>-1){
150
+ $avatar = $wpua_functions->wpua_get_avatar_filter($gravatar, ($params['object']=='user') ? $params['item_id'] : '', ($params['object']=='user') ? (($params['type']=='thumb') ? 50 :150) : 50, '', '');
151
+ return $avatar;
152
+ }
153
+ else
154
+ return $gravatar;
155
+ }
156
+
157
/**
158
* Returns true if user has Gravatar-hosted image
159
* @since 1.4
169
* @return bool $has_gravatar
170
*/
171
public function wpua_has_gravatar($id_or_email="", $has_gravatar=0, $user="", $email="") {
172
+ global $wpua_hash_gravatar,$avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
173
+ // User has WPUA
174
+ //Decide if check gravatar required or not.
175
+ if(trim($avatar_default)!='wp_user_avatar')
176
+ return true;
177
+
178
if(!is_object($id_or_email) && !empty($id_or_email)) {
179
// Find user by ID or e-mail address
180
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
181
// Get registered user e-mail address
182
$email = !empty($user) ? $user->user_email : "";
183
}
184
+
185
+ if($email == ""){
186
+
187
+ if(!is_numeric($id_or_email) and !is_object($id_or_email))
188
+ $email = $id_or_email;
189
+ elseif(!is_numeric($id_or_email) and is_object($id_or_email))
190
+ $email = $id_or_email->comment_author_email;
191
}
192
+ if($email!="")
193
+ {
194
+ $hash = md5(strtolower(trim($email)));
195
+ //check if gravatar exists for hashtag using options
196
+
197
+ if(is_array($wpua_hash_gravatar)){
198
+
199
+
200
+ if ( array_key_exists($hash, $wpua_hash_gravatar) and is_array($wpua_hash_gravatar[$hash]) and array_key_exists(date('m-d-Y'), $wpua_hash_gravatar[$hash]) )
201
+ {
202
+ return (bool) $wpua_hash_gravatar[$hash][date('m-d-Y')];
203
+ }
204
+
205
+ }
206
+
207
+ //end
208
+ if ( isset( $_SERVER['HTTPS'] ) && ( 'on' == $_SERVER['HTTPS'] || 1 == $_SERVER['HTTPS'] ) || isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
209
+ $http='https';
210
+ }else{
211
+ $http='http';
212
+ }
213
+ $gravatar = $http.'://www.gravatar.com/avatar/'.$hash.'?d=404';
214
+
215
+ $data = wp_cache_get($hash);
216
+
217
+ if(false === $data) {
218
+ $response = wp_remote_head($gravatar);
219
+ $data = is_wp_error($response) ? 'not200' : $response['response']['code'];
220
+
221
+ wp_cache_set($hash, $data, $group="", $expire=60*5);
222
+ //here set if hashtag has avatar
223
+ $has_gravatar = ($data == '200') ? true : false;
224
+ if($wpua_hash_gravatar == false){
225
+ $wpua_hash_gravatar[$hash][date('m-d-Y')] = (bool)$has_gravatar;
226
+ add_option('wpua_hash_gravatar',serialize($wpua_hash_gravatar));
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
+ }
256
+ $has_gravatar = ($data == '200') ? true : false;
257
+
258
+ }
259
+ else
260
+ $has_gravatar = false;
261
+
262
+ // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
263
return (bool) $has_gravatar;
264
}
265
266
+
267
/**
268
* Check if local image
269
* @since 1.9.2
350
* @return bool
351
*/
352
public function has_wp_user_avatar($id_or_email="", $has_wpua=0, $user="", $user_id="") {
353
+ global $blog_id, $wpdb, $wpua_avatar_default, $wpua_functions, $avatar_default;
354
if(!is_object($id_or_email) && !empty($id_or_email)) {
355
// Find user by ID or e-mail address
356
+
357
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
358
// Get registered user ID
359
+ $user_id = !empty($user) ? $user->ID : "";
360
}
361
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
362
// Check if avatar is same as default avatar or on excluded list
363
+ $has_wpua = !empty($wpua) && ($avatar_default!='wp_user_avatar' or $wpua != $wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua) ? true : false;
364
return (bool) $has_wpua;
365
}
366
+ /**
367
+ Retrive default image url set by admin.
368
+ */
369
+ public function wpua_default_image($size)
370
+ {
371
+ global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
372
+
373
+ $default_image_details = array();
374
+ // Show custom Default Avatar
375
+ if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
376
+ // Get image
377
+ $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
378
+ // Image src
379
+ $default = $wpua_avatar_default_image[0];
380
+ // Add dimensions if numeric size
381
+ $default_image_details['dimensions'] = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
382
+
383
+ } else {
384
+ // Get mustache image based on numeric size comparison
385
+ if($size > get_option('medium_size_w')) {
386
+ $default = $mustache_original;
387
+ } elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')) {
388
+ $default = $mustache_medium;
389
+ } elseif($size <= get_option('thumbnail_size_w') && $size > 96) {
390
+ $default = $mustache_thumbnail;
391
+ } elseif($size <= 96 && $size > 32) {
392
+ $default = $mustache_avatar;
393
+ } elseif($size <= 32) {
394
+ $default = $mustache_admin;
395
+ }
396
+ // Add dimensions if numeric size
397
+ $default_image_details['dimensions'] = ' width="'.$size.'" height="'.$size.'"';
398
+ }
399
+ // Construct the img tag
400
+ $default_image_details['size'] = $size;
401
+ $default_image_details['src'] = $default;
402
+ return $default_image_details;
403
404
+ }
405
/**
406
* Replace get_avatar only in get_wp_user_avatar
407
* @since 1.4
430
* @return string $avatar
431
*/
432
public function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt="") {
433
+
434
global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
435
// User has WPUA
436
+
437
+ if( $alt == '' ) {
438
+ $alt = apply_filters('wpua_default_alt_tag',__("Avatar",'wp-user-avatar'));
439
+ }
440
+
441
+
442
+ $avatar = str_replace('gravatar_default','',$avatar);
443
if(is_object($id_or_email)) {
444
if(!empty($id_or_email->comment_author_email)) {
445
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
446
} else {
447
+
448
$avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
449
}
450
} else {
452
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
453
// User has Gravatar and Gravatar is not disabled
454
} elseif((bool) $wpua_disable_gravatar != 1 && $wpua_functions->wpua_has_gravatar($id_or_email)) {
455
+ // find our src
456
+ if(!empty($avatar)) {
457
+ $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $avatar, $matches, PREG_SET_ORDER);
458
+ $wpua_avatar_image_src = !empty($matches) ? $matches [0] [1] : "";
459
+ $default_image_details = $this->wpua_default_image($size);
460
+ $wpua_default_avatar_image_src = $default_image_details['src'];
461
+ $wpua_final_avatar_image_src = str_replace('d=wp_user_avatar', 'd='.urlencode($wpua_default_avatar_image_src), $wpua_avatar_image_src);
462
+ }
463
+
464
+ //$avatar = $avatar;
465
+ $avatar = '<img src="'.$wpua_final_avatar_image_src.'"'.$default_image_details['dimensions'].' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.' photo avatar-default" />';
466
+
467
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
468
} elseif($avatar_default == 'wp_user_avatar') {
469
+
470
+ $default_image_details = $this->wpua_default_image($size);
471
+ $avatar = '<img src="'.$default_image_details['src'].'"'.$default_image_details['dimensions'].' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.' photo avatar-default" />';
472
+
473
+ return $avatar;
474
+
475
+ }
476
}
477
/**
478
* Filter get_avatar filter
516
if(!$wpua_functions->wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar') {
517
// Show custom Default Avatar
518
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
519
+ // $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
520
+ $size_numeric_w_x_h = array( get_option( $size . '_size_w' ), get_option( $size . '_size_h' ) );
521
+ $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, $size_numeric_w_x_h);
522
+
523
$default = $wpua_avatar_default_image[0];
524
} else {
525
$default = $mustache_avatar;
533
}
534
} else {
535
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
536
+ // $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
537
+ $size_numeric_w_x_h = array( get_option( $size . '_size_w' ), get_option( $size . '_size_h' ) );
538
+ $wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, $size_numeric_w_x_h);
539
+
540
$default = $wpua_avatar_default_image[0];
541
} else {
542
$default = $mustache_avatar;
552
return apply_filters('wpua_get_avatar_original', $default);
553
}
554
555
+
556
/**
557
* Find WPUA, show get_avatar if empty
558
* @since 1.0
583
public function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt="") {
584
global $all_sizes, $avatar_default, $blog_id, $post, $wpdb, $wpua_avatar_default, $wpua_functions, $_wp_additional_image_sizes;
585
$email='unknown@gravatar.com';
586
+ // Checks if comment
587
+
588
+ if( $alt == '' ) {
589
+ $alt = apply_filters('wpua_default_alt_tag',__("Avatar",'wp-user-avatar'));
590
+ }
591
+
592
if(is_object($id_or_email)) {
593
// Checks if comment author is registered user by user ID
594
if($id_or_email->user_id != 0) {
656
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
657
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
658
}
659
+ $replace = array('wp-user-avatar ', 'wp-user-avatar-'.$get_size.' ', 'wp-user-avatar-'.$size.' ', 'avatar-'.$get_size, ' photo');
660
$replacements = array("", "", "", 'avatar-'.$size, 'wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo');
661
$avatar = str_replace($replace, $replacements, $avatar);
662
}
includes/class-wp-user-avatar-list-table.php CHANGED
@@ -139,7 +139,7 @@ class WP_User_Avatar_List_Table extends WP_List_Table {
139
*/
140
public function get_bulk_actions() {
141
$actions = array();
142
- $actions['delete'] = __('Delete Permanently');
143
return $actions;
144
}
145
@@ -168,7 +168,7 @@ class WP_User_Avatar_List_Table extends WP_List_Table {
168
* @since 1.8
169
*/
170
public function no_items() {
171
- _e('No media attachments found.');
172
}
173
174
/**
@@ -181,7 +181,7 @@ class WP_User_Avatar_List_Table extends WP_List_Table {
181
$columns['cb'] = '<input type="checkbox" />';
182
$columns['icon'] = "";
183
$columns['title'] = _x('File', 'column name');
184
- $columns['author'] = __('Author');
185
$columns['parent'] = _x('Uploaded to', 'column name');
186
$columns['date'] = _x('Date', 'column name');
187
return $columns;
@@ -250,7 +250,7 @@ class WP_User_Avatar_List_Table extends WP_List_Table {
250
?>
251
<th scope="row" class="check-column">
252
<?php if($user_can_edit) { ?>
253
- <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php echo sprintf(__('Select %s'), $att_title);?></label>
254
<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
255
<?php } ?>
256
</th>
@@ -310,17 +310,17 @@ class WP_User_Avatar_List_Table extends WP_List_Table {
310
break;
311
case 'date':
312
if('0000-00-00 00:00:00' == $post->post_date) {
313
- $h_time = __('Unpublished');
314
} else {
315
$m_time = $post->post_date;
316
$time = get_post_time('G', true, $post, false);
317
if ((abs($t_diff = time() - $time)) < DAY_IN_SECONDS) {
318
if ($t_diff < 0)
319
- $h_time = sprintf(__('%s from now'), human_time_diff($time));
320
else
321
- $h_time = sprintf(__('%s ago'), human_time_diff($time));
322
} else {
323
- $h_time = mysql2date(__('Y/m/d'), $m_time);
324
}
325
}
326
?>
@@ -378,22 +378,22 @@ class WP_User_Avatar_List_Table extends WP_List_Table {
378
public function _get_row_actions($post, $att_title) {
379
$actions = array();
380
if(current_user_can('edit_post', $post->ID) && !$this->is_trash) {
381
- $actions['edit'] = '<a href="'.get_edit_post_link($post->ID, true).'">'.__('Edit').'</a>';
382
}
383
if(current_user_can('delete_post', $post->ID)) {
384
if($this->is_trash) {
385
- $actions['untrash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_'.$post->ID)."'>".__('Restore')."</a>";
386
} elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
387
- $actions['trash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_'.$post->ID)."'>".__('Trash')."</a>";
388
}
389
if($this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH) {
390
$delete_ays = (!$this->is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : "";
391
- $actions['delete'] = "<a class='submitdelete'$delete_ays href='".wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_'.$post->ID)."'>".__('Delete Permanently')."</a>";
392
}
393
}
394
if(!$this->is_trash) {
395
$title = _draft_or_post_title($post->post_parent);
396
- $actions['view'] = '<a href="'.get_permalink($post->ID).'" title="'.esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)).'" rel="permalink">'.__('View').'</a>';
397
}
398
return $actions;
399
}
139
*/
140
public function get_bulk_actions() {
141
$actions = array();
142
+ $actions['delete'] = __('Delete Permanently','wp-user-avatar');
143
return $actions;
144
}
145
168
* @since 1.8
169
*/
170
public function no_items() {
171
+ _e('No media attachments found.','wp-user-avatar');
172
}
173
174
/**
181
$columns['cb'] = '<input type="checkbox" />';
182
$columns['icon'] = "";
183
$columns['title'] = _x('File', 'column name');
184
+ $columns['author'] = __('Author','wp-user-avatar');
185
$columns['parent'] = _x('Uploaded to', 'column name');
186
$columns['date'] = _x('Date', 'column name');
187
return $columns;
250
?>
251
<th scope="row" class="check-column">
252
<?php if($user_can_edit) { ?>
253
+ <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php echo sprintf(__('Select %s','wp-user-avatar'), $att_title);?></label>
254
<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
255
<?php } ?>
256
</th>
310
break;
311
case 'date':
312
if('0000-00-00 00:00:00' == $post->post_date) {
313
+ $h_time = __('Unpublished','wp-user-avatar');
314
} else {
315
$m_time = $post->post_date;
316
$time = get_post_time('G', true, $post, false);
317
if ((abs($t_diff = time() - $time)) < DAY_IN_SECONDS) {
318
if ($t_diff < 0)
319
+ $h_time = sprintf(__('%s from now','wp-user-avatar'), human_time_diff($time));
320
else
321
+ $h_time = sprintf(__('%s ago','wp-user-avatar'), human_time_diff($time));
322
} else {
323
+ $h_time = mysql2date(__('Y/m/d','wp-user-avatar'), $m_time);
324
}
325
}
326
?>
378
public function _get_row_actions($post, $att_title) {
379
$actions = array();
380
if(current_user_can('edit_post', $post->ID) && !$this->is_trash) {
381
+ $actions['edit'] = '<a href="'.get_edit_post_link($post->ID, true).'">'.__('Edit','wp-user-avatar').'</a>';
382
}
383
if(current_user_can('delete_post', $post->ID)) {
384
if($this->is_trash) {
385
+ $actions['untrash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_'.$post->ID)."'>".__('Restore','wp-user-avatar')."</a>";
386
} elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
387
+ $actions['trash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_'.$post->ID)."'>".__('Trash','wp-user-avatar')."</a>";
388
}
389
if($this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH) {
390
$delete_ays = (!$this->is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : "";
391
+ $actions['delete'] = "<a class='submitdelete'$delete_ays href='".wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_'.$post->ID)."'>".__('Delete Permanently','wp-user-avatar')."</a>";
392
}
393
}
394
if(!$this->is_trash) {
395
$title = _draft_or_post_title($post->post_parent);
396
+ $actions['view'] = '<a href="'.get_permalink($post->ID).'" title="'.esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)).'" rel="permalink">'.__('View','wp-user-avatar').'</a>';
397
}
398
return $actions;
399
}
includes/class-wp-user-avatar-shortcode.php CHANGED
@@ -57,9 +57,13 @@ class WP_User_Avatar_Shortcode {
57
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
58
// Find user by ID, login, slug, or e-mail address
59
if(!empty($user)) {
60
- $user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
61
- $user = empty($user) ? get_user_by('slug', $user) : $user;
62
- $user = empty($user) ? get_user_by('email', $user) : $user;
63
} else {
64
// Find author's name if id_or_email is empty
65
$author_name = get_query_var('author_name');
@@ -146,7 +150,7 @@ class WP_User_Avatar_Shortcode {
146
}
147
if($update) {
148
// Redirect with updated variable
149
- $redirect_url = add_query_arg(array('updated' => '1'), wp_get_referer());
150
/**
151
* Filter redirect URL
152
* @since 1.9.12
@@ -200,7 +204,7 @@ class WP_User_Avatar_Shortcode {
200
// Show form only for valid user
201
if($valid_user) {
202
// Save
203
- if(isset($_POST['submit']) && $_POST['submit'] && $_POST['action'] == 'update') {
204
do_action('wpua_update', $valid_user->ID);
205
// Check for errors
206
$errors = $this->wpua_edit_user($valid_user->ID);
@@ -209,7 +213,7 @@ class WP_User_Avatar_Shortcode {
209
if(isset($errors) && is_wp_error($errors)) {
210
echo '<div class="error"><p>'.implode("</p>\n<p>", $errors->get_error_messages()).'</p></div>';
211
} elseif(isset($_GET['updated']) && $_GET['updated'] == '1') {
212
- echo '<div class="updated"><p><strong>'.__('Profile updated.').'</strong></p></div>';
213
}
214
// Edit form
215
return $this->wpua_edit_form($valid_user);
@@ -230,10 +234,10 @@ class WP_User_Avatar_Shortcode {
230
?>
231
<form id="wpua-edit-<?php echo $user->ID; ?>" class="wpua-edit" action="" method="post" enctype="multipart/form-data">
232
<?php do_action('wpua_show_profile', $user); ?>
233
- <input type="hidden" name="action" value="update" />
234
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user->ID); ?>" />
235
<?php wp_nonce_field('update-user_'.$user->ID); ?>
236
- <?php submit_button(__('Update Profile')); ?>
237
</form>
238
<?php
239
return ob_get_clean();
57
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
58
// Find user by ID, login, slug, or e-mail address
59
if(!empty($user)) {
60
+ if( $user == 'current' ) {
61
+ $user = wp_get_current_user();
62
+ }else{
63
+ $user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
64
+ $user = empty($user) ? get_user_by('slug', $user) : $user;
65
+ $user = empty($user) ? get_user_by('email', $user) : $user;
66
+ }
67
} else {
68
// Find author's name if id_or_email is empty
69
$author_name = get_query_var('author_name');
150
}
151
if($update) {
152
// Redirect with updated variable
153
+ $redirect_url = esc_url_raw(add_query_arg(array('updated' => '1'), wp_get_referer()));
154
/**
155
* Filter redirect URL
156
* @since 1.9.12
204
// Show form only for valid user
205
if($valid_user) {
206
// Save
207
+ if(isset($_POST['submit']) && $_POST['submit'] && $_POST['wpua_action'] == 'update') {
208
do_action('wpua_update', $valid_user->ID);
209
// Check for errors
210
$errors = $this->wpua_edit_user($valid_user->ID);
213
if(isset($errors) && is_wp_error($errors)) {
214
echo '<div class="error"><p>'.implode("</p>\n<p>", $errors->get_error_messages()).'</p></div>';
215
} elseif(isset($_GET['updated']) && $_GET['updated'] == '1') {
216
+ echo '<div class="updated"><p><strong>'.__('Profile updated.','wp-user-avatar').'</strong></p></div>';
217
}
218
// Edit form
219
return $this->wpua_edit_form($valid_user);
234
?>
235
<form id="wpua-edit-<?php echo $user->ID; ?>" class="wpua-edit" action="" method="post" enctype="multipart/form-data">
236
<?php do_action('wpua_show_profile', $user); ?>
237
+ <input type="hidden" name="wpua_action" value="update" />
238
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user->ID); ?>" />
239
<?php wp_nonce_field('update-user_'.$user->ID); ?>
240
+ <?php submit_button(__('Update Profile','wp-user-avatar')); ?>
241
</form>
242
<?php
243
return ob_get_clean();
includes/class-wp-user-avatar-subscriber.php CHANGED
@@ -96,7 +96,7 @@ class WP_User_Avatar_Subscriber {
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.'));
100
}
101
}
102
@@ -118,7 +118,9 @@ class WP_User_Avatar_Subscriber {
118
if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1) {
119
$user_roles['subscriber']['capabilities']['edit_posts'] = true;
120
} else {
121
- unset($user_roles['subscriber']['capabilities']['edit_posts']);
122
}
123
update_option($wp_user_roles, $user_roles);
124
}
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
118
if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1) {
119
$user_roles['subscriber']['capabilities']['edit_posts'] = true;
120
} else {
121
+ if(isset($user_roles['subscriber']['capabilities']['edit_posts'])){
122
+ unset($user_roles['subscriber']['capabilities']['edit_posts']);
123
+ }
124
}
125
update_option($wp_user_roles, $user_roles);
126
}
includes/class-wp-user-avatar-widget.php CHANGED
@@ -69,16 +69,16 @@ class WP_User_Avatar_Profile_Widget extends WP_Widget {
69
?>
70
<p>
71
<label for="<?php echo $this->get_field_id('title'); ?>">
72
- <?php _e('Title:'); ?>
73
</label>
74
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
75
</p>
76
- <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Description:'); ?></label>
77
<textarea class="widefat" rows="3" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
78
<p>
79
<input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />
80
<label for="<?php echo $this->get_field_id('filter'); ?>">
81
- <?php _e('Automatically add paragraphs'); ?>
82
</label>
83
</p>
84
<?php
69
?>
70
<p>
71
<label for="<?php echo $this->get_field_id('title'); ?>">
72
+ <?php _e('Title:','wp-user-avatar'); ?>
73
</label>
74
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
75
</p>
76
+ <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Description:','wp-user-avatar'); ?></label>
77
<textarea class="widefat" rows="3" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
78
<p>
79
<input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />
80
<label for="<?php echo $this->get_field_id('filter'); ?>">
81
+ <?php _e('Automatically add paragraphs','wp-user-avatar'); ?>
82
</label>
83
</p>
84
<?php
includes/class-wp-user-avatar.php CHANGED
@@ -152,52 +152,56 @@ class WP_User_Avatar {
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
// Get WPUA attachment ID
156
- $wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
157
// Show remove button if WPUA is set
158
- $hide_remove = !has_wp_user_avatar($user->ID) ? 'wpua-hide' : "";
159
// Hide image tags if show avatars is off
160
- $hide_images = !has_wp_user_avatar($user->ID) && (bool) $show_avatars == 0 ? 'wpua-no-avatars' : "";
161
// If avatars are enabled, get original avatar image or show blank
162
- $avatar_medium_src = (bool) $show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original($user->user_email, 'medium') : includes_url().'images/blank.gif';
163
// Check if user has wp_user_avatar, if not show image from above
164
- $avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
165
// Check if user has wp_user_avatar, if not show image from above
166
- $avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
167
- $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php'));
168
// Chck if admin page
169
$is_admin = is_admin() ? '_admin' : "";
170
?>
171
<?php do_action('wpua_before_avatar'.$is_admin); ?>
172
- <input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
173
<?php if($wp_user_avatar->wpua_is_author_or_above()) : // Button to launch Media Uploader ?>
174
- <p id="wpua-add-button"><button type="button" class="button" id="wpua-add" name="wpua-add" data-title="<?php _e('Choose Image'); ?>: <?php echo $user->display_name; ?>"><?php _e('Choose Image'); ?></button></p>
175
<?php elseif(!$wp_user_avatar->wpua_is_author_or_above()) : // Upload button ?>
176
- <p id="wpua-upload-button">
177
- <input name="wpua-file" id="wpua-file" type="file" />
178
- <button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
179
</p>
180
- <p id="wpua-upload-messages">
181
- <span id="wpua-max-upload" class="description"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?></span>
182
- <span id="wpua-allowed-files" class="description"><?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?></span>
183
</p>
184
<?php endif; ?>
185
- <div id="wpua-images" class="<?php echo $hide_images; ?>">
186
- <p id="wpua-preview">
187
<img src="<?php echo $avatar_medium; ?>" alt="" />
188
- <span class="description"><?php _e('Original Size'); ?></span>
189
</p>
190
- <p id="wpua-thumbnail">
191
<img src="<?php echo $avatar_thumbnail; ?>" alt="" />
192
- <span class="description"><?php _e('Thumbnail'); ?></span>
193
</p>
194
- <p id="wpua-remove-button" class="<?php echo $hide_remove; ?>">
195
- <button type="button" class="button" id="wpua-remove" name="wpua-remove"><?php _e('Remove Image'); ?></button>
196
<?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 ?>
197
- <span id="wpua-edit-attachment"><a href="<?php echo $edit_attachment_link; ?>" class="edit-attachment" target="_blank"><?php _e('Edit Image'); ?></a></span>
198
<?php endif; ?>
199
</p>
200
- <p id="wpua-undo-button"><button type="button" class="button" id="wpua-undo" name="wpua-undo"><?php _e('Undo'); ?></button></p>
201
</div>
202
<?php do_action('wpua_after_avatar'.$is_admin); ?>
203
<?php
@@ -221,15 +225,15 @@ class WP_User_Avatar {
221
$upload_dir = wp_upload_dir();
222
// Allow only JPG, GIF, PNG
223
if(!empty($type) && !preg_match('/(jpe?g|gif|png)#x2F;i', $type)) {
224
- $errors->add('wpua_file_type', __('This file is not an image. Please try another.'));
225
}
226
// Upload size limit
227
if(!empty($size) && $size > $wpua_upload_size_limit) {
228
- $errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.'));
229
}
230
// Check if directory is writeable
231
if(!is_writeable($upload_dir['path'])) {
232
- $errors->add('wpua_file_directory', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $upload_dir['path']));
233
}
234
}
235
}
@@ -251,7 +255,7 @@ class WP_User_Avatar {
251
* @since 1.7
252
*/
253
function wpua_file_size_error($errors, $update, $user) {
254
- $errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.'));
255
}
256
add_action('user_profile_update_errors', 'wpua_file_size_error', 10, 3);
257
return;
@@ -288,9 +292,11 @@ class WP_User_Avatar {
288
* @uses wp_update_attachment_metadata()
289
* @uses wp_upload_dir()
290
* @uses wpua_is_author_or_above()
291
*/
292
public static function wpua_action_process_option_update($user_id) {
293
- global $blog_id, $post, $wpdb, $wp_user_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w;
294
// Check if user has publish_posts capability
295
if($wp_user_avatar->wpua_is_author_or_above()) {
296
$wpua_id = isset($_POST['wp-user-avatar']) ? strip_tags($_POST['wp-user-avatar']) : "";
@@ -404,6 +410,7 @@ class WP_User_Avatar {
404
}
405
}
406
}
407
}
408
409
/**
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
225
$upload_dir = wp_upload_dir();
226
// Allow only JPG, GIF, PNG
227
if(!empty($type) && !preg_match('/(jpe?g|gif|png)#x2F;i', $type)) {
228
+ $errors->add('wpua_file_type', __('This file is not an image. Please try another.','wp-user-avatar'));
229
}
230
// Upload size limit
231
if(!empty($size) && $size > $wpua_upload_size_limit) {
232
+ $errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.','wp-user-avatar'));
233
}
234
// Check if directory is writeable
235
if(!is_writeable($upload_dir['path'])) {
236
+ $errors->add('wpua_file_directory', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?','wp-user-avatar'), $upload_dir['path']));
237
}
238
}
239
}
255
* @since 1.7
256
*/
257
function wpua_file_size_error($errors, $update, $user) {
258
+ $errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.','wp-user-avatar'));
259
}
260
add_action('user_profile_update_errors', 'wpua_file_size_error', 10, 3);
261
return;
292
* @uses wp_update_attachment_metadata()
293
* @uses wp_upload_dir()
294
* @uses wpua_is_author_or_above()
295
+ * @uses object $wpua_admin
296
+ * @uses wpua_has_gravatar()
297
*/
298
public static function wpua_action_process_option_update($user_id) {
299
+ global $blog_id, $post, $wpdb, $wp_user_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w, $wpua_admin;
300
// Check if user has publish_posts capability
301
if($wp_user_avatar->wpua_is_author_or_above()) {
302
$wpua_id = isset($_POST['wp-user-avatar']) ? strip_tags($_POST['wp-user-avatar']) : "";
410
}
411
}
412
}
413
+
414
}
415
416
/**
includes/tinymce/window.php CHANGED
@@ -1,202 +1,207 @@
1
- <?php
2
- /**
3
- * TinyMCE modal window.
4
- *
5
- * @package WP User Avatar
6
- * @version 1.9.13
7
- */
8
-
9
- /**
10
- * @since 1.2.1
11
- * @uses get_users()
12
- */
13
-
14
- if(!defined('ABSPATH')) {
15
- die('You are not allowed to call this page directly.');
16
- }
17
- ?>
18
- <!DOCTYPE html>
19
- <html>
20
- <head>
21
- <title><?php _e('WP User Avatar', 'wp-user-avatar'); ?></title>
22
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
23
- <base target="_self" />
24
- <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/jquery.js"></script>
25
- <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.core.min.js"></script>
26
- <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.widget.min.js"></script>
27
- <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js"></script>
28
- <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
29
- <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
30
- <script type="text/javascript">
31
- function wpuaInsertAvatar() {
32
- // Custom shortcode values
33
- var shortcode,
34
- closing_tag,
35
- user = document.getElementById('wp_user_avatar_user').value,
36
- size = document.getElementById('wp_user_avatar_size').value,
37
- size_number = document.getElementById('wp_user_avatar_size_number').value,
38
- align = document.getElementById('wp_user_avatar_align').value,
39
- link = document.getElementById('wp_user_avatar_link').value,
40
- link_external = document.getElementById('wp_user_avatar_link_external').value,
41
- target = document.getElementById('wp_user_avatar_target').value,
42
- caption = document.getElementById('wp_user_avatar_caption').value;
43
-
44
- // Add tag to shortcode only if not blank
45
- var user_tag = (user != "") ? ' user="' + user + '"' : "";
46
- var size_tag = (size != "" && size_number == "") ? ' size="' + size + '"' : "";
47
- size_tag = (size_number != "") ? ' size="' + size_number + '"' : size_tag;
48
- var align_tag = (align != "") ? ' align="' + align + '"' : "";
49
- var link_tag = (link != "" && link != 'custom-url' && link_external == "") ? ' link="' + link + '"' : "";
50
- link_tag = (link_external != "") ? ' link="' + link_external + '"' : link_tag;
51
- var target_tag = document.getElementById('wp_user_avatar_target').checked && (link_tag != "") ? ' target="' + target + '"' : "";
52
-
53
- // Assemble the shortcode
54
- closing_tag = (caption != "") ? "]" + caption + "[/avatar]" : " /]";
55
- shortcode = "<p>[avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + closing_tag + "</p>";
56
-
57
- // Insert into Visual Editor
58
- if(window.tinyMCE) {
59
- var tmce_ver = window.tinyMCE.majorVersion;
60
- if(tmce_ver >= "4") {
61
- window.tinyMCE.execCommand('mceInsertContent', false, shortcode);
62
- } else {
63
- window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
64
- }
65
- tinyMCEPopup.editor.execCommand('mceRepaint');
66
- tinyMCEPopup.close();
67
- }
68
- return;
69
- }
70
- function wpuaInsertAvatarUpload() {
71
- // Upload shortcode
72
- var shortcode = "<p>[avatar_upload /]</p>";
73
-
74
- // Insert into Visual Editor
75
- if(window.tinyMCE) {
76
- var tmce_ver = window.tinyMCE.majorVersion;
77
- if(tmce_ver >= "4") {
78
- window.tinyMCE.execCommand('mceInsertContent', false, shortcode);
79
- } else {
80
- window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
81
- }
82
- tinyMCEPopup.editor.execCommand('mceRepaint');
83
- tinyMCEPopup.close();
84
- }
85
- return;
86
- }
87
-
88
- jQuery(function($) {
89
- // Show link input
90
- $('#wp_user_avatar_link').change(function() {
91
- $('#wp_user_avatar_link_external_section').toggle($('#wp_user_avatar_link').val() == 'custom-url');
92
- });
93
- // Show size input
94
- $('#wp_user_avatar_size').change(function() {
95
- $('#wp_user_avatar_size_number_section').toggle($('#wp_user_avatar_size').val() == 'custom');
96
- });
97
- // Tabs
98
- $('#wpua-tabs').tabs();
99
- });
100
- </script>
101
- <style type="text/css">
102
- ul { margin: 0; padding: 0; list-style: none; }
103
- ul li { float: left; }
104
- ul li a { float: left; padding: 2px 5px; background: #ddd; border: 1px solid #eee; border-bottom: 0; display: block; font-weight: 700; outline: none; text-decoration: none; }
105
- ul li.ui-tabs-active a { background: #fff; }
106
- form { clear: both; background: #fff; border: 1px solid #eee; }
107
- p, h4 { margin: 0; padding: 12px 0 0; }
108
- h4.center { text-align: center; }
109
- label { width: 150px; margin-right: 3px; display: inline-block; text-align: right; vertical-align: top; }
110
- .mceActionPanel { padding: 7px 0 12px; text-align: center; }
111
- .mceActionPanel #insert { float: none; width: 180px; margin: 0 auto; }
112
- #wp_user_avatar_size_number_section, #wp_user_avatar_link_external_section { display: none; }
113
- </style>
114
- </head>
115
- <body id="link" class="wp-core-ui" onload="document.body.style.display='';" style="display:none;">
116
- <div id="wpua-tabs">
117
- <ul>
118
- <li><a href="#wpua"><?php _e('Avatar'); ?></a></li>
119
- <li><a href="#wpua-upload"><?php _e('Upload'); ?></a></li>
120
- </ul>
121
- <form name="wpUserAvatar" action="#">
122
- <div id="wpua">
123
- <p>
124
- <label for="<?php esc_attr_e('wp_user_avatar_user'); ?>"><strong><?php _e('User Name'); ?>:</strong></label>
125
- <select id="<?php esc_attr_e('wp_user_avatar_user'); ?>" name="<?php esc_attr_e('wp_user_avatar_user'); ?>">
126
- <option value=""></option>
127
- <?php $users = get_users(); foreach($users as $user) : ?>
128
- <option value="<?php echo $user->user_login; ?>"><?php echo $user->display_name; ?></option>
129
- <?php endforeach; ?>
130
- </select>
131
- </p>
132
-
133
- <p>
134
- <label for="<?php esc_attr_e('wp_user_avatar_size'); ?>"><strong><?php _e('Size'); ?>:</strong></label>
135
- <select id="<?php esc_attr_e('wp_user_avatar_size'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>">
136
- <option value=""></option>
137
- <option value="original"><?php _e('Original Size'); ?></option>
138
- <option value="large"><?php _e('Large'); ?></option>
139
- <option value="medium"><?php _e('Medium'); ?></option>
140
- <option value="thumbnail"><?php _e('Thumbnail'); ?></option>
141
- <option value="custom"><?php _e('Custom'); ?></option>
142
- </select>
143
- </p>
144
-
145
- <p id="<?php esc_attr_e('wp_user_avatar_size_number_section'); ?>">
146
- <label for="<?php esc_attr_e('wp_user_avatar_size_number'); ?>"><?php _e('Size'); ?>:</label>
147
- <input type="text" size="8" id="<?php esc_attr_e('wp_user_avatar_size_number'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>" value="" />
148
- </p>
149
-
150
- <p>
151
- <label for="<?php esc_attr_e('wp_user_avatar_align'); ?>"><strong><?php _e('Alignment'); ?>:</strong></label>
152
- <select id="<?php esc_attr_e('wp_user_avatar_align'); ?>" name="<?php esc_attr_e('wp_user_avatar_align'); ?>">
153
- <option value=""></option>
154
- <option value="center"><?php _e('Center'); ?></option>
155
- <option value="left"><?php _e('Left'); ?></option>
156
- <option value="right"><?php _e('Right'); ?></option>
157
- </select>
158
- </p>
159
-
160
- <p>
161
- <label for="<?php esc_attr_e('wp_user_avatar_link'); ?>"><strong><?php _e('Link To'); ?>:</strong></label>
162
- <select id="<?php esc_attr_e('wp_user_avatar_link'); ?>" name="<?php esc_attr_e('wp_user_avatar_link'); ?>">
163
- <option value=""></option>
164
- <option value="file"><?php _e('Image File'); ?></option>
165
- <option value="attachment"><?php _e('Attachment Page'); ?></option>
166
- <option value="custom-url"><?php _e('Custom URL'); ?></option>
167
- </select>
168
- </p>
169
-
170
- <p id="<?php esc_attr_e('wp_user_avatar_link_external_section'); ?>">
171
- <label for="<?php esc_attr_e('wp_user_avatar_link_external'); ?>"><?php _e('URL'); ?>:</label>
172
- <input type="text" size="36" id="<?php esc_attr_e('wp_user_avatar_link_external'); ?>" name="<?php esc_attr_e('wp_user_avatar_link_external'); ?>" value="" />
173
- </p>
174
-
175
- <p>
176
- <label for="<?php esc_attr_e('wp_user_avatar_target'); ?>"></label>
177
- <input type="checkbox" id="<?php esc_attr_e('wp_user_avatar_target'); ?>" name="<?php esc_attr_e('wp_user_avatar_target'); ?>" value="_blank" /> <strong><?php _e('Open link in a new window'); ?></strong>
178
- </p>
179
-
180
- <p>
181
- <label for="<?php esc_attr_e('wp_user_avatar_caption'); ?>"><strong><?php _e('Caption'); ?>:</strong></label>
182
- <textarea cols="36" rows="2" id="<?php esc_attr_e('wp_user_avatar_caption'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>"></textarea>
183
- </p>
184
-
185
- <div class="mceActionPanel">
186
- <input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatar();" />
187
- </div>
188
- </div>
189
- <div id="wpua-upload">
190
- <p id="<?php esc_attr_e('wp_user_avatar_upload'); ?>">
191
- <label for="<?php esc_attr_e('wp_user_avatar_upload'); ?>"><strong><?php _e('Upload'); ?>:</strong></label>
192
- <input type="text" size="36" id="<?php esc_attr_e('wp_user_avatar_upload'); ?>" name="<?php esc_attr_e('wp_user_avatar_upload'); ?>" value="<?php esc_attr_e('[avatar_upload]'); ?>" readonly="readonly" />
193
- </p>
194
-
195
- <div class="mceActionPanel">
196
- <input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatarUpload();" />
197
- </div>
198
- </div>
199
- </form>
200
- </div>
201
- </body>
202
- </html>
1
+ <?php
2
+ /**
3
+ * TinyMCE modal window.
4
+ *
5
+ * @package WP User Avatar
6
+ * @version 1.9.13
7
+ */
8
+
9
+ /**
10
+ * @since 1.2.1
11
+ * @uses get_users()
12
+ */
13
+
14
+ if(!defined('ABSPATH')) {
15
+ die('You are not allowed to call this page directly.');
16
+ }
17
+ ?>
18
+ <!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <title><?php _e('WP User Avatar', 'wp-user-avatar'); ?></title>
22
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
23
+ <base target="_self" />
24
+ <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/jquery.js"></script>
25
+ <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
26
+ <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
27
+ <script type="text/javascript">
28
+ function wpuaInsertAvatar() {
29
+ // Custom shortcode values
30
+ var shortcode,
31
+ closing_tag,
32
+ user = document.getElementById('wp_user_avatar_user').value,
33
+ size = document.getElementById('wp_user_avatar_size').value,
34
+ size_number = document.getElementById('wp_user_avatar_size_number').value,
35
+ align = document.getElementById('wp_user_avatar_align').value,
36
+ link = document.getElementById('wp_user_avatar_link').value,
37
+ link_external = document.getElementById('wp_user_avatar_link_external').value,
38
+ target = document.getElementById('wp_user_avatar_target').value,
39
+ caption = document.getElementById('wp_user_avatar_caption').value;
40
+
41
+ // Add tag to shortcode only if not blank
42
+ var user_tag = (user != "") ? ' user="' + user + '"' : "";
43
+ var size_tag = (size != "" && size_number == "") ? ' size="' + size + '"' : "";
44
+ size_tag = (size_number != "") ? ' size="' + size_number + '"' : size_tag;
45
+ var align_tag = (align != "") ? ' align="' + align + '"' : "";
46
+ var link_tag = (link != "" && link != 'custom-url' && link_external == "") ? ' link="' + link + '"' : "";
47
+ link_tag = (link_external != "") ? ' link="' + link_external + '"' : link_tag;
48
+ var target_tag = document.getElementById('wp_user_avatar_target').checked && (link_tag != "") ? ' target="' + target + '"' : "";
49
+
50
+ // Assemble the shortcode
51
+ closing_tag = (caption != "") ? "]" + caption + "[/avatar]" : " /]";
52
+ shortcode = "<p>[avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + closing_tag + "</p>";
53
+
54
+ // Insert into Visual Editor
55
+ if(window.tinyMCE) {
56
+ var tmce_ver = window.tinyMCE.majorVersion;
57
+ if(tmce_ver >= "4") {
58
+ window.tinyMCE.execCommand('mceInsertContent', false, shortcode);
59
+ } else {
60
+ window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
61
+ }
62
+ tinyMCEPopup.editor.execCommand('mceRepaint');
63
+ tinyMCEPopup.close();
64
+ }
65
+ return;
66
+ }
67
+ function wpuaInsertAvatarUpload() {
68
+ // Upload shortcode
69
+ var shortcode = "<p>[avatar_upload /]</p>";
70
+
71
+ // Insert into Visual Editor
72
+ if(window.tinyMCE) {
73
+ var tmce_ver = window.tinyMCE.majorVersion;
74
+ if(tmce_ver >= "4") {
75
+ window.tinyMCE.execCommand('mceInsertContent', false, shortcode);
76
+ } else {
77
+ window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
78
+ }
79
+ tinyMCEPopup.editor.execCommand('mceRepaint');
80
+ tinyMCEPopup.close();
81
+ }
82
+ return;
83
+ }
84
+
85
+ jQuery(function($) {
86
+ // Show link input
87
+ $('#wp_user_avatar_link').change(function() {
88
+ $('#wp_user_avatar_link_external_section').toggle($('#wp_user_avatar_link').val() == 'custom-url');
89
+ });
90
+ // Show size input
91
+ $('#wp_user_avatar_size').change(function() {
92
+ $('#wp_user_avatar_size_number_section').toggle($('#wp_user_avatar_size').val() == 'custom');
93
+ });
94
+
95
+ $("#wpua-tabs li a").click(function(){
96
+ tab_id = $(this).attr('href');
97
+ if( tab_id == '#wpua')
98
+ $("#wpua-upload").hide();
99
+ else
100
+ $('#wpua').hide();
101
+ $(tab_id).show();
102
+ })
103
+ // Tabs
104
+ });
105
+ </script>
106
+ <style type="text/css">
107
+ ul { margin: 0; padding: 0; list-style: none; }
108
+ ul li { float: left; }
109
+ ul li a { float: left; padding: 2px 5px; background: #ddd; border: 1px solid #eee; border-bottom: 0; display: block; font-weight: 700; outline: none; text-decoration: none; }
110
+ ul li.ui-tabs-active a { background: #fff; }
111
+ form { clear: both; background: #fff; border: 1px solid #eee; }
112
+ p, h4 { margin: 0; padding: 12px 0 0; }
113
+ h4.center { text-align: center; }
114
+ label { width: 150px; margin-right: 3px; display: inline-block; text-align: right; vertical-align: top; }
115
+ .mceActionPanel { padding: 7px 0 12px; text-align: center; }
116
+ .mceActionPanel #insert { float: none; width: 180px; margin: 0 auto; }
117
+ #wp_user_avatar_size_number_section, #wp_user_avatar_link_external_section { display: none; }
118
+ </style>
119
+ </head>
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="#">
127
+ <div id="wpua">
128
+ <p>
129
+ <label for="<?php esc_attr_e('wp_user_avatar_user'); ?>"><strong><?php _e('User Name','wp-user-avatar'); ?>:</strong></label>
130
+ <select id="<?php esc_attr_e('wp_user_avatar_user'); ?>" name="<?php esc_attr_e('wp_user_avatar_user'); ?>">
131
+ <option value=""></option>
132
+ <?php $users = get_users(); foreach($users as $user) : ?>
133
+ <option value="<?php echo $user->user_login; ?>"><?php echo $user->display_name; ?></option>
134
+ <?php endforeach; ?>
135
+ </select>
136
+ </p>
137
+
138
+ <p>
139
+ <label for="<?php esc_attr_e('wp_user_avatar_size'); ?>"><strong><?php _e('Size'); ?>:</strong></label>
140
+ <select id="<?php esc_attr_e('wp_user_avatar_size'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>">
141
+ <option value=""></option>
142
+ <option value="original"><?php _e('Original Size','wp-user-avatar'); ?></option>
143
+ <option value="large"><?php _e('Large','wp-user-avatar'); ?></option>
144
+ <option value="medium"><?php _e('Medium','wp-user-avatar'); ?></option>
145
+ <option value="thumbnail"><?php _e('Thumbnail','wp-user-avatar'); ?></option>
146
+ <option value="custom"><?php _e('Custom','wp-user-avatar'); ?></option>
147
+ </select>
148
+ </p>
149
+
150
+ <p id="<?php esc_attr_e('wp_user_avatar_size_number_section'); ?>">
151
+ <label for="<?php esc_attr_e('wp_user_avatar_size_number'); ?>"><?php _e('Size','wp-user-avatar'); ?>:</label>
152
+ <input type="text" size="8" id="<?php esc_attr_e('wp_user_avatar_size_number'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>" value="" />
153
+ </p>
154
+
155
+ <p>
156
+ <label for="<?php esc_attr_e('wp_user_avatar_align'); ?>"><strong><?php _e('Alignment','wp-user-avatar'); ?>:</strong></label>
157
+ <select id="<?php esc_attr_e('wp_user_avatar_align'); ?>" name="<?php esc_attr_e('wp_user_avatar_align'); ?>">
158
+ <option value=""></option>
159
+ <option value="center"><?php _e('Center','wp-user-avatar'); ?></option>
160
+ <option value="left"><?php _e('Left','wp-user-avatar'); ?></option>
161
+ <option value="right"><?php _e('Right','wp-user-avatar'); ?></option>
162
+ </select>
163
+ </p>
164
+
165
+ <p>
166
+ <label for="<?php esc_attr_e('wp_user_avatar_link'); ?>"><strong><?php _e('Link To'); ?>:</strong></label>
167
+ <select id="<?php esc_attr_e('wp_user_avatar_link'); ?>" name="<?php esc_attr_e('wp_user_avatar_link'); ?>">
168
+ <option value=""></option>
169
+ <option value="file"><?php _e('Image File','wp-user-avatar'); ?></option>
170
+ <option value="attachment"><?php _e('Attachment Page','wp-user-avatar'); ?></option>
171
+ <option value="custom-url"><?php _e('Custom URL','wp-user-avatar'); ?></option>
172
+ </select>
173
+ </p>
174
+
175
+ <p id="<?php esc_attr_e('wp_user_avatar_link_external_section'); ?>">
176
+ <label for="<?php esc_attr_e('wp_user_avatar_link_external'); ?>"><?php _e('URL','wp-user-avatar'); ?>:</label>
177
+ <input type="text" size="36" id="<?php esc_attr_e('wp_user_avatar_link_external'); ?>" name="<?php esc_attr_e('wp_user_avatar_link_external'); ?>" value="" />
178
+ </p>
179
+
180
+ <p>
181
+ <label for="<?php esc_attr_e('wp_user_avatar_target'); ?>"></label>
182
+ <input type="checkbox" id="<?php esc_attr_e('wp_user_avatar_target'); ?>" name="<?php esc_attr_e('wp_user_avatar_target'); ?>" value="_blank" /> <strong><?php _e('Open link in a new window','wp-user-avatar'); ?></strong>
183
+ </p>
184
+
185
+ <p>
186
+ <label for="<?php esc_attr_e('wp_user_avatar_caption'); ?>"><strong><?php _e('Caption','wp-user-avatar'); ?>:</strong></label>
187
+ <textarea cols="36" rows="2" id="<?php esc_attr_e('wp_user_avatar_caption'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>"></textarea>
188
+ </p>
189
+
190
+ <div class="mceActionPanel">
191
+ <input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatar();" />
192
+ </div>
193
+ </div>
194
+ <div id="wpua-upload" style="display:none;">
195
+ <p id="<?php esc_attr_e('wp_user_avatar_upload'); ?>">
196
+ <label for="<?php esc_attr_e('wp_user_avatar_upload'); ?>"><strong><?php _e('Upload','wp-user-avatar'); ?>:</strong></label>
197
+ <input type="text" size="36" id="<?php esc_attr_e('wp_user_avatar_upload'); ?>" name="<?php esc_attr_e('wp_user_avatar_upload'); ?>" value="<?php esc_attr_e('[avatar_upload]'); ?>" readonly="readonly" />
198
+ </p>
199
+
200
+ <div class="mceActionPanel">
201
+ <input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post','wp-user-avatar'); ?>" onclick="wpuaInsertAvatarUpload();" />
202
+ </div>
203
+ </div>
204
+ </form>
205
+ </div>
206
+ </body>
207
+ </html>
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').'</h3>';
80
/**
81
* Filter profile title
82
* @since 1.9.4
@@ -85,15 +85,15 @@ 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'); ?></h2>
89
<fieldset class="bbp-form">
90
- <legend><?php _e('Image'); ?></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') ?></legend>
94
<table class="wpuf-table">
95
<tr>
96
- <th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
97
<td>
98
<?php else : // Add to profile without table ?>
99
<div class="wpua-edit-container">
@@ -152,7 +152,7 @@ function wpua_do_before_avatar_admin() {
152
<h3><?php _e('Avatar') ?></h3>
153
<table class="form-table">
154
<tr>
155
- <th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
156
<td>
157
<?php
158
}
@@ -185,12 +185,9 @@ function wpua_donation_message() {
185
* @since 1.6.6
186
*/
187
function wpua_do_donation_message() { ?>
188
- <div class="updated">
189
- <p><?php _e('Do you like WP User Avatar?', 'wp-user-avatar'); ?> <a href="http://wordpress.org/plugins/wp-google-map-plugin/" target="_blank"><?php _e('Try our Google Maps Plugin.', 'wp-user-avatar'); ?></a></p>
190
- </div>
191
<?php
192
}
193
- add_action('wpua_donation_message', 'wpua_do_donation_message');
194
195
/**
196
* Register widget
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
$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>
97
<td>
98
<?php else : // Add to profile without table ?>
99
<div class="wpua-edit-container">
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
}
185
* @since 1.6.6
186
*/
187
function wpua_do_donation_message() { ?>
188
<?php
189
}
190
+ //add_action('wpua_donation_message', 'wpua_do_donation_message');
191
192
/**
193
* Register widget
includes/wpua-globals.php CHANGED
@@ -38,7 +38,13 @@ global $avatar_default,
38
$wpua_user_upload_size_limit,
39
$wpua_upload_size_limit,
40
$wpua_upload_size_limit_with_units,
41
- $all_sizes;
42
43
// Default avatar name
44
$avatar_default = get_option('avatar_default');
38
$wpua_user_upload_size_limit,
39
$wpua_upload_size_limit,
40
$wpua_upload_size_limit_with_units,
41
+ $all_sizes,
42
+ $wpua_hash_gravatar;
43
+
44
+ // Store if hash has gravatar
45
+ $wpua_hash_gravatar = get_option('wpua_hash_gravatar');
46
+ if( $wpua_hash_gravatar != false)
47
+ $wpua_hash_gravatar = maybe_unserialize($wpua_hash_gravatar);
48
49
// Default avatar name
50
$avatar_default = get_option('avatar_default');
includes/wpua-media-page.php CHANGED
@@ -36,7 +36,7 @@
36
require_once(ABSPATH.'wp-admin/admin.php');
37
38
if(!current_user_can('upload_files'))
39
- wp_die(__('You do not have permission to upload files.'));
40
41
global $wpua_admin;
42
@@ -68,13 +68,13 @@
68
}
69
foreach((array) $post_ids as $post_id_del) {
70
if(!current_user_can('delete_post', $post_id_del)) {
71
- wp_die(__('You are not allowed to delete this post.'));
72
}
73
if(!wp_delete_attachment($post_id_del)) {
74
- wp_die(__('Error in deleting.'));
75
}
76
}
77
- $location = add_query_arg('deleted', count($post_ids), $location);
78
break;
79
}
80
wp_redirect($location);
@@ -90,9 +90,9 @@
90
?>
91
<div class="wrap">
92
<h2>
93
- <?php _e('Avatars');
94
if(!empty($_REQUEST['s'])) {
95
- printf('<span class="subtitle">'.__('Search results for &#8220;%s&#8221;').'</span>', get_search_query());
96
}
97
?>
98
</h2>
@@ -107,7 +107,7 @@
107
<?php endif; ?>
108
<?php $wp_list_table->views(); ?>
109
<form id="posts-filter" action="" method="get">
110
- <?php $wp_list_table->search_box(__('Search'), 'media'); ?>
111
<?php $wp_list_table->display(); ?>
112
<div id="ajax-response"></div>
113
<?php find_posts_div(); ?>
36
require_once(ABSPATH.'wp-admin/admin.php');
37
38
if(!current_user_can('upload_files'))
39
+ wp_die(__('You do not have permission to upload files.','wp-user-avatar'));
40
41
global $wpua_admin;
42
68
}
69
foreach((array) $post_ids as $post_id_del) {
70
if(!current_user_can('delete_post', $post_id_del)) {
71
+ wp_die(__('You are not allowed to delete this post.','wp-user-avatar'));
72
}
73
if(!wp_delete_attachment($post_id_del)) {
74
+ wp_die(__('Error in deleting.','wp-user-avatar'));
75
}
76
}
77
+ $location = esc_url_raw(add_query_arg('deleted', count($post_ids), $location));
78
break;
79
}
80
wp_redirect($location);
90
?>
91
<div class="wrap">
92
<h2>
93
+ <?php _e('Avatars','wp-user-avatar');
94
if(!empty($_REQUEST['s'])) {
95
+ printf('<span class="subtitle">'.__('Search results for &#8220;%s&#8221;','wp-user-avatar').'</span>', get_search_query());
96
}
97
?>
98
</h2>
107
<?php endif; ?>
108
<?php $wp_list_table->views(); ?>
109
<form id="posts-filter" action="" method="get">
110
+ <?php $wp_list_table->search_box(__('Search','wp-user-avatar'), 'media'); ?>
111
<?php $wp_list_table->display(); ?>
112
<div id="ajax-response"></div>
113
<?php find_posts_div(); ?>
includes/wpua-options-page.php CHANGED
@@ -51,6 +51,8 @@ $wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_option
51
52
<div class="wrap">
53
<h2><?php echo $wpua_options_page_title; ?></h2>
54
<form method="post" action="<?php echo admin_url('options.php'); ?>">
55
<?php settings_fields('wpua-settings-group'); ?>
56
<?php do_settings_fields('wpua-settings-group', ""); ?>
@@ -118,9 +120,9 @@ $wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_option
118
<legend class="screen-reader-text"><span>'.__('Upload Size Limit', 'wp-user-avatar').' '. __('(only for Contributors & Subscribers)', 'wp-user-avatar').'</span></legend>
119
<input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="'.$wpua_upload_size_limit.'" class="regular-text" />
120
<span id="wpua-readable-size">'.$wpua_upload_size_limit_with_units.'</span>
121
- <span id="wpua-readable-size-error">'.sprintf(__('%s exceeds the maximum upload size for this site.'), "").'</span>
122
<div id="wpua-slider"></div>
123
- <span class="description">'.sprintf(__('Maximum upload file size: %d%s.'), esc_html(wp_max_upload_size()), esc_html(' bytes ('.$upload_size_limit_with_units.')')).'</span>
124
</fieldset>
125
<fieldset>
126
<label for="wp_user_avatar_edit_avatar">
@@ -135,9 +137,9 @@ $wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_option
135
</label>
136
</fieldset>
137
<fieldset id="wpua-resize-sizes"'.$hide_resize.'>
138
- <label for="wp_user_avatar_resize_w">'.__('Width').'</label>
139
<input name="wp_user_avatar_resize_w" type="number" step="1" min="0" id="wp_user_avatar_resize_w" value="'.get_option('wp_user_avatar_resize_w').'" class="small-text" />
140
- <label for="wp_user_avatar_resize_h">'.__('Height').'</label>
141
<input name="wp_user_avatar_resize_h" type="number" step="1" min="0" id="wp_user_avatar_resize_h" value="'.get_option('wp_user_avatar_resize_h').'" class="small-text" />
142
<br />
143
<input name="wp_user_avatar_resize_crop" type="checkbox" id="wp_user_avatar_resize_crop" value="1" '.checked('1', $wpua_resize_crop, 0).' />
@@ -157,29 +159,28 @@ $wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_option
157
?>
158
<table class="form-table">
159
<tr valign="top">
160
- <th scope="row"><?php _e('Avatar Display'); ?></th>
161
<td>
162
<fieldset>
163
- <legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
164
<label for="show_avatars">
165
<input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> />
166
- <?php _e('Show Avatars'); ?>
167
</label>
168
</fieldset>
169
</td>
170
</tr>
171
- <?php if((bool) $wpua_disable_gravatar != 1) : ?>
172
- <tr valign="top" id="avatar-rating">
173
- <th scope="row"><?php _e('Maximum Rating'); ?></th>
174
<td>
175
<fieldset>
176
- <legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
177
<?php
178
$ratings = array(
179
- 'G' => __('G &#8212; Suitable for all audiences'),
180
- 'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
181
- 'R' => __('R &#8212; Intended for adult audiences above 17'),
182
- 'X' => __('X &#8212; Even more mature than above')
183
);
184
foreach ($ratings as $key => $rating) :
185
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
@@ -189,15 +190,12 @@ $wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_option
189
</fieldset>
190
</td>
191
</tr>
192
- <?php else : ?>
193
- <input type="hidden" id="avatar_rating" name="avatar_rating" value="<?php echo get_option('avatar_rating'); ?>" />
194
- <?php endif; ?>
195
<tr valign="top">
196
- <th scope="row"><?php _e('Default Avatar') ?></th>
197
<td class="defaultavatarpicker">
198
<fieldset>
199
- <legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
200
- <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
201
<?php echo $wpua_admin->wpua_add_default_avatar(); ?>
202
</fieldset>
203
</td>
@@ -205,4 +203,31 @@ $wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_option
205
</table>
206
<?php submit_button(); ?>
207
</form>
208
</div>
51
52
<div class="wrap">
53
<h2><?php echo $wpua_options_page_title; ?></h2>
54
+ <table><tr valign="top">
55
+ <td align="top">
56
<form method="post" action="<?php echo admin_url('options.php'); ?>">
57
<?php settings_fields('wpua-settings-group'); ?>
58
<?php do_settings_fields('wpua-settings-group', ""); ?>
120
<legend class="screen-reader-text"><span>'.__('Upload Size Limit', 'wp-user-avatar').' '. __('(only for Contributors & Subscribers)', 'wp-user-avatar').'</span></legend>
121
<input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="'.$wpua_upload_size_limit.'" class="regular-text" />
122
<span id="wpua-readable-size">'.$wpua_upload_size_limit_with_units.'</span>
123
+ <span id="wpua-readable-size-error">'.sprintf(__('%s exceeds the maximum upload size for this site.','wp-user-avatar'), "").'</span>
124
<div id="wpua-slider"></div>
125
+ <span class="description">'.sprintf(__('Maximum upload file size: %d%s.','wp-user-avatar'), esc_html(wp_max_upload_size()), esc_html(' bytes ('.$upload_size_limit_with_units.')')).'</span>
126
</fieldset>
127
<fieldset>
128
<label for="wp_user_avatar_edit_avatar">
137
</label>
138
</fieldset>
139
<fieldset id="wpua-resize-sizes"'.$hide_resize.'>
140
+ <label for="wp_user_avatar_resize_w">'.__('Width','wp-user-avatar').'</label>
141
<input name="wp_user_avatar_resize_w" type="number" step="1" min="0" id="wp_user_avatar_resize_w" value="'.get_option('wp_user_avatar_resize_w').'" class="small-text" />
142
+ <label for="wp_user_avatar_resize_h">'.__('Height','wp-user-avatar').'</label>
143
<input name="wp_user_avatar_resize_h" type="number" step="1" min="0" id="wp_user_avatar_resize_h" value="'.get_option('wp_user_avatar_resize_h').'" class="small-text" />
144
<br />
145
<input name="wp_user_avatar_resize_crop" type="checkbox" id="wp_user_avatar_resize_crop" value="1" '.checked('1', $wpua_resize_crop, 0).' />
159
?>
160
<table class="form-table">
161
<tr valign="top">
162
+ <th scope="row"><?php _e('Avatar Display','wp-user-avatar'); ?></th>
163
<td>
164
<fieldset>
165
+ <legend class="screen-reader-text"><span><?php _e('Avatar Display','wp-user-avatar'); ?></span></legend>
166
<label for="show_avatars">
167
<input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> />
168
+ <?php _e('Show Avatars','wp-user-avatar'); ?>
169
</label>
170
</fieldset>
171
</td>
172
</tr>
173
+ <tr valign="top" id="avatar-rating" <?php echo ((bool) $wpua_disable_gravatar == 1) ? 'style="display:none"' : ''?>>
174
+ <th scope="row"><?php _e('Maximum Rating','wp-user-avatar'); ?></th>
175
<td>
176
<fieldset>
177
+ <legend class="screen-reader-text"><span><?php _e('Maximum Rating','wp-user-avatar'); ?></span></legend>
178
<?php
179
$ratings = array(
180
+ 'G' => __('G &#8212; Suitable for all audiences','wp-user-avatar'),
181
+ 'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above','wp-user-avatar'),
182
+ 'R' => __('R &#8212; Intended for adult audiences above 17','wp-user-avatar'),
183
+ 'X' => __('X &#8212; Even more mature than above','wp-user-avatar')
184
);
185
foreach ($ratings as $key => $rating) :
186
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
190
</fieldset>
191
</td>
192
</tr>
193
<tr valign="top">
194
+ <th scope="row"><?php _e('Default Avatar','wp-user-avatar') ?></th>
195
<td class="defaultavatarpicker">
196
<fieldset>
197
+ <legend class="screen-reader-text"><span><?php _e('Default Avatar','wp-user-avatar'); ?></span></legend>
198
+ <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.','wp-user-avatar'); ?><br />
199
<?php echo $wpua_admin->wpua_add_default_avatar(); ?>
200
</fieldset>
201
</td>
203
</table>
204
<?php submit_button(); ?>
205
</form>
206
+
207
+ </td>
208
+ <td>
209
+ <div id="fc-sidebar">
210
+ <div class="fc-box">
211
+ <h3>WP User Avatar Pro</h3>
212
+ <p><a target="_blank" href="http://www.wpuseravatar.com"><img width="500" src="<?php echo WPUA_URL.'images/wp-user-avatar-banner.png'; ?>" /></a></p>
213
+ <p><em>Introducing awesome features to enhance user experience when they upload own avatar.</em></p>
214
+ <p>Pro features include webcam, custom folder, amazon s3 storage, dropbox storage, cropping and priority support.</p>
215
+ <p><a class="button button-primary button-large" target="_blank" href="http://www.wpuseravatar.com">View Features »</a></p>
216
+ </div>
217
+ <div class="fc-box">
218
+ <h4>Looking for support?</h4>
219
+ <p>Use the <a target="_blank" href="http://www.flippercode.com/forums">support forums</a> on flippercode.com.</p>
220
+ </div>
221
+
222
+ <div class="fc-box">
223
+ <h4>Your Appreciation</h4>
224
+ <ul class="ul-square">
225
+ <li><a target="_blank" href="http://www.wpuseravatar.com/">Upgrade to WP User Avatar Pro</a></li>
226
+ <li><a target="_blank" href="https://wordpress.org/support/view/plugin-reviews/wp-user-avatar?rate=5#postform">Leave a ★★★★★ plugin review on WordPress.org</a></li>
227
+ <li><a target="_blank" href="https://wordpress.org/plugins/wp-user-avatar/">Vote "works" on the WordPress.org plugin page</a></li>
228
+ </ul>
229
+ </div>
230
+ </div>
231
+ </td>
232
+ </tr></table>
233
</div>
js/wp-user-avatar-user.js CHANGED
@@ -28,4 +28,32 @@ jQuery(function($) {
28
$('#wp-user-avatar').val(wpuaID);
29
$('#wp_user_avatar_radio').trigger('click');
30
});
31
});
28
$('#wp-user-avatar').val(wpuaID);
29
$('#wp_user_avatar_radio').trigger('click');
30
});
31
+
32
+ // Store WP Existing User Avatar ID
33
+ var wpuaEID = $('#wp-user-avatar-existing').val();
34
+ // Store WP Existing User Avatar src
35
+ var wpuaESrc = $('#wpua-preview-existing').find('img').attr('src');
36
+ // Remove WP Existing User Avatar
37
+ $('body').on('click', '#wpua-remove-existing', function(e) {
38
+ e.preventDefault();
39
+ $('#wpua-original-existing').remove();
40
+ $('#wpua-remove-button-existing, #wpua-thumbnail-existing').hide();
41
+ $('#wpua-preview-existing').find('img:first').hide();
42
+ $('#wpua-preview-existing').prepend('<img id="wpua-original-existing" />');
43
+ $('#wpua-original-existing').attr('src', wpua_custom.avatar_thumb);
44
+ $('#wp-user-avatar-existing').val("");
45
+ $('#wpua-original-existing, #wpua-undo-button-existing').show();
46
+ $('#wp_user_avatar_radio-existing').trigger('click');
47
+ });
48
+ // Undo WP Existing User Avatar
49
+ $('body').on('click', '#wpua-undo-existing', function(e) {
50
+ e.preventDefault();
51
+ $('#wpua-original-existing').remove();
52
+ $('#wpua-images-existing').removeAttr('style');
53
+ $('#wpua-undo-button-existing').hide();
54
+ $('#wpua-remove-button-existing, #wpua-thumbnail-existing').show();
55
+ $('#wpua-preview-existing').find('img:first').attr('src', wpuaSrc).show();
56
+ $('#wp-user-avatar-existing').val(wpuaID);
57
+ $('#wp_user_avatar_radio-existing').trigger('click');
58
+ });
59
});
js/wp-user-avatar.js CHANGED
@@ -1 +1,123 @@
1
- eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){2.5.p={H:3(){E 2.5.W.P.8.v},M:3(a){q b=2.5.W.P;b.8.v=a;b.8.D=$(\'K.f-Z\').9(\'c\').d(\'k\');u(b.8.v&&b.8.D){$(\'#2-m-n\').o(b.8.v);$(\'#0-T, #0-s-h\').t();$(\'#0-r\').9(\'c\').d(\'k\',b.8.D).O(\'X\',"");$(\'#0-g-h, #0-z\').x();$(\'#C\').w(\'6\')}2.5.p.A().1j()},A:3(){u(4.7){E 4.7}4.7=2.5({S:{12:\'13\'},15:1f,U:$(\'#0-B\').J(\'U\')});4.7.l(\'L\',3(){q a=$(\'#2-m-n\').o();u(a==""){$(\'K.5-14\').9(\'a:y\').w(\'6\')}17{q b=4.N().H(\'j\');f=2.5.f(a);f.Y();b.B(f?[f]:[])}},4.7);4.7.N(\'S\').l(\'F\',4.F);E 4.7},F:3(a){j=4.H(\'j\').10();2.5.p.M(j?j.Q:-1)},R:3(){$(\'G\').l(\'6\',\'#0-B\',3(e){e.I();e.16();2.5.p.A().L()})}}})(V);V(3($){u(18(2)!=\'19\'){2.5.p.R()}$(\'#1a-1b\').d(\'1c\',\'1d/1e-J\');q a=$(\'#2-m-n\').o();q b=$(\'#0-r\').9(\'c\').d(\'k\');$(\'G\').l(\'6\',\'#0-g\',3(e){e.I();$(\'#0-i\').g();$(\'#0-g-h, #0-z\').x();$(\'#0-r\').9(\'c:y\').x();$(\'#0-r\').1g(\'<c Q="0-i" />\');$(\'#0-i\').d(\'k\',1h.1i);$(\'#2-m-n\').o("");$(\'#0-i, #0-s-h\').t();$(\'#C\').w(\'6\')});$(\'G\').l(\'6\',\'#0-s\',3(e){e.I();$(\'#0-i\').g();$(\'#0-T\').O(\'11\');$(\'#0-s-h\').x();$(\'#0-g-h, #0-z\').t();$(\'#0-r\').9(\'c:y\').d(\'k\',b).t();$(\'#2-m-n\').o(a);$(\'#C\').w(\'6\')})});',62,82,'wpua||wp|function|this|media|click|_frame|post|find|||img|attr||attachment|remove|button|original|selection|src|on|user|avatar|val|wpUserAvatar|var|preview|undo|show|if|wpUserAvatarId|trigger|hide|first|thumbnail|frame|add|wp_user_avatar_radio|wpUserAvatarSrc|return|select|body|get|preventDefault|data|div|open|set|state|removeAttr|settings|id|init|library|images|title|jQuery|view|height|fetch|info|single|style|type|image|router|multiple|stopPropagation|else|typeof|undefined|your|profile|enctype|multipart|form|false|prepend|wpua_custom|avatar_thumb|close'.split('|'),0,{}))
1
+ (function($) {
2
+ var id;
3
+ wp.media.wpUserAvatar = {
4
+
5
+ get: function() {
6
+ return wp.media.view.settings.post.wpUserAvatarId
7
+ },
8
+ set: function(a) {
9
+ var b = wp.media.view.settings;
10
+ b.post.wpUserAvatarId = a;
11
+ b.post.wpUserAvatarSrc = $('div.attachment-info').find('img').attr('src');
12
+ if (b.post.wpUserAvatarId && b.post.wpUserAvatarSrc) {
13
+ $('#wp-user-avatar'+id).val(b.post.wpUserAvatarId);
14
+ $('#wpua-images'+id+', #wpua-undo-button'+id).show();
15
+ $('#wpua-preview'+id).find('img').attr('src', b.post.wpUserAvatarSrc).removeAttr('height', "");
16
+ $('#wpua-remove-button'+id+', #wpua-thumbnail'+id).hide();
17
+ $('#wp_user_avatar_radio').trigger('click')
18
+ }
19
+ wp.media.wpUserAvatar.frame().close()
20
+ },
21
+ frame: function() {
22
+ if (this._frame) {
23
+ return this._frame
24
+ }
25
+ this._frame = wp.media({
26
+ library: {
27
+ type: 'image'
28
+ },
29
+ multiple: false,
30
+ title: $('#wpua-add'+id).data('title')
31
+ });
32
+ this._frame.on('open', function() {
33
+ var a = $('#wp-user-avatar'+id).val();
34
+ if (a == "") {
35
+ $('div.media-router').find('a:first').trigger('click')
36
+ } else {
37
+ var b = this.state().get('selection');
38
+ attachment = wp.media.attachment(a);
39
+ attachment.fetch();
40
+ b.add(attachment ? [attachment] : [])
41
+ }
42
+ }, this._frame);
43
+ this._frame.state('library').on('select', this.select);
44
+ return this._frame
45
+ },
46
+ select: function(a) {
47
+ selection = this.get('selection').single();
48
+ wp.media.wpUserAvatar.set(selection ? selection.id : -1)
49
+ },
50
+ init: function() {
51
+ $('body').on('click', '#wpua-add', function(e) {
52
+ e.preventDefault();
53
+ e.stopPropagation();
54
+ id='';
55
+ wp.media.wpUserAvatar.frame().open()
56
+ })
57
+ $('body').on('click', '#wpua-add-existing', function(e) {
58
+ e.preventDefault();
59
+ e.stopPropagation();
60
+ id='-existing';
61
+ wp.media.wpUserAvatar.frame().open()
62
+ })
63
+ }
64
+ }
65
+ })(jQuery);
66
+ jQuery(function($) {
67
+ if (typeof(wp) != 'undefined') {
68
+ wp.media.wpUserAvatar.init()
69
+ }
70
+ $('#your-profile').attr('enctype', 'multipart/form-data');
71
+ var a = $('#wp-user-avatar').val();
72
+ var b = $('#wpua-preview').find('img').attr('src');
73
+ $('body').on('click', '#wpua-remove', function(e) {
74
+ e.preventDefault();
75
+ $('#wpua-original').remove();
76
+ $('#wpua-remove-button, #wpua-thumbnail').hide();
77
+ $('#wpua-preview').find('img:first').hide();
78
+ $('#wpua-preview').prepend('<img id="wpua-original" />');
79
+ $('#wpua-original').attr('src', wpua_custom.avatar_thumb);
80
+ $('#wp-user-avatar').val("");
81
+ $('#wpua-original, #wpua-undo-button').show();
82
+ $('#wp_user_avatar_radio').trigger('click')
83
+ });
84
+ $('body').on('click', '#wpua-undo', function(e) {
85
+ e.preventDefault();
86
+ $('#wpua-original').remove();
87
+ $('#wpua-images').removeAttr('style');
88
+ $('#wpua-undo-button').hide();
89
+ $('#wpua-remove-button, #wpua-thumbnail').show();
90
+ $('#wpua-preview').find('img:first').attr('src', b).show();
91
+ $('#wp-user-avatar').val(a);
92
+ $('#wp_user_avatar_radio').trigger('click')
93
+ })
94
+ });
95
+ jQuery(function($) {
96
+ if (typeof(wp) != 'undefined') {
97
+ wp.media.wpUserAvatar.init()
98
+ }
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();
105
+ $('#wpua-remove-button-existing, #wpua-thumbnail-existing').hide();
106
+ $('#wpua-preview-existing').find('img:first').hide();
107
+ $('#wpua-preview-existing').prepend('<img id="wpua-original-existing" />');
108
+ $('#wpua-original-existing').attr('src', wpua_custom.avatar_thumb);
109
+ $('#wp-user-avatar-existing').val("");
110
+ $('#wpua-original-existing, #wpua-undo-button-existing').show();
111
+ $('#wp_user_avatar_radio').trigger('click')
112
+ });
113
+ $('body').on('click', '#wpua-undo-existing', function(e) {
114
+ e.preventDefault();
115
+ $('#wpua-original-existing').remove();
116
+ $('#wpua-images-existing').removeAttr('style');
117
+ $('#wpua-undo-button-existing').hide();
118
+ $('#wpua-remove-button-existing, #wpua-thumbnail-existing').show();
119
+ $('#wpua-preview-existing').find('img:first').attr('src', b).show();
120
+ $('#wp-user-avatar-existing').val(a);
121
+ $('#wp_user_avatar_radio').trigger('click')
122
+ })
123
+ });
lang/wp-user-avatar-de_DE.mo DELETED
Binary file
lang/wp-user-avatar-de_DE.po DELETED
@@ -1,81 +0,0 @@
1
- # German (de_DE) translation for WP User Avatar.
2
- # Copyright (C) 2014 Bangbay Siboliban.
3
- # This file is distributed under the same license as the WP User Avatar package.
4
- #
5
- msgid ""
6
- msgstr ""
7
- "Project-Id-Version: WP User Avatar 1.9.13\n"
8
- "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
- "PO-Revision-Date: 2014-06-03 00:00-0000\n"
10
- "Language: de_DE\n"
11
- "Last-Translator: WP User Avatar\n"
12
- "Language-Team: WP User Avatar\n"
13
- "MIME-Version: 1.0\n"
14
- "Content-Type: text/plain; charset=UTF-8\n"
15
- "Content-Transfer-Encoding: 8bit\n"
16
-
17
- #: includes/class-wp-user-avatar-admin.php:302
18
- msgid "Donate"
19
- msgstr "Spenden"
20
-
21
- #: includes/wpua-functions.php:189
22
- msgid "Do you like WP User Avatar?"
23
- msgstr "Bist Du mit WP-Benutzer-Avatar zufrieden?"
24
-
25
- #: includes/wpua-functions.php:189
26
- msgid "Make a donation."
27
- msgstr "Spenden"
28
-
29
- #: includes/wpua-options-page.php:83
30
- msgid "Add avatar button to Visual Editor"
31
- msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
32
-
33
- #: includes/wpua-options-page.php:89
34
- msgid "Allow Contributors & Subscribers to upload avatars"
35
- msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
36
-
37
- #: includes/wpua-options-page.php:95
38
- msgid "Disable Gravatar and use only local avatars"
39
- msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
40
-
41
- #: includes/wpua-options-page.php:117
42
- #: includes/wpua-options-page.php:122
43
- msgid "Upload Size Limit"
44
- msgstr "Dateigrößenbeschränkung"
45
-
46
- #: includes/wpua-options-page.php:117
47
- #: includes/wpua-options-page.php:122
48
- msgid "(only for Contributors & Subscribers)"
49
- msgstr "(nur für Mitarbeiter und Abonnenten)"
50
-
51
- #: includes/wpua-options-page.php:132
52
- msgid "Allow users to edit avatars"
53
- msgstr "Benutzer erlauben, Avatare bearbeiten"
54
-
55
- #: includes/wpua-options-page.php:138
56
- msgid "Resize avatars on upload"
57
- msgstr "Resize Avatare beim Upload"
58
-
59
- #: includes/wpua-options-page.php:148
60
- msgid "Crop avatars to exact dimensions"
61
- msgstr "Avatare auf exakte Größe beschneiden"
62
-
63
- #. Plugin Name of the plugin/theme
64
- msgid "WP User Avatar"
65
- msgstr "WP-Benutzer-Avatar"
66
-
67
- #. Plugin URI of the plugin/theme
68
- msgid "http://wordpress.org/plugins/wp-user-avatar/"
69
- msgstr "http://wordpress.org/plugins/wp-user-avatar/"
70
-
71
- #. Description of the plugin/theme
72
- msgid "Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar."
73
- msgstr "Verwenden Sie ein beliebiges Bild aus Ihrer WordPress-Mediathek als ihren Benutzer-Avatar. Fügen Sie einen eigenen Standardavatar hinzu."
74
-
75
- #. Author of the plugin/theme
76
- msgid "Bangbay Siboliban"
77
- msgstr "Bangbay Siboliban"
78
-
79
- #. Author URI of the plugin/theme
80
- msgid "http://siboliban.org/"
81
- msgstr "http://siboliban.org/"
lang/wp-user-avatar-en_US.mo ADDED
Binary file
lang/wp-user-avatar-en_US.po ADDED
@@ -0,0 +1,417 @@