Version Description
- Bug Fix: Load _load_wp_includes mostly only on front pages
- Bug Fix: Check for edit_posts capability before enabling filters for Subscribers
Download this release
Release Info
Developer | flippercode |
Plugin | WP User Avatar |
Version | 1.9.13 |
Comparing to | |
See all releases |
Code changes from version 1.5.6 to 1.9.13
- css/wp-user-avatar.css +7 -5
- images/{wp-user-avatar-150x150.png → wpua-150x150.png} +0 -0
- images/wpua-20x20.png +0 -0
- images/{wp-user-avatar-300x300.png → wpua-300x300.png} +0 -0
- images/{wp-user-avatar-32x32.png → wpua-32x32.png} +0 -0
- images/{wp-user-avatar-96x96.png → wpua-96x96.png} +0 -0
- images/wpua-icon.png +0 -0
- images/{wp-user-avatar.png → wpua.png} +0 -0
- includes/class-wp-user-avatar-admin.php +382 -0
- includes/class-wp-user-avatar-functions.php +440 -0
- includes/class-wp-user-avatar-list-table.php +400 -0
- includes/class-wp-user-avatar-resource-manager.php +208 -0
- includes/class-wp-user-avatar-shortcode.php +253 -0
- includes/class-wp-user-avatar-subscriber.php +135 -0
- includes/class-wp-user-avatar-update.php +116 -0
- includes/class-wp-user-avatar-widget.php +106 -0
- includes/class-wp-user-avatar.php +452 -0
- includes/tinymce.php +0 -47
- includes/tinymce/editor_plugin.js +1 -1
- includes/tinymce/window.php +159 -86
- includes/wpua-functions.php +203 -0
- includes/wpua-globals.php +99 -0
- includes/wpua-media-page.php +116 -0
- includes/wpua-options-page.php +208 -0
- includes/wpua-tinymce.php +54 -0
- index.html +1 -0
- js/wp-user-avatar-admin.js +25 -22
- js/wp-user-avatar-user.js +31 -0
- js/wp-user-avatar.js +1 -1
- lang/wp-user-avatar-de_DE.mo +0 -0
- lang/wp-user-avatar-de_DE.po +35 -15
- lang/wp-user-avatar-es_ES.mo +0 -0
- lang/wp-user-avatar-es_ES.po +35 -15
- lang/wp-user-avatar-fr_FR.mo +0 -0
- lang/wp-user-avatar-fr_FR.po +35 -15
- lang/wp-user-avatar-pl_PL.mo +0 -0
- lang/wp-user-avatar-pl_PL.po +81 -0
- lang/wp-user-avatar-sv_SE.mo +0 -0
- lang/wp-user-avatar-sv_SE.po +35 -15
- readme.txt +361 -35
- uninstall.php +38 -12
- wp-user-avatar.php +83 -969
css/wp-user-avatar.css
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
-
#wpua-errors, #wpua-
|
2 |
-
#wpua-
|
|
|
3 |
#wpua-preview, #wpua-thumbnail { display: inline-block; text-align: center; vertical-align: top; }
|
4 |
-
#wpua-preview { margin-right: 10px !important; }
|
5 |
#wpua-preview img, #wpua-thumbnail img { max-height: 96px; border: 1px solid #dfdfdf; display: block; }
|
|
|
6 |
.defaultavatarpicker #wpua-preview { width: 32px; height: 32px; margin-right: 0; display: inline-block; overflow: hidden; vertical-align: middle; }
|
7 |
.defaultavatarpicker #wpua-preview img { width: 32px; height: auto; border: 0; }
|
8 |
-
#wpua-edit {
|
9 |
-
#wpua-edit #wpua-remove { margin-left: 10px !important; }
|
10 |
#wpua-slider { width: 22.75em; }
|
|
|
11 |
.wpua-hide { display: none !important; }
|
|
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; }
|
12 |
.wpua-hide { display: none !important; }
|
13 |
+
.wpua-no-avatars { display: none; }
|
images/{wp-user-avatar-150x150.png → wpua-150x150.png}
RENAMED
File without changes
|
images/wpua-20x20.png
ADDED
Binary file
|
images/{wp-user-avatar-300x300.png → wpua-300x300.png}
RENAMED
File without changes
|
images/{wp-user-avatar-32x32.png → wpua-32x32.png}
RENAMED
File without changes
|
images/{wp-user-avatar-96x96.png → wpua-96x96.png}
RENAMED
File without changes
|
images/wpua-icon.png
ADDED
Binary file
|
images/{wp-user-avatar.png → wpua.png}
RENAMED
File without changes
|
includes/class-wp-user-avatar-admin.php
ADDED
@@ -0,0 +1,382 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines all of administrative, activation, and deactivation settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Admin {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.8
|
13 |
+
* @uses bool $show_avatars
|
14 |
+
* @uses add_action()
|
15 |
+
* @uses add_filter()
|
16 |
+
* @uses load_plugin_textdomain()
|
17 |
+
* @uses register_activation_hook()
|
18 |
+
* @uses register_deactivation_hook()
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
global $show_avatars;
|
22 |
+
// Initialize default settings
|
23 |
+
register_activation_hook(WPUA_DIR.'wp-user-avatar.php', array($this, 'wpua_options'));
|
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
|
31 |
+
add_action('admin_menu', array($this, 'wpua_admin'));
|
32 |
+
add_action('admin_init', array($this, 'wpua_register_settings'));
|
33 |
+
// Default avatar
|
34 |
+
add_filter('default_avatar_select', array($this, 'wpua_add_default_avatar'), 10);
|
35 |
+
add_filter('whitelist_options', array($this, 'wpua_whitelist_options'), 10);
|
36 |
+
// Additional plugin info
|
37 |
+
add_filter('plugin_action_links', array($this, 'wpua_action_links'), 10, 2);
|
38 |
+
add_filter('plugin_row_meta', array($this, 'wpua_row_meta'), 10, 2);
|
39 |
+
// Hide column in Users table if default avatars are enabled
|
40 |
+
if((bool) $show_avatars == 0) {
|
41 |
+
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
42 |
+
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
|
43 |
+
}
|
44 |
+
// Media states
|
45 |
+
add_filter('display_media_states', array($this, 'wpua_add_media_state'), 10, 1);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Settings saved to wp_options
|
50 |
+
* @since 1.4
|
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');
|
57 |
+
add_option('wp_user_avatar_edit_avatar', '1');
|
58 |
+
add_option('wp_user_avatar_resize_crop', '0');
|
59 |
+
add_option('wp_user_avatar_resize_h', '96');
|
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 |
+
/**
|
67 |
+
* On deactivation
|
68 |
+
* @since 1.4
|
69 |
+
* @uses int $blog_id
|
70 |
+
* @uses object $wpdb
|
71 |
+
* @uses get_blog_prefix()
|
72 |
+
* @uses get_option()
|
73 |
+
* @uses update_option()
|
74 |
+
*/
|
75 |
+
public function wpua_deactivate() {
|
76 |
+
global $blog_id, $wpdb;
|
77 |
+
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
78 |
+
// Get user roles and capabilities
|
79 |
+
$user_roles = get_option($wp_user_roles);
|
80 |
+
// Remove subscribers edit_posts capability
|
81 |
+
unset($user_roles['subscriber']['capabilities']['edit_posts']);
|
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 |
+
/**
|
88 |
+
* Add options page and settings
|
89 |
+
* @since 1.4
|
90 |
+
* @uses add_menu_page()
|
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 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Checks if current page is settings page
|
103 |
+
* @since 1.8.3
|
104 |
+
* @uses string $pagenow
|
105 |
+
* @return bool
|
106 |
+
*/
|
107 |
+
public function wpua_is_menu_page() {
|
108 |
+
global $pagenow;
|
109 |
+
$is_menu_page = ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar') ? true : false;
|
110 |
+
return (bool) $is_menu_page;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Media page
|
115 |
+
* @since 1.8
|
116 |
+
*/
|
117 |
+
public function wpua_media_page() {
|
118 |
+
require_once(WPUA_INC.'wpua-media-page.php');
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Avatars per page
|
123 |
+
* @since 1.8.10
|
124 |
+
* @uses add_screen_option()
|
125 |
+
*/
|
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 |
+
);
|
133 |
+
add_screen_option($option, $args);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Save per page setting
|
138 |
+
* @since 1.8.10
|
139 |
+
* @param int $status
|
140 |
+
* @param string $option
|
141 |
+
* @param int $value
|
142 |
+
* @return int $status
|
143 |
+
*/
|
144 |
+
public function wpua_set_media_screen_option($status, $option, $value) {
|
145 |
+
$status = ($option == 'upload_per_page') ? $value : $status;
|
146 |
+
return $status;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Options page
|
151 |
+
* @since 1.4
|
152 |
+
*/
|
153 |
+
public function wpua_options_page() {
|
154 |
+
require_once(WPUA_INC.'wpua-options-page.php');
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Whitelist settings
|
159 |
+
* @since 1.9
|
160 |
+
* @uses apply_filters()
|
161 |
+
* @uses register_setting()
|
162 |
+
* @return array
|
163 |
+
*/
|
164 |
+
public function wpua_register_settings() {
|
165 |
+
$settings = array();
|
166 |
+
$settings[] = register_setting('wpua-settings-group', 'avatar_rating');
|
167 |
+
$settings[] = register_setting('wpua-settings-group', 'avatar_default');
|
168 |
+
$settings[] = register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar');
|
169 |
+
$settings[] = register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
170 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
171 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
172 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
173 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
|
174 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_crop', 'intval');
|
175 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_h', 'intval');
|
176 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_upload', 'intval');
|
177 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_w', 'intval');
|
178 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
179 |
+
/**
|
180 |
+
* Filter admin whitelist settings
|
181 |
+
* @since 1.9
|
182 |
+
* @param array $settings
|
183 |
+
*/
|
184 |
+
return apply_filters('wpua_register_settings', $settings);
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Add default avatar
|
189 |
+
* @since 1.4
|
190 |
+
* @uses string $avatar_default
|
191 |
+
* @uses string $mustache_admin
|
192 |
+
* @uses string $mustache_medium
|
193 |
+
* @uses int $wpua_avatar_default
|
194 |
+
* @uses bool $wpua_disable_gravatar
|
195 |
+
* @uses object $wpua_functions
|
196 |
+
* @uses get_avatar()
|
197 |
+
* @uses remove_filter()
|
198 |
+
* @uses wpua_attachment_is_image()
|
199 |
+
* @uses wpua_get_attachment_image_src()
|
200 |
+
* @return string
|
201 |
+
*/
|
202 |
+
public function wpua_add_default_avatar() {
|
203 |
+
global $avatar_default, $mustache_admin, $mustache_medium, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
|
204 |
+
// Remove get_avatar filter
|
205 |
+
remove_filter('get_avatar', array($wpua_functions, 'wpua_get_avatar_filter'));
|
206 |
+
// Set avatar_list variable
|
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)) {
|
220 |
+
$avatar_default = 'mystery';
|
221 |
+
}
|
222 |
+
// Take avatar_defaults and get examples for unknown@gravatar.com
|
223 |
+
foreach($avatar_defaults as $default_key => $default_name) {
|
224 |
+
$avatar = get_avatar('unknown@gravatar.com', 32, $default_key);
|
225 |
+
$selected = ($avatar_default == $default_key) ? 'checked="checked" ' : "";
|
226 |
+
$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='".esc_attr($default_key)."' {$selected}/> ";
|
227 |
+
$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&forcedefault=1'", $avatar);
|
228 |
+
$avatar_list .= ' '.$default_name.'</label>';
|
229 |
+
$avatar_list .= '<br />';
|
230 |
+
}
|
231 |
+
// Show remove link if custom Default Avatar is set
|
232 |
+
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
|
233 |
+
$avatar_thumb_src = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array(32,32));
|
234 |
+
$avatar_thumb = $avatar_thumb_src[0];
|
235 |
+
$hide_remove = "";
|
236 |
+
} else {
|
237 |
+
$avatar_thumb = $mustache_admin;
|
238 |
+
$hide_remove = ' class="wpua-hide"';
|
239 |
+
}
|
240 |
+
// Default Avatar is wp_user_avatar, check the radio button next to it
|
241 |
+
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
242 |
+
// Wrap WPUA in div
|
243 |
+
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
|
244 |
+
// Add WPUA to list
|
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 |
+
|
259 |
+
/**
|
260 |
+
* Add default avatar_default to whitelist
|
261 |
+
* @since 1.4
|
262 |
+
* @param array $options
|
263 |
+
* @return array $options
|
264 |
+
*/
|
265 |
+
public function wpua_whitelist_options($options) {
|
266 |
+
$options['discussion'][] = 'avatar_default_wp_user_avatar';
|
267 |
+
return $options;
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Add actions links on plugin page
|
272 |
+
* @since 1.6.6
|
273 |
+
* @param array $links
|
274 |
+
* @param string $file
|
275 |
+
* @return array $links
|
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 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Add row meta on plugin page
|
286 |
+
* @since 1.6.6
|
287 |
+
* @param array $links
|
288 |
+
* @param string $file
|
289 |
+
* @return array $links
|
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 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Add column to Users table
|
301 |
+
* @since 1.4
|
302 |
+
* @param array $columns
|
303 |
+
* @return array
|
304 |
+
*/
|
305 |
+
public function wpua_add_column($columns) {
|
306 |
+
return $columns + array('wp-user-avatar' => __('Avatar'));
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Show thumbnail in Users table
|
311 |
+
* @since 1.4
|
312 |
+
* @param string $value
|
313 |
+
* @param string $column_name
|
314 |
+
* @param int $user_id
|
315 |
+
* @uses int $blog_id
|
316 |
+
* @uses object $wpdb
|
317 |
+
* @uses object $wpua_functions
|
318 |
+
* @uses get_blog_prefix()
|
319 |
+
* @uses get_user_meta()
|
320 |
+
* @uses wpua_get_attachment_image()
|
321 |
+
* @return string $value
|
322 |
+
*/
|
323 |
+
public function wpua_show_column($value, $column_name, $user_id) {
|
324 |
+
global $blog_id, $wpdb, $wpua_functions;
|
325 |
+
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
326 |
+
$wpua_image = $wpua_functions->wpua_get_attachment_image($wpua, array(32,32));
|
327 |
+
if($column_name == 'wp-user-avatar') {
|
328 |
+
$value = $wpua_image;
|
329 |
+
}
|
330 |
+
return $value;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Get list table
|
335 |
+
* @since 1.8
|
336 |
+
* @param string $class
|
337 |
+
* @param array $args
|
338 |
+
* @return object
|
339 |
+
*/
|
340 |
+
public function _wpua_get_list_table($class, $args = array()) {
|
341 |
+
require_once(WPUA_INC.'class-wp-user-avatar-list-table.php');
|
342 |
+
$args['screen'] = 'wp-user-avatar';
|
343 |
+
return new $class($args);
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Add media states
|
348 |
+
* @since 1.4
|
349 |
+
* @param array $states
|
350 |
+
* @uses object $post
|
351 |
+
* @uses int $wpua_avatar_default
|
352 |
+
* @uses apply_filters()
|
353 |
+
* @uses get_post_custom_values()
|
354 |
+
* @return array
|
355 |
+
*/
|
356 |
+
public function wpua_add_media_state($states) {
|
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
|
367 |
+
* @since 1.4
|
368 |
+
* @param array $states
|
369 |
+
*/
|
370 |
+
return apply_filters('wpua_add_media_state', $states);
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Initialize
|
376 |
+
* @since 1.9.2
|
377 |
+
*/
|
378 |
+
function wpua_admin_init() {
|
379 |
+
global $wpua_admin;
|
380 |
+
$wpua_admin = new WP_User_Avatar_Admin();
|
381 |
+
}
|
382 |
+
add_action('init', 'wpua_admin_init');
|
includes/class-wp-user-avatar-functions.php
ADDED
@@ -0,0 +1,440 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core user functions.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Functions {
|
10 |
+
/**
|
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
|
22 |
+
* @param int|string $id_or_email
|
23 |
+
* @param bool $has_gravatar
|
24 |
+
* @param int|string $user
|
25 |
+
* @param string $email
|
26 |
+
* @uses get_user_by()
|
27 |
+
* @uses is_wp_error()
|
28 |
+
* @uses wp_cache_get()
|
29 |
+
* @uses wp_cache_set()
|
30 |
+
* @uses wp_remote_head()
|
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
|
56 |
+
* @param int $attachment_id
|
57 |
+
* @uses apply_filters()
|
58 |
+
* @uses wp_attachment_is_image()
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function wpua_attachment_is_image($attachment_id) {
|
62 |
+
$is_image = wp_attachment_is_image($attachment_id);
|
63 |
+
/**
|
64 |
+
* Filter local image check
|
65 |
+
* @since 1.9.2
|
66 |
+
* @param bool $is_image
|
67 |
+
* @param int $attachment_id
|
68 |
+
*/
|
69 |
+
$is_image = apply_filters('wpua_attachment_is_image', $is_image, $attachment_id);
|
70 |
+
return (bool) $is_image;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get local image tag
|
75 |
+
* @since 1.9.2
|
76 |
+
* @param int $attachment_id
|
77 |
+
* @param int|string $size
|
78 |
+
* @param bool $icon
|
79 |
+
* @param string $attr
|
80 |
+
* @uses apply_filters()
|
81 |
+
* @uses wp_get_attachment_image()
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function wpua_get_attachment_image($attachment_id, $size='thumbnail', $icon=0, $attr='') {
|
85 |
+
$image = wp_get_attachment_image($attachment_id, $size, $icon, $attr);
|
86 |
+
/**
|
87 |
+
* Filter local image tag
|
88 |
+
* @since 1.9.2
|
89 |
+
* @param string $image
|
90 |
+
* @param int $attachment_id
|
91 |
+
* @param int|string $size
|
92 |
+
* @param bool $icon
|
93 |
+
* @param string $attr
|
94 |
+
*/
|
95 |
+
return apply_filters('wpua_get_attachment_image', $image, $attachment_id, $size, $icon, $attr);
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get local image src
|
100 |
+
* @since 1.9.2
|
101 |
+
* @param int $attachment_id
|
102 |
+
* @param int|string $size
|
103 |
+
* @param bool $icon
|
104 |
+
* @uses apply_filters()
|
105 |
+
* @uses wp_get_attachment_image_src()
|
106 |
+
* @return array
|
107 |
+
*/
|
108 |
+
public function wpua_get_attachment_image_src($attachment_id, $size='thumbnail', $icon=0) {
|
109 |
+
$image_src_array = wp_get_attachment_image_src($attachment_id, $size, $icon);
|
110 |
+
/**
|
111 |
+
* Filter local image src
|
112 |
+
* @since 1.9.2
|
113 |
+
* @param array $image_src_array
|
114 |
+
* @param int $attachment_id
|
115 |
+
* @param int|string $size
|
116 |
+
* @param bool $icon
|
117 |
+
*/
|
118 |
+
return apply_filters('wpua_get_attachment_image_src', $image_src_array, $attachment_id, $size, $icon);
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Returns true if user has wp_user_avatar
|
123 |
+
* @since 1.1
|
124 |
+
* @param int|string $id_or_email
|
125 |
+
* @param bool $has_wpua
|
126 |
+
* @param object $user
|
127 |
+
* @param int $user_id
|
128 |
+
* @uses int $blog_id
|
129 |
+
* @uses object $wpdb
|
130 |
+
* @uses int $wpua_avatar_default
|
131 |
+
* @uses object $wpua_functions
|
132 |
+
* @uses get_user_by()
|
133 |
+
* @uses get_user_meta()
|
134 |
+
* @uses get_blog_prefix()
|
135 |
+
* @uses wpua_attachment_is_image()
|
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
|
155 |
+
* @param string $avatar
|
156 |
+
* @param int|string $id_or_email
|
157 |
+
* @param int|string $size
|
158 |
+
* @param string $default
|
159 |
+
* @param string $alt
|
160 |
+
* @uses string $avatar_default
|
161 |
+
* @uses string $mustache_admin
|
162 |
+
* @uses string $mustache_avatar
|
163 |
+
* @uses string $mustache_medium
|
164 |
+
* @uses string $mustache_original
|
165 |
+
* @uses string $mustache_thumbnail
|
166 |
+
* @uses object $post
|
167 |
+
* @uses int $wpua_avatar_default
|
168 |
+
* @uses bool $wpua_disable_gravatar
|
169 |
+
* @uses object $wpua_functions
|
170 |
+
* @uses apply_filters()
|
171 |
+
* @uses get_wp_user_avatar()
|
172 |
+
* @uses has_wp_user_avatar()
|
173 |
+
* @uses wpua_has_gravatar()
|
174 |
+
* @uses wpua_attachment_is_image()
|
175 |
+
* @uses wpua_get_attachment_image_src()
|
176 |
+
* @uses get_option()
|
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 {
|
189 |
+
if(has_wp_user_avatar($id_or_email)) {
|
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
|
226 |
+
* @since 1.9
|
227 |
+
* @param string $avatar
|
228 |
+
* @param int|string $id_or_email
|
229 |
+
* @param int|string $size
|
230 |
+
* @param string $default
|
231 |
+
* @param string $alt
|
232 |
+
*/
|
233 |
+
return apply_filters('wpua_get_avatar_filter', $avatar, $id_or_email, $size, $default, $alt);
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Get original avatar, for when user removes wp_user_avatar
|
238 |
+
* @since 1.4
|
239 |
+
* @param int|string $id_or_email
|
240 |
+
* @param int|string $size
|
241 |
+
* @param string $default
|
242 |
+
* @param string $alt
|
243 |
+
* @uses string $avatar_default
|
244 |
+
* @uses string $mustache_avatar
|
245 |
+
* @uses int $wpua_avatar_default
|
246 |
+
* @uses bool $wpua_disable_gravatar
|
247 |
+
* @uses object $wpua_functions
|
248 |
+
* @uses wpua_attachment_is_image()
|
249 |
+
* @uses wpua_get_attachment_image_src()
|
250 |
+
* @uses wpua_has_gravatar()
|
251 |
+
* @uses add_filter()
|
252 |
+
* @uses apply_filters()
|
253 |
+
* @uses get_avatar()
|
254 |
+
* @uses remove_filter()
|
255 |
+
* @return string $default
|
256 |
+
*/
|
257 |
+
public function wpua_get_avatar_original($id_or_email="", $size="", $default="", $alt="") {
|
258 |
+
global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
|
259 |
+
// Remove get_avatar filter
|
260 |
+
remove_filter('get_avatar', array($wpua_functions, 'wpua_get_avatar_filter'));
|
261 |
+
if((bool) $wpua_disable_gravatar != 1) {
|
262 |
+
// User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
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;
|
270 |
+
}
|
271 |
+
} else {
|
272 |
+
// Get image from Gravatar, whether it's the user's image or default image
|
273 |
+
$wpua_image = get_avatar($id_or_email, $size);
|
274 |
+
// Takes the img tag, extracts the src
|
275 |
+
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
276 |
+
$default = !empty($matches) ? $matches [0] [1] : "";
|
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;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
// Enable get_avatar filter
|
287 |
+
add_filter('get_avatar', array($wpua_functions, 'wpua_get_avatar_filter'), 10, 5);
|
288 |
+
/**
|
289 |
+
* Filter original avatar src
|
290 |
+
* @since 1.9
|
291 |
+
* @param string $default
|
292 |
+
*/
|
293 |
+
return apply_filters('wpua_get_avatar_original', $default);
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Find WPUA, show get_avatar if empty
|
298 |
+
* @since 1.0
|
299 |
+
* @param int|string $id_or_email
|
300 |
+
* @param int|string $size
|
301 |
+
* @param string $align
|
302 |
+
* @param string $alt
|
303 |
+
* @uses array $_wp_additional_image_sizes
|
304 |
+
* @uses array $all_sizes
|
305 |
+
* @uses string $avatar_default
|
306 |
+
* @uses int $blog_id
|
307 |
+
* @uses object $post
|
308 |
+
* @uses object $wpdb
|
309 |
+
* @uses int $wpua_avatar_default
|
310 |
+
* @uses object $wpua_functions
|
311 |
+
* @uses apply_filters()
|
312 |
+
* @uses get_the_author_meta()
|
313 |
+
* @uses get_blog_prefix()
|
314 |
+
* @uses get_user_by()
|
315 |
+
* @uses get_query_var()
|
316 |
+
* @uses is_author()
|
317 |
+
* @uses wpua_attachment_is_image()
|
318 |
+
* @uses wpua_get_attachment_image_src()
|
319 |
+
* @uses get_option()
|
320 |
+
* @uses get_avatar()
|
321 |
+
* @return string $avatar
|
322 |
+
*/
|
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) {
|
330 |
+
$email = $id_or_email->user_id;
|
331 |
+
// Checks that comment author isn't anonymous
|
332 |
+
} elseif(!empty($id_or_email->comment_author_email)) {
|
333 |
+
// Checks if comment author is registered user by e-mail address
|
334 |
+
$user = get_user_by('email', $id_or_email->comment_author_email);
|
335 |
+
// Get registered user info from profile, otherwise e-mail address should be value
|
336 |
+
$email = !empty($user) ? $user->ID : $id_or_email->comment_author_email;
|
337 |
+
}
|
338 |
+
$alt = $id_or_email->comment_author;
|
339 |
+
} else {
|
340 |
+
if(!empty($id_or_email)) {
|
341 |
+
// Find user by ID or e-mail address
|
342 |
+
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
343 |
+
} else {
|
344 |
+
// Find author's name if id_or_email is empty
|
345 |
+
$author_name = get_query_var('author_name');
|
346 |
+
if(is_author()) {
|
347 |
+
// On author page, get user by page slug
|
348 |
+
$user = get_user_by('slug', $author_name);
|
349 |
+
} else {
|
350 |
+
// On post, get user by author meta
|
351 |
+
$user_id = get_the_author_meta('ID');
|
352 |
+
$user = get_user_by('id', $user_id);
|
353 |
+
}
|
354 |
+
}
|
355 |
+
// Set user's ID and name
|
356 |
+
if(!empty($user)) {
|
357 |
+
$email = $user->ID;
|
358 |
+
$alt = $user->display_name;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
// Checks if user has WPUA
|
362 |
+
$wpua_meta = get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $email);
|
363 |
+
// Add alignment class
|
364 |
+
$alignclass = !empty($align) && ($align == 'left' || $align == 'right' || $align == 'center') ? ' align'.$align : ' alignnone';
|
365 |
+
// User has WPUA, check if on excluded list and bypass get_avatar
|
366 |
+
if(!empty($wpua_meta) && $wpua_functions->wpua_attachment_is_image($wpua_meta)) {
|
367 |
+
// Numeric size use size array
|
368 |
+
$get_size = is_numeric($size) ? array($size,$size) : $size;
|
369 |
+
// Get image src
|
370 |
+
$wpua_image = $wpua_functions->wpua_get_attachment_image_src($wpua_meta, $get_size);
|
371 |
+
// Add dimensions to img only if numeric size was specified
|
372 |
+
$dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
|
373 |
+
// Construct the img tag
|
374 |
+
$avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo" />';
|
375 |
+
} else {
|
376 |
+
// Check for custom image sizes
|
377 |
+
if(in_array($size, $all_sizes)) {
|
378 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
379 |
+
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
380 |
+
} else {
|
381 |
+
$get_size = $_wp_additional_image_sizes[$size]['width'];
|
382 |
+
}
|
383 |
+
} else {
|
384 |
+
// Numeric sizes leave as-is
|
385 |
+
$get_size = $size;
|
386 |
+
}
|
387 |
+
// User with no WPUA uses get_avatar
|
388 |
+
$avatar = get_avatar($email, $get_size, $default="", $alt="");
|
389 |
+
// Remove width and height for non-numeric sizes
|
390 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
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 |
+
}
|
398 |
+
/**
|
399 |
+
* Filter get_wp_user_avatar
|
400 |
+
* @since 1.9
|
401 |
+
* @param string $avatar
|
402 |
+
* @param int|string $id_or_email
|
403 |
+
* @param int|string $size
|
404 |
+
* @param string $align
|
405 |
+
* @param string $alt
|
406 |
+
*/
|
407 |
+
return apply_filters('get_wp_user_avatar', $avatar, $id_or_email, $size, $align, $alt);
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Return just the image src
|
412 |
+
* @since 1.1
|
413 |
+
* @param int|string $id_or_email
|
414 |
+
* @param int|string $size
|
415 |
+
* @param string $align
|
416 |
+
* @uses get_wp_user_avatar()
|
417 |
+
* @return string
|
418 |
+
*/
|
419 |
+
public function get_wp_user_avatar_src($id_or_email="", $size="", $align="") {
|
420 |
+
$wpua_image_src = "";
|
421 |
+
// Gets the avatar img tag
|
422 |
+
$wpua_image = get_wp_user_avatar($id_or_email, $size, $align);
|
423 |
+
// Takes the img tag, extracts the src
|
424 |
+
if(!empty($wpua_image)) {
|
425 |
+
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
426 |
+
$wpua_image_src = !empty($matches) ? $matches [0] [1] : "";
|
427 |
+
}
|
428 |
+
return $wpua_image_src;
|
429 |
+
}
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Initialize
|
434 |
+
* @since 1.9.2
|
435 |
+
*/
|
436 |
+
function wpua_functions_init() {
|
437 |
+
global $wpua_functions;
|
438 |
+
$wpua_functions = new WP_User_Avatar_Functions();
|
439 |
+
}
|
440 |
+
add_action('plugins_loaded', 'wpua_functions_init');
|
includes/class-wp-user-avatar-list-table.php
ADDED
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Based on WP_Media_List_Table class.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_List_Table extends WP_List_Table {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.8
|
13 |
+
* @param array $args
|
14 |
+
* @uses array $avatars
|
15 |
+
* @uses object $post
|
16 |
+
* @uses int $wpua_avatar_default
|
17 |
+
* @uses get_query_var()
|
18 |
+
* @uses have_posts()
|
19 |
+
* @uses the_post()
|
20 |
+
* @uses wp_edit_attachments_query
|
21 |
+
* @uses WP_Query()
|
22 |
+
* @uses wp_reset_query()
|
23 |
+
*/
|
24 |
+
public function __construct($args = array()) {
|
25 |
+
global $avatars, $post, $wpua_avatar_default;
|
26 |
+
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
|
27 |
+
$q = array(
|
28 |
+
'paged' => $paged,
|
29 |
+
'post_type' => 'attachment',
|
30 |
+
'post_status' => 'inherit',
|
31 |
+
'posts_per_page' => '-1',
|
32 |
+
'meta_query' => array(
|
33 |
+
array(
|
34 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
35 |
+
'value' => "",
|
36 |
+
'compare' => '!='
|
37 |
+
)
|
38 |
+
)
|
39 |
+
);
|
40 |
+
$avatars_wp_query = new WP_Query($q);
|
41 |
+
$avatars = array();
|
42 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
43 |
+
$avatars[] = $post->ID;
|
44 |
+
endwhile;
|
45 |
+
wp_reset_query();
|
46 |
+
// Include default avatar
|
47 |
+
$avatars[] = $wpua_avatar_default;
|
48 |
+
parent::__construct(array(
|
49 |
+
'plural' => 'media',
|
50 |
+
'screen' => isset($args['screen']) ? $args['screen'] : null
|
51 |
+
));
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Only users with edit_users capability can use this section
|
56 |
+
* @since 1.8
|
57 |
+
* @uses current_user_can()
|
58 |
+
*/
|
59 |
+
public function ajax_user_can() {
|
60 |
+
return current_user_can('edit_users');
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Search form
|
65 |
+
* @since 1.8
|
66 |
+
* @param string $text
|
67 |
+
* @param int $input_id
|
68 |
+
* @uses _admin_search_query()
|
69 |
+
* @uses has_items()
|
70 |
+
* @uses submit_button()
|
71 |
+
*/
|
72 |
+
public function search_box($text, $input_id) {
|
73 |
+
if(empty($_REQUEST['s']) && !$this->has_items()) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
$input_id = $input_id.'-search-input';
|
77 |
+
if(!empty($_REQUEST['orderby'])) {
|
78 |
+
echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
|
79 |
+
}
|
80 |
+
if(!empty($_REQUEST['order'])) {
|
81 |
+
echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
|
82 |
+
}
|
83 |
+
if(!empty($_REQUEST['post_mime_type'])) {
|
84 |
+
echo '<input type="hidden" name="post_mime_type" value="'.esc_attr($_REQUEST['post_mime_type']).'" />';
|
85 |
+
}
|
86 |
+
if(!empty($_REQUEST['detached'])) {
|
87 |
+
echo '<input type="hidden" name="detached" value="'.esc_attr($_REQUEST['detached']).'" />';
|
88 |
+
}
|
89 |
+
?>
|
90 |
+
<p class="search-box">
|
91 |
+
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
|
92 |
+
<input type="hidden" id="page" name="page" value="wp-user-avatar-library" />
|
93 |
+
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
94 |
+
<?php submit_button($text, 'button', false, false, array('id' => 'search-submit')); ?>
|
95 |
+
</p>
|
96 |
+
<?php
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Return only avatars and paginate results
|
101 |
+
* @since 1.8
|
102 |
+
* @uses array $avatars
|
103 |
+
* @uses wp_edit_attachments_query()
|
104 |
+
*/
|
105 |
+
public function prepare_items() {
|
106 |
+
global $avail_post_mime_types, $avatars, $lost, $post, $post_mime_types, $wp_query, $wpdb;
|
107 |
+
$q = $_REQUEST;
|
108 |
+
$q['post__in'] = $avatars;
|
109 |
+
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
|
110 |
+
$this->is_trash = isset($_REQUEST['status']) && $_REQUEST['status'] == 'trash';
|
111 |
+
$this->set_pagination_args(array(
|
112 |
+
'total_items' => $wp_query->found_posts,
|
113 |
+
'total_pages' => $wp_query->max_num_pages,
|
114 |
+
'per_page' => $wp_query->query_vars['posts_per_page'],
|
115 |
+
));
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Links to available table views
|
120 |
+
* @since 1.8
|
121 |
+
* @uses array $avatars
|
122 |
+
* @uses add_query_arg()
|
123 |
+
* @uses number_format_i18n()
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public function get_views() {
|
127 |
+
global $avatars;
|
128 |
+
$type_links = array();
|
129 |
+
$_total_posts = count(array_filter($avatars));
|
130 |
+
$class = (empty($_GET['post_mime_type']) && !isset($_GET['status'])) ? ' class="current"' : "";
|
131 |
+
$type_links['all'] = sprintf('<a href="%s">', esc_url(add_query_arg(array('page' => 'wp-user-avatar-library'), 'admin.php'))).sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files'), number_format_i18n($_total_posts)).'</a>';
|
132 |
+
return $type_links;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Bulk action available with this table
|
137 |
+
* @since 1.8
|
138 |
+
* @return array
|
139 |
+
*/
|
140 |
+
public function get_bulk_actions() {
|
141 |
+
$actions = array();
|
142 |
+
$actions['delete'] = __('Delete Permanently');
|
143 |
+
return $actions;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Current action from bulk actions list
|
148 |
+
* @since 1.8
|
149 |
+
* @uses current_action()
|
150 |
+
* @return string|bool
|
151 |
+
*/
|
152 |
+
public function current_action() {
|
153 |
+
return parent::current_action();
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Checks whether table has items
|
158 |
+
* @since 1.8
|
159 |
+
* @uses have_posts()
|
160 |
+
* @return bool
|
161 |
+
*/
|
162 |
+
public function has_items() {
|
163 |
+
return have_posts();
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Message displayed when no items
|
168 |
+
* @since 1.8
|
169 |
+
*/
|
170 |
+
public function no_items() {
|
171 |
+
_e('No media attachments found.');
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Columns in this table
|
176 |
+
* @since 1.8
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
+
public function get_columns() {
|
180 |
+
$columns = array();
|
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;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Sortable columns in this table
|
192 |
+
* @since 1.8
|
193 |
+
* @return array
|
194 |
+
*/
|
195 |
+
public function get_sortable_columns() {
|
196 |
+
return array(
|
197 |
+
'title' => 'title',
|
198 |
+
'author' => 'author',
|
199 |
+
'date' => array('date', true)
|
200 |
+
);
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Display for rows in table
|
205 |
+
* @since 1.8
|
206 |
+
* @uses object $post
|
207 |
+
* @uses object $wpdb
|
208 |
+
* @uses object $wpua_functions
|
209 |
+
* @uses add_filter()
|
210 |
+
* @uses _draft_or_post_title()
|
211 |
+
* @uses _media_states()
|
212 |
+
* @uses current_user_can()
|
213 |
+
* @uses get_attached_file()
|
214 |
+
* @uses get_current_user_id()
|
215 |
+
* @uses get_edit_post_link()
|
216 |
+
* @uses get_edit_user_link()
|
217 |
+
* @uses get_post_mime_type()
|
218 |
+
* @uses get_the_author()
|
219 |
+
* @uses get_the_author_meta()
|
220 |
+
* @uses get_userdata()
|
221 |
+
* @uses have_posts()
|
222 |
+
* @uses the_post()
|
223 |
+
* @uses wpua_get_attachment_image()
|
224 |
+
*/
|
225 |
+
public function display_rows() {
|
226 |
+
global $post, $wpdb, $wpua_functions;
|
227 |
+
add_filter('the_title','esc_html');
|
228 |
+
$alt = "";
|
229 |
+
while (have_posts()) : the_post();
|
230 |
+
$user_can_edit = current_user_can('edit_post', $post->ID);
|
231 |
+
if($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash') {
|
232 |
+
continue;
|
233 |
+
}
|
234 |
+
$alt = ('alternate' == $alt) ? "" : 'alternate';
|
235 |
+
$post_owner = (get_current_user_id() == $post->post_author) ? 'self' : 'other';
|
236 |
+
$att_title = _draft_or_post_title();
|
237 |
+
?>
|
238 |
+
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim($alt.' author-'.$post_owner.' status-'.$post->post_status); ?>' valign="top">
|
239 |
+
<?php
|
240 |
+
list($columns, $hidden) = $this->get_column_info();
|
241 |
+
foreach($columns as $column_name => $column_display_name) {
|
242 |
+
$class = "class='$column_name column-$column_name'";
|
243 |
+
$style = "";
|
244 |
+
if(in_array($column_name, $hidden)) {
|
245 |
+
$style = ' style="display:none;"';
|
246 |
+
}
|
247 |
+
$attributes = $class.$style;
|
248 |
+
switch($column_name) {
|
249 |
+
case 'cb':
|
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>
|
257 |
+
<?php
|
258 |
+
break;
|
259 |
+
case 'icon':
|
260 |
+
$attributes = 'class="column-icon media-icon"'.$style;
|
261 |
+
?>
|
262 |
+
<td <?php echo $attributes ?>><?php
|
263 |
+
if($thumb = $wpua_functions->wpua_get_attachment_image($post->ID, array(80, 60), true)) {
|
264 |
+
if($this->is_trash || !$user_can_edit) {
|
265 |
+
echo $thumb;
|
266 |
+
} else {
|
267 |
+
?>
|
268 |
+
<a href="<?php echo get_edit_post_link($post->ID, true); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>">
|
269 |
+
<?php echo $thumb; ?>
|
270 |
+
</a>
|
271 |
+
<?php } }
|
272 |
+
?>
|
273 |
+
</td>
|
274 |
+
<?php
|
275 |
+
break;
|
276 |
+
case 'title':
|
277 |
+
?>
|
278 |
+
<td <?php echo $attributes ?>><strong>
|
279 |
+
<?php if($this->is_trash || !$user_can_edit) {
|
280 |
+
echo $att_title;
|
281 |
+
} else { ?>
|
282 |
+
<a href="<?php echo get_edit_post_link($post->ID, true); ?>"
|
283 |
+
title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>">
|
284 |
+
<?php echo $att_title; ?></a>
|
285 |
+
<?php };
|
286 |
+
_media_states($post); ?></strong>
|
287 |
+
<p>
|
288 |
+
<?php
|
289 |
+
if(preg_match('/^.*?\.(\w+)$/', get_attached_file($post->ID), $matches)) {
|
290 |
+
echo esc_html(strtoupper($matches[1]));
|
291 |
+
} else {
|
292 |
+
echo strtoupper(str_replace('image/', "", get_post_mime_type()));
|
293 |
+
}
|
294 |
+
?>
|
295 |
+
</p>
|
296 |
+
<?php echo $this->row_actions($this->_get_row_actions($post, $att_title)); ?>
|
297 |
+
</td>
|
298 |
+
<?php
|
299 |
+
break;
|
300 |
+
case 'author':
|
301 |
+
?>
|
302 |
+
<td <?php echo $attributes ?>>
|
303 |
+
<?php
|
304 |
+
printf('<a href="%s">%s</a>',
|
305 |
+
esc_url(add_query_arg(array('author' => get_the_author_meta('ID')), 'upload.php')),
|
306 |
+
get_the_author()
|
307 |
+
); ?>
|
308 |
+
</td>
|
309 |
+
<?php
|
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 |
+
?>
|
327 |
+
<td <?php echo $attributes ?>><?php echo $h_time ?></td>
|
328 |
+
<?php
|
329 |
+
break;
|
330 |
+
case 'parent':
|
331 |
+
global $blog_id, $wpdb;
|
332 |
+
// Find all users with this WPUA
|
333 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
334 |
+
$wpuas = $wpdb->get_results($wpdb->prepare("SELECT wpum.user_id FROM $wpdb->usermeta AS wpum, $wpdb->users AS wpu WHERE wpum.meta_key = %s AND wpum.meta_value = %d AND wpum.user_id = wpu.ID ORDER BY wpu.user_login", $wpua_metakey, $post->ID));
|
335 |
+
// Find users without WPUA
|
336 |
+
$nowpuas = $wpdb->get_results($wpdb->prepare("SELECT wpu.ID FROM $wpdb->users AS wpu, $wpdb->usermeta AS wpum WHERE wpum.meta_key = %s AND wpum.meta_value = %d AND wpum.user_id = wpu.ID ORDER BY wpu.user_login", $wpua_metakey, ""));
|
337 |
+
$user_array = array();
|
338 |
+
?>
|
339 |
+
<td <?php echo $attributes ?>>
|
340 |
+
<strong>
|
341 |
+
<?php
|
342 |
+
if(!empty($wpuas)) {
|
343 |
+
foreach($wpuas as $usermeta) {
|
344 |
+
$user = get_userdata($usermeta->user_id);
|
345 |
+
$user_array[] = '<a href="'.get_edit_user_link($user->ID).'">'.$user->user_login.'</a>';
|
346 |
+
}
|
347 |
+
} else {
|
348 |
+
foreach($nowpuas as $usermeta) {
|
349 |
+
$user = get_userdata($usermeta->ID);
|
350 |
+
$user_array[] = '<a href="'.get_edit_user_link($user->ID).'">'.$user->user_login.'</a>';
|
351 |
+
}
|
352 |
+
}
|
353 |
+
?>
|
354 |
+
<?php echo implode(', ', array_filter($user_array)); ?>
|
355 |
+
</strong>
|
356 |
+
</td>
|
357 |
+
<?php
|
358 |
+
break;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
?>
|
362 |
+
</tr>
|
363 |
+
<?php endwhile;
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Actions for rows in table
|
368 |
+
* @since 1.8
|
369 |
+
* @uses object $post
|
370 |
+
* @uses string $att_title
|
371 |
+
* @uses _draft_or_post_title()
|
372 |
+
* @uses current_user_can()
|
373 |
+
* @uses get_edit_post_link()
|
374 |
+
* @uses get_permalink()
|
375 |
+
* @uses wp_nonce_url()
|
376 |
+
* @return array
|
377 |
+
*/
|
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&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&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&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 “%s”'), $title)).'" rel="permalink">'.__('View').'</a>';
|
397 |
+
}
|
398 |
+
return $actions;
|
399 |
+
}
|
400 |
+
}
|
includes/class-wp-user-avatar-resource-manager.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Move body CSS to head and JS to footer.
|
4 |
+
* Borrowed from NextGEN Gallery C_Photocrati_Resource_Manager class.
|
5 |
+
*
|
6 |
+
* @package WP User Avatar
|
7 |
+
* @version 1.9.13
|
8 |
+
*/
|
9 |
+
|
10 |
+
class WP_User_Avatar_Resource_Manager {
|
11 |
+
static $instance = NULL;
|
12 |
+
|
13 |
+
public $marker = '<!-- wp_user_avatar_resource_manager_marker -->';
|
14 |
+
|
15 |
+
var $buffer = '';
|
16 |
+
var $styles = '';
|
17 |
+
var $other_output = '';
|
18 |
+
var $wrote_footer = FALSE;
|
19 |
+
var $run_shutdown = FALSE;
|
20 |
+
var $valid_request = TRUE;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Start buffering all generated output. We'll then do two things with the buffer
|
24 |
+
* 1) Find stylesheets lately enqueued and move them to the header
|
25 |
+
* 2) Ensure that wp_print_footer_scripts() is called
|
26 |
+
* @since 1.9.5
|
27 |
+
*/
|
28 |
+
function __construct() {
|
29 |
+
// Validate the request
|
30 |
+
$this->validate_request();
|
31 |
+
add_action('init', array(&$this, 'start_buffer'), 1);
|
32 |
+
add_action('wp_footer', array(&$this, 'print_marker'), -1);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Created early as possible in the wp_footer action this is the string to which we
|
37 |
+
* will move JS resources after
|
38 |
+
* @since 1.9.8
|
39 |
+
*/
|
40 |
+
function print_marker() {
|
41 |
+
print $this->marker;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Determines if the resource manager should perform its routines for this request
|
46 |
+
* @since 1.9.5
|
47 |
+
* @return bool
|
48 |
+
*/
|
49 |
+
function validate_request() {
|
50 |
+
$retval = TRUE;
|
51 |
+
if(is_admin()) {
|
52 |
+
if(isset($_REQUEST['page']) && !preg_match("#^(wp_user_avatar)#", $_REQUEST['page'])) {
|
53 |
+
$retval = FALSE;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
if(strpos($_SERVER['REQUEST_URI'], 'wp-admin/update') !== FALSE) {
|
57 |
+
$retval = FALSE;
|
58 |
+
} elseif(isset($_GET['display_gallery_iframe'])) {
|
59 |
+
$retval = FALSE;
|
60 |
+
} elseif(defined('WP_ADMIN') && WP_ADMIN && defined('DOING_AJAX') && DOING_AJAX) {
|
61 |
+
$retval = FALSE;
|
62 |
+
} elseif(preg_match("/(js|css|xsl|xml|kml)$/", $_SERVER['REQUEST_URI'])) {
|
63 |
+
$retval = FALSE;
|
64 |
+
} elseif(preg_match("/\\.(\\w{3,4})$/", $_SERVER['REQUEST_URI'], $match)) {
|
65 |
+
if(!in_array($match[1], array('htm', 'html', 'php'))) {
|
66 |
+
$retval = FALSE;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
$this->valid_request = $retval;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Start the output buffers
|
74 |
+
* @since 1.9.5
|
75 |
+
*/
|
76 |
+
function start_buffer() {
|
77 |
+
if(defined('WPUA_DISABLE_RESOURCE_MANAGER') && WPUA_DISABLE_RESOURCE_MANAGER) {
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
if(apply_filters('run_wpua_resource_manager', $this->valid_request)) {
|
81 |
+
ob_start(array(&$this, 'output_buffer_handler'));
|
82 |
+
ob_start(array(&$this, 'get_buffer'));
|
83 |
+
add_action('wp_print_footer_scripts', array(&$this, 'get_resources'), 1);
|
84 |
+
add_action('admin_print_footer_scripts', array(&$this, 'get_resources'), 1);
|
85 |
+
add_action('shutdown', array(&$this, 'shutdown'));
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @since 1.9.5
|
91 |
+
*/
|
92 |
+
function get_resources() {
|
93 |
+
ob_start();
|
94 |
+
wp_print_styles();
|
95 |
+
print_admin_styles();
|
96 |
+
$this->styles = ob_get_clean();
|
97 |
+
if(!is_admin()) {
|
98 |
+
ob_start();
|
99 |
+
wp_print_scripts();
|
100 |
+
$this->scripts = ob_get_clean();
|
101 |
+
}
|
102 |
+
$this->wrote_footer = TRUE;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Output the buffer after PHP execution has ended (but before shutdown)
|
107 |
+
* @since 1.9.5
|
108 |
+
* @param string $content
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
function output_buffer_handler($content) {
|
112 |
+
return $this->output_buffer();
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Removes the closing </html> tag from the output buffer. We'll then write our own closing tag
|
117 |
+
* in the shutdown function after running wp_print_footer_scripts()
|
118 |
+
* @since 1.9.5
|
119 |
+
* @param string $content
|
120 |
+
* @return mixed
|
121 |
+
*/
|
122 |
+
function get_buffer($content) {
|
123 |
+
$this->buffer = $content;
|
124 |
+
return '';
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Moves resources to their appropriate place
|
130 |
+
* @since 1.9.5
|
131 |
+
*/
|
132 |
+
function move_resources() {
|
133 |
+
if($this->valid_request) {
|
134 |
+
// Move stylesheets to head
|
135 |
+
if($this->styles) {
|
136 |
+
$this->buffer = str_ireplace('</head>', $this->styles.'</head>', $this->buffer);
|
137 |
+
}
|
138 |
+
// Move the scripts to the bottom of the page
|
139 |
+
if($this->scripts) {
|
140 |
+
$this->buffer = str_ireplace($this->marker, $this->marker.$this->scripts, $this->buffer);
|
141 |
+
}
|
142 |
+
if($this->other_output) {
|
143 |
+
$this->buffer = str_replace($this->marker, $this->marker.$this->other_output, $this->buffer);
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* When PHP has finished, we output the footer scripts and closing tags
|
150 |
+
* @since 1.9.5
|
151 |
+
*/
|
152 |
+
function output_buffer($in_shutdown=FALSE) {
|
153 |
+
// If the footer scripts haven't been outputted, then
|
154 |
+
// we need to take action - as they're required
|
155 |
+
if(!$this->wrote_footer) {
|
156 |
+
// If W3TC is installed and activated, we can't output the
|
157 |
+
// scripts and manipulate the buffer, so we can only provide a warning
|
158 |
+
if(defined('W3TC') && defined('WP_DEBUG') && WP_DEBUG && !is_admin()) {
|
159 |
+
if(!defined('DONOTCACHEPAGE')) define('DONOTCACHEPAGE', TRUE);
|
160 |
+
if(!did_action('wp_footer')) {
|
161 |
+
error_log("We're sorry, but your theme's page template didn't make a call to wp_footer(), which is required by WP User Avatar. Please add this call to your page templates.");
|
162 |
+
} else {
|
163 |
+
error_log("We're sorry, but your theme's page template didn't make a call to wp_print_footer_scripts(), which is required by WP User Avatar. Please add this call to your page templates.");
|
164 |
+
}
|
165 |
+
// We don't want to manipulate the buffer if it doesn't contain HTML
|
166 |
+
} elseif(strpos($this->buffer, '</body>') === FALSE) {
|
167 |
+
$this->valid_request = FALSE;
|
168 |
+
}
|
169 |
+
// The output_buffer() function has been called in the PHP shutdown callback
|
170 |
+
// This will allow us to print the scripts ourselves and manipulate the buffer
|
171 |
+
if($in_shutdown === TRUE) {
|
172 |
+
ob_start();
|
173 |
+
if(!did_action('wp_footer')) {
|
174 |
+
wp_footer();
|
175 |
+
} else {
|
176 |
+
wp_print_footer_scripts();
|
177 |
+
}
|
178 |
+
$this->other_output = ob_get_clean();
|
179 |
+
}
|
180 |
+
// W3TC isn't activated and we're not in the shutdown callback.
|
181 |
+
// We'll therefore add a shutdown callback to print the scripts
|
182 |
+
else {
|
183 |
+
$this->run_shutdown = TRUE;
|
184 |
+
return '';
|
185 |
+
}
|
186 |
+
}
|
187 |
+
// Once we have the footer scripts, we can modify the buffer and
|
188 |
+
// move the resources around
|
189 |
+
if ($this->wrote_footer) $this->move_resources();
|
190 |
+
return $this->buffer;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* PHP shutdown callback. Manipulate and output the buffer
|
195 |
+
* @since 1.9.5
|
196 |
+
*/
|
197 |
+
function shutdown() {
|
198 |
+
if($this->run_shutdown) echo $this->output_buffer(TRUE);
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @since 1.9.5
|
203 |
+
*/
|
204 |
+
static function init() {
|
205 |
+
$klass = get_class();
|
206 |
+
return self::$instance = new $klass;
|
207 |
+
}
|
208 |
+
}
|
includes/class-wp-user-avatar-shortcode.php
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines shortcodes.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Shortcode {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.8
|
13 |
+
* @uses object $wp_user_avatar
|
14 |
+
* @uses add_action()
|
15 |
+
* @uses add_shortcode()
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
global $wp_user_avatar;
|
19 |
+
add_shortcode('avatar', array($this, 'wpua_shortcode'));
|
20 |
+
add_shortcode('avatar_upload', array($this, 'wpua_edit_shortcode'));
|
21 |
+
// Add avatar and scripts to avatar_upload
|
22 |
+
add_action('wpua_show_profile', array($wp_user_avatar, 'wpua_action_show_user_profile'));
|
23 |
+
add_action('wpua_show_profile', array($wp_user_avatar, 'wpua_media_upload_scripts'));
|
24 |
+
add_action('wpua_update', array($wp_user_avatar, 'wpua_action_process_option_update'));
|
25 |
+
// Add error messages to avatar_upload
|
26 |
+
add_action('wpua_update_errors', array($wp_user_avatar, 'wpua_upload_errors'), 10, 3);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Display shortcode
|
31 |
+
* @since 1.4
|
32 |
+
* @param array $atts
|
33 |
+
* @param string $content
|
34 |
+
* @uses array $_wp_additional_image_sizes
|
35 |
+
* @uses array $all_sizes
|
36 |
+
* @uses int $blog_id
|
37 |
+
* @uses object $post
|
38 |
+
* @uses object $wpdb
|
39 |
+
* @uses do_shortcode()
|
40 |
+
* @uses get_attachment_link()
|
41 |
+
* @uses get_blog_prefix()
|
42 |
+
* @uses get_option()
|
43 |
+
* @uses get_user_by()
|
44 |
+
* @uses get_query_var()
|
45 |
+
* @uses get_the_author_meta()
|
46 |
+
* @uses get_user_meta()
|
47 |
+
* @uses get_wp_user_avatar_src()
|
48 |
+
* @uses get_wp_user_avatar()
|
49 |
+
* @uses image_add_caption()
|
50 |
+
* @uses is_author()
|
51 |
+
* @uses shortcode_atts()
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function wpua_shortcode($atts, $content=null) {
|
55 |
+
global $all_sizes, $blog_id, $post, $wpdb;
|
56 |
+
// Set shortcode attributes
|
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');
|
66 |
+
if(is_author()) {
|
67 |
+
// On author page, get user by page slug
|
68 |
+
$user = get_user_by('slug', $author_name);
|
69 |
+
} else {
|
70 |
+
// On post, get user by author meta
|
71 |
+
$user_id = get_the_author_meta('ID');
|
72 |
+
$user = get_user_by('id', $user_id);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
// Numeric sizes leave as-is
|
76 |
+
$get_size = $size;
|
77 |
+
// Check for custom image sizes if there are captions
|
78 |
+
if(!empty($content)) {
|
79 |
+
if(in_array($size, $all_sizes)) {
|
80 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
81 |
+
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
82 |
+
} else {
|
83 |
+
$get_size = $_wp_additional_image_sizes[$size]['width'];
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
// Get user ID
|
88 |
+
$id_or_email = !empty($user) ? $user->ID : 'unknown@gravatar.com';
|
89 |
+
// Check if link is set
|
90 |
+
if(!empty($link)) {
|
91 |
+
// CSS class is same as link type, except for URL
|
92 |
+
$link_class = $link;
|
93 |
+
if($link == 'file') {
|
94 |
+
// Get image src
|
95 |
+
$link = get_wp_user_avatar_src($id_or_email, 'original');
|
96 |
+
} elseif($link == 'attachment') {
|
97 |
+
// Get attachment URL
|
98 |
+
$link = get_attachment_link(get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email));
|
99 |
+
} else {
|
100 |
+
// URL
|
101 |
+
$link_class = 'custom';
|
102 |
+
}
|
103 |
+
// Open in new window
|
104 |
+
$target_link = !empty($target) ? ' target="'.$target.'"' : "";
|
105 |
+
// Wrap the avatar inside the link
|
106 |
+
$html = '<a href="'.$link.'" class="wp-user-avatar-link wp-user-avatar-'.$link_class.'"'.$target_link.'>'.get_wp_user_avatar($id_or_email, $get_size, $align).'</a>';
|
107 |
+
} else {
|
108 |
+
$html = get_wp_user_avatar($id_or_email, $get_size, $align);
|
109 |
+
}
|
110 |
+
// Check if caption is set
|
111 |
+
if(!empty($content)) {
|
112 |
+
// Get attachment ID
|
113 |
+
$wpua = get_user_meta($id_or_email, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
114 |
+
// Clean up caption
|
115 |
+
$content = trim($content);
|
116 |
+
$content = preg_replace('/\r|\n/', "", $content);
|
117 |
+
$content = preg_replace('/<\/p><p>/', "", $content, 1);
|
118 |
+
$content = preg_replace('/<\/p><p>$/', "", $content);
|
119 |
+
$content = str_replace('</p><p>', "<br /><br />", $content);
|
120 |
+
$avatar = do_shortcode(image_add_caption($html, $wpua, $content, $title="", $align, $link, $get_size, $alt=""));
|
121 |
+
} else {
|
122 |
+
$avatar = $html;
|
123 |
+
}
|
124 |
+
return $avatar;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Update user
|
129 |
+
* @since 1.8
|
130 |
+
* @param bool $user_id
|
131 |
+
* @uses add_query_arg()
|
132 |
+
* @uses apply_filters()
|
133 |
+
* @uses do_action_ref_array()
|
134 |
+
* @uses wp_get_referer()
|
135 |
+
* @uses wp_redirect()
|
136 |
+
* @uses wp_safe_redirect()
|
137 |
+
*/
|
138 |
+
private function wpua_edit_user($user_id=0) {
|
139 |
+
$update = $user_id ? true : false;
|
140 |
+
$user = new stdClass;
|
141 |
+
$errors = new WP_Error();
|
142 |
+
do_action_ref_array('wpua_update_errors', array(&$errors, $update, &$user));
|
143 |
+
if($errors->get_error_codes()) {
|
144 |
+
// Return with errors
|
145 |
+
return $errors;
|
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
|
153 |
+
* @param string $redirect_url
|
154 |
+
*/
|
155 |
+
$redirect_url = apply_filters('wpua_edit_user_redirect_url', $redirect_url);
|
156 |
+
/**
|
157 |
+
* Filter wp_safe_redirect or wp_redirect
|
158 |
+
* @since 1.9.12
|
159 |
+
* @param bool $safe_redirect
|
160 |
+
*/
|
161 |
+
$safe_redirect = apply_filters('wpua_edit_user_safe_redirect', true);
|
162 |
+
$safe_redirect ? wp_safe_redirect($redirect_url) : wp_redirect($redirect_url);
|
163 |
+
exit;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Edit shortcode
|
169 |
+
* @since 1.8
|
170 |
+
* @param array $atts
|
171 |
+
* @uses $wp_user_avatar
|
172 |
+
* @uses $wpua_allow_upload
|
173 |
+
* @uses current_user_can()
|
174 |
+
* @uses do_action()
|
175 |
+
* @uses get_error_messages()
|
176 |
+
* @uses get_user_by()
|
177 |
+
* @uses is_user_logged_in()
|
178 |
+
* @uses is_wp_error()
|
179 |
+
* @uses shortcode_atts()
|
180 |
+
* @uses wpua_edit_form()
|
181 |
+
* @uses wpua_edit_user()
|
182 |
+
* @uses wpua_is_author_or_above()
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function wpua_edit_shortcode($atts) {
|
186 |
+
global $current_user, $errors, $wp_user_avatar, $wpua_allow_upload;
|
187 |
+
// Shortcode only works for users with permission
|
188 |
+
if($wp_user_avatar->wpua_is_author_or_above() || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())) {
|
189 |
+
extract(shortcode_atts(array('user' => ""), $atts));
|
190 |
+
// Default user is current user
|
191 |
+
$valid_user = $current_user;
|
192 |
+
// Find user by ID, login, slug, or e-mail address
|
193 |
+
if(!empty($user)) {
|
194 |
+
$get_user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
|
195 |
+
$get_user = empty($get_user) ? get_user_by('slug', $user) : $get_user;
|
196 |
+
$get_user = empty($get_user) ? get_user_by('email', $user) : $get_user;
|
197 |
+
// Check if current user can edit this user
|
198 |
+
$valid_user = current_user_can('edit_user', $get_user) ? $get_user : null;
|
199 |
+
}
|
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);
|
207 |
+
}
|
208 |
+
// Errors
|
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);
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Edit form
|
222 |
+
* @since 1.8
|
223 |
+
* @param object $user
|
224 |
+
* @uses do_action()
|
225 |
+
* @uses submit_button()
|
226 |
+
* @uses wp_nonce_field()
|
227 |
+
*/
|
228 |
+
private function wpua_edit_form($user) {
|
229 |
+
ob_start();
|
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();
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Initialize
|
245 |
+
* @since 1.9.2
|
246 |
+
*/
|
247 |
+
function wpua_shortcode_init() {
|
248 |
+
global $wpua_shortcode;
|
249 |
+
$wpua_shortcode = new WP_User_Avatar_Shortcode();
|
250 |
+
// Clean output
|
251 |
+
ob_start();
|
252 |
+
}
|
253 |
+
add_action('init', 'wpua_shortcode_init');
|
includes/class-wp-user-avatar-subscriber.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Settings only for subscribers and contributors.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Subscriber {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.8
|
13 |
+
* @uses object $wp_user_avatar
|
14 |
+
* @uses bool $wpua_allow_upload
|
15 |
+
* @uses add_action()
|
16 |
+
* @uses current_user_can()
|
17 |
+
* @uses wpua_is_author_or_above()
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
global $wp_user_avatar, $wpua_allow_upload;
|
21 |
+
if((bool) $wpua_allow_upload == 1) {
|
22 |
+
add_action('user_edit_form_tag', array($this, 'wpua_add_edit_form_multipart_encoding'));
|
23 |
+
// Only Subscribers lack delete_posts capability
|
24 |
+
if(!current_user_can('delete_posts') && current_user_can('edit_posts') && !$wp_user_avatar->wpua_is_author_or_above()) {
|
25 |
+
add_action('admin_menu', array($this, 'wpua_subscriber_remove_menu_pages'));
|
26 |
+
add_action('wp_before_admin_bar_render', array($this, 'wpua_subscriber_remove_menu_bar_items'));
|
27 |
+
add_action('wp_dashboard_setup', array($this, 'wpua_subscriber_remove_dashboard_widgets'));
|
28 |
+
add_action('admin_init', array($this, 'wpua_subscriber_offlimits'));
|
29 |
+
}
|
30 |
+
}
|
31 |
+
add_action('admin_init', array($this, 'wpua_subscriber_capability'));
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Allow multipart data in form
|
36 |
+
* @since 1.4.1
|
37 |
+
*/
|
38 |
+
public function wpua_add_edit_form_multipart_encoding() {
|
39 |
+
echo ' enctype="multipart/form-data"';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Remove menu items
|
44 |
+
* @since 1.4
|
45 |
+
* @uses remove_menu_page()
|
46 |
+
*/
|
47 |
+
public function wpua_subscriber_remove_menu_pages() {
|
48 |
+
remove_menu_page('edit.php');
|
49 |
+
remove_menu_page('edit-comments.php');
|
50 |
+
remove_menu_page('tools.php');
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Remove menu bar items
|
55 |
+
* @since 1.5.1
|
56 |
+
* @uses object $wp_admin_bar
|
57 |
+
* @uses remove_menu()
|
58 |
+
*/
|
59 |
+
public function wpua_subscriber_remove_menu_bar_items() {
|
60 |
+
global $wp_admin_bar;
|
61 |
+
$wp_admin_bar->remove_menu('comments');
|
62 |
+
$wp_admin_bar->remove_menu('new-content');
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Remove dashboard items
|
67 |
+
* @since 1.4
|
68 |
+
* @uses remove_meta_box()
|
69 |
+
*/
|
70 |
+
public function wpua_subscriber_remove_dashboard_widgets() {
|
71 |
+
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
|
72 |
+
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
|
73 |
+
remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Restrict access to pages
|
78 |
+
* @since 1.4
|
79 |
+
* @uses string $pagenow
|
80 |
+
* @uses bool $wpua_edit_avatar
|
81 |
+
* @uses apply_filters()
|
82 |
+
* @uses do_action()
|
83 |
+
* @uses wp_die()
|
84 |
+
*/
|
85 |
+
public function wpua_subscriber_offlimits() {
|
86 |
+
global $pagenow, $wpua_edit_avatar;
|
87 |
+
$offlimits = array('edit.php', 'edit-comments.php', 'post-new.php', 'tools.php');
|
88 |
+
if((bool) $wpua_edit_avatar != 1) {
|
89 |
+
array_push($offlimits, 'post.php');
|
90 |
+
}
|
91 |
+
/**
|
92 |
+
* Filter restricted pages
|
93 |
+
* @since 1.9
|
94 |
+
* @param array $offlimits
|
95 |
+
*/
|
96 |
+
$offlimits = apply_filters('wpua_subscriber_offlimits', $offlimits);
|
97 |
+
if(in_array($pagenow, $offlimits)) {
|
98 |
+
do_action('admin_page_access_denied');
|
99 |
+
wp_die(__('You do not have sufficient permissions to access this page.'));
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Give subscribers edit_posts capability
|
105 |
+
* @since 1.8.3
|
106 |
+
* @uses int $blog_id
|
107 |
+
* @uses object $wpdb
|
108 |
+
* @uses bool $wpua_allow_upload
|
109 |
+
* @uses bool $wpua_edit_avatar
|
110 |
+
* @uses get_blog_prefix()
|
111 |
+
* @uses get_option()
|
112 |
+
* @uses update_option()
|
113 |
+
*/
|
114 |
+
public function wpua_subscriber_capability() {
|
115 |
+
global $blog_id, $wpdb, $wpua_allow_upload, $wpua_edit_avatar;
|
116 |
+
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
117 |
+
$user_roles = get_option($wp_user_roles);
|
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 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Initialize
|
129 |
+
* @since 1.9.5
|
130 |
+
*/
|
131 |
+
function wpua_subscriber_init() {
|
132 |
+
global $wpua_subscriber;
|
133 |
+
$wpua_subscriber = new WP_User_Avatar_Subscriber();
|
134 |
+
}
|
135 |
+
add_action('init', 'wpua_subscriber_init');
|
includes/class-wp-user-avatar-update.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Updates for legacy settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Update {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.8
|
13 |
+
* @uses bool $wpua_default_avatar_updated
|
14 |
+
* @uses bool $wpua_media_updated
|
15 |
+
* @uses bool $wpua_users_updated
|
16 |
+
* @uses add_action()
|
17 |
+
*/
|
18 |
+
public function __construct() {
|
19 |
+
global $wpua_default_avatar_updated, $wpua_media_updated, $wpua_users_updated;
|
20 |
+
if(empty($wpua_default_avatar_updated)) {
|
21 |
+
add_action('admin_init', array($this, 'wpua_default_avatar'));
|
22 |
+
}
|
23 |
+
if(empty($wpua_users_updated)) {
|
24 |
+
add_action('admin_init', array($this, 'wpua_user_meta'));
|
25 |
+
}
|
26 |
+
if(empty($wpua_media_updated)) {
|
27 |
+
add_action('admin_init', array($this, 'wpua_media_state'));
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Update default avatar to new format
|
33 |
+
* @since 1.4
|
34 |
+
* @uses string $avatar_default
|
35 |
+
* @uses string $mustache_original
|
36 |
+
* @uses int $wpua_avatar_default
|
37 |
+
* @uses update_option()
|
38 |
+
* @uses wp_get_attachment_image_src()
|
39 |
+
*/
|
40 |
+
public function wpua_default_avatar() {
|
41 |
+
global $avatar_default, $mustache_original, $wpua_avatar_default;
|
42 |
+
// If default avatar is the old mustache URL, update it
|
43 |
+
if($avatar_default == $mustache_original) {
|
44 |
+
update_option('avatar_default', 'wp_user_avatar');
|
45 |
+
}
|
46 |
+
// If user had an image URL as the default avatar, replace with ID instead
|
47 |
+
if(!empty($wpua_avatar_default)) {
|
48 |
+
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, 'medium');
|
49 |
+
if($avatar_default == $wpua_avatar_default_image[0]) {
|
50 |
+
update_option('avatar_default', 'wp_user_avatar');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
update_option('wp_user_avatar_default_avatar_updated', '1');
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Rename user meta to match database settings
|
58 |
+
* @since 1.4
|
59 |
+
* @uses int $blog_id
|
60 |
+
* @uses object $wpdb
|
61 |
+
* @uses delete_user_meta()
|
62 |
+
* @uses get_blog_prefix()
|
63 |
+
* @uses get_user_meta()
|
64 |
+
* @uses get_users()
|
65 |
+
* @uses update_option()
|
66 |
+
* @uses update_user_meta()
|
67 |
+
*/
|
68 |
+
public function wpua_user_meta() {
|
69 |
+
global $blog_id, $wpdb;
|
70 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
71 |
+
// If database tables start with something other than wp_
|
72 |
+
if($wpua_metakey != 'wp_user_avatar') {
|
73 |
+
$users = get_users();
|
74 |
+
// Move current user metakeys to new metakeys
|
75 |
+
foreach($users as $user) {
|
76 |
+
$wpua = get_user_meta($user->ID, 'wp_user_avatar', true);
|
77 |
+
if(!empty($wpua)) {
|
78 |
+
update_user_meta($user->ID, $wpua_metakey, $wpua);
|
79 |
+
delete_user_meta($user->ID, 'wp_user_avatar');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
update_option('wp_user_avatar_users_updated', '1');
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Add media state to existing avatars
|
88 |
+
* @since 1.4
|
89 |
+
* @uses int $blog_id
|
90 |
+
* @uses object $wpdb
|
91 |
+
* @uses add_post_meta()
|
92 |
+
* @uses get_blog_prefix()
|
93 |
+
* @uses get_results()
|
94 |
+
* @uses update_option()
|
95 |
+
*/
|
96 |
+
public function wpua_media_state() {
|
97 |
+
global $blog_id, $wpdb;
|
98 |
+
// Find all users with WPUA
|
99 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
100 |
+
$wpuas = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != %d AND meta_value != %d", $wpua_metakey, 0, ""));
|
101 |
+
foreach($wpuas as $usermeta) {
|
102 |
+
add_post_meta($usermeta->meta_value, '_wp_attachment_wp_user_avatar', $usermeta->user_id);
|
103 |
+
}
|
104 |
+
update_option('wp_user_avatar_media_updated', '1');
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Initialize
|
110 |
+
* @since 1.9.2
|
111 |
+
*/
|
112 |
+
function wpua_update_init() {
|
113 |
+
global $wpua_update;
|
114 |
+
$wpua_update = new WP_User_Avatar_Update();
|
115 |
+
}
|
116 |
+
add_action('init', 'wpua_update_init');
|
includes/class-wp-user-avatar-widget.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines widgets.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Profile_Widget extends WP_Widget {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.9.4
|
13 |
+
*/
|
14 |
+
public function __construct() {
|
15 |
+
$widget_ops = array('classname' => 'widget_wp_user_avatar', 'description' => __('Insert').' '.__('[avatar_upload]', 'wp-user-avatar').'.');
|
16 |
+
parent::__construct('wp_user_avatar_profile', __('WP User Avatar', 'wp-user-avatar'), $widget_ops);
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Add [avatar_upload] to widget
|
21 |
+
* @since 1.9.4
|
22 |
+
* @param array $args
|
23 |
+
* @param array $instance
|
24 |
+
* @uses object $wp_user_avatar
|
25 |
+
* @uses bool $wpua_allow_upload
|
26 |
+
* @uses object $wpua_shortcode
|
27 |
+
* @uses add_filter()
|
28 |
+
* @uses apply_filters()
|
29 |
+
* @uses is_user_logged_in()
|
30 |
+
* @uses remove_filter()
|
31 |
+
* @uses wpua_edit_shortcode()
|
32 |
+
* @uses wpua_is_author_or_above()
|
33 |
+
*/
|
34 |
+
public function widget($args, $instance) {
|
35 |
+
global $wp_user_avatar, $wpua_allow_upload, $wpua_shortcode;
|
36 |
+
extract($args);
|
37 |
+
$instance = apply_filters('wpua_widget_instance', $instance);
|
38 |
+
$title = apply_filters('widget_title', empty($instance['title']) ? "" : $instance['title'], $instance, $this->id_base);
|
39 |
+
$text = apply_filters('widget_text', empty($instance['text']) ? "" : $instance['text'], $instance);
|
40 |
+
// Show widget only for users with permission
|
41 |
+
if($wp_user_avatar->wpua_is_author_or_above() || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())) {
|
42 |
+
echo $before_widget;
|
43 |
+
if(!empty($title)) {
|
44 |
+
echo $before_title.$title.$after_title;
|
45 |
+
}
|
46 |
+
if(!empty($text)) {
|
47 |
+
echo '<div class="textwidget">';
|
48 |
+
echo !empty($instance['filter']) ? wpautop($text) : $text;
|
49 |
+
echo '</div>';
|
50 |
+
}
|
51 |
+
// Remove profile title
|
52 |
+
add_filter('wpua_profile_title', '__return_null');
|
53 |
+
// Get [avatar_upload] shortcode
|
54 |
+
echo $wpua_shortcode->wpua_edit_shortcode("");
|
55 |
+
remove_filter('wpua_profile_title', '__return_null');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Set title
|
61 |
+
* @since 1.9.4
|
62 |
+
* @param array $instance
|
63 |
+
* @uses wp_parse_args()
|
64 |
+
*/
|
65 |
+
public function form($instance) {
|
66 |
+
$instance = wp_parse_args((array) $instance, array('title' => "", 'text' => ""));
|
67 |
+
$title = strip_tags($instance['title']);
|
68 |
+
$text = esc_textarea($instance['text']);
|
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
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Update widget
|
89 |
+
* @since 1.9.4
|
90 |
+
* @param array $new_instance
|
91 |
+
* @param array $old_instance
|
92 |
+
* @uses current_user_can()
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function update($new_instance, $old_instance) {
|
96 |
+
$instance = $old_instance;
|
97 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
98 |
+
if(current_user_can('unfiltered_html')) {
|
99 |
+
$instance['text'] = $new_instance['text'];
|
100 |
+
} else {
|
101 |
+
$instance['text'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['text'])));
|
102 |
+
}
|
103 |
+
$instance['filter'] = isset($new_instance['filter']);
|
104 |
+
return $instance;
|
105 |
+
}
|
106 |
+
}
|
includes/class-wp-user-avatar.php
ADDED
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines all profile and upload settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar {
|
10 |
+
/**
|
11 |
+
* Constructor
|
12 |
+
* @since 1.8
|
13 |
+
* @uses string $pagenow
|
14 |
+
* @uses bool $show_avatars
|
15 |
+
* @uses object $wpua_admin
|
16 |
+
* @uses bool $wpua_allow_upload
|
17 |
+
* @uses add_action()
|
18 |
+
* @uses add_filterI]()
|
19 |
+
* @uses is_admin()
|
20 |
+
* @uses is_user_logged_in()
|
21 |
+
* @uses wpua_is_author_or_above()
|
22 |
+
* @uses wpua_is_menu_page()
|
23 |
+
*/
|
24 |
+
public function __construct() {
|
25 |
+
global $pagenow, $show_avatars, $wpua_admin, $wpua_allow_upload;
|
26 |
+
// Add WPUA to profile for users with permission
|
27 |
+
if($this->wpua_is_author_or_above() || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())) {
|
28 |
+
// Profile functions and scripts
|
29 |
+
add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
30 |
+
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
31 |
+
add_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
32 |
+
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
33 |
+
add_action('user_new_form', array($this, 'wpua_action_show_user_profile'));
|
34 |
+
add_action('user_register', array($this, 'wpua_action_process_option_update'));
|
35 |
+
// Admin scripts
|
36 |
+
$pages = array('profile.php', 'options-discussion.php', 'user-edit.php', 'user-new.php');
|
37 |
+
if(in_array($pagenow, $pages) || $wpua_admin->wpua_is_menu_page()) {
|
38 |
+
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
39 |
+
}
|
40 |
+
// Front pages
|
41 |
+
if(!is_admin()) {
|
42 |
+
add_action('show_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
43 |
+
add_action('edit_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
44 |
+
}
|
45 |
+
if(!$this->wpua_is_author_or_above()) {
|
46 |
+
// Upload errors
|
47 |
+
add_action('user_profile_update_errors', array($this, 'wpua_upload_errors'), 10, 3);
|
48 |
+
// Prefilter upload size
|
49 |
+
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
add_filter('media_view_settings', array($this, 'wpua_media_view_settings'), 10, 1);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Avatars have no parent posts
|
57 |
+
* @since 1.8.4
|
58 |
+
* @param array $settings
|
59 |
+
* @uses object $post
|
60 |
+
* @uses bool $wpua_is_profile
|
61 |
+
* @uses is_admin()
|
62 |
+
* array $settings
|
63 |
+
*/
|
64 |
+
public function wpua_media_view_settings($settings) {
|
65 |
+
global $post, $wpua_is_profile;
|
66 |
+
// Get post ID so not to interfere with media uploads
|
67 |
+
$post_id = is_object($post) ? $post->ID : 0;
|
68 |
+
// Don't use post ID on front pages if there's a WPUA uploader
|
69 |
+
$settings['post']['id'] = (!is_admin() && $wpua_is_profile == 1) ? 0 : $post_id;
|
70 |
+
return $settings;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Media Uploader
|
75 |
+
* @since 1.4
|
76 |
+
* @param object $user
|
77 |
+
* @uses object $current_user
|
78 |
+
* @uses string $mustache_admin
|
79 |
+
* @uses string $pagenow
|
80 |
+
* @uses object $post
|
81 |
+
* @uses bool $show_avatars
|
82 |
+
* @uses object $wp_user_avatar
|
83 |
+
* @uses object $wpua_admin
|
84 |
+
* @uses object $wpua_functions
|
85 |
+
* @uses bool $wpua_is_profile
|
86 |
+
* @uses int $wpua_upload_size_limit
|
87 |
+
* @uses get_user_by()
|
88 |
+
* @uses wp_enqueue_script()
|
89 |
+
* @uses wp_enqueue_media()
|
90 |
+
* @uses wp_enqueue_style()
|
91 |
+
* @uses wp_localize_script()
|
92 |
+
* @uses wp_max_upload_size()
|
93 |
+
* @uses wpua_get_avatar_original()
|
94 |
+
* @uses wpua_is_author_or_above()
|
95 |
+
* @uses wpua_is_menu_page()
|
96 |
+
*/
|
97 |
+
public static function wpua_media_upload_scripts($user="") {
|
98 |
+
global $current_user, $mustache_admin, $pagenow, $post, $show_avatars, $wp_user_avatar, $wpua_admin, $wpua_functions, $wpua_is_profile, $wpua_upload_size_limit;
|
99 |
+
// This is a profile page
|
100 |
+
$wpua_is_profile = 1;
|
101 |
+
$user = ($pagenow == 'user-edit.php' && isset($_GET['user_id'])) ? get_user_by('id', $_GET['user_id']) : $current_user;
|
102 |
+
wp_enqueue_style('wp-user-avatar', WPUA_URL.'css/wp-user-avatar.css', "", WPUA_VERSION);
|
103 |
+
wp_enqueue_script('jquery');
|
104 |
+
if($wp_user_avatar->wpua_is_author_or_above()) {
|
105 |
+
wp_enqueue_script('admin-bar');
|
106 |
+
wp_enqueue_media(array('post' => $post));
|
107 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URL.'js/wp-user-avatar.js', array('jquery', 'media-editor'), WPUA_VERSION, true);
|
108 |
+
} else {
|
109 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URL.'js/wp-user-avatar-user.js', array('jquery'), WPUA_VERSION, true);
|
110 |
+
}
|
111 |
+
// Admin scripts
|
112 |
+
if($pagenow == 'options-discussion.php' || $wpua_admin->wpua_is_menu_page()) {
|
113 |
+
// Size limit slider
|
114 |
+
wp_enqueue_script('jquery-ui-slider');
|
115 |
+
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URL.'css/jquery.ui.slider.css', "", null);
|
116 |
+
// Default avatar
|
117 |
+
wp_localize_script('wp-user-avatar', 'wpua_custom', array('avatar_thumb' => $mustache_admin));
|
118 |
+
// Settings control
|
119 |
+
wp_enqueue_script('wp-user-avatar-admin', WPUA_URL.'js/wp-user-avatar-admin.js', array('wp-user-avatar'), WPUA_VERSION, true);
|
120 |
+
wp_localize_script('wp-user-avatar-admin', 'wpua_admin', array('upload_size_limit' => $wpua_upload_size_limit, 'max_upload_size' => wp_max_upload_size()));
|
121 |
+
} else {
|
122 |
+
// Original user avatar
|
123 |
+
$avatar_medium_src = (bool) $show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original($user->user_email, 'medium') : includes_url().'images/blank.gif';
|
124 |
+
wp_localize_script('wp-user-avatar', 'wpua_custom', array('avatar_thumb' => $avatar_medium_src));
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Add to edit user profile
|
130 |
+
* @since 1.4
|
131 |
+
* @param object $user
|
132 |
+
* @uses int $blog_id
|
133 |
+
* @uses object $current_user
|
134 |
+
* @uses bool $show_avatars
|
135 |
+
* @uses object $wpdb
|
136 |
+
* @uses object $wp_user_avatar
|
137 |
+
* @uses bool $wpua_allow_upload
|
138 |
+
* @uses bool $wpua_edit_avatar
|
139 |
+
* @uses object $wpua_functions
|
140 |
+
* @uses string $wpua_upload_size_limit_with_units
|
141 |
+
* @uses add_query_arg()
|
142 |
+
* @uses admin_url()
|
143 |
+
* @uses do_action()
|
144 |
+
* @uses get_blog_prefix()
|
145 |
+
* @uses get_user_meta()
|
146 |
+
* @uses get_wp_user_avatar_src()
|
147 |
+
* @uses has_wp_user_avatar()
|
148 |
+
* @uses is_admin()
|
149 |
+
* @uses wpua_author()
|
150 |
+
* @uses wpua_get_avatar_original()
|
151 |
+
* @uses wpua_is_author_or_above()
|
152 |
+
*/
|
153 |
+
public static function wpua_action_show_user_profile($user) {
|
154 |
+
global $blog_id, $current_user, $show_avatars, $wpdb, $wp_user_avatar, $wpua_allow_upload, $wpua_edit_avatar, $wpua_functions, $wpua_upload_size_limit_with_units;
|
155 |
+
// 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
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Add upload error messages
|
208 |
+
* @since 1.7.1
|
209 |
+
* @param array $errors
|
210 |
+
* @param bool $update
|
211 |
+
* @param object $user
|
212 |
+
* @uses int $wpua_upload_size_limit
|
213 |
+
* @uses add()
|
214 |
+
* @uses wp_upload_dir()
|
215 |
+
*/
|
216 |
+
public static function wpua_upload_errors($errors, $update, $user) {
|
217 |
+
global $wpua_upload_size_limit;
|
218 |
+
if($update && !empty($_FILES['wpua-file'])) {
|
219 |
+
$size = $_FILES['wpua-file']['size'];
|
220 |
+
$type = $_FILES['wpua-file']['type'];
|
221 |
+
$upload_dir = wp_upload_dir();
|
222 |
+
// Allow only JPG, GIF, PNG
|
223 |
+
if(!empty($type) && !preg_match('/(jpe?g|gif|png)$/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 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Set upload size limit
|
239 |
+
* @since 1.5
|
240 |
+
* @param object $file
|
241 |
+
* @uses int $wpua_upload_size_limit
|
242 |
+
* @uses add_action()
|
243 |
+
* @return object $file
|
244 |
+
*/
|
245 |
+
public function wpua_handle_upload_prefilter($file) {
|
246 |
+
global $wpua_upload_size_limit;
|
247 |
+
$size = $file['size'];
|
248 |
+
if(!empty($size) && $size > $wpua_upload_size_limit) {
|
249 |
+
/**
|
250 |
+
* Error handling that only appears on front pages
|
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;
|
258 |
+
}
|
259 |
+
return $file;
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Update user meta
|
264 |
+
* @since 1.4
|
265 |
+
* @param int $user_id
|
266 |
+
* @uses int $blog_id
|
267 |
+
* @uses object $post
|
268 |
+
* @uses object $wpdb
|
269 |
+
* @uses object $wp_user_avatar
|
270 |
+
* @uses bool $wpua_resize_crop
|
271 |
+
* @uses int $wpua_resize_h
|
272 |
+
* @uses bool $wpua_resize_upload
|
273 |
+
* @uses int $wpua_resize_w
|
274 |
+
* @uses add_post_meta()
|
275 |
+
* @uses delete_metadata()
|
276 |
+
* @uses get_blog_prefix()
|
277 |
+
* @uses is_wp_error()
|
278 |
+
* @uses update_post_meta()
|
279 |
+
* @uses update_user_meta()
|
280 |
+
* @uses wp_delete_attachment()
|
281 |
+
* @uses wp_generate_attachment_metadata()
|
282 |
+
* @uses wp_get_image_editor()
|
283 |
+
* @uses wp_handle_upload()
|
284 |
+
* @uses wp_insert_attachment()
|
285 |
+
* @uses WP_Query()
|
286 |
+
* @uses wp_read_image_metadata()
|
287 |
+
* @uses wp_reset_query()
|
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']) : "";
|
297 |
+
// Remove old attachment postmeta
|
298 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
299 |
+
// Create new attachment postmeta
|
300 |
+
add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
301 |
+
// Update usermeta
|
302 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
303 |
+
} else {
|
304 |
+
// Remove attachment info if avatar is blank
|
305 |
+
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])) {
|
306 |
+
// Delete other uploads by user
|
307 |
+
$q = array(
|
308 |
+
'author' => $user_id,
|
309 |
+
'post_type' => 'attachment',
|
310 |
+
'post_status' => 'inherit',
|
311 |
+
'posts_per_page' => '-1',
|
312 |
+
'meta_query' => array(
|
313 |
+
array(
|
314 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
315 |
+
'value' => "",
|
316 |
+
'compare' => '!='
|
317 |
+
)
|
318 |
+
)
|
319 |
+
);
|
320 |
+
$avatars_wp_query = new WP_Query($q);
|
321 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
322 |
+
wp_delete_attachment($post->ID);
|
323 |
+
endwhile;
|
324 |
+
wp_reset_query();
|
325 |
+
// Remove attachment postmeta
|
326 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
327 |
+
// Remove usermeta
|
328 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
329 |
+
}
|
330 |
+
// Create attachment from upload
|
331 |
+
if(isset($_POST['submit']) && $_POST['submit'] && !empty($_FILES['wpua-file'])) {
|
332 |
+
$name = $_FILES['wpua-file']['name'];
|
333 |
+
$file = wp_handle_upload($_FILES['wpua-file'], array('test_form' => false));
|
334 |
+
$type = $_FILES['wpua-file']['type'];
|
335 |
+
$upload_dir = wp_upload_dir();
|
336 |
+
if(is_writeable($upload_dir['path'])) {
|
337 |
+
if(!empty($type) && preg_match('/(jpe?g|gif|png)$/i', $type)) {
|
338 |
+
// Resize uploaded image
|
339 |
+
if((bool) $wpua_resize_upload == 1) {
|
340 |
+
// Original image
|
341 |
+
$uploaded_image = wp_get_image_editor($file['file']);
|
342 |
+
// Check for errors
|
343 |
+
if(!is_wp_error($uploaded_image)) {
|
344 |
+
// Resize image
|
345 |
+
$uploaded_image->resize($wpua_resize_w, $wpua_resize_h, $wpua_resize_crop);
|
346 |
+
// Save image
|
347 |
+
$resized_image = $uploaded_image->save($file['file']);
|
348 |
+
}
|
349 |
+
}
|
350 |
+
// Break out file info
|
351 |
+
$name_parts = pathinfo($name);
|
352 |
+
$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
|
353 |
+
$url = $file['url'];
|
354 |
+
$file = $file['file'];
|
355 |
+
$title = $name;
|
356 |
+
// Use image exif/iptc data for title if possible
|
357 |
+
if($image_meta = @wp_read_image_metadata($file)) {
|
358 |
+
if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))) {
|
359 |
+
$title = $image_meta['title'];
|
360 |
+
}
|
361 |
+
}
|
362 |
+
// Construct the attachment array
|
363 |
+
$attachment = array(
|
364 |
+
'guid' => $url,
|
365 |
+
'post_mime_type' => $type,
|
366 |
+
'post_title' => $title,
|
367 |
+
'post_content' => ""
|
368 |
+
);
|
369 |
+
// This should never be set as it would then overwrite an existing attachment
|
370 |
+
if(isset($attachment['ID'])) {
|
371 |
+
unset($attachment['ID']);
|
372 |
+
}
|
373 |
+
// Save the attachment metadata
|
374 |
+
$attachment_id = wp_insert_attachment($attachment, $file);
|
375 |
+
if(!is_wp_error($attachment_id)) {
|
376 |
+
// Delete other uploads by user
|
377 |
+
$q = array(
|
378 |
+
'author' => $user_id,
|
379 |
+
'post_type' => 'attachment',
|
380 |
+
'post_status' => 'inherit',
|
381 |
+
'posts_per_page' => '-1',
|
382 |
+
'meta_query' => array(
|
383 |
+
array(
|
384 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
385 |
+
'value' => "",
|
386 |
+
'compare' => '!='
|
387 |
+
)
|
388 |
+
)
|
389 |
+
);
|
390 |
+
$avatars_wp_query = new WP_Query($q);
|
391 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
392 |
+
wp_delete_attachment($post->ID);
|
393 |
+
endwhile;
|
394 |
+
wp_reset_query();
|
395 |
+
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
396 |
+
// Remove old attachment postmeta
|
397 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
398 |
+
// Create new attachment postmeta
|
399 |
+
update_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
|
400 |
+
// Update usermeta
|
401 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
|
402 |
+
}
|
403 |
+
}
|
404 |
+
}
|
405 |
+
}
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Check attachment is owned by user
|
411 |
+
* @since 1.4
|
412 |
+
* @param int $attachment_id
|
413 |
+
* @param int $user_id
|
414 |
+
* @param bool $wpua_author
|
415 |
+
* @uses get_post()
|
416 |
+
* @return bool
|
417 |
+
*/
|
418 |
+
private function wpua_author($attachment_id, $user_id, $wpua_author=0) {
|
419 |
+
$attachment = get_post($attachment_id);
|
420 |
+
if(!empty($attachment) && $attachment->post_author == $user_id) {
|
421 |
+
$wpua_author = true;
|
422 |
+
}
|
423 |
+
return (bool) $wpua_author;
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* Check if current user has at least Author privileges
|
428 |
+
* @since 1.8.5
|
429 |
+
* @uses current_user_can()
|
430 |
+
* @uses apply_filters()
|
431 |
+
* @return bool
|
432 |
+
*/
|
433 |
+
public function wpua_is_author_or_above() {
|
434 |
+
$is_author_or_above = (current_user_can('edit_published_posts') && current_user_can('upload_files') && current_user_can('publish_posts') && current_user_can('delete_published_posts')) ? true : false;
|
435 |
+
/**
|
436 |
+
* Filter Author privilege check
|
437 |
+
* @since 1.9.2
|
438 |
+
* @param bool $is_author_or_above
|
439 |
+
*/
|
440 |
+
return (bool) apply_filters('wpua_is_author_or_above', $is_author_or_above);
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Initialize WP_User_Avatar
|
446 |
+
* @since 1.8
|
447 |
+
*/
|
448 |
+
function wpua_init() {
|
449 |
+
global $wp_user_avatar;
|
450 |
+
$wp_user_avatar = new WP_User_Avatar();
|
451 |
+
}
|
452 |
+
add_action('init', 'wpua_init');
|
includes/tinymce.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package WP User Avatar
|
4 |
-
* @version 1.5.6
|
5 |
-
*/
|
6 |
-
|
7 |
-
if(!defined('ABSPATH')){
|
8 |
-
die(__('You are not allowed to call this page directly.'));
|
9 |
-
@header('Content-Type:'.get_option('html_type').';charset='.get_option('blog_charset'));
|
10 |
-
}
|
11 |
-
|
12 |
-
function wpua_myplugin_addbuttons(){
|
13 |
-
// Don't bother doing this stuff if the current user lacks permissions
|
14 |
-
if(!current_user_can('edit_posts') && !current_user_can('edit_pages')){
|
15 |
-
return;
|
16 |
-
}
|
17 |
-
// Add only in Rich Editor mode
|
18 |
-
if(get_user_option('rich_editing') == 'true'){
|
19 |
-
add_filter('mce_external_plugins', 'wpua_add_myplugin_tinymce_plugin');
|
20 |
-
add_filter('mce_buttons', 'wpua_register_myplugin_button');
|
21 |
-
}
|
22 |
-
}
|
23 |
-
// init process for button control
|
24 |
-
add_action('init', 'wpua_myplugin_addbuttons');
|
25 |
-
|
26 |
-
|
27 |
-
function wpua_register_myplugin_button($buttons){
|
28 |
-
array_push($buttons, 'separator', 'wpUserAvatar');
|
29 |
-
return $buttons;
|
30 |
-
}
|
31 |
-
|
32 |
-
// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
|
33 |
-
function wpua_add_myplugin_tinymce_plugin($plugin_array){
|
34 |
-
$plugin_array['wpUserAvatar'] = WPUA_URLPATH.'includes/tinymce/editor_plugin.js';
|
35 |
-
return $plugin_array;
|
36 |
-
}
|
37 |
-
|
38 |
-
// Call TinyMCE window content via admin-ajax
|
39 |
-
function wpua_ajax_tinymce(){
|
40 |
-
if(!current_user_can('edit_posts') && !current_user_can('edit_pages')){
|
41 |
-
die('You are not allowed to call this page directly.');
|
42 |
-
}
|
43 |
-
include_once(WPUA_ABSPATH.'includes/tinymce/window.php');
|
44 |
-
die();
|
45 |
-
}
|
46 |
-
add_action('wp_ajax_wp_user_avatar_tinymce', 'wpua_ajax_tinymce');
|
47 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/tinymce/editor_plugin.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(){tinymce.
|
1 |
+
(function(){tinymce.create('tinymce.plugins.wpUserAvatar',{init:function(c,d){c.addCommand('mceWpUserAvatar',function(){c.windowManager.open({file:ajaxurl+'?action=wp_user_avatar_tinymce',width:500,height:360,inline:1},{plugin_url:d})});c.addButton('wpUserAvatar',{title:'Insert WP User Avatar',cmd:'mceWpUserAvatar',image:d+'/../../images/wpua-20x20.png'});c.onNodeChange.add(function(a,b,n){b.setActive('wpUserAvatar',n.nodeName=='IMG')})},createControl:function(n,a){return null},getInfo:function(){return{longname:'WP User Avatar',author:'Bangbay Siboliban',authorurl:'http://siboliban.org/',infourl:'http://wordpress.org/plugins/wp-user-avatar/',version:"1.9.13"}}});tinymce.PluginManager.add('wpUserAvatar',tinymce.plugins.wpUserAvatar)})();
|
includes/tinymce/window.php
CHANGED
@@ -1,129 +1,202 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
}
|
11 |
?>
|
12 |
-
|
|
|
13 |
<head>
|
14 |
<title><?php _e('WP User Avatar', 'wp-user-avatar'); ?></title>
|
15 |
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
16 |
<base target="_self" />
|
17 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/jquery.js"></script>
|
|
|
|
|
|
|
18 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
|
19 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
|
20 |
<script type="text/javascript">
|
21 |
-
function
|
22 |
// Custom shortcode values
|
23 |
-
var shortcode
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
31 |
|
32 |
// Add tag to shortcode only if not blank
|
33 |
var user_tag = (user != "") ? ' user="' + user + '"' : "";
|
34 |
var size_tag = (size != "" && size_number == "") ? ' size="' + size + '"' : "";
|
35 |
-
|
36 |
var align_tag = (align != "") ? ' align="' + align + '"' : "";
|
37 |
var link_tag = (link != "" && link != 'custom-url' && link_external == "") ? ' link="' + link + '"' : "";
|
38 |
-
|
39 |
var target_tag = document.getElementById('wp_user_avatar_target').checked && (link_tag != "") ? ' target="' + target + '"' : "";
|
40 |
-
|
41 |
-
shortcode = "<p>[avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + "]</p>";
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
tinyMCEPopup.editor.execCommand('mceRepaint');
|
46 |
tinyMCEPopup.close();
|
47 |
}
|
48 |
return;
|
49 |
}
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
});
|
54 |
-
|
55 |
-
|
|
|
56 |
});
|
|
|
|
|
57 |
});
|
58 |
</script>
|
59 |
<style type="text/css">
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
p, h4 { margin: 0; padding: 12px 0 0; }
|
62 |
h4.center { text-align: center; }
|
63 |
-
label { width: 150px; display: inline-block; text-align: right; }
|
64 |
.mceActionPanel { padding: 7px 0 12px; text-align: center; }
|
65 |
.mceActionPanel #insert { float: none; width: 180px; margin: 0 auto; }
|
66 |
#wp_user_avatar_size_number_section, #wp_user_avatar_link_external_section { display: none; }
|
67 |
</style>
|
68 |
</head>
|
69 |
-
<body id="link" class="wp-core-ui" onload="document.body.style.display=
|
70 |
-
<
|
71 |
-
<
|
72 |
-
|
73 |
-
<
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
<
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
</body>
|
129 |
</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/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>
|
includes/wpua-functions.php
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Public user functions.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Returns true if user has wp_user_avatar
|
11 |
+
* @since 1.8
|
12 |
+
* @param int|string $id_or_email
|
13 |
+
* @param bool $has_wpua
|
14 |
+
* @param object $user
|
15 |
+
* @param int $user_id
|
16 |
+
* @uses object $wpua_functions
|
17 |
+
* @return object has_wp_user_avatar()
|
18 |
+
*/
|
19 |
+
function has_wp_user_avatar($id_or_email="", $has_wpua="", $user="", $user_id="") {
|
20 |
+
global $wpua_functions;
|
21 |
+
return $wpua_functions->has_wp_user_avatar($id_or_email, $has_wpua, $user, $user_id);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Find WPUA, show get_avatar if empty
|
26 |
+
* @since 1.8
|
27 |
+
* @param int|string $id_or_email
|
28 |
+
* @param int|string $size
|
29 |
+
* @param string $align
|
30 |
+
* @param string $alt
|
31 |
+
* @uses object $wpua_functions
|
32 |
+
* @return object get_wp_user_avatar()
|
33 |
+
*/
|
34 |
+
function get_wp_user_avatar($id_or_email="", $size="", $align="", $alt="") {
|
35 |
+
global $wpua_functions;
|
36 |
+
return $wpua_functions->get_wp_user_avatar($id_or_email, $size, $align, $alt);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return just the image src
|
41 |
+
* @since 1.8
|
42 |
+
* @param int|string $id_or_email
|
43 |
+
* @param int|string $size
|
44 |
+
* @param string $align
|
45 |
+
* @uses object $wpua_functions
|
46 |
+
* @return object get_wp_user_avatar_src()
|
47 |
+
*/
|
48 |
+
function get_wp_user_avatar_src($id_or_email="", $size="", $align="") {
|
49 |
+
global $wpua_functions;
|
50 |
+
return $wpua_functions->get_wp_user_avatar_src($id_or_email, $size, $align);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Before wrapper for profile
|
55 |
+
* @since 1.6
|
56 |
+
* @uses do_action()
|
57 |
+
*/
|
58 |
+
function wpua_before_avatar() {
|
59 |
+
do_action('wpua_before_avatar');
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* After wrapper for profile
|
64 |
+
* @since 1.6
|
65 |
+
* @uses do_action()
|
66 |
+
*/
|
67 |
+
function wpua_after_avatar() {
|
68 |
+
do_action('wpua_after_avatar');
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Before avatar container
|
73 |
+
* @since 1.6
|
74 |
+
* @uses apply_filters()
|
75 |
+
* @uses bbp_is_edit()
|
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
|
83 |
+
* @param string $wpua_profile_title
|
84 |
+
*/
|
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">
|
100 |
+
<?php echo $wpua_profile_title; ?>
|
101 |
+
<?php endif; ?>
|
102 |
+
<?php
|
103 |
+
}
|
104 |
+
add_action('wpua_before_avatar', 'wpua_do_before_avatar');
|
105 |
+
|
106 |
+
/**
|
107 |
+
* After avatar container
|
108 |
+
* @since 1.6
|
109 |
+
* @uses bbp_is_edit()
|
110 |
+
* @uses wpuf_has_shortcode()
|
111 |
+
*/
|
112 |
+
function wpua_do_after_avatar() {
|
113 |
+
?>
|
114 |
+
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
115 |
+
</fieldset>
|
116 |
+
<?php elseif(class_exists('WPUF_Main') && wpuf_has_shortcode('wpuf_editprofile')) : // Add to WP User Frontend profile with same style ?>
|
117 |
+
</td>
|
118 |
+
</tr>
|
119 |
+
</table>
|
120 |
+
</fieldset>
|
121 |
+
<?php else : // Add to profile without table ?>
|
122 |
+
</div>
|
123 |
+
<?php endif; ?>
|
124 |
+
<?php
|
125 |
+
}
|
126 |
+
add_action('wpua_after_avatar', 'wpua_do_after_avatar');
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Before wrapper for profile in admin section
|
130 |
+
* @since 1.9.4
|
131 |
+
* @uses do_action()
|
132 |
+
*/
|
133 |
+
function wpua_before_avatar_admin() {
|
134 |
+
do_action('wpua_before_avatar_admin');
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* After wrapper for profile in admin section
|
139 |
+
* @since 1.9.4
|
140 |
+
* @uses do_action()
|
141 |
+
*/
|
142 |
+
function wpua_after_avatar_admin() {
|
143 |
+
do_action('wpua_after_avatar_admin');
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Before avatar container in admin section
|
148 |
+
* @since 1.9.4
|
149 |
+
*/
|
150 |
+
function wpua_do_before_avatar_admin() {
|
151 |
+
?>
|
152 |
+
<h3><?php _e('Avatar') ?></h3>
|
153 |
+
<table class="form-table">
|
154 |
+
<tr>
|
155 |
+
<th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
|
156 |
+
<td>
|
157 |
+
<?php
|
158 |
+
}
|
159 |
+
add_action('wpua_before_avatar_admin', 'wpua_do_before_avatar_admin');
|
160 |
+
|
161 |
+
/**
|
162 |
+
* After avatar container in admin section
|
163 |
+
* @since 1.9.4
|
164 |
+
*/
|
165 |
+
function wpua_do_after_avatar_admin() {
|
166 |
+
?>
|
167 |
+
</td>
|
168 |
+
</tr>
|
169 |
+
</table>
|
170 |
+
<?php
|
171 |
+
}
|
172 |
+
add_action('wpua_after_avatar_admin', 'wpua_do_after_avatar_admin');
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Filter for the inevitable complaints about the donation message :(
|
176 |
+
* @since 1.6.6
|
177 |
+
* @uses do_action()
|
178 |
+
*/
|
179 |
+
function wpua_donation_message() {
|
180 |
+
do_action('wpua_donation_message');
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* 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
|
197 |
+
* @since 1.9.4
|
198 |
+
* @uses register_widget()
|
199 |
+
*/
|
200 |
+
function wpua_widgets_init() {
|
201 |
+
register_widget('WP_User_Avatar_Profile_Widget');
|
202 |
+
}
|
203 |
+
add_action('widgets_init', 'wpua_widgets_init');
|
includes/wpua-globals.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Global variables used in plugin.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @since 1.8
|
11 |
+
* @uses get_intermediate_image_sizes()
|
12 |
+
* @uses get_option()
|
13 |
+
* @uses wp_max_upload_size()
|
14 |
+
*/
|
15 |
+
|
16 |
+
// Define global variables
|
17 |
+
global $avatar_default,
|
18 |
+
$show_avatars,
|
19 |
+
$wpua_allow_upload,
|
20 |
+
$wpua_avatar_default,
|
21 |
+
$wpua_disable_gravatar,
|
22 |
+
$wpua_edit_avatar,
|
23 |
+
$wpua_resize_crop,
|
24 |
+
$wpua_resize_h,
|
25 |
+
$wpua_resize_upload,
|
26 |
+
$wpua_resize_w,
|
27 |
+
$wpua_tinymce,
|
28 |
+
$mustache_original,
|
29 |
+
$mustache_medium,
|
30 |
+
$mustache_thumbnail,
|
31 |
+
$mustache_avatar,
|
32 |
+
$mustache_admin,
|
33 |
+
$wpua_default_avatar_updated,
|
34 |
+
$wpua_users_updated,
|
35 |
+
$wpua_media_updated,
|
36 |
+
$upload_size_limit,
|
37 |
+
$upload_size_limit_with_units,
|
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');
|
45 |
+
// Attachment ID of default avatar
|
46 |
+
$wpua_avatar_default = get_option('avatar_default_wp_user_avatar');
|
47 |
+
|
48 |
+
// Booleans
|
49 |
+
$show_avatars = get_option('show_avatars');
|
50 |
+
$wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
|
51 |
+
$wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
|
52 |
+
$wpua_edit_avatar = get_option('wp_user_avatar_edit_avatar');
|
53 |
+
$wpua_resize_crop = get_option('wp_user_avatar_resize_crop');
|
54 |
+
$wpua_resize_upload = get_option('wp_user_avatar_resize_upload');
|
55 |
+
$wpua_tinymce = get_option('wp_user_avatar_tinymce');
|
56 |
+
|
57 |
+
// Resize dimensions
|
58 |
+
$wpua_resize_h = get_option('wp_user_avatar_resize_h');
|
59 |
+
$wpua_resize_w = get_option('wp_user_avatar_resize_w');
|
60 |
+
|
61 |
+
// Default avatar 512x512
|
62 |
+
$mustache_original = WPUA_URL.'images/wpua.png';
|
63 |
+
// Default avatar 300x300
|
64 |
+
$mustache_medium = WPUA_URL.'images/wpua-300x300.png';
|
65 |
+
// Default avatar 150x150
|
66 |
+
$mustache_thumbnail = WPUA_URL.'images/wpua-150x150.png';
|
67 |
+
// Default avatar 96x96
|
68 |
+
$mustache_avatar = WPUA_URL.'images/wpua-96x96.png';
|
69 |
+
// Default avatar 32x32
|
70 |
+
$mustache_admin = WPUA_URL.'images/wpua-32x32.png';
|
71 |
+
|
72 |
+
// Check for updates
|
73 |
+
$wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
|
74 |
+
$wpua_users_updated = get_option('wp_user_avatar_users_updated');
|
75 |
+
$wpua_media_updated = get_option('wp_user_avatar_media_updated');
|
76 |
+
|
77 |
+
// Server upload size limit
|
78 |
+
$upload_size_limit = wp_max_upload_size();
|
79 |
+
// Convert to KB
|
80 |
+
if($upload_size_limit > 1024) {
|
81 |
+
$upload_size_limit /= 1024;
|
82 |
+
}
|
83 |
+
$upload_size_limit_with_units = (int) $upload_size_limit.'KB';
|
84 |
+
|
85 |
+
// User upload size limit
|
86 |
+
$wpua_user_upload_size_limit = get_option('wp_user_avatar_upload_size_limit');
|
87 |
+
if($wpua_user_upload_size_limit == 0 || $wpua_user_upload_size_limit > wp_max_upload_size()) {
|
88 |
+
$wpua_user_upload_size_limit = wp_max_upload_size();
|
89 |
+
}
|
90 |
+
// Value in bytes
|
91 |
+
$wpua_upload_size_limit = $wpua_user_upload_size_limit;
|
92 |
+
// Convert to KB
|
93 |
+
if($wpua_user_upload_size_limit > 1024) {
|
94 |
+
$wpua_user_upload_size_limit /= 1024;
|
95 |
+
}
|
96 |
+
$wpua_upload_size_limit_with_units = (int) $wpua_user_upload_size_limit.'KB';
|
97 |
+
|
98 |
+
// Check for custom image sizes
|
99 |
+
$all_sizes = array_merge(get_intermediate_image_sizes(), array('original'));
|
includes/wpua-media-page.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Media Library view of all avatars in use.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @since 1.8
|
11 |
+
* @uses object $wpua_admin
|
12 |
+
* @uses _wpua_get_list_table()
|
13 |
+
* @uses add_query_arg()
|
14 |
+
* @uses check_admin_referer()
|
15 |
+
* @uses current_action()
|
16 |
+
* @uses current_user_can()
|
17 |
+
* @uses display()
|
18 |
+
* @uses esc_url()
|
19 |
+
* @uses find_posts_div()
|
20 |
+
* @uses get_pagenum()
|
21 |
+
* @uses get_search_query
|
22 |
+
* @uses number_format_i18n()
|
23 |
+
* @uses prepare_items()
|
24 |
+
* @uses remove_query_arg()
|
25 |
+
* @uses search_box()
|
26 |
+
* @uses views()
|
27 |
+
* @uses wp_delete_attachment()
|
28 |
+
* @uses wp_die()
|
29 |
+
* @uses wp_enqueue_script()
|
30 |
+
* @uses wp_get_referer()
|
31 |
+
* @uses wp_redirect()
|
32 |
+
* @uses wp_unslash()
|
33 |
+
*/
|
34 |
+
|
35 |
+
/** WordPress Administration Bootstrap */
|
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 |
+
|
43 |
+
$wp_list_table = $wpua_admin->_wpua_get_list_table('WP_User_Avatar_List_Table');
|
44 |
+
$pagenum = $wp_list_table->get_pagenum();
|
45 |
+
|
46 |
+
// Handle bulk actions
|
47 |
+
$doaction = $wp_list_table->current_action();
|
48 |
+
|
49 |
+
if($doaction) {
|
50 |
+
check_admin_referer('bulk-media');
|
51 |
+
|
52 |
+
if(isset($_REQUEST['media'])) {
|
53 |
+
$post_ids = $_REQUEST['media'];
|
54 |
+
} elseif(isset($_REQUEST['ids'])) {
|
55 |
+
$post_ids = explode(',', $_REQUEST['ids']);
|
56 |
+
}
|
57 |
+
|
58 |
+
$location = esc_url(add_query_arg(array('page' => 'wp-user-avatar-library'), 'admin.php'));
|
59 |
+
if($referer = wp_get_referer()) {
|
60 |
+
if(false !== strpos($referer, 'admin.php')) {
|
61 |
+
$location = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted'), $referer);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
switch($doaction) {
|
65 |
+
case 'delete':
|
66 |
+
if(!isset($post_ids)) {
|
67 |
+
break;
|
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);
|
81 |
+
exit;
|
82 |
+
} elseif(!empty($_GET['_wp_http_referer'])) {
|
83 |
+
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
|
84 |
+
exit;
|
85 |
+
}
|
86 |
+
$wp_list_table->prepare_items();
|
87 |
+
wp_enqueue_script('wp-ajax-response');
|
88 |
+
wp_enqueue_script('jquery-ui-draggable');
|
89 |
+
wp_enqueue_script('media');
|
90 |
+
?>
|
91 |
+
<div class="wrap">
|
92 |
+
<h2>
|
93 |
+
<?php _e('Avatars');
|
94 |
+
if(!empty($_REQUEST['s'])) {
|
95 |
+
printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', get_search_query());
|
96 |
+
}
|
97 |
+
?>
|
98 |
+
</h2>
|
99 |
+
<?php
|
100 |
+
$message = "";
|
101 |
+
if(!empty($_GET['deleted']) && $deleted = absint($_GET['deleted'])) {
|
102 |
+
$message = sprintf(_n('Media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted), number_format_i18n($_GET['deleted']));
|
103 |
+
$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
|
104 |
+
}
|
105 |
+
if(!empty($message)) : ?>
|
106 |
+
<div id="message" class="updated"><p><?php echo $message; ?></p></div>
|
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(); ?>
|
114 |
+
<br class="clear" />
|
115 |
+
</form>
|
116 |
+
</div>
|
includes/wpua-options-page.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin page to change plugin options.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @since 1.4
|
11 |
+
* @uses bool $show_avatars
|
12 |
+
* @uses string $upload_size_limit_with_units
|
13 |
+
* @uses object $wpua_admin
|
14 |
+
* @uses bool $wpua_allow_upload
|
15 |
+
* @uses bool $wpua_disable_gravatar
|
16 |
+
* @uses bool $wpua_edit_avatar
|
17 |
+
* @uses bool $wpua_resize_crop
|
18 |
+
* @uses int int $wpua_resize_h
|
19 |
+
* @uses bool $wpua_resize_upload
|
20 |
+
* @uses int $wpua_resize_w
|
21 |
+
* @uses object $wpua_subscriber
|
22 |
+
* @uses bool $wpua_tinymce
|
23 |
+
* @uses int $wpua_upload_size_limit
|
24 |
+
* @uses string $wpua_upload_size_limit_with_units
|
25 |
+
* @uses admin_url()
|
26 |
+
* @uses apply_filters()
|
27 |
+
* @uses checked()
|
28 |
+
* @uses do_action()
|
29 |
+
* @uses do_settings_fields()
|
30 |
+
* @uses get_option()
|
31 |
+
* @uses settings_fields()
|
32 |
+
* @uses submit_button()
|
33 |
+
* @uses wpua_add_default_avatar()
|
34 |
+
*/
|
35 |
+
|
36 |
+
global $show_avatars, $upload_size_limit_with_units, $wpua_admin, $wpua_allow_upload, $wpua_disable_gravatar, $wpua_edit_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w, $wpua_subscriber, $wpua_tinymce, $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
|
37 |
+
$updated = false;
|
38 |
+
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') {
|
39 |
+
$updated = true;
|
40 |
+
}
|
41 |
+
$hide_size = (bool) $wpua_allow_upload != 1 ? ' style="display:none;"' : "";
|
42 |
+
$hide_resize = (bool) $wpua_resize_upload != 1 ? ' style="display:none;"' : "";
|
43 |
+
$wpua_options_page_title = __('WP User Avatar', 'wp-user-avatar');
|
44 |
+
/**
|
45 |
+
* Filter admin page title
|
46 |
+
* @since 1.9
|
47 |
+
* @param string $wpua_options_page_title
|
48 |
+
*/
|
49 |
+
$wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_options_page_title);
|
50 |
+
?>
|
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', ""); ?>
|
57 |
+
<?php do_action('wpua_donation_message'); ?>
|
58 |
+
<table class="form-table">
|
59 |
+
<?php
|
60 |
+
// Format settings in table rows
|
61 |
+
$wpua_before_settings = array();
|
62 |
+
/**
|
63 |
+
* Filter settings at beginning of table
|
64 |
+
* @since 1.9
|
65 |
+
* @param array $wpua_before_settings
|
66 |
+
*/
|
67 |
+
$wpua_before_settings = apply_filters('wpua_before_settings', $wpua_before_settings);
|
68 |
+
echo implode("", $wpua_before_settings);
|
69 |
+
?>
|
70 |
+
<tr valign="top">
|
71 |
+
<th scope="row"><?php _e('Settings'); ?></th>
|
72 |
+
<td>
|
73 |
+
<?php
|
74 |
+
// Format settings in fieldsets
|
75 |
+
$wpua_settings = array();
|
76 |
+
$wpua_settings['tinymce'] = '<fieldset>
|
77 |
+
<label for="wp_user_avatar_tinymce">
|
78 |
+
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" '.checked($wpua_tinymce, 1, 0).' />'
|
79 |
+
.__('Add avatar button to Visual Editor', 'wp-user-avatar').'
|
80 |
+
</label>
|
81 |
+
</fieldset>';
|
82 |
+
$wpua_settings['upload'] ='<fieldset>
|
83 |
+
<label for="wp_user_avatar_allow_upload">
|
84 |
+
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" '.checked($wpua_allow_upload, 1, 0).' />'
|
85 |
+
.__('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar').'
|
86 |
+
</label>
|
87 |
+
</fieldset>';
|
88 |
+
$wpua_settings['gravatar'] ='<fieldset>
|
89 |
+
<label for="wp_user_avatar_disable_gravatar">
|
90 |
+
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" '.checked($wpua_disable_gravatar, 1, 0).' />'
|
91 |
+
.__('Disable Gravatar and use only local avatars', 'wp-user-avatar').'
|
92 |
+
</label>
|
93 |
+
</fieldset>';
|
94 |
+
/**
|
95 |
+
* Filter main settings
|
96 |
+
* @since 1.9
|
97 |
+
* @param array $wpua_settings
|
98 |
+
*/
|
99 |
+
$wpua_settings = apply_filters('wpua_settings', $wpua_settings);
|
100 |
+
echo implode("", $wpua_settings);
|
101 |
+
?>
|
102 |
+
</td>
|
103 |
+
</tr>
|
104 |
+
</table>
|
105 |
+
<?php
|
106 |
+
// Format settings in table
|
107 |
+
$wpua_subscriber_settings = array();
|
108 |
+
$wpua_subscriber_settings['subscriber-settings'] = '<div id="wpua-contributors-subscribers"'.$hide_size.'>
|
109 |
+
<table class="form-table">
|
110 |
+
<tr valign="top">
|
111 |
+
<th scope="row">
|
112 |
+
<label for="wp_user_avatar_upload_size_limit">'
|
113 |
+
.__('Upload Size Limit', 'wp-user-avatar').' '.__('(only for Contributors & Subscribers)', 'wp-user-avatar').'
|
114 |
+
</label>
|
115 |
+
</th>
|
116 |
+
<td>
|
117 |
+
<fieldset>
|
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">
|
127 |
+
<input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" '.checked($wpua_edit_avatar, 1, 0).' />'
|
128 |
+
.__('Allow users to edit avatars', 'wp-user-avatar').'
|
129 |
+
</label>
|
130 |
+
</fieldset>
|
131 |
+
<fieldset>
|
132 |
+
<label for="wp_user_avatar_resize_upload">
|
133 |
+
<input name="wp_user_avatar_resize_upload" type="checkbox" id="wp_user_avatar_resize_upload" value="1" '.checked($wpua_resize_upload, 1, 0).' />'
|
134 |
+
.__('Resize avatars on upload', 'wp-user-avatar').'
|
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).' />
|
144 |
+
<label for="wp_user_avatar_resize_crop">'.__('Crop avatars to exact dimensions', 'wp-user-avatar').'</label>
|
145 |
+
</fieldset>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
</table>
|
149 |
+
</div>';
|
150 |
+
/**
|
151 |
+
* Filter Subscriber settings
|
152 |
+
* @since 1.9
|
153 |
+
* @param array $wpua_subscriber_settings
|
154 |
+
*/
|
155 |
+
$wpua_subscriber_settings = apply_filters('wpua_subscriber_settings', $wpua_subscriber_settings);
|
156 |
+
echo implode("", $wpua_subscriber_settings);
|
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 — Suitable for all audiences'),
|
180 |
+
'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'),
|
181 |
+
'R' => __('R — Intended for adult audiences above 17'),
|
182 |
+
'X' => __('X — Even more mature than above')
|
183 |
+
);
|
184 |
+
foreach ($ratings as $key => $rating) :
|
185 |
+
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
|
186 |
+
echo "\n\t<label><input type='radio' name='avatar_rating' value='".esc_attr($key)."' $selected/> $rating</label><br />";
|
187 |
+
endforeach;
|
188 |
+
?>
|
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>
|
204 |
+
</tr>
|
205 |
+
</table>
|
206 |
+
<?php submit_button(); ?>
|
207 |
+
</form>
|
208 |
+
</div>
|
includes/wpua-tinymce.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* TinyMCE button for Visual Editor.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Add TinyMCE button
|
11 |
+
* @since 1.9.5
|
12 |
+
* @uses add_filter()
|
13 |
+
* @uses get_user_option()
|
14 |
+
*/
|
15 |
+
function wpua_add_buttons() {
|
16 |
+
// Add only in Rich Editor mode
|
17 |
+
if(get_user_option('rich_editing') == 'true') {
|
18 |
+
add_filter('mce_external_plugins', 'wpua_add_tinymce_plugin');
|
19 |
+
add_filter('mce_buttons', 'wpua_register_button');
|
20 |
+
}
|
21 |
+
}
|
22 |
+
add_action('init', 'wpua_add_buttons');
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Register TinyMCE button
|
26 |
+
* @since 1.9.5
|
27 |
+
* @param array $buttons
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
function wpua_register_button($buttons) {
|
31 |
+
array_push($buttons, 'separator', 'wpUserAvatar');
|
32 |
+
return $buttons;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Load TinyMCE plugin
|
37 |
+
* @since 1.9.5
|
38 |
+
* @param array $plugin_array
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
function wpua_add_tinymce_plugin($plugins) {
|
42 |
+
$plugins['wpUserAvatar'] = WPUA_INC_URL.'tinymce/editor_plugin.js';
|
43 |
+
return $plugins;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Call TinyMCE window content via admin-ajax
|
48 |
+
* @since 1.4
|
49 |
+
*/
|
50 |
+
function wpua_ajax_tinymce() {
|
51 |
+
include_once(WPUA_INC.'tinymce/window.php');
|
52 |
+
die();
|
53 |
+
}
|
54 |
+
add_action('wp_ajax_wp_user_avatar_tinymce', 'wpua_ajax_tinymce');
|
index.html
CHANGED
@@ -1 +1,2 @@
|
|
1 |
<!-- Thanks for using WP User Avatar! -->
|
|
1 |
<!-- Thanks for using WP User Avatar! -->
|
2 |
+
<!-- This page is intentionally blank. -->
|
js/wp-user-avatar-admin.js
CHANGED
@@ -1,37 +1,40 @@
|
|
1 |
-
jQuery(function(){
|
2 |
// Show size info only if allow uploads is checked
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
});
|
6 |
// Hide Gravatars if disable Gravatars is checked
|
7 |
-
|
8 |
-
if(
|
9 |
-
|
10 |
-
|
11 |
}
|
12 |
-
jQuery('#wpua-message').show();
|
13 |
});
|
14 |
// Add size slider
|
15 |
-
|
16 |
value: parseInt(wpua_admin.upload_size_limit),
|
17 |
min: 0,
|
18 |
max: parseInt(wpua_admin.max_upload_size),
|
19 |
step: 1,
|
20 |
-
slide: function(event, ui){
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
}
|
26 |
});
|
27 |
// Update readable size on keyup
|
28 |
-
|
29 |
-
var
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
});
|
36 |
-
|
37 |
});
|
1 |
+
jQuery(function($) {
|
2 |
// Show size info only if allow uploads is checked
|
3 |
+
$('#wp_user_avatar_allow_upload').change(function() {
|
4 |
+
$('#wpua-contributors-subscribers').slideToggle($('#wp_user_avatar_allow_upload').is(':checked'));
|
5 |
+
});
|
6 |
+
// Show resize info only if resize uploads is checked
|
7 |
+
$('#wp_user_avatar_resize_upload').change(function() {
|
8 |
+
$('#wpua-resize-sizes').slideToggle($('#wp_user_avatar_resize_upload').is(':checked'));
|
9 |
});
|
10 |
// Hide Gravatars if disable Gravatars is checked
|
11 |
+
$('#wp_user_avatar_disable_gravatar').change(function() {
|
12 |
+
if($('#wp-avatars').length) {
|
13 |
+
$('#wp-avatars, #avatar-rating').slideToggle(!$('#wp_user_avatar_disable_gravatar').is(':checked'));
|
14 |
+
$('#wp_user_avatar_radio').trigger('click');
|
15 |
}
|
|
|
16 |
});
|
17 |
// Add size slider
|
18 |
+
$('#wpua-slider').slider({
|
19 |
value: parseInt(wpua_admin.upload_size_limit),
|
20 |
min: 0,
|
21 |
max: parseInt(wpua_admin.max_upload_size),
|
22 |
step: 1,
|
23 |
+
slide: function(event, ui) {
|
24 |
+
$('#wp_user_avatar_upload_size_limit').val(ui.value);
|
25 |
+
$('#wpua-readable-size').html(Math.floor(ui.value / 1024) + 'KB');
|
26 |
+
$('#wpua-readable-size-error').hide();
|
27 |
+
$('#wpua-readable-size').removeClass('wpua-error');
|
28 |
}
|
29 |
});
|
30 |
// Update readable size on keyup
|
31 |
+
$('#wp_user_avatar_upload_size_limit').keyup(function() {
|
32 |
+
var wpuaUploadSizeLimit = $(this).val();
|
33 |
+
wpuaUploadSizeLimit = wpuaUploadSizeLimit.replace(/\D/g, "");
|
34 |
+
$(this).val(wpuaUploadSizeLimit);
|
35 |
+
$('#wpua-readable-size').html(Math.floor(wpuaUploadSizeLimit / 1024) + 'KB');
|
36 |
+
$('#wpua-readable-size-error').toggle(wpuaUploadSizeLimit > parseInt(wpua_admin.max_upload_size));
|
37 |
+
$('#wpua-readable-size').toggleClass('wpua-error', wpuaUploadSizeLimit > parseInt(wpua_admin.max_upload_size));
|
38 |
});
|
39 |
+
$('#wp_user_avatar_upload_size_limit').val($('#wpua-slider').slider('value'));
|
40 |
});
|
js/wp-user-avatar-user.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function($) {
|
2 |
+
// Add enctype to form with JavaScript as backup
|
3 |
+
$('#your-profile').attr('enctype', 'multipart/form-data');
|
4 |
+
// Store WP User Avatar ID
|
5 |
+
var wpuaID = $('#wp-user-avatar').val();
|
6 |
+
// Store WP User Avatar src
|
7 |
+
var wpuaSrc = $('#wpua-preview').find('img').attr('src');
|
8 |
+
// Remove WP User Avatar
|
9 |
+
$('body').on('click', '#wpua-remove', function(e) {
|
10 |
+
e.preventDefault();
|
11 |
+
$('#wpua-original').remove();
|
12 |
+
$('#wpua-remove-button, #wpua-thumbnail').hide();
|
13 |
+
$('#wpua-preview').find('img:first').hide();
|
14 |
+
$('#wpua-preview').prepend('<img id="wpua-original" />');
|
15 |
+
$('#wpua-original').attr('src', wpua_custom.avatar_thumb);
|
16 |
+
$('#wp-user-avatar').val("");
|
17 |
+
$('#wpua-original, #wpua-undo-button').show();
|
18 |
+
$('#wp_user_avatar_radio').trigger('click');
|
19 |
+
});
|
20 |
+
// Undo WP User Avatar
|
21 |
+
$('body').on('click', '#wpua-undo', function(e) {
|
22 |
+
e.preventDefault();
|
23 |
+
$('#wpua-original').remove();
|
24 |
+
$('#wpua-images').removeAttr('style');
|
25 |
+
$('#wpua-undo-button').hide();
|
26 |
+
$('#wpua-remove-button, #wpua-thumbnail').show();
|
27 |
+
$('#wpua-preview').find('img:first').attr('src', wpuaSrc).show();
|
28 |
+
$('#wp-user-avatar').val(wpuaID);
|
29 |
+
$('#wp_user_avatar_radio').trigger('click');
|
30 |
+
});
|
31 |
+
});
|
js/wp-user-avatar.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function
|
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,{}))
|
lang/wp-user-avatar-de_DE.mo
CHANGED
Binary file
|
lang/wp-user-avatar-de_DE.po
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
# German (de_DE) translation for WP User Avatar.
|
2 |
-
# Copyright (C)
|
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date:
|
10 |
"Language: de_DE\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\n"
|
@@ -14,32 +14,52 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
|
19 |
-
|
20 |
-
msgstr "Klicken Sie %s, um Ihre Änderungen zu speichern"
|
21 |
|
22 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
|
25 |
|
26 |
-
#:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
|
29 |
|
30 |
-
#:
|
31 |
msgid "Disable Gravatar and use only local avatars"
|
32 |
msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
|
33 |
|
34 |
-
#:
|
35 |
-
#:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Dateigrößenbeschränkung
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
#:
|
40 |
msgid "Allow users to edit avatars"
|
41 |
msgstr "Benutzer erlauben, Avatare bearbeiten"
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
#. Plugin Name of the plugin/theme
|
44 |
msgid "WP User Avatar"
|
45 |
msgstr "WP-Benutzer-Avatar"
|
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"
|
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"
|
lang/wp-user-avatar-es_ES.mo
CHANGED
Binary file
|
lang/wp-user-avatar-es_ES.po
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
# Spanish (es_ES) translation for WP User Avatar.
|
2 |
-
# Copyright (C)
|
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date:
|
10 |
"Language: es_ES\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\n"
|
@@ -14,32 +14,52 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
|
19 |
-
|
20 |
-
msgstr "Haz clic %s para guardar los cambios"
|
21 |
|
22 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Añadir botón avatar al editor visual"
|
25 |
|
26 |
-
#:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Permitir los colaboradores y los suscriptores subir avatares"
|
29 |
|
30 |
-
#:
|
31 |
msgid "Disable Gravatar and use only local avatars"
|
32 |
msgstr "Desactivar Gravatar y utilizar sólo los avatares locales"
|
33 |
|
34 |
-
#:
|
35 |
-
#:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Sube límite de tamaño
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
#:
|
40 |
msgid "Allow users to edit avatars"
|
41 |
msgstr "Permitir a los usuarios editar avatar"
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
#. Plugin Name of the plugin/theme
|
44 |
msgid "WP User Avatar"
|
45 |
msgstr "WP-Usuario-Avatar"
|
1 |
# Spanish (es_ES) 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: es_ES\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\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 "Donar"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:189
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "¿Está satisfecho con WP-Usuario-Avatar?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:189
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Donar"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:83
|
30 |
msgid "Add avatar button to Visual Editor"
|
31 |
msgstr "Añadir botón avatar al editor visual"
|
32 |
|
33 |
+
#: includes/wpua-options-page.php:89
|
34 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
35 |
msgstr "Permitir los colaboradores y los suscriptores subir avatares"
|
36 |
|
37 |
+
#: includes/wpua-options-page.php:95
|
38 |
msgid "Disable Gravatar and use only local avatars"
|
39 |
msgstr "Desactivar Gravatar y utilizar sólo los avatares locales"
|
40 |
|
41 |
+
#: includes/wpua-options-page.php:117
|
42 |
+
#: includes/wpua-options-page.php:122
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Sube límite de tamaño"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:117
|
47 |
+
#: includes/wpua-options-page.php:122
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(para colaboradores y suscriptores)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:132
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Permitir a los usuarios editar avatar"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:138
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Cambiar el tamaño de avatares en carga"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:148
|
60 |
+
msgid "Crop avatars to exact dimensions"
|
61 |
+
msgstr "Recortar los avatares a sus dimensiones exactas"
|
62 |
+
|
63 |
#. Plugin Name of the plugin/theme
|
64 |
msgid "WP User Avatar"
|
65 |
msgstr "WP-Usuario-Avatar"
|
lang/wp-user-avatar-fr_FR.mo
CHANGED
Binary file
|
lang/wp-user-avatar-fr_FR.po
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
# French (fr_FR) translation for WP User Avatar.
|
2 |
-
# Copyright (C)
|
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date:
|
10 |
"Language: fr_FR\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\n"
|
@@ -14,32 +14,52 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
|
19 |
-
|
20 |
-
msgstr "Cliquez sur %s pour enregistrer vos modifications"
|
21 |
|
22 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
|
25 |
|
26 |
-
#:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Permettre aux contributeurs et aux abonnés d'envoyer des avatars"
|
29 |
|
30 |
-
#:
|
31 |
msgid "Disable Gravatar and use only local avatars"
|
32 |
msgstr "Désactiver Gravatar et utiliser les avatars fournis"
|
33 |
|
34 |
-
#:
|
35 |
-
#:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Taille limite d'envoi de fichiers
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
#:
|
40 |
msgid "Allow users to edit avatars"
|
41 |
msgstr "Permettre aux utilisateurs de modifier avatar"
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
#. Plugin Name of the plugin/theme
|
44 |
msgid "WP User Avatar"
|
45 |
msgstr "WP-Utilisateur-Avatar"
|
1 |
# French (fr_FR) 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: fr_FR\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\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 "Faites un don"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:189
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Etes-vous satisfait avec WP-Utilisateur-Avatar?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:189
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Faites un don"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:83
|
30 |
msgid "Add avatar button to Visual Editor"
|
31 |
msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
|
32 |
|
33 |
+
#: includes/wpua-options-page.php:89
|
34 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
35 |
msgstr "Permettre aux contributeurs et aux abonnés d'envoyer des avatars"
|
36 |
|
37 |
+
#: includes/wpua-options-page.php:95
|
38 |
msgid "Disable Gravatar and use only local avatars"
|
39 |
msgstr "Désactiver Gravatar et utiliser les avatars fournis"
|
40 |
|
41 |
+
#: includes/wpua-options-page.php:117
|
42 |
+
#: includes/wpua-options-page.php:122
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Taille limite d'envoi de fichiers"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:117
|
47 |
+
#: includes/wpua-options-page.php:122
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(pour contributeurs et abonnés)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:132
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Permettre aux utilisateurs de modifier avatar"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:138
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Redimensionner avatars lors du téléchargement"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:148
|
60 |
+
msgid "Crop avatars to exact dimensions"
|
61 |
+
msgstr "Recadrer les avatars pour parvenir aux dimensions exactes"
|
62 |
+
|
63 |
#. Plugin Name of the plugin/theme
|
64 |
msgid "WP User Avatar"
|
65 |
msgstr "WP-Utilisateur-Avatar"
|
lang/wp-user-avatar-pl_PL.mo
ADDED
Binary file
|
lang/wp-user-avatar-pl_PL.po
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Polish (pl_PL) 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 "Dotuj"
|
20 |
+
|
21 |
+
#: includes/wpua-functions.php:189
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Jesteś zadowolony z Wp User Avatar"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:189
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Dokonaj dotacji"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:83
|
30 |
+
msgid "Add avatar button to Visual Editor"
|
31 |
+
msgstr "Dodaj przycisk avatara do edytora wizualnego"
|
32 |
+
|
33 |
+
#: includes/wpua-options-page.php:89
|
34 |
+
msgid "Allow Contributors & Subscribers to upload avatars"
|
35 |
+
msgstr "Pozwalaj kontrybutorom oraz subskrynentom przesyłać awatary"
|
36 |
+
|
37 |
+
#: includes/wpua-options-page.php:95
|
38 |
+
msgid "Disable Gravatar and use only local avatars"
|
39 |
+
msgstr "Wyłącz gravatary i używaj tylko lokalnych awatarów"
|
40 |
+
|
41 |
+
#: includes/wpua-options-page.php:117
|
42 |
+
#: includes/wpua-options-page.php:122
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Limit wielkości pliku"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:117
|
47 |
+
#: includes/wpua-options-page.php:122
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(tylko dla subskrynentów i kontrybutorów)"
|
50 |
+
|
51 |
+
#: includes/wpua-options-page.php:132
|
52 |
+
msgid "Allow users to edit avatars"
|
53 |
+
msgstr "Pozwalaj użytkownikom edytować awatary"
|
54 |
+
|
55 |
+
#: includes/wpua-options-page.php:138
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Zmieniaj rozmiar po przesłaniu"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:148
|
60 |
+
msgid "Crop avatars to exact dimensions"
|
61 |
+
msgstr "Przytnij awatar do dokładnych rozmiarów"
|
62 |
+
|
63 |
+
#. Plugin Name of the plugin/theme
|
64 |
+
msgid "WP User Avatar"
|
65 |
+
msgstr "WP Awatar Użytkownika"
|
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 "Użyj dowolnego obrazka z biblioteki mediów jako awatar użytkownika. Dodaj swój własny domyślny awatar."
|
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-sv_SE.mo
CHANGED
Binary file
|
lang/wp-user-avatar-sv_SE.po
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
# Swedish (sv_SE) translation for WP User Avatar.
|
2 |
-
# Copyright (C)
|
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date:
|
10 |
"Language: sv_SE\n"
|
11 |
"Last-Translator: Mattias Tengblad <mst@eyesx.com>\n"
|
12 |
"Language-Team: WordPress Sverige <info@wpsv.se>\n"
|
@@ -14,32 +14,52 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
|
19 |
-
|
20 |
-
msgstr "Klicka på %s för att spara dina ändringar"
|
21 |
|
22 |
-
#:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Lägg till knapp för avatarer i den visuella redigeraren"
|
25 |
|
26 |
-
#:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
|
29 |
|
30 |
-
#:
|
31 |
msgid "Disable Gravatar and use only local avatars"
|
32 |
msgstr "Inaktivera Gravatar och använd endast lokala avatarer"
|
33 |
|
34 |
-
#:
|
35 |
-
#:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Storleksgräns för uppladdningar
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
#:
|
40 |
msgid "Allow users to edit avatars"
|
41 |
msgstr "Tillåt användare att redigera avatarer"
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
#. Plugin Name of the plugin/theme
|
44 |
msgid "WP User Avatar"
|
45 |
msgstr "Visningsbild (avatar)"
|
1 |
# Swedish (sv_SE) 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: sv_SE\n"
|
11 |
"Last-Translator: Mattias Tengblad <mst@eyesx.com>\n"
|
12 |
"Language-Team: WordPress Sverige <info@wpsv.se>\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 "Donera"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:189
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Är du nöjd med Visningsbild (avatar)?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:189
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Donera"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:83
|
30 |
msgid "Add avatar button to Visual Editor"
|
31 |
msgstr "Lägg till knapp för avatarer i den visuella redigeraren"
|
32 |
|
33 |
+
#: includes/wpua-options-page.php:89
|
34 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
35 |
msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
|
36 |
|
37 |
+
#: includes/wpua-options-page.php:95
|
38 |
msgid "Disable Gravatar and use only local avatars"
|
39 |
msgstr "Inaktivera Gravatar och använd endast lokala avatarer"
|
40 |
|
41 |
+
#: includes/wpua-options-page.php:117
|
42 |
+
#: includes/wpua-options-page.php:122
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Storleksgräns för uppladdningar"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:117
|
47 |
+
#: includes/wpua-options-page.php:122
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(endast för medarbetare & prenumeranter)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:132
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Tillåt användare att redigera avatarer"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:138
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Ändra storlek på avatarer på uppladdning"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:148
|
60 |
+
msgid "Crop avatars to exact dimensions"
|
61 |
+
msgstr "Beskär avatarer till exakta dimensioner"
|
62 |
+
|
63 |
#. Plugin Name of the plugin/theme
|
64 |
msgid "WP User Avatar"
|
65 |
msgstr "Visningsbild (avatar)"
|
readme.txt
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
=== WP User Avatar ===
|
2 |
|
3 |
-
Contributors:
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
Stable tag: 1.5.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -13,26 +12,35 @@ Use any image from your WordPress Media Library as a custom user avatar. Add you
|
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
-
WordPress currently only allows you to use custom avatars that are uploaded through [Gravatar](http://gravatar.com/). WP User Avatar enables you to use any photo uploaded into your Media Library as an avatar. This means you use the same uploader and library as your posts. No extra folders or image editing functions are necessary.
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
|
20 |
* Upload your own Default Avatar in your WP User Avatar settings.
|
21 |
* Show the user's [Gravatar](http://gravatar.com/) avatar or Default Avatar if the user doesn't have a WP User Avatar image.
|
22 |
* Disable [Gravatar](http://gravatar.com/) avatars and use only local avatars.
|
23 |
-
* Use the <code>[
|
|
|
24 |
* Allow Contributors and Subscribers to upload their own avatars.
|
25 |
-
* Limit upload file size for Contributors and Subscribers.
|
|
|
|
|
26 |
|
27 |
== Installation ==
|
28 |
|
|
|
|
|
29 |
1. Download, install, and activate the WP User Avatar plugin.
|
30 |
2. On your profile edit page, click "Edit Image".
|
31 |
3. Choose an image, then click "Select Image".
|
32 |
4. Click "Update Profile".
|
33 |
5. Upload your own Default Avatar in your WP User Avatar settings (optional). You can also allow Contributors & Subscribers to upload avatars and disable Gravatar.
|
34 |
6. Choose a theme that has avatar support. In your theme, manually replace <code>get_avatar</code> with <code>get_wp_user_avatar</code> or leave <code>get_avatar</code> as-is. [Read about the differences here](http://wordpress.org/extend/plugins/wp-user-avatar/faq/).
|
35 |
-
7. You can also use the <code>[avatar]</code>
|
36 |
|
37 |
**Example Usage**
|
38 |
|
@@ -90,11 +98,25 @@ For comments, you must specify the $comment variable.
|
|
90 |
|
91 |
**Other Available Functions**
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
= [avatar] shortcode =
|
94 |
|
95 |
You can use the <code>[avatar]</code> shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.
|
96 |
|
97 |
-
`[avatar user="admin" size="medium" align="left" link="file"]`
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
= get_wp_user_avatar_src =
|
100 |
|
@@ -118,6 +140,8 @@ Returns true if the user has a WP User Avatar image. You must specify the user I
|
|
118 |
|
119 |
== Frequently Asked Questions ==
|
120 |
|
|
|
|
|
121 |
= How do I use WP User Avatar? =
|
122 |
|
123 |
First, choose a theme that has avatar support. In your theme, you have a choice of manually replacing <code>get_avatar</code> with <code>get_wp_user_avatar</code>, or leaving <code>get_avatar</code> as-is. Here are the differences:
|
@@ -126,9 +150,10 @@ First, choose a theme that has avatar support. In your theme, you have a choice
|
|
126 |
|
127 |
1. Allows you to use the values "original", "large", "medium", or "thumbnail" for your avatar size.
|
128 |
2. Doesn't add a fixed width and height to the image if you use the aforementioned values. This will give you more flexibility to resize the image with CSS.
|
129 |
-
3.
|
130 |
-
4.
|
131 |
-
5. Shows
|
|
|
132 |
|
133 |
= get_avatar =
|
134 |
|
@@ -143,17 +168,9 @@ First, choose a theme that has avatar support. In your theme, you have a choice
|
|
143 |
= Can I create a custom Default Avatar? =
|
144 |
In your WP User Avatar settings, you can upload your own Default Avatar.
|
145 |
|
146 |
-
= Can I
|
147 |
-
|
148 |
-
You can use the <code>[avatar]</code> shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.
|
149 |
-
|
150 |
-
`[avatar user="admin" size="96" align="left" link="file"]`
|
151 |
-
|
152 |
-
Outputs:
|
153 |
|
154 |
-
|
155 |
-
<img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96 alignleft" />
|
156 |
-
</a>`
|
157 |
|
158 |
= Can Contributors or Subscribers choose their own WP User Avatar image? =
|
159 |
Yes, if you enable "Allow Contributors & Subscribers to upload avatars" in the WP User Avatar settings. These users will see a slightly different interface because they are allowed only one image upload.
|
@@ -162,14 +179,14 @@ Yes, if you enable "Allow Contributors & Subscribers to upload avatars" in the W
|
|
162 |
|
163 |
Yes, for registered users. Non-registered comment authors will show their [Gravatar](http://gravatar.com/) avatars or Default Avatar.
|
164 |
|
165 |
-
= Can I disable all Gravatar avatars? =
|
166 |
-
|
167 |
-
In your WP User Avatar settings, you can select "Disable Gravatar — Use only local avatars" to disable all [Gravatar](http://gravatar.com/) avatars on your site and replace them with your Default Avatar. This will affect your registered users and non-registered comment authors.
|
168 |
-
|
169 |
= Will WP User Avatar work with bbPress? =
|
170 |
|
171 |
Yes!
|
172 |
|
|
|
|
|
|
|
|
|
173 |
= Will WP User Avatar work with WordPress Multisite? =
|
174 |
|
175 |
Yes, however, each site has its own avatar settings. If you set a WP User Avatar image on one site, you have to set it again for different sites in your network.
|
@@ -178,6 +195,41 @@ Yes, however, each site has its own avatar settings. If you set a WP User Avatar
|
|
178 |
|
179 |
For Administrators, WP User Avatar adds a column with avatar thumbnails to your Users list table. If "Show Avatars" is enabled in your WP User Avatar settings, you will see avatars to the left of each username instead of in a new column.
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
= What CSS can I use with WP User Avatar? =
|
182 |
|
183 |
WP User Avatar will add the CSS classes "wp-user-avatar" and "wp-user-avatar-{size}" to your image. If you add an alignment, the corresponding alignment class will be added:
|
@@ -206,7 +258,7 @@ If you use the <code>[avatar]</code> shortcode, WP User Avatar will add the CSS
|
|
206 |
* Attachment: wp-user-avatar-attachment
|
207 |
* Custom URL: wp-user-avatar-custom
|
208 |
|
209 |
-
`[avatar user="admin" size="96" align="left" link="attachment"]`
|
210 |
|
211 |
Outputs:
|
212 |
|
@@ -219,17 +271,287 @@ Outputs:
|
|
219 |
* <code>has_wp_user_avatar</code>: checks if the user has a WP User Avatar image
|
220 |
* [See example usage here](http://wordpress.org/extend/plugins/wp-user-avatar/installation/)
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
== Screenshots ==
|
223 |
|
224 |
1. WP User Avatar admin settings.
|
225 |
2. WP User Avatar lets you upload your own Default Avatar.
|
226 |
3. WP User Avatar adds a field to your profile edit page.
|
227 |
4. After you've chosen a WP User Avatar image, you will see the option to remove it.
|
228 |
-
5. WP User Avatar adds a button to insert the [avatar] shortcode in the Visual Editor.
|
229 |
-
6. Options for the [avatar] shortcode.
|
230 |
|
231 |
== Changelog ==
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
= 1.5.6 =
|
234 |
* Update: Use cache for wpua_has_gravatar
|
235 |
|
@@ -238,7 +560,7 @@ Outputs:
|
|
238 |
* Bug Fix: Remove edit_posts capability if Subscribers can't edit avatar
|
239 |
|
240 |
= 1.5.4 =
|
241 |
-
* Add: Option to enable avatar editing privilege for Subscribers
|
242 |
* Add: Swedish translation
|
243 |
* Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
|
244 |
* Update: Load JavaScript in footer
|
@@ -270,7 +592,7 @@ Outputs:
|
|
270 |
* Bug Fix: Use wp_die for errors
|
271 |
|
272 |
= 1.4 =
|
273 |
-
* Add: Uploader for
|
274 |
* Add: Media states for avatar images
|
275 |
* Add: Plugin admin settings
|
276 |
* Update: Change support only to WP 3.4+
|
@@ -330,7 +652,7 @@ Outputs:
|
|
330 |
= 1.2 =
|
331 |
* Add: Default Avatar setting
|
332 |
|
333 |
-
= 1.1.
|
334 |
* Bug Fix: Change update_usermeta to update_user_meta
|
335 |
|
336 |
= 1.1.6 =
|
@@ -374,6 +696,10 @@ Outputs:
|
|
374 |
|
375 |
== Upgrade Notice ==
|
376 |
|
|
|
|
|
|
|
|
|
377 |
= 1.5.3 =
|
378 |
* Notice: WP User Avatar 1.5.3 only supports WordPress 3.5 and above. If you are using an older version of WordPress, please upgrade your version of WordPress first.
|
379 |
|
1 |
=== WP User Avatar ===
|
2 |
|
3 |
+
Contributors: flippercode
|
4 |
+
Tags: author image, author photo, author avatar, avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo, widget
|
5 |
+
Requires at least: 3.6
|
6 |
+
Tested up to: 3.9
|
7 |
+
Stable tag: 1.9.13
|
|
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
WordPress currently only allows you to use custom avatars that are uploaded through [Gravatar](http://gravatar.com/). **WP User Avatar** enables you to use any photo uploaded into your Media Library as an avatar. This means you use the same uploader and library as your posts. No extra folders or image editing functions are necessary.
|
16 |
|
17 |
+
**Maintained and Supported by Flipper Code**
|
18 |
+
|
19 |
+
Flipper Code has been providing WordPress Services since 2008. Flipper Code expertise in [custom plugins development](http://codecanyon.net/user/flippercode/portfolio) and [wordpress websites development](http://www.flippercode.com/our-portfolio/).
|
20 |
+
|
21 |
+
**WP User Avatar** also lets you:
|
22 |
|
23 |
* Upload your own Default Avatar in your WP User Avatar settings.
|
24 |
* Show the user's [Gravatar](http://gravatar.com/) avatar or Default Avatar if the user doesn't have a WP User Avatar image.
|
25 |
* Disable [Gravatar](http://gravatar.com/) avatars and use only local avatars.
|
26 |
+
* Use the <code>[avatar_upload]</code> shortcode to add a standalone uploader to a front page or widget. This uploader is only visible to logged-in users.
|
27 |
+
* Use the <code>[avatar]</code> shortcode in your posts. These shortcodes will work with any theme, whether it has avatar support or not.
|
28 |
* Allow Contributors and Subscribers to upload their own avatars.
|
29 |
+
* Limit upload file size and image dimensions for Contributors and Subscribers.
|
30 |
+
|
31 |
+
Visit [WP User Avatar](http://wpuseravatar.com/) for more information and documentation.
|
32 |
|
33 |
== Installation ==
|
34 |
|
35 |
+
Visit [WP User Avatar](http://wpuseravatar.com/) for more information and documentation.
|
36 |
+
|
37 |
1. Download, install, and activate the WP User Avatar plugin.
|
38 |
2. On your profile edit page, click "Edit Image".
|
39 |
3. Choose an image, then click "Select Image".
|
40 |
4. Click "Update Profile".
|
41 |
5. Upload your own Default Avatar in your WP User Avatar settings (optional). You can also allow Contributors & Subscribers to upload avatars and disable Gravatar.
|
42 |
6. Choose a theme that has avatar support. In your theme, manually replace <code>get_avatar</code> with <code>get_wp_user_avatar</code> or leave <code>get_avatar</code> as-is. [Read about the differences here](http://wordpress.org/extend/plugins/wp-user-avatar/faq/).
|
43 |
+
7. You can also use the <code>[avatar_upload]</code> and <code>[avatar]</code> shortcodes in your posts. These shortcodes will work with any theme, whether it has avatar support or not.
|
44 |
|
45 |
**Example Usage**
|
46 |
|
98 |
|
99 |
**Other Available Functions**
|
100 |
|
101 |
+
= [avatar_upload] shortcode =
|
102 |
+
|
103 |
+
You can use the <code>[avatar_upload]</code> shortcode to add a standalone uploader to a front page or widget. This uploader is only visible to logged-in users. If you want to integrate the uploader into a profile edit page, see [Other Notes](http://wordpress.org/plugins/wp-user-avatar/other_notes/).
|
104 |
+
|
105 |
+
You can specify a user with the shortcode, but you must have <code>edit_user</code> capability for that particular user.
|
106 |
+
|
107 |
+
`[avatar_upload user="admin"]`
|
108 |
+
|
109 |
= [avatar] shortcode =
|
110 |
|
111 |
You can use the <code>[avatar]</code> shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.
|
112 |
|
113 |
+
`[avatar user="admin" size="medium" align="left" link="file" /]`
|
114 |
+
|
115 |
+
You can also add a caption to the shortcode:
|
116 |
+
|
117 |
+
`[avatar user="admin" size="medium" align="left" link="file"]Photo Credit: Your Name[/avatar]`
|
118 |
+
|
119 |
+
**Note:** If you are using one shortcode without a caption and another shortcode with a caption on the same page, you must close the caption-less shortcode with a forward slash before the closing bracket: <code>[avatar /]</code> instead of <code>[avatar]</code>
|
120 |
|
121 |
= get_wp_user_avatar_src =
|
122 |
|
140 |
|
141 |
== Frequently Asked Questions ==
|
142 |
|
143 |
+
Visit [WP User Avatar](http://wpuseravatar.com/) for more information and documentation.
|
144 |
+
|
145 |
= How do I use WP User Avatar? =
|
146 |
|
147 |
First, choose a theme that has avatar support. In your theme, you have a choice of manually replacing <code>get_avatar</code> with <code>get_wp_user_avatar</code>, or leaving <code>get_avatar</code> as-is. Here are the differences:
|
150 |
|
151 |
1. Allows you to use the values "original", "large", "medium", or "thumbnail" for your avatar size.
|
152 |
2. Doesn't add a fixed width and height to the image if you use the aforementioned values. This will give you more flexibility to resize the image with CSS.
|
153 |
+
3. Allows you to use custom image sizes registered with [<code>add_image_size</code>](http://codex.wordpress.org/Function_Reference/add_image_size) (fixed width and height are added to the image).
|
154 |
+
4. Optionally adds CSS classes "alignleft", "alignright", or "aligncenter" to position your avatar.
|
155 |
+
5. Shows nothing if the user has no WP User Avatar image.
|
156 |
+
6. Shows the user's [Gravatar](http://gravatar.com/) avatar or Default Avatar only if "Show Avatars" is enabled in your WP User Avatar settings.
|
157 |
|
158 |
= get_avatar =
|
159 |
|
168 |
= Can I create a custom Default Avatar? =
|
169 |
In your WP User Avatar settings, you can upload your own Default Avatar.
|
170 |
|
171 |
+
= Can I disable all Gravatar avatars? =
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
In your WP User Avatar settings, you can select "Disable Gravatar — Use only local avatars" to disable all [Gravatar](http://gravatar.com/) avatars on your site and replace them with your Default Avatar. This will affect your registered users and non-registered comment authors.
|
|
|
|
|
174 |
|
175 |
= Can Contributors or Subscribers choose their own WP User Avatar image? =
|
176 |
Yes, if you enable "Allow Contributors & Subscribers to upload avatars" in the WP User Avatar settings. These users will see a slightly different interface because they are allowed only one image upload.
|
179 |
|
180 |
Yes, for registered users. Non-registered comment authors will show their [Gravatar](http://gravatar.com/) avatars or Default Avatar.
|
181 |
|
|
|
|
|
|
|
|
|
182 |
= Will WP User Avatar work with bbPress? =
|
183 |
|
184 |
Yes!
|
185 |
|
186 |
+
= Will WP User Avatar work with BuddyPress? =
|
187 |
+
|
188 |
+
No, BuddyPress has its own custom avatar functions and WP User Avatar will override only some of them. It's best to use BuddyPress without WP User Avatar.
|
189 |
+
|
190 |
= Will WP User Avatar work with WordPress Multisite? =
|
191 |
|
192 |
Yes, however, each site has its own avatar settings. If you set a WP User Avatar image on one site, you have to set it again for different sites in your network.
|
195 |
|
196 |
For Administrators, WP User Avatar adds a column with avatar thumbnails to your Users list table. If "Show Avatars" is enabled in your WP User Avatar settings, you will see avatars to the left of each username instead of in a new column.
|
197 |
|
198 |
+
= Can I use the WP User Avatar uploader in a front page or widget? =
|
199 |
+
|
200 |
+
Yes, you can use the <code>[avatar_upload]</code> shortcode to put a standalone uploader in a front page or widget. This uploader is only visible to logged-in users. If you want to integrate the uploader into a profile edit page, see [Other Notes](http://wordpress.org/plugins/wp-user-avatar/other_notes/).
|
201 |
+
|
202 |
+
You can specify a user with the shortcode, but you must have <code>'edit_user'</code> capability to change the user's avatar.
|
203 |
+
|
204 |
+
`[avatar_upload user="admin"]`
|
205 |
+
|
206 |
+
= Can I insert WP User Avatar directly into a post? =
|
207 |
+
|
208 |
+
You can use the <code>[avatar]</code> shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.
|
209 |
+
|
210 |
+
`[avatar user="admin" size="96" align="left" link="file" /]`
|
211 |
+
|
212 |
+
Outputs:
|
213 |
+
|
214 |
+
`<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
|
215 |
+
<img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96 alignleft" />
|
216 |
+
</a>`
|
217 |
+
|
218 |
+
If you have a caption, the output will be similar to how WordPress adds captions to other images.
|
219 |
+
|
220 |
+
`[avatar user="admin" size="96" align="left" link="file"]Photo Credit: Your Name[/avatar]`
|
221 |
+
|
222 |
+
Outputs:
|
223 |
+
|
224 |
+
`<div style="width: 106px" class="wp-caption alignleft">
|
225 |
+
<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
|
226 |
+
<img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96" />
|
227 |
+
</a>
|
228 |
+
<p class="wp-caption-text">Photo Credit: Your Name</p>
|
229 |
+
</div>`
|
230 |
+
|
231 |
+
**Note:** If you are using one shortcode without a caption and another shortcode with a caption on the same page, you must close the caption-less shortcode with a forward slash before the closing bracket: <code>[avatar /]</code> instead of <code>[avatar]</code>
|
232 |
+
|
233 |
= What CSS can I use with WP User Avatar? =
|
234 |
|
235 |
WP User Avatar will add the CSS classes "wp-user-avatar" and "wp-user-avatar-{size}" to your image. If you add an alignment, the corresponding alignment class will be added:
|
258 |
* Attachment: wp-user-avatar-attachment
|
259 |
* Custom URL: wp-user-avatar-custom
|
260 |
|
261 |
+
`[avatar user="admin" size="96" align="left" link="attachment" /]`
|
262 |
|
263 |
Outputs:
|
264 |
|
271 |
* <code>has_wp_user_avatar</code>: checks if the user has a WP User Avatar image
|
272 |
* [See example usage here](http://wordpress.org/extend/plugins/wp-user-avatar/installation/)
|
273 |
|
274 |
+
= There's a call for donations in the WP User Avatar settings. How can I remove it? =
|
275 |
+
I've spent countless hours developing this plugin for free. If you're able to give a donation I'd appreciate it, but it's by no means a requirement. You can remove the message by adding this to the <code>functions.php</code> file of your theme:
|
276 |
+
|
277 |
+
`remove_action('wpua_donation_message', 'wpua_do_donation_message');`
|
278 |
+
|
279 |
+
== Advanced Settings ==
|
280 |
+
|
281 |
+
Visit [WP User Avatar](http://wpuseravatar.com/) for more information and documentation.
|
282 |
+
|
283 |
+
= Add WP User Avatar to your own profile edit page =
|
284 |
+
|
285 |
+
You can use the [avatar_upload] shortcode to add a standalone uploader to any page. It's best to use this uploader by itself and without other profile fields.
|
286 |
+
|
287 |
+
If you're building your own profile edit page with other fields, WP User Avatar is automatically added to the [show_user_profile](http://codex.wordpress.org/Plugin_API/Action_Reference/show_user_profile) and [edit_user_profile](http://codex.wordpress.org/Plugin_API/Action_Reference/show_user_profile) hooks. If you'd rather have WP User Avatar in its own section, you could add another hook:
|
288 |
+
|
289 |
+
`do_action('edit_user_avatar', $current_user);`
|
290 |
+
|
291 |
+
Then, to add WP User Avatar to that hook and remove it from the other hooks outside of the administration panel, you would add this code to the <code>functions.php</code> file of your theme:
|
292 |
+
|
293 |
+
`function my_avatar_filter() {
|
294 |
+
// Remove from show_user_profile hook
|
295 |
+
remove_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
296 |
+
remove_action('show_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
297 |
+
|
298 |
+
// Remove from edit_user_profile hook
|
299 |
+
remove_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
300 |
+
remove_action('edit_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
301 |
+
|
302 |
+
// Add to edit_user_avatar hook
|
303 |
+
add_action('edit_user_avatar', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
304 |
+
add_action('edit_user_avatar', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
305 |
+
}
|
306 |
+
|
307 |
+
// Loads only outside of administration panel
|
308 |
+
if(!is_admin()) {
|
309 |
+
add_action('init','my_avatar_filter');
|
310 |
+
}`
|
311 |
+
|
312 |
+
= HTML Wrapper =
|
313 |
+
|
314 |
+
You can change the HTML wrapper of the WP User Avatar section by using the functions <code>wpua_before_avatar</code> and <code>wpua_after_avatar</code>. By default, the avatar code is structured like this:
|
315 |
+
|
316 |
+
`<div class="wpua-edit-container">
|
317 |
+
<h3>Avatar</h3>
|
318 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
|
319 |
+
<p id="wpua-add-button">
|
320 |
+
<button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
|
321 |
+
</p>
|
322 |
+
<p id="wpua-preview">
|
323 |
+
<img src="{imageURL}" alt="" />
|
324 |
+
Original Size
|
325 |
+
</p>
|
326 |
+
<p id="wpua-thumbnail">
|
327 |
+
<img src="{imageURL}" alt="" />
|
328 |
+
Thumbnail
|
329 |
+
</p>
|
330 |
+
<p id="wpua-remove-button">
|
331 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove">Default Avatar</button>
|
332 |
+
</p>
|
333 |
+
<p id="wpua-undo-button">
|
334 |
+
<button type="button" class="button" id="wpua-undo" name="wpua-undo">Undo</button>
|
335 |
+
</p>
|
336 |
+
</div>`
|
337 |
+
|
338 |
+
To strip out the div container and h3 heading, you would add the following filters to the <code>functions.php</code> file in your theme:
|
339 |
+
|
340 |
+
`remove_action('wpua_before_avatar', 'wpua_do_before_avatar');
|
341 |
+
remove_action('wpua_after_avatar', 'wpua_do_after_avatar');`
|
342 |
+
|
343 |
+
To add your own wrapper, you could create something like this:
|
344 |
+
|
345 |
+
`function my_before_avatar() {
|
346 |
+
echo '<div id="my-avatar">';
|
347 |
+
}
|
348 |
+
add_action('wpua_before_avatar', 'my_before_avatar');
|
349 |
+
|
350 |
+
function my_after_avatar() {
|
351 |
+
echo '</div>';
|
352 |
+
}
|
353 |
+
add_action('wpua_after_avatar', 'my_after_avatar');`
|
354 |
+
|
355 |
+
This would output:
|
356 |
+
|
357 |
+
`<div id="my-avatar">
|
358 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
|
359 |
+
<p id="wpua-add-button">
|
360 |
+
<button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
|
361 |
+
</p>
|
362 |
+
<p id="wpua-preview">
|
363 |
+
<img src="{imageURL}" alt="" />
|
364 |
+
<span class="description">Original Size</span>
|
365 |
+
</p>
|
366 |
+
<p id="wpua-thumbnail">
|
367 |
+
<img src="{imageURL}" alt="" />
|
368 |
+
<span class="description">Thumbnail</span>
|
369 |
+
</p>
|
370 |
+
<p id="wpua-remove-button">
|
371 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove">Default Avatar</button>
|
372 |
+
</p>
|
373 |
+
<p id="wpua-undo-button">
|
374 |
+
<button type="button" class="button" id="wpua-undo" name="wpua-undo">Undo</button>
|
375 |
+
</p>
|
376 |
+
</div>`
|
377 |
+
|
378 |
== Screenshots ==
|
379 |
|
380 |
1. WP User Avatar admin settings.
|
381 |
2. WP User Avatar lets you upload your own Default Avatar.
|
382 |
3. WP User Avatar adds a field to your profile edit page.
|
383 |
4. After you've chosen a WP User Avatar image, you will see the option to remove it.
|
|
|
|
|
384 |
|
385 |
== Changelog ==
|
386 |
|
387 |
+
= 1.9.13 =
|
388 |
+
* Bug Fix: Load _load_wp_includes mostly only on front pages
|
389 |
+
* Bug Fix: Check for edit_posts capability before enabling filters for Subscribers
|
390 |
+
|
391 |
+
= 1.9.12 =
|
392 |
+
* Add: wpua_edit_user_redirect_url filter
|
393 |
+
* Add: wpua_edit_user_safe_redirect filter
|
394 |
+
* Bug Fix: Clean output buffer
|
395 |
+
* Update: Description field for widget
|
396 |
+
|
397 |
+
= 1.9.11 =
|
398 |
+
* Update: Disable resource manager until a better solution comes along
|
399 |
+
|
400 |
+
= 1.9.10 =
|
401 |
+
* Bug Fix: Check for TinyMCE version
|
402 |
+
|
403 |
+
= 1.9.9 =
|
404 |
+
* Bug Fix: TinyMCE not loaded
|
405 |
+
|
406 |
+
= 1.9.8 =
|
407 |
+
* Bug Fix: Check user permissions for displaying widget
|
408 |
+
* Update: Load resource manager only if NextGEN Gallery isn't installed
|
409 |
+
|
410 |
+
= 1.9.7 =
|
411 |
+
* Bug Fix: Remove resource manager
|
412 |
+
* Bug Fix: User ID in shortcode
|
413 |
+
|
414 |
+
= 1.9.6 =
|
415 |
+
* Bug Fix: Load resource manager on front pages only
|
416 |
+
* Update: [avatar_upload] user variable
|
417 |
+
* Update: Documentation
|
418 |
+
|
419 |
+
= 1.9.5 =
|
420 |
+
* Add: Start documentation of functions
|
421 |
+
* Bug Fix: [avatar_upload] permalink and redirect
|
422 |
+
|
423 |
+
= 1.9.4 =
|
424 |
+
* Add: Widget for [avatar_upload]
|
425 |
+
* Add: wpua_before_avatar_admin and wpua_after_avatar_admin for admin pages
|
426 |
+
* Bug Fix: Load functions class on plugins_loaded
|
427 |
+
* Update: Allow non-numeric WPUA value
|
428 |
+
|
429 |
+
= 1.9.3 =
|
430 |
+
* Bug Fix: Missing php
|
431 |
+
|
432 |
+
= 1.9.2 =
|
433 |
+
* Add: Setup class
|
434 |
+
* Bug Fix: Give wpua_attachment_is_image filter two variables
|
435 |
+
* Bug Fix: Return [avatar_upload] instead of echo
|
436 |
+
* Remove: Unneccessary filters
|
437 |
+
* Update: Allow upload to overwrite avatar for Contributors & Subscribers
|
438 |
+
* Update: Move Edit Image link for Contributors & Subscribers
|
439 |
+
* Update: Move text from localize script to data attribute
|
440 |
+
* Update: Shorten variable names
|
441 |
+
* Update: Wrap all classes in init
|
442 |
+
|
443 |
+
= 1.9.1 =
|
444 |
+
* Bug Fix: Double underscore for options page title
|
445 |
+
* Bug Fix: Remove TinyMCE language pack
|
446 |
+
* Bug Fix: Wrong variables in get_wp_user_avatar filter
|
447 |
+
|
448 |
+
= 1.9 =
|
449 |
+
* Add: Filters throughout plugin
|
450 |
+
* Bug Fix: Die messages
|
451 |
+
* Update: Move public functions to class
|
452 |
+
|
453 |
+
= 1.8.10 =
|
454 |
+
* Add: Search and screen option in Media Library view
|
455 |
+
* Bug Fix: Bulk delete in Media Library view
|
456 |
+
* Bug Fix: Hide captions if "Show Avatars" is off
|
457 |
+
* Bug Fix: Update avatar metadata on removal
|
458 |
+
* Update: Choose Image text
|
459 |
+
* Update: Show only images in Media Library modal
|
460 |
+
* Update: Show upload tab if no WP User Avatar image has been selected yet
|
461 |
+
|
462 |
+
= 1.8.9 =
|
463 |
+
* Bug Fix: Check for post object
|
464 |
+
|
465 |
+
= 1.8.8 =
|
466 |
+
* Bug Fix: Media upload scripts
|
467 |
+
|
468 |
+
= 1.8.7 =
|
469 |
+
* Bug Fix: Bad reference to wpua_is_author_or_above
|
470 |
+
|
471 |
+
= 1.8.6 =
|
472 |
+
* Bug Fix: Check for media upload scripts before setting post parent
|
473 |
+
|
474 |
+
= 1.8.5 =
|
475 |
+
* Add: Capability check in one function
|
476 |
+
|
477 |
+
= 1.8.4 =
|
478 |
+
* Bug Fix: Set avatar post parent to 0
|
479 |
+
|
480 |
+
= 1.8.3 =
|
481 |
+
* Bug Fix: Prevent attachment insert without image
|
482 |
+
* Update: Check for delete_posts capability instead of user role for Subscribers
|
483 |
+
* Update: Refactor and clean up
|
484 |
+
|
485 |
+
= 1.8.2 =
|
486 |
+
* Bug Fix: Edit avatar setting
|
487 |
+
|
488 |
+
= 1.8.1 =
|
489 |
+
* Bug Fix: Reattach scripts to profile action
|
490 |
+
|
491 |
+
= 1.8 =
|
492 |
+
* Add: Front page uploader
|
493 |
+
* Add: Media Library view of all avatars
|
494 |
+
* Bug Fix: Identify public static functions
|
495 |
+
* Update: Refactor code into separate classes
|
496 |
+
* Update: Translations
|
497 |
+
|
498 |
+
= 1.7.2 =
|
499 |
+
* Bug Fix: Files not committed properly in previous release
|
500 |
+
|
501 |
+
= 1.7.1 =
|
502 |
+
* Update: Error message handling for front pages
|
503 |
+
|
504 |
+
= 1.7 =
|
505 |
+
* Add: Caption for avatar
|
506 |
+
* Add: Polish translation
|
507 |
+
* Update: Error message handling
|
508 |
+
|
509 |
+
= 1.6.8 =
|
510 |
+
* Bug Fix: Shortcode without user
|
511 |
+
|
512 |
+
= 1.6.7 =
|
513 |
+
* Add: Undo button
|
514 |
+
* Bug Fix: Get original avatar
|
515 |
+
|
516 |
+
= 1.6.6 =
|
517 |
+
* Add: Donation message
|
518 |
+
* Bug Fix: Die page when image is too large
|
519 |
+
* Bug Fix: Resize images uploaded through plugin only
|
520 |
+
* Remove: Unused function
|
521 |
+
* Update: Refactor JavaScript
|
522 |
+
|
523 |
+
= 1.6.5 =
|
524 |
+
* Bug Fix: Use entire comment object instead of just e-mail address
|
525 |
+
|
526 |
+
= 1.6.4 =
|
527 |
+
* Bug Fix: Correct avatar not showing in widget
|
528 |
+
* Update: Check compatibility to 3.7.1
|
529 |
+
|
530 |
+
= 1.6.3 =
|
531 |
+
* Bug Fix: Checkbox value for "Crop avatars to exact dimensions"
|
532 |
+
|
533 |
+
= 1.6.2 =
|
534 |
+
* Bug Fix: Show Default Avatar if attachment doesn't exist
|
535 |
+
* Bug Fix: manage_users_custom_column not returning values
|
536 |
+
|
537 |
+
= 1.6.1 =
|
538 |
+
* Bug Fix: Profile not saving without an avatar for Contributors & Subscribers
|
539 |
+
|
540 |
+
= 1.6.0 =
|
541 |
+
* Add: Filters to change profile HTML structure
|
542 |
+
* Add: Recognition of sizes registered with add_image_size
|
543 |
+
* Add: Resize image options for Contributors & Subscribers
|
544 |
+
* Bug Fix: Rerrange CSS class names
|
545 |
+
|
546 |
+
= 1.5.8 =
|
547 |
+
* Bug Fix: Add function exists checks to prevent redeclare errors
|
548 |
+
* Bug Fix: Page die if file upload is too big
|
549 |
+
* Bug Fix: Upload file with submit
|
550 |
+
|
551 |
+
= 1.5.7 =
|
552 |
+
* Bug Fix: Separate out JavaScript for Contributors & Subscribers
|
553 |
+
* Bug Fix: Subscriber uploader not finding error type
|
554 |
+
|
555 |
= 1.5.6 =
|
556 |
* Update: Use cache for wpua_has_gravatar
|
557 |
|
560 |
* Bug Fix: Remove edit_posts capability if Subscribers can't edit avatar
|
561 |
|
562 |
= 1.5.4 =
|
563 |
+
* Add: Option to enable avatar editing privilege for Contributors & Subscribers
|
564 |
* Add: Swedish translation
|
565 |
* Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
|
566 |
* Update: Load JavaScript in footer
|
592 |
* Bug Fix: Use wp_die for errors
|
593 |
|
594 |
= 1.4 =
|
595 |
+
* Add: Uploader for Contributors & Subscribers
|
596 |
* Add: Media states for avatar images
|
597 |
* Add: Plugin admin settings
|
598 |
* Update: Change support only to WP 3.4+
|
652 |
= 1.2 =
|
653 |
* Add: Default Avatar setting
|
654 |
|
655 |
+
= 1.1.8 =
|
656 |
* Bug Fix: Change update_usermeta to update_user_meta
|
657 |
|
658 |
= 1.1.6 =
|
696 |
|
697 |
== Upgrade Notice ==
|
698 |
|
699 |
+
= 1.8 =
|
700 |
+
* New Feature: Front page uploader
|
701 |
+
* New Feature: Media Library view of all avatars
|
702 |
+
|
703 |
= 1.5.3 =
|
704 |
* Notice: WP User Avatar 1.5.3 only supports WordPress 3.5 and above. If you are using an older version of WordPress, please upgrade your version of WordPress first.
|
705 |
|
uninstall.php
CHANGED
@@ -1,31 +1,52 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
11 |
|
12 |
-
global $
|
13 |
$users = get_users();
|
|
|
14 |
// Remove settings for all sites in multisite
|
15 |
-
if(is_multisite()){
|
16 |
-
$blogs =
|
17 |
-
foreach($users as $user){
|
18 |
-
foreach($blogs as $blog){
|
19 |
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog->blog_id).'user_avatar');
|
20 |
}
|
21 |
}
|
22 |
-
foreach($blogs as $blog){
|
23 |
switch_to_blog($blog->blog_id);
|
24 |
delete_option('avatar_default_wp_user_avatar');
|
25 |
delete_option('wp_user_avatar_allow_upload');
|
26 |
delete_option('wp_user_avatar_disable_gravatar');
|
27 |
delete_option('wp_user_avatar_edit_avatar');
|
28 |
delete_option('wp_user_avatar_load_scripts');
|
|
|
|
|
|
|
|
|
29 |
delete_option('wp_user_avatar_tinymce');
|
30 |
delete_option('wp_user_avatar_upload_size_limit');
|
31 |
delete_option('wp_user_avatar_default_avatar_updated');
|
@@ -33,7 +54,7 @@ if(is_multisite()){
|
|
33 |
delete_option('wp_user_avatar_users_updated');
|
34 |
}
|
35 |
} else {
|
36 |
-
foreach($users as $user){
|
37 |
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar');
|
38 |
}
|
39 |
delete_option('avatar_default_wp_user_avatar');
|
@@ -41,14 +62,19 @@ if(is_multisite()){
|
|
41 |
delete_option('wp_user_avatar_disable_gravatar');
|
42 |
delete_option('wp_user_avatar_edit_avatar');
|
43 |
delete_option('wp_user_avatar_load_scripts');
|
|
|
|
|
|
|
|
|
44 |
delete_option('wp_user_avatar_tinymce');
|
45 |
delete_option('wp_user_avatar_upload_size_limit');
|
46 |
delete_option('wp_user_avatar_default_avatar_updated');
|
47 |
delete_option('wp_user_avatar_media_updated');
|
48 |
delete_option('wp_user_avatar_users_updated');
|
49 |
}
|
|
|
50 |
// Delete post meta
|
51 |
delete_post_meta_by_key('_wp_attachment_wp_user_avatar');
|
|
|
52 |
// Reset all default avatars to Mystery Man
|
53 |
update_option('avatar_default', 'mystery');
|
54 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Remove user metadata and options on plugin delete.
|
4 |
+
*
|
5 |
* @package WP User Avatar
|
6 |
+
* @version 1.9.13
|
7 |
*/
|
8 |
|
9 |
+
/**
|
10 |
+
* @since 1.4
|
11 |
+
* @uses int $blog_id
|
12 |
+
* @uses object $wpdb
|
13 |
+
* @uses delete_option()
|
14 |
+
* @uses delete_post_meta_by_key()
|
15 |
+
* @uses delete_user_meta()
|
16 |
+
* @uses get_users()
|
17 |
+
* @uses get_blog_prefix()
|
18 |
+
* @uses is_multisite()
|
19 |
+
* @uses switch_to_blog()
|
20 |
+
* @uses update_option()
|
21 |
+
* @uses wp_get_sites()
|
22 |
+
*/
|
23 |
+
|
24 |
+
if(!defined('WP_UNINSTALL_PLUGIN')) {
|
25 |
+
die('You are not allowed to call this page directly.');
|
26 |
}
|
27 |
|
28 |
+
global $blog_id, $wpdb;
|
29 |
$users = get_users();
|
30 |
+
|
31 |
// Remove settings for all sites in multisite
|
32 |
+
if(is_multisite()) {
|
33 |
+
$blogs = wp_get_sites();
|
34 |
+
foreach($users as $user) {
|
35 |
+
foreach($blogs as $blog) {
|
36 |
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog->blog_id).'user_avatar');
|
37 |
}
|
38 |
}
|
39 |
+
foreach($blogs as $blog) {
|
40 |
switch_to_blog($blog->blog_id);
|
41 |
delete_option('avatar_default_wp_user_avatar');
|
42 |
delete_option('wp_user_avatar_allow_upload');
|
43 |
delete_option('wp_user_avatar_disable_gravatar');
|
44 |
delete_option('wp_user_avatar_edit_avatar');
|
45 |
delete_option('wp_user_avatar_load_scripts');
|
46 |
+
delete_option('wp_user_avatar_resize_crop');
|
47 |
+
delete_option('wp_user_avatar_resize_h');
|
48 |
+
delete_option('wp_user_avatar_resize_upload');
|
49 |
+
delete_option('wp_user_avatar_resize_w');
|
50 |
delete_option('wp_user_avatar_tinymce');
|
51 |
delete_option('wp_user_avatar_upload_size_limit');
|
52 |
delete_option('wp_user_avatar_default_avatar_updated');
|
54 |
delete_option('wp_user_avatar_users_updated');
|
55 |
}
|
56 |
} else {
|
57 |
+
foreach($users as $user) {
|
58 |
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar');
|
59 |
}
|
60 |
delete_option('avatar_default_wp_user_avatar');
|
62 |
delete_option('wp_user_avatar_disable_gravatar');
|
63 |
delete_option('wp_user_avatar_edit_avatar');
|
64 |
delete_option('wp_user_avatar_load_scripts');
|
65 |
+
delete_option('wp_user_avatar_resize_crop');
|
66 |
+
delete_option('wp_user_avatar_resize_h');
|
67 |
+
delete_option('wp_user_avatar_resize_upload');
|
68 |
+
delete_option('wp_user_avatar_resize_w');
|
69 |
delete_option('wp_user_avatar_tinymce');
|
70 |
delete_option('wp_user_avatar_upload_size_limit');
|
71 |
delete_option('wp_user_avatar_default_avatar_updated');
|
72 |
delete_option('wp_user_avatar_media_updated');
|
73 |
delete_option('wp_user_avatar_users_updated');
|
74 |
}
|
75 |
+
|
76 |
// Delete post meta
|
77 |
delete_post_meta_by_key('_wp_attachment_wp_user_avatar');
|
78 |
+
|
79 |
// Reset all default avatars to Mystery Man
|
80 |
update_option('avatar_default', 'mystery');
|
|
wp-user-avatar.php
CHANGED
@@ -1,987 +1,101 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
|
|
6 |
/*
|
7 |
Plugin Name: WP User Avatar
|
8 |
Plugin URI: http://wordpress.org/plugins/wp-user-avatar/
|
9 |
Description: Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.
|
10 |
-
Author:
|
11 |
-
Author URI: http://
|
12 |
-
Version: 1.
|
13 |
Text Domain: wp-user-avatar
|
14 |
Domain Path: /lang/
|
15 |
*/
|
16 |
|
17 |
-
if(!defined('ABSPATH')){
|
18 |
-
die(
|
19 |
-
@header('Content-Type:'.get_option('html_type').';charset='.get_option('blog_charset'));
|
20 |
-
}
|
21 |
-
|
22 |
-
// Define paths and variables
|
23 |
-
define('WPUA_VERSION', ' 1.5.6');
|
24 |
-
define('WPUA_FOLDER', basename(dirname(__FILE__)));
|
25 |
-
define('WPUA_ABSPATH', trailingslashit(str_replace('\\', '/', WP_PLUGIN_DIR.'/'.WPUA_FOLDER)));
|
26 |
-
define('WPUA_URLPATH', trailingslashit(plugins_url(WPUA_FOLDER)));
|
27 |
-
|
28 |
-
// Define global variables
|
29 |
-
$avatar_default = get_option('avatar_default');
|
30 |
-
$show_avatars = get_option('show_avatars');
|
31 |
-
$wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
|
32 |
-
$wpua_avatar_default = get_option('avatar_default_wp_user_avatar');
|
33 |
-
$wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
|
34 |
-
$wpua_edit_avatar = get_option('wp_user_avatar_edit_avatar');
|
35 |
-
$wpua_tinymce = get_option('wp_user_avatar_tinymce');
|
36 |
-
$mustache_original = WPUA_URLPATH.'images/wp-user-avatar.png';
|
37 |
-
$mustache_medium = WPUA_URLPATH.'images/wp-user-avatar-300x300.png';
|
38 |
-
$mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
|
39 |
-
$mustache_avatar = WPUA_URLPATH.'images/wp-user-avatar-96x96.png';
|
40 |
-
$mustache_admin = WPUA_URLPATH.'images/wp-user-avatar-32x32.png';
|
41 |
-
|
42 |
-
// Check for updates
|
43 |
-
$wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
|
44 |
-
$wpua_users_updated = get_option('wp_user_avatar_users_updated');
|
45 |
-
$wpua_media_updated = get_option('wp_user_avatar_media_updated');
|
46 |
-
|
47 |
-
// Max upload size
|
48 |
-
if(!function_exists('wp_max_upload_size')){
|
49 |
-
require_once(ABSPATH.'wp-admin/includes/template.php');
|
50 |
-
}
|
51 |
-
|
52 |
-
// Server upload size limit
|
53 |
-
$upload_size_limit = wp_max_upload_size();
|
54 |
-
// Convert to KB
|
55 |
-
if($upload_size_limit > 1024){
|
56 |
-
$upload_size_limit /= 1024;
|
57 |
-
}
|
58 |
-
$upload_size_limit_with_units = (int) $upload_size_limit.'KB';
|
59 |
-
|
60 |
-
// User upload size limit
|
61 |
-
$wpua_user_upload_size_limit = get_option('wp_user_avatar_upload_size_limit');
|
62 |
-
if($wpua_user_upload_size_limit == 0 || $wpua_user_upload_size_limit > wp_max_upload_size()){
|
63 |
-
$wpua_user_upload_size_limit = wp_max_upload_size();
|
64 |
-
}
|
65 |
-
// Value in bytes
|
66 |
-
$wpua_upload_size_limit = $wpua_user_upload_size_limit;
|
67 |
-
// Convert to KB
|
68 |
-
if($wpua_user_upload_size_limit > 1024){
|
69 |
-
$wpua_user_upload_size_limit /= 1024;
|
70 |
-
}
|
71 |
-
$wpua_upload_size_limit_with_units = (int) $wpua_user_upload_size_limit.'KB';
|
72 |
-
|
73 |
-
// Load add-ons
|
74 |
-
if((bool) $wpua_tinymce == 1){
|
75 |
-
include_once(WPUA_ABSPATH.'includes/tinymce.php');
|
76 |
-
}
|
77 |
-
|
78 |
-
// Load translations
|
79 |
-
load_plugin_textdomain('wp-user-avatar', "", WPUA_FOLDER.'/lang');
|
80 |
-
|
81 |
-
// Initialize default settings
|
82 |
-
register_activation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_options');
|
83 |
-
|
84 |
-
// Remove subscribers edit_posts capability
|
85 |
-
register_deactivation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_deactivate');
|
86 |
-
|
87 |
-
// Settings saved to wp_options
|
88 |
-
function wpua_options(){
|
89 |
-
add_option('avatar_default_wp_user_avatar', "");
|
90 |
-
add_option('wp_user_avatar_allow_upload', '0');
|
91 |
-
add_option('wp_user_avatar_disable_gravatar', '0');
|
92 |
-
add_option('wp_user_avatar_edit_avatar', '1');
|
93 |
-
add_option('wp_user_avatar_tinymce', '1');
|
94 |
-
add_option('wp_user_avatar_upload_size_limit', '0');
|
95 |
-
}
|
96 |
-
add_action('admin_init', 'wpua_options');
|
97 |
-
|
98 |
-
// Update default avatar to new format
|
99 |
-
if(empty($wpua_default_avatar_updated)){
|
100 |
-
function wpua_default_avatar(){
|
101 |
-
global $avatar_default, $mustache_original, $wpua_avatar_default;
|
102 |
-
// If default avatar is the old mustache URL, update it
|
103 |
-
if($avatar_default == $mustache_original){
|
104 |
-
update_option('avatar_default', 'wp_user_avatar');
|
105 |
-
}
|
106 |
-
// If user had an image URL as the default avatar, replace with ID instead
|
107 |
-
if(!empty($wpua_avatar_default)){
|
108 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, 'medium');
|
109 |
-
if($avatar_default == $wpua_avatar_default_image[0]){
|
110 |
-
update_option('avatar_default', 'wp_user_avatar');
|
111 |
-
}
|
112 |
-
}
|
113 |
-
update_option('wp_user_avatar_default_avatar_updated', '1');
|
114 |
-
}
|
115 |
-
add_action('admin_init', 'wpua_default_avatar');
|
116 |
-
}
|
117 |
-
|
118 |
-
// Rename user meta to match database settings
|
119 |
-
if(empty($wpua_users_updated)){
|
120 |
-
function wpua_user_meta(){
|
121 |
-
global $blog_id, $wpdb;
|
122 |
-
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
123 |
-
// If database tables start with something other than wp_
|
124 |
-
if($wpua_metakey != 'wp_user_avatar'){
|
125 |
-
$users = get_users();
|
126 |
-
// Move current user metakeys to new metakeys
|
127 |
-
foreach($users as $user){
|
128 |
-
$wpua = get_user_meta($user->ID, 'wp_user_avatar', true);
|
129 |
-
if(!empty($wpua)){
|
130 |
-
update_user_meta($user->ID, $wpua_metakey, $wpua);
|
131 |
-
delete_user_meta($user->ID, 'wp_user_avatar');
|
132 |
-
}
|
133 |
-
}
|
134 |
-
}
|
135 |
-
update_option('wp_user_avatar_users_updated', '1');
|
136 |
-
}
|
137 |
-
add_action('admin_init', 'wpua_user_meta');
|
138 |
-
}
|
139 |
-
|
140 |
-
// Add media state to existing avatars
|
141 |
-
if(empty($wpua_media_updated)){
|
142 |
-
function wpua_media_state(){
|
143 |
-
global $blog_id, $wpdb;
|
144 |
-
// Find all users with WPUA
|
145 |
-
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
146 |
-
$wpuas = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != %d AND meta_value != %d", $wpua_metakey, 0, ""));
|
147 |
-
foreach($wpuas as $usermeta){
|
148 |
-
add_post_meta($usermeta->meta_value, '_wp_attachment_wp_user_avatar', $usermeta->user_id);
|
149 |
-
}
|
150 |
-
update_option('wp_user_avatar_media_updated', '1');
|
151 |
-
}
|
152 |
-
add_action('admin_init', 'wpua_media_state');
|
153 |
}
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
}
|
220 |
-
add_action('admin_init', 'wpua_subscriber_offlimits');
|
221 |
}
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
228 |
-
$user_roles = get_option($wp_user_roles);
|
229 |
-
$user_roles['subscriber']['capabilities']['edit_posts'] = true;
|
230 |
-
update_option($wp_user_roles, $user_roles);
|
231 |
-
}
|
232 |
-
add_action('admin_init', 'wpua_subscriber_add_cap');
|
233 |
-
}
|
234 |
-
|
235 |
-
// Remove subscribers edit_posts capability
|
236 |
-
function wpua_subscriber_remove_cap(){
|
237 |
-
global $blog_id, $wpdb;
|
238 |
-
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
239 |
-
$user_roles = get_option($wp_user_roles);
|
240 |
-
unset($user_roles['subscriber']['capabilities']['edit_posts']);
|
241 |
-
update_option($wp_user_roles, $user_roles);
|
242 |
-
}
|
243 |
-
|
244 |
-
// On deactivation
|
245 |
-
function wpua_deactivate(){
|
246 |
-
// Remove subscribers edit_posts capability
|
247 |
-
wpua_subscriber_remove_cap();
|
248 |
-
// Reset all default avatar to Mystery Man
|
249 |
-
update_option('avatar_default', 'mystery');
|
250 |
-
}
|
251 |
-
|
252 |
-
// WP User Avatar
|
253 |
-
if(!class_exists('wp_user_avatar')){
|
254 |
-
class wp_user_avatar{
|
255 |
-
function wp_user_avatar(){
|
256 |
-
global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_upload_size_limit;
|
257 |
-
// Add WPUA to profile
|
258 |
-
if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
|
259 |
-
// For themes that use this function
|
260 |
-
if(!function_exists('get_current_screen')){
|
261 |
-
require_once(ABSPATH.'wp-admin/includes/screen.php');
|
262 |
-
}
|
263 |
-
// Profile functions and scripts
|
264 |
-
add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
265 |
-
add_action('edit_user_profile', array($this, 'wpua_action_show_user_profile'));
|
266 |
-
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
267 |
-
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
268 |
-
add_action('show_user_profile', array($this, 'wpua_media_upload_scripts'));
|
269 |
-
add_action('edit_user_profile', array($this, 'wpua_media_upload_scripts'));
|
270 |
-
// Admin scripts
|
271 |
-
if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
|
272 |
-
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
273 |
-
}
|
274 |
-
// Prefilter upload size
|
275 |
-
if(!current_user_can('upload_files')){
|
276 |
-
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'), 10, 1);
|
277 |
-
}
|
278 |
-
// Admin menu settings
|
279 |
-
add_action('admin_menu', 'wpua_admin');
|
280 |
-
add_filter('plugin_action_links', array($this, 'wpua_plugin_settings_links'), 10, 2);
|
281 |
-
// Hide column in Users table if default avatars are enabled
|
282 |
-
if((bool) $show_avatars == 0 && is_admin()){
|
283 |
-
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
284 |
-
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
|
285 |
-
}
|
286 |
-
}
|
287 |
-
}
|
288 |
-
|
289 |
-
// Add to edit user profile
|
290 |
-
function wpua_action_show_user_profile($user){
|
291 |
-
global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_edit_avatar, $wpua_upload_size_limit_with_units;
|
292 |
-
// Get WPUA attachment ID
|
293 |
-
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
294 |
-
// Show remove button if WPUA is set
|
295 |
-
$hide_remove = !has_wp_user_avatar($user->ID) ? ' wpua-hide' : "";
|
296 |
-
// If avatars are enabled, get original avatar image or show blank
|
297 |
-
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
298 |
-
// Check if user has wp_user_avatar, if not show image from above
|
299 |
-
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
|
300 |
-
// Check if user has wp_user_avatar, if not show image from above
|
301 |
-
$avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
|
302 |
-
// Change text on message based on current user
|
303 |
-
$profile = ($current_user->ID == $user->ID) ? '“'.__('Update Profile').'”' : '“'.__('Update User').'”';
|
304 |
-
?>
|
305 |
-
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
306 |
-
<h2 class="entry-title"><?php _e('Avatar'); ?></h2>
|
307 |
-
<fieldset class="bbp-form">
|
308 |
-
<legend><?php _e('Image'); ?></legend>
|
309 |
-
<?php else : // Add to profile with admin style ?>
|
310 |
-
<h3><?php _e('Avatar') ?></h3>
|
311 |
-
<table class="form-table">
|
312 |
-
<tr>
|
313 |
-
<th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
|
314 |
-
<td>
|
315 |
-
<?php endif; ?>
|
316 |
-
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
317 |
-
<?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
|
318 |
-
<p><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
|
319 |
-
<?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
|
320 |
-
<input name="wp-user-avatar-file" id="wpua-file" type="file" />
|
321 |
-
<button type="submit" class="button" id="upload-wp-user-avatar" name="upload-wp-user-avatar" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
|
322 |
-
<p>
|
323 |
-
<?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?>
|
324 |
-
<br />
|
325 |
-
<?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?>
|
326 |
-
</p>
|
327 |
-
<?php elseif((bool) $wpua_edit_avatar == 1 && !current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) : // Edit button ?>
|
328 |
-
<?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
|
329 |
-
<p><button type="button" class="button" id="wpua-edit" name="wpua-edit" onclick="window.open('<?php echo $edit_attachment_link; ?>', '_self');"><?php _e('Edit Image'); ?></button></p>
|
330 |
-
<?php endif; ?>
|
331 |
-
<p id="wpua-preview">
|
332 |
-
<img src="<?php echo $avatar_medium; ?>" alt="" />
|
333 |
-
<?php _e('Original Size'); ?>
|
334 |
-
</p>
|
335 |
-
<p id="wpua-thumbnail">
|
336 |
-
<img src="<?php echo $avatar_thumbnail; ?>" alt="" />
|
337 |
-
<?php _e('Thumbnail'); ?>
|
338 |
-
</p>
|
339 |
-
<p><button type="button" class="button<?php echo $hide_remove; ?>" id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?></button></p>
|
340 |
-
<p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
|
341 |
-
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
342 |
-
</fieldset>
|
343 |
-
<?php else : // Add to profile with admin style ?>
|
344 |
-
</td>
|
345 |
-
</tr>
|
346 |
-
</table>
|
347 |
-
<?php endif; ?>
|
348 |
-
<?php
|
349 |
-
}
|
350 |
-
|
351 |
-
// Set upload size limit for users without upload_files capability
|
352 |
-
function wpua_handle_upload_prefilter($file){
|
353 |
-
global $wpua_upload_size_limit;
|
354 |
-
$size = $file['size'];
|
355 |
-
if($size > $wpua_upload_size_limit){
|
356 |
-
$file['error'] = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
|
357 |
-
}
|
358 |
-
return $file;
|
359 |
-
}
|
360 |
-
|
361 |
-
// Update user meta
|
362 |
-
function wpua_action_process_option_update($user_id){
|
363 |
-
global $blog_id, $wpdb;
|
364 |
-
// Check if user has upload_files capability
|
365 |
-
if(current_user_can('upload_files')){
|
366 |
-
$wpua_id = isset($_POST['wp-user-avatar']) ? intval($_POST['wp-user-avatar']) : "";
|
367 |
-
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
|
368 |
-
add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
369 |
-
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
370 |
-
} else {
|
371 |
-
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
|
372 |
-
// Uploads by user
|
373 |
-
$attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, 'attachment'));
|
374 |
-
foreach($attachments as $attachment){
|
375 |
-
// Delete attachment if not used by another user
|
376 |
-
if(!wpua_image($attachment->ID, $user_id)){
|
377 |
-
wp_delete_post($attachment->ID);
|
378 |
-
}
|
379 |
-
}
|
380 |
-
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
381 |
-
}
|
382 |
-
// Create attachment from upload
|
383 |
-
if(isset($_POST['upload-wp-user-avatar']) && $_POST['upload-wp-user-avatar']){
|
384 |
-
if(!function_exists('wp_handle_upload')){
|
385 |
-
require_once(ABSPATH.'wp-admin/includes/admin.php');
|
386 |
-
require_once(ABSPATH.'wp-admin/includes/file.php');
|
387 |
-
}
|
388 |
-
$name = $_FILES['wp-user-avatar-file']['name'];
|
389 |
-
$file = wp_handle_upload($_FILES['wp-user-avatar-file'], array('test_form' => false));
|
390 |
-
$type = $file['type'];
|
391 |
-
// Allow only JPG, GIF, PNG
|
392 |
-
if($file['error'] || !preg_match('/(jpe?g|gif|png)$/i', $type)){
|
393 |
-
if($file['error']){
|
394 |
-
wp_die($file['error']);
|
395 |
-
} else {
|
396 |
-
wp_die(__('Sorry, this file type is not permitted for security reasons.'));
|
397 |
-
}
|
398 |
-
}
|
399 |
-
// Break out file info
|
400 |
-
$name_parts = pathinfo($name);
|
401 |
-
$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
|
402 |
-
$url = $file['url'];
|
403 |
-
$file = $file['file'];
|
404 |
-
$title = $name;
|
405 |
-
// Use image exif/iptc data for title if possible
|
406 |
-
if($image_meta = @wp_read_image_metadata($file)){
|
407 |
-
if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))){
|
408 |
-
$title = $image_meta['title'];
|
409 |
-
}
|
410 |
-
}
|
411 |
-
// Construct the attachment array
|
412 |
-
$attachment = array(
|
413 |
-
'guid' => $url,
|
414 |
-
'post_mime_type' => $type,
|
415 |
-
'post_title' => $title
|
416 |
-
);
|
417 |
-
// This should never be set as it would then overwrite an existing attachment
|
418 |
-
if(isset($attachment['ID'])){
|
419 |
-
unset($attachment['ID']);
|
420 |
-
}
|
421 |
-
// Save the attachment metadata
|
422 |
-
$attachment_id = wp_insert_attachment($attachment, $file);
|
423 |
-
if(!is_wp_error($attachment_id)){
|
424 |
-
require_once(ABSPATH.'wp-admin/includes/image.php');
|
425 |
-
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
426 |
-
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
|
427 |
-
add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
|
428 |
-
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
|
429 |
-
}
|
430 |
-
}
|
431 |
-
}
|
432 |
-
}
|
433 |
-
|
434 |
-
// Add button to attach image for WP 3.4 and older
|
435 |
-
function wpua_add_attachment_field_to_edit($fields, $post){
|
436 |
-
$image = wp_get_attachment_image_src($post->ID, "medium");
|
437 |
-
$button = '<button type="button" class="button" id="set-wp-user-avatar-image" name="set-wp-user-avatar-image" onclick="wpuaSetAvatar(\''.$post->ID.'\', \''.$image[0].'\')">'.__('Select Image').'</button>';
|
438 |
-
$fields['wp-user-avatar'] = array(
|
439 |
-
'label' => __('WP User Avatar', 'wp-user-avatar'),
|
440 |
-
'input' => 'html',
|
441 |
-
'html' => $button
|
442 |
-
);
|
443 |
-
return $fields;
|
444 |
-
}
|
445 |
-
|
446 |
-
// Add settings link on plugin page
|
447 |
-
function wpua_plugin_settings_links($links, $file){
|
448 |
-
if(basename($file) == basename(plugin_basename(__FILE__))){
|
449 |
-
$settings_link = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('options-general.php')).'">'.__('Settings').'</a>';
|
450 |
-
$links = array_merge($links, array($settings_link));
|
451 |
-
}
|
452 |
-
return $links;
|
453 |
-
}
|
454 |
-
|
455 |
-
// Add column to Users table
|
456 |
-
function wpua_add_column($columns){
|
457 |
-
return $columns + array('wp-user-avatar' => __('WP User Avatar', 'wp-user-avatar'));
|
458 |
-
}
|
459 |
-
|
460 |
-
// Show thumbnail in Users table
|
461 |
-
function wpua_show_column($value, $column_name, $user_id){
|
462 |
-
global $blog_id, $wpdb;
|
463 |
-
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
464 |
-
$wpua_image = wp_get_attachment_image($wpua, array(32,32));
|
465 |
-
if($column_name == 'wp-user-avatar'){
|
466 |
-
return $wpua_image;
|
467 |
-
}
|
468 |
-
}
|
469 |
-
|
470 |
-
// Media uploader
|
471 |
-
function wpua_media_upload_scripts($user=""){
|
472 |
-
global $mustache_admin, $pagenow, $show_avatars, $wpua_upload_size_limit;
|
473 |
-
wp_enqueue_script('jquery');
|
474 |
-
if(current_user_can('upload_files')){
|
475 |
-
wp_enqueue_script('admin-bar');
|
476 |
-
wp_enqueue_media();
|
477 |
-
}
|
478 |
-
wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION, true);
|
479 |
-
wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
|
480 |
-
// Admin scripts
|
481 |
-
if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
|
482 |
-
// Size limit slider
|
483 |
-
wp_enqueue_script('jquery-ui-slider');
|
484 |
-
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URLPATH.'css/jquery.ui.slider.css', "", null);
|
485 |
-
// Remove/edit settings
|
486 |
-
$wpua_custom_scripts = array('section' => __('Default Avatar'), 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $mustache_admin);
|
487 |
-
wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
|
488 |
-
// Settings control
|
489 |
-
wp_enqueue_script('wp-user-avatar-admin', WPUA_URLPATH.'js/wp-user-avatar-admin.js', array('wp-user-avatar'), WPUA_VERSION, true);
|
490 |
-
$wpua_admin_scripts = array('upload_size_limit' => $wpua_upload_size_limit, 'max_upload_size' => wp_max_upload_size());
|
491 |
-
wp_localize_script('wp-user-avatar-admin', 'wpua_admin', $wpua_admin_scripts);
|
492 |
-
} else {
|
493 |
-
// User remove/edit settings
|
494 |
-
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
495 |
-
$wpua_custom_scripts = array('section' => $user->display_name, 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $avatar_medium_src);
|
496 |
-
wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
|
497 |
-
}
|
498 |
-
}
|
499 |
-
}
|
500 |
-
|
501 |
-
// Returns true if user has Gravatar-hosted image
|
502 |
-
function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
|
503 |
-
if(!is_object($id_or_email) && !empty($id_or_email)){
|
504 |
-
// Find user by ID or e-mail address
|
505 |
-
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
506 |
-
// Get registered user e-mail address
|
507 |
-
$email = !empty($user) ? $user->user_email : "";
|
508 |
-
}
|
509 |
-
// Check if Gravatar image returns 200 (OK) or 404 (Not Found)
|
510 |
-
$hash = md5(strtolower(trim($email)));
|
511 |
-
$gravatar = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
|
512 |
-
$data = wp_cache_get($hash);
|
513 |
-
if(false === $data){
|
514 |
-
$response = wp_remote_head($gravatar);
|
515 |
-
$data = is_wp_error($response) ? 'not200' : $response['response']['code'];
|
516 |
-
wp_cache_set($hash, $data, $group="", $expire=60*5);
|
517 |
-
}
|
518 |
-
$has_gravatar = ($data == '200') ? true : false;
|
519 |
-
return $has_gravatar;
|
520 |
-
}
|
521 |
-
|
522 |
-
// Returns true if user has wp_user_avatar
|
523 |
-
function has_wp_user_avatar($id_or_email="", $has_wpua=false, $user="", $user_id=""){
|
524 |
-
global $blog_id, $wpdb;
|
525 |
-
if(!is_object($id_or_email) && !empty($id_or_email)){
|
526 |
-
// Find user by ID or e-mail address
|
527 |
-
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
528 |
-
// Get registered user ID
|
529 |
-
$user_id = !empty($user) ? $user->ID : "";
|
530 |
-
}
|
531 |
-
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
532 |
-
$has_wpua = !empty($wpua) ? true : false;
|
533 |
-
return $has_wpua;
|
534 |
-
}
|
535 |
-
|
536 |
-
// Replace get_avatar only in get_wp_user_avatar
|
537 |
-
function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt=""){
|
538 |
-
global $avatar_default, $comment, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar;
|
539 |
-
// User has WPUA
|
540 |
-
if(is_object($id_or_email)){
|
541 |
-
if(!empty($comment->comment_author_email)){
|
542 |
-
$avatar = get_wp_user_avatar($comment, $size, $default, $alt);
|
543 |
-
} else {
|
544 |
-
$avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
|
545 |
-
}
|
546 |
-
} else {
|
547 |
-
if(has_wp_user_avatar($id_or_email)){
|
548 |
-
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
|
549 |
-
// User has Gravatar and Gravatar is not disabled
|
550 |
-
} elseif((bool) $wpua_disable_gravatar != 1 && wpua_has_gravatar($id_or_email)){
|
551 |
-
$avatar = $avatar;
|
552 |
-
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
553 |
-
} elseif($avatar_default == 'wp_user_avatar'){
|
554 |
-
// Show custom Default Avatar
|
555 |
-
if(!empty($wpua_avatar_default)){
|
556 |
-
// Get image
|
557 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
558 |
-
// Image src
|
559 |
-
$default = $wpua_avatar_default_image[0];
|
560 |
-
// Add dimensions if numeric size
|
561 |
-
$dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
|
562 |
-
$defaultcss = "";
|
563 |
-
} else {
|
564 |
-
// Get mustache image based on numeric size comparison
|
565 |
-
if($size > get_option('medium_size_w')){
|
566 |
-
$default = $mustache_original;
|
567 |
-
} elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')){
|
568 |
-
$default = $mustache_medium;
|
569 |
-
} elseif($size <= get_option('thumbnail_size_w') && $size > 96){
|
570 |
-
$default = $mustache_thumbnail;
|
571 |
-
} elseif($size <= 96 && $size > 32){
|
572 |
-
$default = $mustache_avatar;
|
573 |
-
} elseif($size <= 32){
|
574 |
-
$default = $mustache_admin;
|
575 |
-
}
|
576 |
-
// Add dimensions if numeric size
|
577 |
-
$dimensions = ' width="'.$size.'" height="'.$size.'"';
|
578 |
-
$defaultcss = ' avatar-default';
|
579 |
-
}
|
580 |
-
// Construct the img tag
|
581 |
-
$avatar = "<img src='".$default."'".$dimensions." alt='".$alt."' class='wp-user-avatar wp-user-avatar-".$size." avatar avatar-".$size." photo'".$defaultcss." />";
|
582 |
-
}
|
583 |
-
}
|
584 |
-
return $avatar;
|
585 |
-
}
|
586 |
-
add_filter('get_avatar', 'wpua_get_avatar_filter', 10, 6);
|
587 |
-
|
588 |
-
// Get original avatar, for when user removes wp_user_avatar
|
589 |
-
function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt=""){
|
590 |
-
global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar;
|
591 |
-
// Remove get_avatar filter only in admin
|
592 |
-
if(is_admin()){
|
593 |
-
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
594 |
-
}
|
595 |
-
if((bool) $wpua_disable_gravatar != 1){
|
596 |
-
// User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
597 |
-
if(!wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar'){
|
598 |
-
// Show custom Default Avatar
|
599 |
-
if(!empty($wpua_avatar_default)){
|
600 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
601 |
-
$default = $wpua_avatar_default_image[0];
|
602 |
-
} else {
|
603 |
-
$default = $mustache_avatar;
|
604 |
-
}
|
605 |
-
} else {
|
606 |
-
// Get image from Gravatar, whether it's the user's image or default image
|
607 |
-
$wpua_image = get_avatar($id_or_email, $size);
|
608 |
-
// Takes the img tag, extracts the src
|
609 |
-
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
610 |
-
$default = $matches [0] [1];
|
611 |
-
}
|
612 |
-
} else {
|
613 |
-
if(!empty($wpua_avatar_default)){
|
614 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
615 |
-
$default = $wpua_avatar_default_image[0];
|
616 |
-
} else {
|
617 |
-
$default = $mustache_avatar;
|
618 |
-
}
|
619 |
-
}
|
620 |
-
return $default;
|
621 |
-
}
|
622 |
-
|
623 |
-
// Find WPUA, show get_avatar if empty
|
624 |
-
function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt=""){
|
625 |
-
global $avatar_default, $blog_id, $comment, $post, $wpdb;
|
626 |
-
// Checks if comment
|
627 |
-
if(is_object($id_or_email)){
|
628 |
-
// Checks if comment author is registered user by user ID
|
629 |
-
if($comment->user_id != 0){
|
630 |
-
$id_or_email = $comment->user_id;
|
631 |
-
// Checks that comment author isn't anonymous
|
632 |
-
} elseif(!empty($comment->comment_author_email)){
|
633 |
-
// Checks if comment author is registered user by e-mail address
|
634 |
-
$user = get_user_by('email', $comment->comment_author_email);
|
635 |
-
// Get registered user info from profile, otherwise e-mail address should be value
|
636 |
-
$id_or_email = !empty($user) ? $user->ID : $comment->comment_author_email;
|
637 |
-
}
|
638 |
-
$alt = $comment->comment_author;
|
639 |
-
} else {
|
640 |
-
if(!empty($id_or_email)){
|
641 |
-
// Find user by ID or e-mail address
|
642 |
-
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
643 |
-
} else {
|
644 |
-
// Find author's name if id_or_email is empty
|
645 |
-
$author_name = get_query_var('author_name');
|
646 |
-
if(is_author()){
|
647 |
-
// On author page, get user by page slug
|
648 |
-
$user = get_user_by('slug', $author_name);
|
649 |
-
} else {
|
650 |
-
// On post, get user by author meta
|
651 |
-
$user_id = get_the_author_meta('ID');
|
652 |
-
$user = get_user_by('id', $user_id);
|
653 |
-
}
|
654 |
-
}
|
655 |
-
// Set user's ID and name
|
656 |
-
if(!empty($user)){
|
657 |
-
$id_or_email = $user->ID;
|
658 |
-
$alt = $user->display_name;
|
659 |
-
}
|
660 |
-
}
|
661 |
-
// Checks if user has WPUA
|
662 |
-
$wpua_meta = !empty($id_or_email) ? get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email) : "";
|
663 |
-
// Add alignment class
|
664 |
-
$alignclass = !empty($align) ? ' align'.$align : "";
|
665 |
-
// User has WPUA, bypass get_avatar
|
666 |
-
if(!empty($wpua_meta)){
|
667 |
-
// Numeric size use size array
|
668 |
-
$get_size = is_numeric($size) ? array($size,$size) : $size;
|
669 |
-
// Get image src
|
670 |
-
$wpua_image = wp_get_attachment_image_src($wpua_meta, $get_size);
|
671 |
-
// Add dimensions to img only if numeric size was specified
|
672 |
-
$dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
|
673 |
-
// Construct the img tag
|
674 |
-
$avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="wp-user-avatar wp-user-avatar-'.$size.$alignclass.' avatar avatar avatar-'.$size.' photo" />';
|
675 |
-
} else {
|
676 |
-
// Get numeric sizes for non-numeric sizes based on media options
|
677 |
-
if($size == 'original' || $size == 'large' || $size == 'medium' || $size == 'thumbnail'){
|
678 |
-
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
679 |
-
} else {
|
680 |
-
// Numeric sizes leave as-is
|
681 |
-
$get_size = $size;
|
682 |
-
}
|
683 |
-
// User with no WPUA uses get_avatar
|
684 |
-
$avatar = get_avatar($id_or_email, $get_size, $default="", $alt="");
|
685 |
-
// Remove width and height for non-numeric sizes
|
686 |
-
if(!is_numeric($size)){
|
687 |
-
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
|
688 |
-
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
|
689 |
-
$avatar = str_replace('wp-user-avatar wp-user-avatar-'.$get_size.' ', "", $avatar);
|
690 |
-
$avatar = str_replace("class='", "class='wp-user-avatar wp-user-avatar-".$size.$alignclass." ", $avatar);
|
691 |
-
}
|
692 |
-
}
|
693 |
-
return $avatar;
|
694 |
-
}
|
695 |
-
|
696 |
-
// Return just the image src
|
697 |
-
function get_wp_user_avatar_src($id_or_email, $size="", $align=""){
|
698 |
-
$wpua_image_src = "";
|
699 |
-
// Gets the avatar img tag
|
700 |
-
$wpua_image = get_wp_user_avatar($id_or_email, $size, $align);
|
701 |
-
// Takes the img tag, extracts the src
|
702 |
-
if(!empty($wpua_image)){
|
703 |
-
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
704 |
-
$wpua_image_src = $matches [0] [1];
|
705 |
-
}
|
706 |
-
return $wpua_image_src;
|
707 |
-
}
|
708 |
-
|
709 |
-
// Shortcode
|
710 |
-
function wpua_shortcode($atts, $content){
|
711 |
-
global $blog_id, $wpdb;
|
712 |
-
// Set shortcode attributes
|
713 |
-
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
|
714 |
-
// Find user by ID, login, slug, or e-mail address
|
715 |
-
if(!empty($user)){
|
716 |
-
$user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
|
717 |
-
$user = empty($user) ? get_user_by('slug', $user) : $user;
|
718 |
-
$user = empty($user) ? get_user_by('email', $user) : $user;
|
719 |
-
}
|
720 |
-
// Get user ID
|
721 |
-
$id_or_email = !empty($user) ? $user->ID : "";
|
722 |
-
// Check if link is set
|
723 |
-
if(!empty($link)){
|
724 |
-
// CSS class is same as link type, except for URL
|
725 |
-
$link_class = $link;
|
726 |
-
// Open in new window
|
727 |
-
$target_link = !empty($target) ? ' target="'.$target.'"' : "";
|
728 |
-
if($link == 'file'){
|
729 |
-
// Get image src
|
730 |
-
$image_link = get_wp_user_avatar_src($id_or_email, 'original', $align);
|
731 |
-
} elseif($link == 'attachment'){
|
732 |
-
// Get attachment URL
|
733 |
-
$image_link = get_attachment_link(get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email));
|
734 |
-
} else {
|
735 |
-
// URL
|
736 |
-
$image_link = $link;
|
737 |
-
$link_class = 'custom';
|
738 |
-
}
|
739 |
-
// Wrap the avatar inside the link
|
740 |
-
$avatar = '<a href="'.$image_link.'" class="wp-user-avatar-link wp-user-avatar-'.$link_class.'"'.$target_link.'>'.get_wp_user_avatar($id_or_email, $size, $align).'</a>';
|
741 |
-
} else {
|
742 |
-
// Get WPUA as normal
|
743 |
-
$avatar = get_wp_user_avatar($id_or_email, $size, $align);
|
744 |
-
}
|
745 |
-
return $avatar;
|
746 |
-
}
|
747 |
-
add_shortcode('avatar', 'wpua_shortcode');
|
748 |
-
|
749 |
-
// Add default avatar
|
750 |
-
function wpua_add_default_avatar($avatar_list=null){
|
751 |
-
global $avatar_default, $mustache_admin, $mustache_medium, $wpua_avatar_default, $wpua_disable_gravatar;
|
752 |
-
// Remove get_avatar filter
|
753 |
-
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
754 |
-
// Set avatar_list variable
|
755 |
-
$avatar_list = "";
|
756 |
-
// Set avatar defaults
|
757 |
-
$avatar_defaults = array(
|
758 |
-
'mystery' => __('Mystery Man'),
|
759 |
-
'blank' => __('Blank'),
|
760 |
-
'gravatar_default' => __('Gravatar Logo'),
|
761 |
-
'identicon' => __('Identicon (Generated)'),
|
762 |
-
'wavatar' => __('Wavatar (Generated)'),
|
763 |
-
'monsterid' => __('MonsterID (Generated)'),
|
764 |
-
'retro' => __('Retro (Generated)')
|
765 |
-
);
|
766 |
-
// No Default Avatar, set to Mystery Man
|
767 |
-
if(empty($avatar_default)){
|
768 |
-
$avatar_default = 'mystery';
|
769 |
-
}
|
770 |
-
// Take avatar_defaults and get examples for unknown@gravatar.com
|
771 |
-
foreach($avatar_defaults as $default_key => $default_name){
|
772 |
-
$avatar = get_avatar('unknown@gravatar.com', 32, $default_key);
|
773 |
-
$selected = ($avatar_default == $default_key) ? 'checked="checked" ' : "";
|
774 |
-
$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='".esc_attr($default_key)."' {$selected}/> ";
|
775 |
-
$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&forcedefault=1'", $avatar);
|
776 |
-
$avatar_list .= ' '.$default_name.'</label>';
|
777 |
-
$avatar_list .= '<br />';
|
778 |
-
}
|
779 |
-
// Show remove link if custom Default Avatar is set
|
780 |
-
if(!empty($wpua_avatar_default)){
|
781 |
-
$avatar_thumb_src = wp_get_attachment_image_src($wpua_avatar_default, array(32,32));
|
782 |
-
$avatar_thumb = $avatar_thumb_src[0];
|
783 |
-
$hide_remove = "";
|
784 |
-
} else {
|
785 |
-
$avatar_thumb = $mustache_admin;
|
786 |
-
$hide_remove = ' class="wpua-hide"';
|
787 |
-
}
|
788 |
-
// Default Avatar is wp_user_avatar, check the radio button next to it
|
789 |
-
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
790 |
-
// Wrap WPUA in div
|
791 |
-
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
|
792 |
-
// Add WPUA to list
|
793 |
-
$wpua_list = "\n\t<label><input type='radio' name='avatar_default' id='wp_user_avatar_radio' value='wp_user_avatar'$selected_avatar /> ";
|
794 |
-
$wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
|
795 |
-
$wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
|
796 |
-
$wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add">'.__('Edit Image').'</button>';
|
797 |
-
$wpua_list .= '<a href="#" id="wpua-remove"'.$hide_remove.'>'.__('Remove').'</a></p>';
|
798 |
-
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
|
799 |
-
$wpua_list .= '<p id="wpua-message">'.sprintf(__('Click %s to save your changes', 'wp-user-avatar'), '“'.__('Save Changes').'”').'</p>';
|
800 |
-
if((bool) $wpua_disable_gravatar != 1){
|
801 |
-
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
|
802 |
-
} else {
|
803 |
-
return $wpua_list;
|
804 |
-
}
|
805 |
-
}
|
806 |
-
add_filter('default_avatar_select', 'wpua_add_default_avatar', 10);
|
807 |
-
|
808 |
-
// Add default avatar_default to whitelist
|
809 |
-
function wpua_whitelist_options($whitelist_options){
|
810 |
-
$whitelist_options['discussion'][] = 'avatar_default_wp_user_avatar';
|
811 |
-
return $whitelist_options;
|
812 |
-
}
|
813 |
-
add_filter('whitelist_options', 'wpua_whitelist_options', 10);
|
814 |
-
|
815 |
-
// Add media state
|
816 |
-
function wpua_add_media_state($media_states){
|
817 |
-
global $post, $wpua_avatar_default;
|
818 |
-
$is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
|
819 |
-
if(!empty($is_wpua)){
|
820 |
-
$media_states[] = __('Avatar');
|
821 |
-
}
|
822 |
-
if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)){
|
823 |
-
$media_states[] = __('Default Avatar');
|
824 |
-
}
|
825 |
-
return apply_filters('wpua_add_media_state', $media_states);
|
826 |
-
}
|
827 |
-
add_filter('display_media_states', 'wpua_add_media_state', 10, 1);
|
828 |
-
|
829 |
-
// Check if image is used as WPUA
|
830 |
-
function wpua_image($attachment_id, $user_id, $wpua_image=false){
|
831 |
-
global $wpdb;
|
832 |
-
$wpua = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s AND meta_value != %d", $attachment_id, '_wp_attachment_wp_user_avatar', $user_id));
|
833 |
-
if(!empty($wpua)){
|
834 |
-
$wpua_image = true;
|
835 |
-
}
|
836 |
-
return $wpua_image;
|
837 |
-
}
|
838 |
-
|
839 |
-
// Check who owns image
|
840 |
-
function wpua_author($attachment_id, $user_id, $wpua_author=false){
|
841 |
-
$attachment = get_post($attachment_id);
|
842 |
-
if(!empty($attachment) && $attachment->post_author == $user_id){
|
843 |
-
$wpua_author = true;
|
844 |
-
}
|
845 |
-
return $wpua_author;
|
846 |
-
}
|
847 |
-
|
848 |
-
// Admin page
|
849 |
-
function wpua_options_page(){
|
850 |
-
global $show_avatars, $upload_size_limit_with_units, $wpua_allow_upload, $wpua_disable_gravatar, $wpua_edit_avatar, $wpua_tinymce, $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
|
851 |
-
// Give subscribers edit_posts capability
|
852 |
-
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && (empty($wpua_allow_upload) || empty($wpua_edit_avatar))){
|
853 |
-
wpua_subscriber_remove_cap();
|
854 |
-
}
|
855 |
-
$hide_size = (bool) $wpua_allow_upload != 1 ? ' class="wpua-hide"' : "";
|
856 |
-
?>
|
857 |
-
<div class="wrap">
|
858 |
-
<?php screen_icon(); ?>
|
859 |
-
<h2><?php _e('WP User Avatar', 'wp-user-avatar'); ?></h2>
|
860 |
-
<form method="post" action="options.php">
|
861 |
-
<?php settings_fields('wpua-settings-group'); ?>
|
862 |
-
<?php do_settings_fields('wpua-settings-group', ""); ?>
|
863 |
-
<table class="form-table">
|
864 |
-
<tr valign="top">
|
865 |
-
<th scope="row"><?php _e('Settings'); ?></th>
|
866 |
-
<td>
|
867 |
-
<fieldset>
|
868 |
-
<legend class="screen-reader-text"><span><?php _e('Settings'); ?></span></legend>
|
869 |
-
<label for="wp_user_avatar_tinymce">
|
870 |
-
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" <?php checked($wpua_tinymce, 1); ?> />
|
871 |
-
<?php _e('Add avatar button to Visual Editor', 'wp-user-avatar'); ?>
|
872 |
-
</label>
|
873 |
-
<br />
|
874 |
-
<label for="wp_user_avatar_allow_upload">
|
875 |
-
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" <?php checked($wpua_allow_upload, 1); ?> />
|
876 |
-
<?php _e('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar'); ?>
|
877 |
-
</label>
|
878 |
-
<br />
|
879 |
-
<label for="wp_user_avatar_disable_gravatar">
|
880 |
-
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
|
881 |
-
<?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
|
882 |
-
</label>
|
883 |
-
</fieldset>
|
884 |
-
</td>
|
885 |
-
</tr>
|
886 |
-
<tr id="wpua-size-limit" valign="top"<?php echo $hide_size; ?>>
|
887 |
-
<th scope="row">
|
888 |
-
<label for="wp_user_avatar_upload_size_limit">
|
889 |
-
<?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
|
890 |
-
</label>
|
891 |
-
</th>
|
892 |
-
<td>
|
893 |
-
<fieldset>
|
894 |
-
<legend class="screen-reader-text"><span><?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?></span></legend>
|
895 |
-
<input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="<?php echo $wpua_upload_size_limit; ?>" class="regular-text" />
|
896 |
-
<span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
|
897 |
-
<span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ""); ?></span>
|
898 |
-
<div id="wpua-slider"></div>
|
899 |
-
<span class="description"><?php printf(__('Maximum upload file size: %d%s.'), esc_html(wp_max_upload_size()), esc_html(' bytes ('.$upload_size_limit_with_units.')')); ?></span>
|
900 |
-
<br />
|
901 |
-
<label for="wp_user_avatar_edit_avatar">
|
902 |
-
<input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" <?php checked($wpua_edit_avatar, 1); ?> />
|
903 |
-
<?php _e('Allow users to edit avatars', 'wp-user-avatar'); ?>
|
904 |
-
</label>
|
905 |
-
</fieldset>
|
906 |
-
</td>
|
907 |
-
</tr>
|
908 |
-
</table>
|
909 |
-
<h3 class="title"><?php _e('Avatars'); ?></h3>
|
910 |
-
<p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
|
911 |
-
<table class="form-table">
|
912 |
-
<tr valign="top">
|
913 |
-
<th scope="row"><?php _e('Avatar Display'); ?></th>
|
914 |
-
<td>
|
915 |
-
<fieldset>
|
916 |
-
<legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
|
917 |
-
<label for="show_avatars">
|
918 |
-
<input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> />
|
919 |
-
<?php _e('Show Avatars'); ?>
|
920 |
-
</label>
|
921 |
-
</fieldset>
|
922 |
-
</td>
|
923 |
-
</tr>
|
924 |
-
<tr valign="top">
|
925 |
-
<th scope="row"><?php _e('Maximum Rating'); ?></th>
|
926 |
-
<td>
|
927 |
-
<fieldset>
|
928 |
-
<legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
|
929 |
-
<?php
|
930 |
-
$ratings = array(
|
931 |
-
'G' => __('G — Suitable for all audiences'),
|
932 |
-
'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'),
|
933 |
-
'R' => __('R — Intended for adult audiences above 17'),
|
934 |
-
'X' => __('X — Even more mature than above')
|
935 |
-
);
|
936 |
-
foreach ($ratings as $key => $rating) :
|
937 |
-
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
|
938 |
-
echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
|
939 |
-
endforeach;
|
940 |
-
?>
|
941 |
-
</fieldset>
|
942 |
-
</td>
|
943 |
-
</tr>
|
944 |
-
<tr valign="top">
|
945 |
-
<th scope="row"><?php _e('Default Avatar') ?></th>
|
946 |
-
<td class="defaultavatarpicker">
|
947 |
-
<fieldset>
|
948 |
-
<legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
|
949 |
-
<?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 />
|
950 |
-
<?php echo wpua_add_default_avatar(); ?>
|
951 |
-
</fieldset>
|
952 |
-
</td>
|
953 |
-
</tr>
|
954 |
-
</table>
|
955 |
-
<?php submit_button(); ?>
|
956 |
-
</form>
|
957 |
-
</div>
|
958 |
-
<?php
|
959 |
-
}
|
960 |
-
|
961 |
-
// Whitelist settings
|
962 |
-
function wpua_admin_settings(){
|
963 |
-
register_setting('wpua-settings-group', 'avatar_rating');
|
964 |
-
register_setting('wpua-settings-group', 'avatar_default');
|
965 |
-
register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar', 'intval');
|
966 |
-
register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
967 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
968 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
969 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
970 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
|
971 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
972 |
-
}
|
973 |
-
|
974 |
-
// Add options page and settings
|
975 |
-
function wpua_admin(){
|
976 |
-
add_options_page(__('WP User Avatar', 'wp-user-avatar'), __('WP User Avatar', 'wp-user-avatar'), 'manage_options', 'wp-user-avatar', 'wpua_options_page');
|
977 |
-
add_action('admin_init', 'wpua_admin_settings');
|
978 |
-
}
|
979 |
-
|
980 |
-
// Initialize WPUA after other plugins are loaded
|
981 |
-
function wpua_load(){
|
982 |
-
global $wpua_instance;
|
983 |
-
$wpua_instance = new wp_user_avatar();
|
984 |
-
}
|
985 |
-
add_action('plugins_loaded', 'wpua_load');
|
986 |
-
}
|
987 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.9.13
|
5 |
*/
|
6 |
+
|
7 |
/*
|
8 |
Plugin Name: WP User Avatar
|
9 |
Plugin URI: http://wordpress.org/plugins/wp-user-avatar/
|
10 |
Description: Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.
|
11 |
+
Author: flippercode
|
12 |
+
Author URI: http://www.flippercode.com/
|
13 |
+
Version: 1.9.13
|
14 |
Text Domain: wp-user-avatar
|
15 |
Domain Path: /lang/
|
16 |
*/
|
17 |
|
18 |
+
if(!defined('ABSPATH')) {
|
19 |
+
die('You are not allowed to call this page directly.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
+
/**
|
23 |
+
* Let's get started!
|
24 |
+
*/
|
25 |
+
class WP_User_Avatar_Setup {
|
26 |
+
/**
|
27 |
+
* Constructor
|
28 |
+
* @since 1.9.2
|
29 |
+
*/
|
30 |
+
public function __construct() {
|
31 |
+
$this->_define_constants();
|
32 |
+
$this->_load_wp_includes();
|
33 |
+
$this->_load_wpua();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Define paths
|
38 |
+
* @since 1.9.2
|
39 |
+
*/
|
40 |
+
private function _define_constants() {
|
41 |
+
define('WPUA_VERSION', '1.9.13');
|
42 |
+
define('WPUA_FOLDER', basename(dirname(__FILE__)));
|
43 |
+
define('WPUA_DIR', plugin_dir_path(__FILE__));
|
44 |
+
define('WPUA_INC', WPUA_DIR.'includes'.'/');
|
45 |
+
define('WPUA_URL', plugin_dir_url(WPUA_FOLDER).WPUA_FOLDER.'/');
|
46 |
+
define('WPUA_INC_URL', WPUA_URL.'includes'.'/');
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* WordPress includes used in plugin
|
51 |
+
* @since 1.9.2
|
52 |
+
* @uses is_admin()
|
53 |
+
*/
|
54 |
+
private function _load_wp_includes() {
|
55 |
+
if(!is_admin()) {
|
56 |
+
// wp_handle_upload
|
57 |
+
require_once(ABSPATH.'wp-admin/includes/file.php');
|
58 |
+
// wp_generate_attachment_metadata
|
59 |
+
require_once(ABSPATH.'wp-admin/includes/image.php');
|
60 |
+
// image_add_caption
|
61 |
+
require_once(ABSPATH.'wp-admin/includes/media.php');
|
62 |
+
// submit_button
|
63 |
+
require_once(ABSPATH.'wp-admin/includes/template.php');
|
64 |
+
}
|
65 |
+
// add_screen_option
|
66 |
+
require_once(ABSPATH.'wp-admin/includes/screen.php');
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Load WP User Avatar
|
71 |
+
* @since 1.9.2
|
72 |
+
* @uses bool $wpua_tinymce
|
73 |
+
* @uses is_admin()
|
74 |
+
*/
|
75 |
+
private function _load_wpua() {
|
76 |
+
global $wpua_tinymce;
|
77 |
+
require_once(WPUA_INC.'wpua-globals.php');
|
78 |
+
require_once(WPUA_INC.'wpua-functions.php');
|
79 |
+
require_once(WPUA_INC.'class-wp-user-avatar-admin.php');
|
80 |
+
require_once(WPUA_INC.'class-wp-user-avatar.php');
|
81 |
+
require_once(WPUA_INC.'class-wp-user-avatar-functions.php');
|
82 |
+
// Only needed on front pages and if NextGEN Gallery isn't installed
|
83 |
+
// if(!is_admin() && !defined('NEXTGEN_GALLERY_PLUGIN_DIR') && !defined('NGG_GALLERY_PLUGIN_DIR')) {
|
84 |
+
// require_once(WPUA_INC.'class-wp-user-avatar-resource-manager.php');
|
85 |
+
// WP_User_Avatar_Resource_Manager::init();
|
86 |
+
// }
|
87 |
+
require_once(WPUA_INC.'class-wp-user-avatar-shortcode.php');
|
88 |
+
require_once(WPUA_INC.'class-wp-user-avatar-subscriber.php');
|
89 |
+
require_once(WPUA_INC.'class-wp-user-avatar-update.php');
|
90 |
+
require_once(WPUA_INC.'class-wp-user-avatar-widget.php');
|
91 |
+
// Load TinyMCE only if enabled
|
92 |
+
if((bool) $wpua_tinymce == 1) {
|
93 |
+
require_once(WPUA_INC.'wpua-tinymce.php');
|
94 |
}
|
95 |
}
|
|
|
96 |
}
|
97 |
|
98 |
+
/**
|
99 |
+
* Initialize
|
100 |
+
*/
|
101 |
+
new WP_User_Avatar_Setup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|