Version Description
- Bug Fix: Missing php
Download this release
Release Info
Developer | bangbay |
Plugin | WP User Avatar |
Version | 1.9.3 |
Comparing to | |
See all releases |
Code changes from version 1.5.4 to 1.9.3
- css/wp-user-avatar.css +6 -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 +256 -0
- includes/class-wp-user-avatar-functions.php +252 -0
- includes/class-wp-user-avatar-list-table.php +288 -0
- includes/class-wp-user-avatar-shortcode.php +160 -0
- includes/class-wp-user-avatar-subscriber.php +84 -0
- includes/class-wp-user-avatar-update.php +77 -0
- includes/class-wp-user-avatar.php +310 -0
- includes/tinymce/editor_plugin.js +1 -1
- includes/tinymce/window.php +122 -71
- includes/wpua-functions.php +96 -0
- includes/wpua-globals.php +80 -0
- includes/wpua-media-page.php +85 -0
- includes/wpua-options-page.php +165 -0
- includes/{tinymce.php → wpua-tinymce.php} +12 -17
- 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 +307 -32
- uninstall.php +20 -10
- wp-user-avatar.php +36 -961
css/wp-user-avatar.css
CHANGED
@@ -1,11 +1,12 @@
|
|
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 |
.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 #wpua-remove, #wpua-edit #wpua-undo, #wpua-edit-attachment { margin-left: 10px !important; }
|
|
|
9 |
#wpua-slider { width: 22.75em; }
|
10 |
+
#wpua-upload-messages span { display: block; }
|
11 |
.wpua-hide { display: none !important; }
|
12 |
+
.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,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines all of administrative, activation, and deactivation settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Admin {
|
10 |
+
public function __construct() {
|
11 |
+
global $show_avatars, $wpua_allow_upload, $wpua_tinymce;
|
12 |
+
// Initialize default settings
|
13 |
+
register_activation_hook(WPUA_DIR.'wp-user-avatar.php', array($this, 'wpua_options'));
|
14 |
+
// Settings saved to wp_options
|
15 |
+
add_action('admin_init', array($this, 'wpua_options'));
|
16 |
+
// Remove subscribers edit_posts capability
|
17 |
+
register_deactivation_hook(WPUA_DIR.'wp-user-avatar.php', array($this, 'wpua_deactivate'));
|
18 |
+
// Translations
|
19 |
+
load_plugin_textdomain('wp-user-avatar', "", WPUA_FOLDER.'/lang');
|
20 |
+
// Admin menu settings
|
21 |
+
add_action('admin_menu', array($this, 'wpua_admin'));
|
22 |
+
add_action('admin_init', array($this, 'wpua_register_settings'));
|
23 |
+
// Default avatar
|
24 |
+
add_filter('default_avatar_select', array($this, 'wpua_add_default_avatar'), 10);
|
25 |
+
add_filter('whitelist_options', array($this, 'wpua_whitelist_options'), 10);
|
26 |
+
// Additional plugin info
|
27 |
+
add_filter('plugin_action_links', array($this, 'wpua_action_links'), 10, 2);
|
28 |
+
add_filter('plugin_row_meta', array($this, 'wpua_row_meta'), 10, 2);
|
29 |
+
// Hide column in Users table if default avatars are enabled
|
30 |
+
if((bool) $show_avatars == 0 && is_admin()) {
|
31 |
+
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
32 |
+
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
|
33 |
+
}
|
34 |
+
// Media states
|
35 |
+
add_filter('display_media_states', array($this, 'wpua_add_media_state'), 10, 1);
|
36 |
+
// Load TinyMCE only if enabled
|
37 |
+
if((bool) $wpua_tinymce == 1) {
|
38 |
+
include_once(WPUA_INC.'wpua-tinymce.php');
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
// Settings saved to wp_options
|
43 |
+
public function wpua_options() {
|
44 |
+
add_option('avatar_default_wp_user_avatar', "");
|
45 |
+
add_option('wp_user_avatar_allow_upload', '0');
|
46 |
+
add_option('wp_user_avatar_disable_gravatar', '0');
|
47 |
+
add_option('wp_user_avatar_edit_avatar', '1');
|
48 |
+
add_option('wp_user_avatar_resize_crop', '0');
|
49 |
+
add_option('wp_user_avatar_resize_h', '96');
|
50 |
+
add_option('wp_user_avatar_resize_upload', '0');
|
51 |
+
add_option('wp_user_avatar_resize_w', '96');
|
52 |
+
add_option('wp_user_avatar_tinymce', '1');
|
53 |
+
add_option('wp_user_avatar_upload_size_limit', '0');
|
54 |
+
}
|
55 |
+
|
56 |
+
// On deactivation
|
57 |
+
public function wpua_deactivate() {
|
58 |
+
global $blog_id, $wpdb;
|
59 |
+
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
60 |
+
$user_roles = get_option($wp_user_roles);
|
61 |
+
// Remove subscribers edit_posts capability
|
62 |
+
unset($user_roles['subscriber']['capabilities']['edit_posts']);
|
63 |
+
update_option($wp_user_roles, $user_roles);
|
64 |
+
// Reset all default avatar to Mystery Man
|
65 |
+
update_option('avatar_default', 'mystery');
|
66 |
+
}
|
67 |
+
|
68 |
+
// Add options page and settings
|
69 |
+
public function wpua_admin() {
|
70 |
+
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');
|
71 |
+
add_submenu_page('wp-user-avatar', __('Settings'), __('Settings'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'));
|
72 |
+
$hook = add_submenu_page('wp-user-avatar', __('Library'), __('Library'), 'manage_options', 'wp-user-avatar-library', array($this, 'wpua_media_page'));
|
73 |
+
add_action("load-$hook", array($this, 'wpua_media_screen_option'));
|
74 |
+
add_filter('set-screen-option', array($this, 'wpua_set_media_screen_option'), 10, 3);
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
// Checks if current page is settings page
|
79 |
+
public function wpua_is_menu_page() {
|
80 |
+
global $pagenow;
|
81 |
+
$is_menu_page = ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar') ? true : false;
|
82 |
+
return $is_menu_page;
|
83 |
+
}
|
84 |
+
|
85 |
+
// Media page
|
86 |
+
public function wpua_media_page() {
|
87 |
+
require_once(WPUA_INC.'wpua-media-page.php');
|
88 |
+
}
|
89 |
+
|
90 |
+
// Avatars per page
|
91 |
+
public function wpua_media_screen_option() {
|
92 |
+
$option = 'per_page';
|
93 |
+
$args = array(
|
94 |
+
'label' => __('Avatars'),
|
95 |
+
'default' => 10,
|
96 |
+
'option' => 'upload_per_page'
|
97 |
+
);
|
98 |
+
add_screen_option($option, $args);
|
99 |
+
}
|
100 |
+
|
101 |
+
// Save per page setting
|
102 |
+
public function wpua_set_media_screen_option($status, $option, $value) {
|
103 |
+
if($option == 'upload_per_page') {
|
104 |
+
return $value;
|
105 |
+
}
|
106 |
+
return $status;
|
107 |
+
}
|
108 |
+
|
109 |
+
// Options page
|
110 |
+
public function wpua_options_page() {
|
111 |
+
require_once(WPUA_INC.'wpua-options-page.php');
|
112 |
+
}
|
113 |
+
|
114 |
+
// Whitelist settings
|
115 |
+
public function wpua_register_settings() {
|
116 |
+
$settings = array();
|
117 |
+
$settings[] = register_setting('wpua-settings-group', 'avatar_rating');
|
118 |
+
$settings[] = register_setting('wpua-settings-group', 'avatar_default');
|
119 |
+
$settings[] = register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar');
|
120 |
+
$settings[] = register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
121 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
122 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
123 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
124 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
|
125 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_crop', 'intval');
|
126 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_h', 'intval');
|
127 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_upload', 'intval');
|
128 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_resize_w', 'intval');
|
129 |
+
$settings[] = register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
130 |
+
return apply_filters('wpua_register_settings', $settings);
|
131 |
+
}
|
132 |
+
|
133 |
+
// Add default avatar
|
134 |
+
public function wpua_add_default_avatar($avatar_list=null) {
|
135 |
+
global $avatar_default, $mustache_admin, $mustache_medium, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
|
136 |
+
// Remove get_avatar filter
|
137 |
+
remove_filter('get_avatar', array($wpua_functions, 'wpua_get_avatar_filter'));
|
138 |
+
// Set avatar_list variable
|
139 |
+
$avatar_list = "";
|
140 |
+
// Set avatar defaults
|
141 |
+
$avatar_defaults = array(
|
142 |
+
'mystery' => __('Mystery Man'),
|
143 |
+
'blank' => __('Blank'),
|
144 |
+
'gravatar_default' => __('Gravatar Logo'),
|
145 |
+
'identicon' => __('Identicon (Generated)'),
|
146 |
+
'wavatar' => __('Wavatar (Generated)'),
|
147 |
+
'monsterid' => __('MonsterID (Generated)'),
|
148 |
+
'retro' => __('Retro (Generated)')
|
149 |
+
);
|
150 |
+
// No Default Avatar, set to Mystery Man
|
151 |
+
if(empty($avatar_default)) {
|
152 |
+
$avatar_default = 'mystery';
|
153 |
+
}
|
154 |
+
// Take avatar_defaults and get examples for unknown@gravatar.com
|
155 |
+
foreach($avatar_defaults as $default_key => $default_name) {
|
156 |
+
$avatar = get_avatar('unknown@gravatar.com', 32, $default_key);
|
157 |
+
$selected = ($avatar_default == $default_key) ? 'checked="checked" ' : "";
|
158 |
+
$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='".esc_attr($default_key)."' {$selected}/> ";
|
159 |
+
$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&forcedefault=1'", $avatar);
|
160 |
+
$avatar_list .= ' '.$default_name.'</label>';
|
161 |
+
$avatar_list .= '<br />';
|
162 |
+
}
|
163 |
+
// Show remove link if custom Default Avatar is set
|
164 |
+
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
|
165 |
+
$avatar_thumb_src = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array(32,32));
|
166 |
+
$avatar_thumb = $avatar_thumb_src[0];
|
167 |
+
$hide_remove = "";
|
168 |
+
} else {
|
169 |
+
$avatar_thumb = $mustache_admin;
|
170 |
+
$hide_remove = ' class="wpua-hide"';
|
171 |
+
}
|
172 |
+
// Default Avatar is wp_user_avatar, check the radio button next to it
|
173 |
+
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
174 |
+
// Wrap WPUA in div
|
175 |
+
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
|
176 |
+
// Add WPUA to list
|
177 |
+
$wpua_list = "\n\t<label><input type='radio' name='avatar_default' id='wp_user_avatar_radio' value='wp_user_avatar'$selected_avatar /> ";
|
178 |
+
$wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
|
179 |
+
$wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
|
180 |
+
$wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add" data-title="'._('Choose Image').': '._('Default Avatar').'">'.__('Choose Image').'</button>';
|
181 |
+
$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>';
|
182 |
+
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
|
183 |
+
$wpua_list .= '<div id="wpua-modal"></div>';
|
184 |
+
if((bool) $wpua_disable_gravatar != 1) {
|
185 |
+
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
|
186 |
+
} else {
|
187 |
+
return $wpua_list;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
// Add default avatar_default to whitelist
|
192 |
+
public function wpua_whitelist_options($options) {
|
193 |
+
$options['discussion'][] = 'avatar_default_wp_user_avatar';
|
194 |
+
return $options;
|
195 |
+
}
|
196 |
+
|
197 |
+
// Add actions links on plugin page
|
198 |
+
public function wpua_action_links($links, $file) {
|
199 |
+
if(basename(dirname($file)) == 'wp-user-avatar') {
|
200 |
+
$links[] = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('admin.php')).'">'.__('Settings').'</a>';
|
201 |
+
}
|
202 |
+
return $links;
|
203 |
+
}
|
204 |
+
|
205 |
+
// Add row meta on plugin page
|
206 |
+
public function wpua_row_meta($links, $file) {
|
207 |
+
if(basename(dirname($file)) == 'wp-user-avatar') {
|
208 |
+
$links[] = '<a href="http://wordpress.org/support/plugin/wp-user-avatar" target="_blank">'.__('Support Forums').'</a>';
|
209 |
+
$links[] = '<a href="http://siboliban.org/donate" target="_blank">'.__('Donate', 'wp-user-avatar').'</a>';
|
210 |
+
}
|
211 |
+
return $links;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Add column to Users table
|
215 |
+
public function wpua_add_column($columns) {
|
216 |
+
return $columns + array('wp-user-avatar' => __('WP User Avatar', 'wp-user-avatar'));
|
217 |
+
}
|
218 |
+
|
219 |
+
// Show thumbnail in Users table
|
220 |
+
public function wpua_show_column($value, $column_name, $user_id) {
|
221 |
+
global $blog_id, $wpdb;
|
222 |
+
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
223 |
+
$wpua_image = wp_get_attachment_image($wpua, array(32,32));
|
224 |
+
if($column_name == 'wp-user-avatar') {
|
225 |
+
$value = $wpua_image;
|
226 |
+
}
|
227 |
+
return $value;
|
228 |
+
}
|
229 |
+
|
230 |
+
// Get list table
|
231 |
+
public function _wpua_get_list_table($class, $args = array()) {
|
232 |
+
require_once(WPUA_INC.'class-wp-user-avatar-list-table.php');
|
233 |
+
$args['screen'] = 'wp-user-avatar';
|
234 |
+
return new $class($args);
|
235 |
+
}
|
236 |
+
|
237 |
+
// Add media states
|
238 |
+
public function wpua_add_media_state($states) {
|
239 |
+
global $post, $wpua_avatar_default;
|
240 |
+
$is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
|
241 |
+
if(!empty($is_wpua)) {
|
242 |
+
$states[] = __('Avatar');
|
243 |
+
}
|
244 |
+
if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)) {
|
245 |
+
$states[] = __('Default Avatar');
|
246 |
+
}
|
247 |
+
return apply_filters('wpua_add_media_state', $states);
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
// Initialize WP_User_Avatar_Admin
|
252 |
+
function wpua_admin_init() {
|
253 |
+
global $wpua_admin;
|
254 |
+
$wpua_admin = new WP_User_Avatar_Admin();
|
255 |
+
}
|
256 |
+
add_action('init', 'wpua_admin_init');
|
includes/class-wp-user-avatar-functions.php
ADDED
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Core user functions.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Functions {
|
10 |
+
public function __construct() {
|
11 |
+
add_filter('get_avatar', array($this, 'wpua_get_avatar_filter'), 10, 5);
|
12 |
+
}
|
13 |
+
|
14 |
+
// Returns true if user has Gravatar-hosted image
|
15 |
+
public function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email="") {
|
16 |
+
if(!is_object($id_or_email) && !empty($id_or_email)) {
|
17 |
+
// Find user by ID or e-mail address
|
18 |
+
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
19 |
+
// Get registered user e-mail address
|
20 |
+
$email = !empty($user) ? $user->user_email : "";
|
21 |
+
}
|
22 |
+
// Check if Gravatar image returns 200 (OK) or 404 (Not Found)
|
23 |
+
$hash = md5(strtolower(trim($email)));
|
24 |
+
$gravatar = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
|
25 |
+
$data = wp_cache_get($hash);
|
26 |
+
if(false === $data) {
|
27 |
+
$response = wp_remote_head($gravatar);
|
28 |
+
$data = is_wp_error($response) ? 'not200' : $response['response']['code'];
|
29 |
+
wp_cache_set($hash, $data, $group="", $expire=60*5);
|
30 |
+
}
|
31 |
+
$has_gravatar = ($data == '200') ? true : false;
|
32 |
+
return $has_gravatar;
|
33 |
+
}
|
34 |
+
|
35 |
+
// Check if local image
|
36 |
+
public function wpua_attachment_is_image($attachment_id) {
|
37 |
+
$is_image = wp_attachment_is_image($attachment_id);
|
38 |
+
$is_image = apply_filters('wpua_attachment_is_image', $is_image, $attachment_id);
|
39 |
+
return $is_image;
|
40 |
+
}
|
41 |
+
|
42 |
+
// Get image src
|
43 |
+
public function wpua_get_attachment_image_src($attachment_id, $size='thumbnail', $icon=false) {
|
44 |
+
$image_src_array = wp_get_attachment_image_src($attachment_id, $size, $icon);
|
45 |
+
return apply_filters('wpua_get_attachment_image_src', $image_src_array, $attachment_id, $size, $icon);
|
46 |
+
}
|
47 |
+
|
48 |
+
// Returns true if user has wp_user_avatar
|
49 |
+
public function has_wp_user_avatar($id_or_email="", $has_wpua=false, $user="", $user_id="") {
|
50 |
+
global $blog_id, $wpdb, $wpua_functions;
|
51 |
+
if(!is_object($id_or_email) && !empty($id_or_email)) {
|
52 |
+
// Find user by ID or e-mail address
|
53 |
+
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
54 |
+
// Get registered user ID
|
55 |
+
$user_id = !empty($user) ? $user->ID : "";
|
56 |
+
}
|
57 |
+
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
58 |
+
$has_wpua = !empty($wpua) && $wpua_functions->wpua_attachment_is_image($wpua) ? true : false;
|
59 |
+
return $has_wpua;
|
60 |
+
}
|
61 |
+
|
62 |
+
// Replace get_avatar only in get_wp_user_avatar
|
63 |
+
public function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt="") {
|
64 |
+
global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
|
65 |
+
// User has WPUA
|
66 |
+
if(is_object($id_or_email)) {
|
67 |
+
if(!empty($id_or_email->comment_author_email)) {
|
68 |
+
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
|
69 |
+
} else {
|
70 |
+
$avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
|
71 |
+
}
|
72 |
+
} else {
|
73 |
+
if(has_wp_user_avatar($id_or_email)) {
|
74 |
+
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
|
75 |
+
// User has Gravatar and Gravatar is not disabled
|
76 |
+
} elseif((bool) $wpua_disable_gravatar != 1 && $wpua_functions->wpua_has_gravatar($id_or_email)) {
|
77 |
+
$avatar = $avatar;
|
78 |
+
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
79 |
+
} elseif($avatar_default == 'wp_user_avatar') {
|
80 |
+
// Show custom Default Avatar
|
81 |
+
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
|
82 |
+
// Get image
|
83 |
+
$wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
84 |
+
// Image src
|
85 |
+
$default = $wpua_avatar_default_image[0];
|
86 |
+
// Add dimensions if numeric size
|
87 |
+
$dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
|
88 |
+
} else {
|
89 |
+
// Get mustache image based on numeric size comparison
|
90 |
+
if($size > get_option('medium_size_w')) {
|
91 |
+
$default = $mustache_original;
|
92 |
+
} elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')) {
|
93 |
+
$default = $mustache_medium;
|
94 |
+
} elseif($size <= get_option('thumbnail_size_w') && $size > 96) {
|
95 |
+
$default = $mustache_thumbnail;
|
96 |
+
} elseif($size <= 96 && $size > 32) {
|
97 |
+
$default = $mustache_avatar;
|
98 |
+
} elseif($size <= 32) {
|
99 |
+
$default = $mustache_admin;
|
100 |
+
}
|
101 |
+
// Add dimensions if numeric size
|
102 |
+
$dimensions = ' width="'.$size.'" height="'.$size.'"';
|
103 |
+
}
|
104 |
+
// Construct the img tag
|
105 |
+
$avatar = '<img src="'.$default.'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.' photo avatar-default" />';
|
106 |
+
}
|
107 |
+
}
|
108 |
+
return apply_filters('wpua_get_avatar_filter', $avatar, $id_or_email, $size, $default, $alt);
|
109 |
+
}
|
110 |
+
|
111 |
+
// Get original avatar, for when user removes wp_user_avatar
|
112 |
+
public function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt="") {
|
113 |
+
global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar, $wpua_functions;
|
114 |
+
// Remove get_avatar filter
|
115 |
+
remove_filter('get_avatar', array($wpua_functions, 'wpua_get_avatar_filter'));
|
116 |
+
if((bool) $wpua_disable_gravatar != 1) {
|
117 |
+
// User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
118 |
+
if(!$wpua_functions->wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar') {
|
119 |
+
// Show custom Default Avatar
|
120 |
+
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
|
121 |
+
$wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
122 |
+
$default = $wpua_avatar_default_image[0];
|
123 |
+
} else {
|
124 |
+
$default = $mustache_avatar;
|
125 |
+
}
|
126 |
+
} else {
|
127 |
+
// Get image from Gravatar, whether it's the user's image or default image
|
128 |
+
$wpua_image = get_avatar($id_or_email, $size);
|
129 |
+
// Takes the img tag, extracts the src
|
130 |
+
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
131 |
+
$default = !empty($matches) ? $matches [0] [1] : "";
|
132 |
+
}
|
133 |
+
} else {
|
134 |
+
if(!empty($wpua_avatar_default) && $wpua_functions->wpua_attachment_is_image($wpua_avatar_default)) {
|
135 |
+
$wpua_avatar_default_image = $wpua_functions->wpua_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
136 |
+
$default = $wpua_avatar_default_image[0];
|
137 |
+
} else {
|
138 |
+
$default = $mustache_avatar;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
// Enable get_avatar filter
|
142 |
+
add_filter('get_avatar', array($wpua_functions, 'wpua_get_avatar_filter'), 10, 5);
|
143 |
+
return apply_filters('wpua_get_avatar_original', $default);
|
144 |
+
}
|
145 |
+
|
146 |
+
// Find WPUA, show get_avatar if empty
|
147 |
+
public function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt="") {
|
148 |
+
global $all_sizes, $avatar_default, $blog_id, $post, $wpdb, $wpua_functions, $_wp_additional_image_sizes;
|
149 |
+
$email='unknown@gravatar.com';
|
150 |
+
// Checks if comment
|
151 |
+
if(is_object($id_or_email)) {
|
152 |
+
// Checks if comment author is registered user by user ID
|
153 |
+
if($id_or_email->user_id != 0) {
|
154 |
+
$email = $id_or_email->user_id;
|
155 |
+
// Checks that comment author isn't anonymous
|
156 |
+
} elseif(!empty($id_or_email->comment_author_email)) {
|
157 |
+
// Checks if comment author is registered user by e-mail address
|
158 |
+
$user = get_user_by('email', $id_or_email->comment_author_email);
|
159 |
+
// Get registered user info from profile, otherwise e-mail address should be value
|
160 |
+
$email = !empty($user) ? $user->ID : $id_or_email->comment_author_email;
|
161 |
+
}
|
162 |
+
$alt = $id_or_email->comment_author;
|
163 |
+
} else {
|
164 |
+
if(!empty($id_or_email)) {
|
165 |
+
// Find user by ID or e-mail address
|
166 |
+
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
167 |
+
} else {
|
168 |
+
// Find author's name if id_or_email is empty
|
169 |
+
$author_name = get_query_var('author_name');
|
170 |
+
if(is_author()) {
|
171 |
+
// On author page, get user by page slug
|
172 |
+
$user = get_user_by('slug', $author_name);
|
173 |
+
} else {
|
174 |
+
// On post, get user by author meta
|
175 |
+
$user_id = get_the_author_meta('ID');
|
176 |
+
$user = get_user_by('id', $user_id);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
// Set user's ID and name
|
180 |
+
if(!empty($user)) {
|
181 |
+
$email = $user->ID;
|
182 |
+
$alt = $user->display_name;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
// Checks if user has WPUA
|
186 |
+
$wpua_meta = get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $email);
|
187 |
+
// Add alignment class
|
188 |
+
$alignclass = !empty($align) && ($align == 'left' || $align == 'right' || $align == 'center') ? ' align'.$align : ' alignnone';
|
189 |
+
// User has WPUA, bypass get_avatar
|
190 |
+
if(!empty($wpua_meta)) {
|
191 |
+
// Numeric size use size array
|
192 |
+
$get_size = is_numeric($size) ? array($size,$size) : $size;
|
193 |
+
// Get image src
|
194 |
+
$wpua_image = $wpua_functions->wpua_get_attachment_image_src($wpua_meta, $get_size);
|
195 |
+
// Add dimensions to img only if numeric size was specified
|
196 |
+
$dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
|
197 |
+
// Construct the img tag
|
198 |
+
$avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo" />';
|
199 |
+
} else {
|
200 |
+
// Check for custom image sizes
|
201 |
+
if(in_array($size, $all_sizes)) {
|
202 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
203 |
+
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
204 |
+
} else {
|
205 |
+
$get_size = $_wp_additional_image_sizes[$size]['width'];
|
206 |
+
}
|
207 |
+
} else {
|
208 |
+
// Numeric sizes leave as-is
|
209 |
+
$get_size = $size;
|
210 |
+
}
|
211 |
+
// User with no WPUA uses get_avatar
|
212 |
+
$avatar = get_avatar($email, $get_size, $default="", $alt="");
|
213 |
+
// Remove width and height for non-numeric sizes
|
214 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
215 |
+
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
|
216 |
+
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
|
217 |
+
}
|
218 |
+
$str_replace = array('wp-user-avatar ', 'wp-user-avatar-'.$get_size.' ', 'wp-user-avatar-'.$size.' ', 'avatar-'.$get_size, 'photo');
|
219 |
+
$str_replacements = array("", "", "", 'avatar-'.$size, 'wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo');
|
220 |
+
$avatar = str_replace($str_replace, $str_replacements, $avatar);
|
221 |
+
}
|
222 |
+
return apply_filters('get_wp_user_avatar', $avatar, $id_or_email, $size, $align, $alt);
|
223 |
+
}
|
224 |
+
|
225 |
+
// Return just the image src
|
226 |
+
public function get_wp_user_avatar_src($id_or_email, $size="", $align="") {
|
227 |
+
$wpua_image_src = "";
|
228 |
+
// Gets the avatar img tag
|
229 |
+
$wpua_image = get_wp_user_avatar($id_or_email, $size, $align);
|
230 |
+
// Takes the img tag, extracts the src
|
231 |
+
if(!empty($wpua_image)) {
|
232 |
+
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
233 |
+
$wpua_image_src = !empty($matches) ? $matches [0] [1] : "";
|
234 |
+
}
|
235 |
+
return $wpua_image_src;
|
236 |
+
}
|
237 |
+
|
238 |
+
// Check if avatar_upload is in use
|
239 |
+
public function wpua_has_shortcode() {
|
240 |
+
global $post;
|
241 |
+
$content = !empty($post->post_content) ? $post->post_content : null;
|
242 |
+
$has_shortcode = has_shortcode($content, 'avatar_upload') ? true : false;
|
243 |
+
return $has_shortcode;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
// Initialize WP_User_Avatar_Functions
|
248 |
+
function wpua_functions_init() {
|
249 |
+
global $wpua_functions;
|
250 |
+
$wpua_functions = new WP_User_Avatar_Functions();
|
251 |
+
}
|
252 |
+
add_action('init', 'wpua_functions_init');
|
includes/class-wp-user-avatar-list-table.php
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Based on WP_Media_List_Table class.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_List_Table extends WP_List_Table {
|
10 |
+
function __construct($args = array()) {
|
11 |
+
global $avatars_array, $post, $wpua_avatar_default;
|
12 |
+
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
|
13 |
+
$q = array(
|
14 |
+
'paged' => $paged,
|
15 |
+
'post_type' => 'attachment',
|
16 |
+
'post_status' => 'inherit',
|
17 |
+
'posts_per_page' => '-1',
|
18 |
+
'meta_query' => array(
|
19 |
+
array(
|
20 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
21 |
+
'value' => '',
|
22 |
+
'compare' => '!='
|
23 |
+
)
|
24 |
+
)
|
25 |
+
);
|
26 |
+
$avatars_wp_query = new WP_Query($q);
|
27 |
+
$avatars_array = array();
|
28 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
29 |
+
$avatars_array[] = $post->ID;
|
30 |
+
endwhile;
|
31 |
+
wp_reset_query();
|
32 |
+
// Include default avatar
|
33 |
+
$avatars_array[] = $wpua_avatar_default;
|
34 |
+
parent::__construct(array(
|
35 |
+
'plural' => 'media',
|
36 |
+
'screen' => isset($args['screen']) ? $args['screen'] : null
|
37 |
+
));
|
38 |
+
}
|
39 |
+
|
40 |
+
function ajax_user_can() {
|
41 |
+
return current_user_can('upload_files');
|
42 |
+
}
|
43 |
+
|
44 |
+
function search_box($text, $input_id) {
|
45 |
+
if(empty($_REQUEST['s']) && !$this->has_items())
|
46 |
+
return;
|
47 |
+
$input_id = $input_id.'-search-input';
|
48 |
+
if(!empty($_REQUEST['orderby']))
|
49 |
+
echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
|
50 |
+
if(!empty($_REQUEST['order']))
|
51 |
+
echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
|
52 |
+
if(!empty($_REQUEST['post_mime_type']))
|
53 |
+
echo '<input type="hidden" name="post_mime_type" value="'.esc_attr($_REQUEST['post_mime_type']).'" />';
|
54 |
+
if(!empty( $_REQUEST['detached']))
|
55 |
+
echo '<input type="hidden" name="detached" value="'.esc_attr($_REQUEST['detached']).'" />';
|
56 |
+
?>
|
57 |
+
<p class="search-box">
|
58 |
+
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
|
59 |
+
<input type="hidden" id="page" name="page" value="wp-user-avatar-library" />
|
60 |
+
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
61 |
+
<?php submit_button($text, 'button', false, false, array('id' => 'search-submit')); ?>
|
62 |
+
</p>
|
63 |
+
<?php
|
64 |
+
}
|
65 |
+
|
66 |
+
function prepare_items() {
|
67 |
+
global $avatars_array, $lost, $wpdb, $wp_query, $post_mime_types, $avail_post_mime_types, $post;
|
68 |
+
$q = $_REQUEST;
|
69 |
+
$q['post__in'] = $avatars_array;
|
70 |
+
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
|
71 |
+
$this->is_trash = isset($_REQUEST['status']) && 'trash' == $_REQUEST['status'];
|
72 |
+
$this->set_pagination_args(array(
|
73 |
+
'total_items' => $wp_query->found_posts,
|
74 |
+
'total_pages' => $wp_query->max_num_pages,
|
75 |
+
'per_page' => $wp_query->query_vars['posts_per_page'],
|
76 |
+
));
|
77 |
+
}
|
78 |
+
|
79 |
+
function get_views() {
|
80 |
+
global $avatars_array;
|
81 |
+
$type_links = array();
|
82 |
+
$_total_posts = count(array_filter($avatars_array));
|
83 |
+
$class = (empty($_GET['post_mime_type']) && !isset($_GET['status'])) ? ' class="current"' : '';
|
84 |
+
$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>';
|
85 |
+
return $type_links;
|
86 |
+
}
|
87 |
+
|
88 |
+
function get_bulk_actions() {
|
89 |
+
$actions = array();
|
90 |
+
$actions['delete'] = __('Delete Permanently');
|
91 |
+
return $actions;
|
92 |
+
}
|
93 |
+
|
94 |
+
function current_action() {
|
95 |
+
return parent::current_action();
|
96 |
+
}
|
97 |
+
|
98 |
+
function has_items() {
|
99 |
+
return have_posts();
|
100 |
+
}
|
101 |
+
|
102 |
+
function no_items() {
|
103 |
+
_e('No media attachments found.');
|
104 |
+
}
|
105 |
+
|
106 |
+
function get_columns() {
|
107 |
+
$posts_columns = array();
|
108 |
+
$posts_columns['cb'] = '<input type="checkbox" />';
|
109 |
+
$posts_columns['icon'] = '';
|
110 |
+
$posts_columns['title'] = _x('File', 'column name');
|
111 |
+
$posts_columns['author'] = __('Author');
|
112 |
+
$posts_columns['parent'] = _x('Uploaded to', 'column name');
|
113 |
+
$posts_columns['date'] = _x('Date', 'column name');
|
114 |
+
return $posts_columns;
|
115 |
+
}
|
116 |
+
|
117 |
+
function get_sortable_columns() {
|
118 |
+
return array(
|
119 |
+
'title' => 'title',
|
120 |
+
'author' => 'author',
|
121 |
+
'date' => array('date', true),
|
122 |
+
);
|
123 |
+
}
|
124 |
+
|
125 |
+
function display_rows() {
|
126 |
+
global $post, $wpdb;
|
127 |
+
add_filter('the_title','esc_html');
|
128 |
+
$alt = '';
|
129 |
+
while (have_posts()) : the_post();
|
130 |
+
$user_can_edit = current_user_can('edit_post', $post->ID);
|
131 |
+
|
132 |
+
if($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash')
|
133 |
+
continue;
|
134 |
+
|
135 |
+
$alt = ('alternate' == $alt) ? '' : 'alternate';
|
136 |
+
$post_owner = (get_current_user_id() == $post->post_author) ? 'self' : 'other';
|
137 |
+
$att_title = _draft_or_post_title();
|
138 |
+
?>
|
139 |
+
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim($alt.' author-'.$post_owner.' status-'.$post->post_status); ?>' valign="top">
|
140 |
+
<?php
|
141 |
+
list( $columns, $hidden ) = $this->get_column_info();
|
142 |
+
foreach($columns as $column_name => $column_display_name) {
|
143 |
+
$class = "class='$column_name column-$column_name'";
|
144 |
+
$style = '';
|
145 |
+
if(in_array($column_name, $hidden)) {
|
146 |
+
$style = ' style="display:none;"';
|
147 |
+
}
|
148 |
+
$attributes = $class.$style;
|
149 |
+
switch($column_name) {
|
150 |
+
case 'cb':
|
151 |
+
?>
|
152 |
+
<th scope="row" class="check-column">
|
153 |
+
<?php if ( $user_can_edit ) { ?>
|
154 |
+
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php echo sprintf(__('Select %s'), $att_title);?></label>
|
155 |
+
<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
|
156 |
+
<?php } ?>
|
157 |
+
</th>
|
158 |
+
<?php
|
159 |
+
break;
|
160 |
+
case 'icon':
|
161 |
+
$attributes = 'class="column-icon media-icon"'.$style;
|
162 |
+
?>
|
163 |
+
<td <?php echo $attributes ?>><?php
|
164 |
+
if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
|
165 |
+
if ( $this->is_trash || ! $user_can_edit ) {
|
166 |
+
echo $thumb;
|
167 |
+
} else {
|
168 |
+
?>
|
169 |
+
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
|
170 |
+
<?php echo $thumb; ?>
|
171 |
+
</a>
|
172 |
+
<?php } }
|
173 |
+
?>
|
174 |
+
</td>
|
175 |
+
<?php
|
176 |
+
break;
|
177 |
+
case 'title':
|
178 |
+
?>
|
179 |
+
<td <?php echo $attributes ?>><strong>
|
180 |
+
<?php if ( $this->is_trash || ! $user_can_edit ) {
|
181 |
+
echo $att_title;
|
182 |
+
} else { ?>
|
183 |
+
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>"
|
184 |
+
title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
|
185 |
+
<?php echo $att_title; ?></a>
|
186 |
+
<?php };
|
187 |
+
_media_states( $post ); ?></strong>
|
188 |
+
<p>
|
189 |
+
<?php
|
190 |
+
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
|
191 |
+
echo esc_html( strtoupper( $matches[1] ) );
|
192 |
+
else
|
193 |
+
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
|
194 |
+
?>
|
195 |
+
</p>
|
196 |
+
<?php echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); ?>
|
197 |
+
</td>
|
198 |
+
<?php
|
199 |
+
break;
|
200 |
+
case 'author':
|
201 |
+
?>
|
202 |
+
<td <?php echo $attributes ?>>
|
203 |
+
<?php
|
204 |
+
printf( '<a href="%s">%s</a>',
|
205 |
+
esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
|
206 |
+
get_the_author()
|
207 |
+
); ?>
|
208 |
+
</td>
|
209 |
+
<?php
|
210 |
+
break;
|
211 |
+
case 'date':
|
212 |
+
if ( '0000-00-00 00:00:00' == $post->post_date ) {
|
213 |
+
$h_time = __( 'Unpublished' );
|
214 |
+
} else {
|
215 |
+
$m_time = $post->post_date;
|
216 |
+
$time = get_post_time( 'G', true, $post, false );
|
217 |
+
if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
|
218 |
+
if ( $t_diff < 0 )
|
219 |
+
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
|
220 |
+
else
|
221 |
+
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
|
222 |
+
} else {
|
223 |
+
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
?>
|
227 |
+
<td <?php echo $attributes ?>><?php echo $h_time ?></td>
|
228 |
+
<?php
|
229 |
+
break;
|
230 |
+
case 'parent':
|
231 |
+
global $blog_id, $wpdb;
|
232 |
+
// Find all users with this WPUA
|
233 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
234 |
+
$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));
|
235 |
+
// Find users without WPUA
|
236 |
+
$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, ""));
|
237 |
+
$user_array = array();
|
238 |
+
?>
|
239 |
+
<td <?php echo $attributes ?>>
|
240 |
+
<strong>
|
241 |
+
<?php
|
242 |
+
if(!empty($wpuas)) {
|
243 |
+
foreach($wpuas as $usermeta) {
|
244 |
+
$user = get_userdata($usermeta->user_id);
|
245 |
+
$user_array[] = '<a href="'.get_edit_user_link($user->ID).'">'.$user->user_login.'</a>';
|
246 |
+
}
|
247 |
+
} else {
|
248 |
+
foreach($nowpuas as $usermeta) {
|
249 |
+
$user = get_userdata($usermeta->ID);
|
250 |
+
$user_array[] = '<a href="'.get_edit_user_link($user->ID).'">'.$user->user_login.'</a>';
|
251 |
+
}
|
252 |
+
}
|
253 |
+
?>
|
254 |
+
<?php echo implode(', ', array_filter($user_array)); ?>
|
255 |
+
</strong>
|
256 |
+
</td>
|
257 |
+
<?php
|
258 |
+
break;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
?>
|
262 |
+
</tr>
|
263 |
+
<?php endwhile;
|
264 |
+
}
|
265 |
+
|
266 |
+
function _get_row_actions($post, $att_title) {
|
267 |
+
$actions = array();
|
268 |
+
if(current_user_can('edit_post', $post->ID) && !$this->is_trash) {
|
269 |
+
$actions['edit'] = '<a href="'.get_edit_post_link($post->ID, true).'">'.__('Edit').'</a>';
|
270 |
+
}
|
271 |
+
if(current_user_can('delete_post', $post->ID)) {
|
272 |
+
if($this->is_trash) {
|
273 |
+
$actions['untrash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_'.$post->ID)."'>".__('Restore')."</a>";
|
274 |
+
} elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
|
275 |
+
$actions['trash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_'. $post->ID)."'>".__('Trash')."</a>";
|
276 |
+
}
|
277 |
+
if($this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH) {
|
278 |
+
$delete_ays = (!$this->is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : '';
|
279 |
+
$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>";
|
280 |
+
}
|
281 |
+
}
|
282 |
+
if(!$this->is_trash) {
|
283 |
+
$title =_draft_or_post_title($post->post_parent);
|
284 |
+
$actions['view'] = '<a href="'.get_permalink($post->ID).'" title="'.esc_attr(sprintf(__('View “%s”'), $title)).'" rel="permalink">'.__('View').'</a>';
|
285 |
+
}
|
286 |
+
return $actions;
|
287 |
+
}
|
288 |
+
}
|
includes/class-wp-user-avatar-shortcode.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines shortcodes.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Shortcode {
|
10 |
+
public function __construct() {
|
11 |
+
global $wp_user_avatar;
|
12 |
+
add_shortcode('avatar', array($this, 'wpua_shortcode'));
|
13 |
+
add_shortcode('avatar_upload', array($this, 'wpua_edit_shortcode'));
|
14 |
+
// Add avatar and scripts to avatar_upload
|
15 |
+
add_action('wpua_show_profile', array($wp_user_avatar, 'wpua_action_show_user_profile'));
|
16 |
+
add_action('wpua_show_profile', array($wp_user_avatar, 'wpua_media_upload_scripts'));
|
17 |
+
add_action('wpua_update', array($wp_user_avatar, 'wpua_action_process_option_update'));
|
18 |
+
// Add error messages to avatar_upload
|
19 |
+
add_action('wpua_update_errors', array($wp_user_avatar, 'wpua_upload_errors'), 10, 3);
|
20 |
+
}
|
21 |
+
|
22 |
+
// Display shortcode
|
23 |
+
public function wpua_shortcode($atts, $content=null) {
|
24 |
+
global $all_sizes, $blog_id, $post, $wpdb;
|
25 |
+
// Set shortcode attributes
|
26 |
+
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
|
27 |
+
// Find user by ID, login, slug, or e-mail address
|
28 |
+
if(!empty($user)) {
|
29 |
+
$user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
|
30 |
+
$user = empty($user) ? get_user_by('slug', $user) : $user;
|
31 |
+
$user = empty($user) ? get_user_by('email', $user) : $user;
|
32 |
+
} else {
|
33 |
+
// Find author's name if id_or_email is empty
|
34 |
+
$author_name = get_query_var('author_name');
|
35 |
+
if(is_author()) {
|
36 |
+
// On author page, get user by page slug
|
37 |
+
$user = get_user_by('slug', $author_name);
|
38 |
+
} else {
|
39 |
+
// On post, get user by author meta
|
40 |
+
$user_id = get_the_author_meta('ID');
|
41 |
+
$user = get_user_by('id', $user_id);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
// Numeric sizes leave as-is
|
45 |
+
$get_size = $size;
|
46 |
+
// Check for custom image sizes if there are captions
|
47 |
+
if(!empty($content)) {
|
48 |
+
if(in_array($size, $all_sizes)) {
|
49 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
50 |
+
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
51 |
+
} else {
|
52 |
+
$get_size = $_wp_additional_image_sizes[$size]['width'];
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
// Get user ID
|
57 |
+
$id_or_email = !empty($user) ? $user->ID : 'unknown@gravatar.com';
|
58 |
+
// Check if link is set
|
59 |
+
if(!empty($link)) {
|
60 |
+
// CSS class is same as link type, except for URL
|
61 |
+
$link_class = $link;
|
62 |
+
if($link == 'file') {
|
63 |
+
// Get image src
|
64 |
+
$link = get_wp_user_avatar_src($id_or_email, 'original');
|
65 |
+
} elseif($link == 'attachment') {
|
66 |
+
// Get attachment URL
|
67 |
+
$link = get_attachment_link(get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email));
|
68 |
+
} else {
|
69 |
+
// URL
|
70 |
+
$link_class = 'custom';
|
71 |
+
}
|
72 |
+
// Open in new window
|
73 |
+
$target_link = !empty($target) ? ' target="'.$target.'"' : "";
|
74 |
+
// Wrap the avatar inside the link
|
75 |
+
$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>';
|
76 |
+
} else {
|
77 |
+
$html = get_wp_user_avatar($id_or_email, $get_size, $align);
|
78 |
+
}
|
79 |
+
// Check if caption is set
|
80 |
+
if(!empty($content)) {
|
81 |
+
// Get attachment ID
|
82 |
+
$wpua = get_user_meta($id_or_email, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
83 |
+
// Clean up caption
|
84 |
+
$content = trim($content);
|
85 |
+
$content = preg_replace('/\r|\n/', "", $content);
|
86 |
+
$content = preg_replace('/<\/p><p>/', "", $content, 1);
|
87 |
+
$content = preg_replace('/<\/p><p>$/', "", $content);
|
88 |
+
$content = str_replace('</p><p>', "<br /><br />", $content);
|
89 |
+
$avatar = do_shortcode(image_add_caption($html, $wpua, $content, $title="", $align, $link, $get_size, $alt=""));
|
90 |
+
} else {
|
91 |
+
$avatar = $html;
|
92 |
+
}
|
93 |
+
return $avatar;
|
94 |
+
}
|
95 |
+
|
96 |
+
// Update user
|
97 |
+
private function wpua_edit_user($user_id = 0) {
|
98 |
+
$user = new stdClass;
|
99 |
+
if($user_id) {
|
100 |
+
$update = true;
|
101 |
+
$user->ID = (int) $user_id;
|
102 |
+
} else {
|
103 |
+
$update = false;
|
104 |
+
}
|
105 |
+
$errors = new WP_Error();
|
106 |
+
do_action_ref_array('wpua_update_errors', array(&$errors, $update, &$user));
|
107 |
+
if($errors->get_error_codes()) {
|
108 |
+
return $errors;
|
109 |
+
}
|
110 |
+
if($update) {
|
111 |
+
$user_id = wp_update_user($user);
|
112 |
+
}
|
113 |
+
return $user_id;
|
114 |
+
}
|
115 |
+
|
116 |
+
// Edit shortcode
|
117 |
+
public function wpua_edit_shortcode($atts) {
|
118 |
+
global $current_user, $errors;
|
119 |
+
// Shortcode only works with logged in user
|
120 |
+
if(is_user_logged_in()) {
|
121 |
+
// Save
|
122 |
+
if(isset($_POST['submit']) && $_POST['submit'] && $_POST['action'] == 'update') {
|
123 |
+
do_action('wpua_update', $current_user->ID);
|
124 |
+
// Check for errors
|
125 |
+
$errors = $this->wpua_edit_user($current_user->ID);
|
126 |
+
}
|
127 |
+
// Errors
|
128 |
+
if(isset($errors) && is_wp_error($errors)) {
|
129 |
+
echo '<div class="error"><p>'.implode( "</p>\n<p>", $errors->get_error_messages()).'</p></div>';
|
130 |
+
} elseif(isset($errors) && !is_wp_error($errors)) {
|
131 |
+
echo '<div class="updated"><p><strong>'.__('Profile updated.').'</strong></p></div>';
|
132 |
+
}
|
133 |
+
// Edit form
|
134 |
+
return $this->wpua_edit_form();
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
// Edit form
|
139 |
+
public function wpua_edit_form() {
|
140 |
+
global $current_user;
|
141 |
+
ob_start();
|
142 |
+
?>
|
143 |
+
<form id="wpua-edit-<?php echo $current_user->ID; ?>" class="wpua-edit" action="<?php echo get_permalink(); ?>" method="post" enctype="multipart/form-data">
|
144 |
+
<?php do_action('wpua_show_profile', $current_user); ?>
|
145 |
+
<input type="hidden" name="action" value="update" />
|
146 |
+
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($current_user->ID); ?>" />
|
147 |
+
<?php wp_nonce_field('update-user_'.$current_user->ID); ?>
|
148 |
+
<?php submit_button(__('Save')); ?>
|
149 |
+
</form>
|
150 |
+
<?php
|
151 |
+
return ob_get_clean();
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
// Initialize WP_User_Avatar_Shortcode
|
156 |
+
function wpua_shortcode_init() {
|
157 |
+
global $wpua_shortcode;
|
158 |
+
$wpua_shortcode = new WP_User_Avatar_Shortcode();
|
159 |
+
}
|
160 |
+
add_action('init', 'wpua_shortcode_init');
|
includes/class-wp-user-avatar-subscriber.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Settings only for subscribers and contributors.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Subscriber {
|
10 |
+
public function __construct() {
|
11 |
+
global $wp_user_avatar, $wpua_allow_upload;
|
12 |
+
if((bool) $wpua_allow_upload == 1) {
|
13 |
+
add_action('user_edit_form_tag', array($this, 'wpua_add_edit_form_multipart_encoding'));
|
14 |
+
// Only Subscribers lack delete_posts capability
|
15 |
+
if(!current_user_can('delete_posts') && !$wp_user_avatar->wpua_is_author_or_above()) {
|
16 |
+
add_action('admin_menu', array($this, 'wpua_subscriber_remove_menu_pages'));
|
17 |
+
add_action('wp_before_admin_bar_render', array($this, 'wpua_subscriber_remove_menu_bar_items'));
|
18 |
+
add_action('wp_dashboard_setup', array($this, 'wpua_subscriber_remove_dashboard_widgets'));
|
19 |
+
add_action('admin_init', array($this, 'wpua_subscriber_offlimits'));
|
20 |
+
}
|
21 |
+
}
|
22 |
+
add_action('admin_init', array($this, 'wpua_subscriber_capability'));
|
23 |
+
}
|
24 |
+
|
25 |
+
// Allow multipart data in form
|
26 |
+
public function wpua_add_edit_form_multipart_encoding() {
|
27 |
+
echo ' enctype="multipart/form-data"';
|
28 |
+
}
|
29 |
+
|
30 |
+
// Remove menu items
|
31 |
+
public function wpua_subscriber_remove_menu_pages() {
|
32 |
+
remove_menu_page('edit.php');
|
33 |
+
remove_menu_page('edit-comments.php');
|
34 |
+
remove_menu_page('tools.php');
|
35 |
+
}
|
36 |
+
|
37 |
+
// Remove menu bar items
|
38 |
+
public function wpua_subscriber_remove_menu_bar_items() {
|
39 |
+
global $wp_admin_bar;
|
40 |
+
$wp_admin_bar->remove_menu('comments');
|
41 |
+
$wp_admin_bar->remove_menu('new-content');
|
42 |
+
}
|
43 |
+
|
44 |
+
// Remove dashboard items
|
45 |
+
public function wpua_subscriber_remove_dashboard_widgets() {
|
46 |
+
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
|
47 |
+
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
|
48 |
+
remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
|
49 |
+
}
|
50 |
+
|
51 |
+
// Restrict access to pages
|
52 |
+
public function wpua_subscriber_offlimits() {
|
53 |
+
global $pagenow, $wpua_edit_avatar;
|
54 |
+
$offlimits = array('edit.php', 'edit-comments.php', 'post-new.php', 'tools.php');
|
55 |
+
if((bool) $wpua_edit_avatar != 1) {
|
56 |
+
array_push($offlimits, 'post.php');
|
57 |
+
}
|
58 |
+
$offlimits = apply_filters('wpua_subscriber_offlimits', $offlimits);
|
59 |
+
if(in_array($pagenow, $offlimits)) {
|
60 |
+
do_action('admin_page_access_denied');
|
61 |
+
wp_die(__('You do not have sufficient permissions to access this page.'));
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Give subscribers edit_posts capability
|
66 |
+
public function wpua_subscriber_capability() {
|
67 |
+
global $blog_id, $wpdb, $wpua_allow_upload, $wpua_edit_avatar;;
|
68 |
+
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
69 |
+
$user_roles = get_option($wp_user_roles);
|
70 |
+
if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1) {
|
71 |
+
$user_roles['subscriber']['capabilities']['edit_posts'] = true;
|
72 |
+
} else {
|
73 |
+
unset($user_roles['subscriber']['capabilities']['edit_posts']);
|
74 |
+
}
|
75 |
+
update_option($wp_user_roles, $user_roles);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
// Initialize WP_User_Avatar_Subscriber
|
80 |
+
function wpua_subcriber_init() {
|
81 |
+
global $wpua_subscriber;
|
82 |
+
$wpua_subscriber = new WP_User_Avatar_Subscriber();
|
83 |
+
}
|
84 |
+
add_action('init', 'wpua_subcriber_init');
|
includes/class-wp-user-avatar-update.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Updates for legacy settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Update {
|
10 |
+
public function __construct() {
|
11 |
+
global $wpua_default_avatar_updated, $wpua_media_updated, $wpua_users_updated;
|
12 |
+
if(empty($wpua_default_avatar_updated)) {
|
13 |
+
add_action('admin_init', array($this, 'wpua_default_avatar'));
|
14 |
+
}
|
15 |
+
if(empty($wpua_users_updated)) {
|
16 |
+
add_action('admin_init', array($this, 'wpua_user_meta'));
|
17 |
+
}
|
18 |
+
if(empty($wpua_media_updated)) {
|
19 |
+
add_action('admin_init', array($this, 'wpua_media_state'));
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
// Update default avatar to new format
|
24 |
+
public function wpua_default_avatar() {
|
25 |
+
global $avatar_default, $mustache_original, $wpua_avatar_default;
|
26 |
+
// If default avatar is the old mustache URL, update it
|
27 |
+
if($avatar_default == $mustache_original) {
|
28 |
+
update_option('avatar_default', 'wp_user_avatar');
|
29 |
+
}
|
30 |
+
// If user had an image URL as the default avatar, replace with ID instead
|
31 |
+
if(!empty($wpua_avatar_default)) {
|
32 |
+
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, 'medium');
|
33 |
+
if($avatar_default == $wpua_avatar_default_image[0]) {
|
34 |
+
update_option('avatar_default', 'wp_user_avatar');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
update_option('wp_user_avatar_default_avatar_updated', '1');
|
38 |
+
}
|
39 |
+
|
40 |
+
// Rename user meta to match database settings
|
41 |
+
public function wpua_user_meta() {
|
42 |
+
global $blog_id, $wpdb;
|
43 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
44 |
+
// If database tables start with something other than wp_
|
45 |
+
if($wpua_metakey != 'wp_user_avatar') {
|
46 |
+
$users = get_users();
|
47 |
+
// Move current user metakeys to new metakeys
|
48 |
+
foreach($users as $user) {
|
49 |
+
$wpua = get_user_meta($user->ID, 'wp_user_avatar', true);
|
50 |
+
if(!empty($wpua)) {
|
51 |
+
update_user_meta($user->ID, $wpua_metakey, $wpua);
|
52 |
+
delete_user_meta($user->ID, 'wp_user_avatar');
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
update_option('wp_user_avatar_users_updated', '1');
|
57 |
+
}
|
58 |
+
|
59 |
+
// Add media state to existing avatars
|
60 |
+
public function wpua_media_state() {
|
61 |
+
global $blog_id, $wpdb;
|
62 |
+
// Find all users with WPUA
|
63 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
64 |
+
$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, ""));
|
65 |
+
foreach($wpuas as $usermeta) {
|
66 |
+
add_post_meta($usermeta->meta_value, '_wp_attachment_wp_user_avatar', $usermeta->user_id);
|
67 |
+
}
|
68 |
+
update_option('wp_user_avatar_media_updated', '1');
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
// Initialize WP_User_Avatar_Update
|
73 |
+
function wpua_update_init() {
|
74 |
+
global $wpua_update;
|
75 |
+
$wpua_update = new WP_User_Avatar_Update();
|
76 |
+
}
|
77 |
+
add_action('init', 'wpua_update_init');
|
includes/class-wp-user-avatar.php
ADDED
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines all profile and upload settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar {
|
10 |
+
public function __construct() {
|
11 |
+
global $pagenow, $show_avatars, $wpua_admin, $wpua_allow_upload;
|
12 |
+
// Add WPUA to profile
|
13 |
+
if($this->wpua_is_author_or_above() || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())) {
|
14 |
+
// Profile functions and scripts
|
15 |
+
add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
16 |
+
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
17 |
+
add_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
18 |
+
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
19 |
+
add_action('user_new_form', array($this, 'wpua_action_show_user_profile'));
|
20 |
+
add_action('user_register', array($this, 'wpua_action_process_option_update'));
|
21 |
+
// Admin scripts
|
22 |
+
$pages = array('profile.php', 'options-discussion.php', 'user-edit.php', 'user-new.php');
|
23 |
+
if(in_array($pagenow, $pages) || $wpua_admin->wpua_is_menu_page()) {
|
24 |
+
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
25 |
+
}
|
26 |
+
// Front pages
|
27 |
+
if(!is_admin()) {
|
28 |
+
add_action('show_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
29 |
+
add_action('edit_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
30 |
+
}
|
31 |
+
if(!$this->wpua_is_author_or_above()) {
|
32 |
+
// Upload errors
|
33 |
+
add_action('user_profile_update_errors', array($this, 'wpua_upload_errors'), 10, 3);
|
34 |
+
// Prefilter upload size
|
35 |
+
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'));
|
36 |
+
}
|
37 |
+
}
|
38 |
+
add_filter('media_view_settings', array($this, 'wpua_media_view_settings'), 10, 1);
|
39 |
+
}
|
40 |
+
|
41 |
+
// Avatars have no parent posts
|
42 |
+
public function wpua_media_view_settings($settings) {
|
43 |
+
global $post, $wpua_is_profile;
|
44 |
+
// Get post ID so not to interfere with media uploads
|
45 |
+
$post_id = is_object($post) ? $post->ID : 0;
|
46 |
+
// Don't use post ID on front pages if there's a WPUA uploader
|
47 |
+
$settings['post']['id'] = (!is_admin() && $wpua_is_profile == 1) ? 0 : $post_id;
|
48 |
+
return $settings;
|
49 |
+
}
|
50 |
+
|
51 |
+
// Media Uploader
|
52 |
+
public static function wpua_media_upload_scripts($user="") {
|
53 |
+
global $current_user, $mustache_admin, $pagenow, $post, $show_avatars, $wp_user_avatar, $wpua_admin, $wpua_functions, $wpua_is_profile, $wpua_upload_size_limit;
|
54 |
+
// This is a profile page
|
55 |
+
$wpua_is_profile = true;
|
56 |
+
$user = ($pagenow == 'user-edit.php' && isset($_GET['user_id'])) ? get_user_by('id', $_GET['user_id']) : $current_user;
|
57 |
+
wp_enqueue_script('jquery');
|
58 |
+
if($wp_user_avatar->wpua_is_author_or_above()) {
|
59 |
+
wp_enqueue_script('admin-bar');
|
60 |
+
wp_enqueue_media(array('post' => $post));
|
61 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URL.'js/wp-user-avatar.js', array('jquery', 'media-editor'), WPUA_VERSION, true);
|
62 |
+
} else {
|
63 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URL.'js/wp-user-avatar-user.js', array('jquery'), WPUA_VERSION, true);
|
64 |
+
}
|
65 |
+
wp_enqueue_style('wp-user-avatar', WPUA_URL.'css/wp-user-avatar.css', array('media-views'), WPUA_VERSION);
|
66 |
+
// Admin scripts
|
67 |
+
if($pagenow == 'options-discussion.php' || $wpua_admin->wpua_is_menu_page()) {
|
68 |
+
// Size limit slider
|
69 |
+
wp_enqueue_script('jquery-ui-slider');
|
70 |
+
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URL.'css/jquery.ui.slider.css', "", null);
|
71 |
+
// Remove/edit settings
|
72 |
+
wp_localize_script('wp-user-avatar', 'wpua_custom', array('avatar_thumb' => $mustache_admin));
|
73 |
+
// Settings control
|
74 |
+
wp_enqueue_script('wp-user-avatar-admin', WPUA_URL.'js/wp-user-avatar-admin.js', array('wp-user-avatar'), WPUA_VERSION, true);
|
75 |
+
wp_localize_script('wp-user-avatar-admin', 'wpua_admin', array('upload_size_limit' => $wpua_upload_size_limit, 'max_upload_size' => wp_max_upload_size()));
|
76 |
+
} else {
|
77 |
+
// User remove/edit settings
|
78 |
+
$avatar_medium_src = (bool) $show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original($user->user_email, 'medium') : includes_url().'images/blank.gif';
|
79 |
+
wp_localize_script('wp-user-avatar', 'wpua_custom', array('avatar_thumb' => $avatar_medium_src));
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
// Add to edit user profile
|
84 |
+
public static function wpua_action_show_user_profile($user) {
|
85 |
+
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;
|
86 |
+
// Get WPUA attachment ID
|
87 |
+
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
88 |
+
// Show remove button if WPUA is set
|
89 |
+
$hide_remove = !has_wp_user_avatar($user->ID) ? 'wpua-hide' : "";
|
90 |
+
// Hide image tags if show avatars is off
|
91 |
+
$hide_images = !has_wp_user_avatar($user->ID) && (bool) $show_avatars == 0 ? 'wpua-no-avatars' : "";
|
92 |
+
// If avatars are enabled, get original avatar image or show blank
|
93 |
+
$avatar_medium_src = (bool) $show_avatars == 1 ? $wpua_functions->wpua_get_avatar_original($user->user_email, 'medium') : includes_url().'images/blank.gif';
|
94 |
+
// Check if user has wp_user_avatar, if not show image from above
|
95 |
+
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
|
96 |
+
// Check if user has wp_user_avatar, if not show image from above
|
97 |
+
$avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
|
98 |
+
$edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php'));
|
99 |
+
?>
|
100 |
+
<?php do_action('wpua_before_avatar'); ?>
|
101 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
102 |
+
<?php if($wp_user_avatar->wpua_is_author_or_above()) : // Button to launch Media Uploader ?>
|
103 |
+
<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>
|
104 |
+
<?php elseif(!$wp_user_avatar->wpua_is_author_or_above()) : // Upload button ?>
|
105 |
+
<p id="wpua-upload-button">
|
106 |
+
<input name="wpua-file" id="wpua-file" type="file" />
|
107 |
+
<button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
|
108 |
+
</p>
|
109 |
+
<p id="wpua-upload-messages">
|
110 |
+
<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>
|
111 |
+
<span id="wpua-allowed-files" class="description"><?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?></span>
|
112 |
+
</p>
|
113 |
+
<?php endif; ?>
|
114 |
+
<div id="wpua-images" class="<?php echo $hide_images; ?>">
|
115 |
+
<p id="wpua-preview">
|
116 |
+
<img src="<?php echo $avatar_medium; ?>" alt="" />
|
117 |
+
<span class="description"><?php _e('Original Size'); ?></span>
|
118 |
+
</p>
|
119 |
+
<p id="wpua-thumbnail">
|
120 |
+
<img src="<?php echo $avatar_thumbnail; ?>" alt="" />
|
121 |
+
<span class="description"><?php _e('Thumbnail'); ?></span>
|
122 |
+
</p>
|
123 |
+
<p id="wpua-remove-button" class="<?php echo $hide_remove; ?>">
|
124 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove"><?php _e('Remove Image'); ?></button>
|
125 |
+
<?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 ?>
|
126 |
+
<span id="wpua-edit-attachment"><a href="<?php echo $edit_attachment_link; ?>" class="edit-attachment" target="_blank"><?php _e('Edit Image'); ?></a></span>
|
127 |
+
<?php endif; ?>
|
128 |
+
</p>
|
129 |
+
<p id="wpua-undo-button"><button type="button" class="button" id="wpua-undo" name="wpua-undo"><?php _e('Undo'); ?></button></p>
|
130 |
+
</div>
|
131 |
+
<?php do_action('wpua_after_avatar'); ?>
|
132 |
+
<?php
|
133 |
+
}
|
134 |
+
|
135 |
+
// Add upload error messages
|
136 |
+
public static function wpua_upload_errors($errors, $update, $user) {
|
137 |
+
global $wpua_upload_size_limit;
|
138 |
+
if($update && !empty($_FILES['wpua-file'])) {
|
139 |
+
$size = $_FILES['wpua-file']['size'];
|
140 |
+
$type = $_FILES['wpua-file']['type'];
|
141 |
+
$upload_dir = wp_upload_dir();
|
142 |
+
// Allow only JPG, GIF, PNG
|
143 |
+
if(!empty($type) && !preg_match('/(jpe?g|gif|png)$/i', $type)) {
|
144 |
+
$errors->add('wpua_file_type', __('This file is not an image. Please try another.'));
|
145 |
+
}
|
146 |
+
// Upload size limit
|
147 |
+
if(!empty($size) && $size > $wpua_upload_size_limit) {
|
148 |
+
$errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.'));
|
149 |
+
}
|
150 |
+
// Check if directory is writeable
|
151 |
+
if(!is_writeable($upload_dir['path'])) {
|
152 |
+
$errors->add('wpua_file_directory', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $upload_dir['path']));
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
// Set upload size limit
|
158 |
+
public function wpua_handle_upload_prefilter($file) {
|
159 |
+
global $wpua_upload_size_limit;
|
160 |
+
$size = $file['size'];
|
161 |
+
if(!empty($size) && $size > $wpua_upload_size_limit) {
|
162 |
+
function wpua_file_size_error($errors, $update, $user) {
|
163 |
+
$errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.'));
|
164 |
+
}
|
165 |
+
add_action('user_profile_update_errors', 'wpua_file_size_error', 10, 3);
|
166 |
+
return;
|
167 |
+
}
|
168 |
+
return $file;
|
169 |
+
}
|
170 |
+
|
171 |
+
// Update user meta
|
172 |
+
public static function wpua_action_process_option_update($user_id) {
|
173 |
+
global $blog_id, $post, $wpdb, $wp_user_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w;
|
174 |
+
// Check if user has publish_posts capability
|
175 |
+
if($wp_user_avatar->wpua_is_author_or_above()) {
|
176 |
+
$wpua_id = isset($_POST['wp-user-avatar']) ? intval($_POST['wp-user-avatar']) : "";
|
177 |
+
// Remove old attachment postmeta
|
178 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
179 |
+
// Create new attachment postmeta
|
180 |
+
add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
181 |
+
// Update usermeta
|
182 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
183 |
+
} else {
|
184 |
+
// Remove attachment info if avatar is blank
|
185 |
+
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])) {
|
186 |
+
// Delete other uploads by user
|
187 |
+
$q = array(
|
188 |
+
'author' => $user_id,
|
189 |
+
'post_type' => 'attachment',
|
190 |
+
'post_status' => 'inherit',
|
191 |
+
'posts_per_page' => '-1',
|
192 |
+
'meta_query' => array(
|
193 |
+
array(
|
194 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
195 |
+
'value' => '',
|
196 |
+
'compare' => '!='
|
197 |
+
)
|
198 |
+
)
|
199 |
+
);
|
200 |
+
$avatars_wp_query = new WP_Query($q);
|
201 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
202 |
+
wp_delete_attachment($post->ID);
|
203 |
+
endwhile;
|
204 |
+
wp_reset_query();
|
205 |
+
// Remove attachment postmeta
|
206 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
207 |
+
// Remove usermeta
|
208 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
209 |
+
}
|
210 |
+
// Create attachment from upload
|
211 |
+
if(isset($_POST['submit']) && $_POST['submit'] && !empty($_FILES['wpua-file'])) {
|
212 |
+
$name = $_FILES['wpua-file']['name'];
|
213 |
+
$file = wp_handle_upload($_FILES['wpua-file'], array('test_form' => false));
|
214 |
+
$type = $_FILES['wpua-file']['type'];
|
215 |
+
$upload_dir = wp_upload_dir();
|
216 |
+
if(is_writeable($upload_dir['path'])) {
|
217 |
+
if(!empty($type) && preg_match('/(jpe?g|gif|png)$/i', $type)) {
|
218 |
+
// Resize uploaded image
|
219 |
+
if((bool) $wpua_resize_upload == 1) {
|
220 |
+
// Original image
|
221 |
+
$uploaded_image = wp_get_image_editor($file['file']);
|
222 |
+
// Check for errors
|
223 |
+
if(!is_wp_error($uploaded_image)) {
|
224 |
+
// Resize image
|
225 |
+
$uploaded_image->resize($wpua_resize_w, $wpua_resize_h, $wpua_resize_crop);
|
226 |
+
// Save image
|
227 |
+
$resized_image = $uploaded_image->save($file['file']);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
// Break out file info
|
231 |
+
$name_parts = pathinfo($name);
|
232 |
+
$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
|
233 |
+
$url = $file['url'];
|
234 |
+
$file = $file['file'];
|
235 |
+
$title = $name;
|
236 |
+
// Use image exif/iptc data for title if possible
|
237 |
+
if($image_meta = @wp_read_image_metadata($file)) {
|
238 |
+
if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))) {
|
239 |
+
$title = $image_meta['title'];
|
240 |
+
}
|
241 |
+
}
|
242 |
+
// Construct the attachment array
|
243 |
+
$attachment = array(
|
244 |
+
'guid' => $url,
|
245 |
+
'post_mime_type' => $type,
|
246 |
+
'post_title' => $title,
|
247 |
+
'post_content' => ""
|
248 |
+
);
|
249 |
+
// This should never be set as it would then overwrite an existing attachment
|
250 |
+
if(isset($attachment['ID'])) {
|
251 |
+
unset($attachment['ID']);
|
252 |
+
}
|
253 |
+
// Save the attachment metadata
|
254 |
+
$attachment_id = wp_insert_attachment($attachment, $file);
|
255 |
+
if(!is_wp_error($attachment_id)) {
|
256 |
+
// Delete other uploads by user
|
257 |
+
$q = array(
|
258 |
+
'author' => $user_id,
|
259 |
+
'post_type' => 'attachment',
|
260 |
+
'post_status' => 'inherit',
|
261 |
+
'posts_per_page' => '-1',
|
262 |
+
'meta_query' => array(
|
263 |
+
array(
|
264 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
265 |
+
'value' => '',
|
266 |
+
'compare' => '!='
|
267 |
+
)
|
268 |
+
)
|
269 |
+
);
|
270 |
+
$avatars_wp_query = new WP_Query($q);
|
271 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
272 |
+
wp_delete_attachment($post->ID);
|
273 |
+
endwhile;
|
274 |
+
wp_reset_query();
|
275 |
+
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
276 |
+
// Remove old attachment postmeta
|
277 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
278 |
+
// Create new attachment postmeta
|
279 |
+
update_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
|
280 |
+
// Update usermeta
|
281 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
// Check who owns image
|
290 |
+
private function wpua_author($attachment_id, $user_id, $wpua_author=false) {
|
291 |
+
$attachment = get_post($attachment_id);
|
292 |
+
if(!empty($attachment) && $attachment->post_author == $user_id) {
|
293 |
+
$wpua_author = true;
|
294 |
+
}
|
295 |
+
return $wpua_author;
|
296 |
+
}
|
297 |
+
|
298 |
+
// Check if current user has at least Author privileges
|
299 |
+
public function wpua_is_author_or_above() {
|
300 |
+
$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;
|
301 |
+
return apply_filters('wpua_is_author_or_above', $is_author_or_above);
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
// Initialize WP_User_Avatar
|
306 |
+
function wpua_init() {
|
307 |
+
global $wp_user_avatar;
|
308 |
+
$wp_user_avatar = new WP_User_Avatar();
|
309 |
+
}
|
310 |
+
add_action('init', 'wpua_init');
|
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.3"}}});tinymce.PluginManager.add('wpUserAvatar',tinymce.plugins.wpUserAvatar)})();
|
includes/tinymce/window.php
CHANGED
@@ -1,26 +1,31 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
-
if(!defined('ABSPATH')){
|
8 |
-
die(
|
9 |
-
@header('Content-Type:'.get_option('html_type').';charset='.get_option('blog_charset'));
|
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 |
var user = document.getElementById('wp_user_avatar_user').value;
|
25 |
var size = document.getElementById('wp_user_avatar_size').value;
|
26 |
var size_number = document.getElementById('wp_user_avatar_size_number').value;
|
@@ -28,102 +33,148 @@ if(!defined('ABSPATH')){
|
|
28 |
var link = document.getElementById('wp_user_avatar_link').value;
|
29 |
var link_external = document.getElementById('wp_user_avatar_link_external').value;
|
30 |
var target = document.getElementById('wp_user_avatar_target').value;
|
|
|
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 |
window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
|
45 |
tinyMCEPopup.editor.execCommand('mceRepaint');
|
46 |
tinyMCEPopup.close();
|
47 |
}
|
48 |
return;
|
49 |
}
|
50 |
-
jQuery(function(){
|
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 |
-
</select>
|
89 |
-
</p>
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
<option value="left"><?php _e('Left'); ?></option>
|
101 |
-
<option value="right"><?php _e('Right'); ?></option>
|
102 |
-
</select></p>
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
<option value="file"><?php _e('Image File'); ?></option>
|
109 |
-
<option value="attachment"><?php _e('Attachment Page'); ?></option>
|
110 |
-
<option value="custom-url"><?php _e('Custom URL'); ?></option>
|
111 |
-
</select>
|
112 |
-
</p>
|
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.3
|
7 |
*/
|
8 |
|
9 |
+
if(!defined('ABSPATH')) {
|
10 |
+
die('You are not allowed to call this page directly.');
|
|
|
11 |
}
|
12 |
?>
|
13 |
+
<!DOCTYPE html>
|
14 |
+
<html>
|
15 |
<head>
|
16 |
<title><?php _e('WP User Avatar', 'wp-user-avatar'); ?></title>
|
17 |
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
18 |
<base target="_self" />
|
19 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/jquery.js"></script>
|
20 |
+
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.core.min.js"></script>
|
21 |
+
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.widget.min.js"></script>
|
22 |
+
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js"></script>
|
23 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
|
24 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
|
25 |
<script type="text/javascript">
|
26 |
+
function wpuaInsertAvatar() {
|
27 |
// Custom shortcode values
|
28 |
+
var shortcode, closing_tag;
|
29 |
var user = document.getElementById('wp_user_avatar_user').value;
|
30 |
var size = document.getElementById('wp_user_avatar_size').value;
|
31 |
var size_number = document.getElementById('wp_user_avatar_size_number').value;
|
33 |
var link = document.getElementById('wp_user_avatar_link').value;
|
34 |
var link_external = document.getElementById('wp_user_avatar_link_external').value;
|
35 |
var target = document.getElementById('wp_user_avatar_target').value;
|
36 |
+
var caption = document.getElementById('wp_user_avatar_caption').value;
|
37 |
|
38 |
// Add tag to shortcode only if not blank
|
39 |
var user_tag = (user != "") ? ' user="' + user + '"' : "";
|
40 |
var size_tag = (size != "" && size_number == "") ? ' size="' + size + '"' : "";
|
41 |
+
size_tag = (size_number != "") ? ' size="' + size_number + '"' : size_tag;
|
42 |
var align_tag = (align != "") ? ' align="' + align + '"' : "";
|
43 |
var link_tag = (link != "" && link != 'custom-url' && link_external == "") ? ' link="' + link + '"' : "";
|
44 |
+
link_tag = (link_external != "") ? ' link="' + link_external + '"' : link_tag;
|
45 |
var target_tag = document.getElementById('wp_user_avatar_target').checked && (link_tag != "") ? ' target="' + target + '"' : "";
|
|
|
|
|
46 |
|
47 |
+
// Assemble the shortcode
|
48 |
+
closing_tag = (caption != "") ? "]" + caption + "[/avatar]" : " /]";
|
49 |
+
shortcode = "<p>[avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + closing_tag + "</p>";
|
50 |
+
|
51 |
+
if(window.tinyMCE) {
|
52 |
+
window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
|
53 |
+
tinyMCEPopup.editor.execCommand('mceRepaint');
|
54 |
+
tinyMCEPopup.close();
|
55 |
+
}
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
function wpuaInsertAvatarUpload() {
|
59 |
+
// Upload shortcode
|
60 |
+
var shortcode = "<p>[avatar_upload]</p>";
|
61 |
+
|
62 |
+
if(window.tinyMCE) {
|
63 |
window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
|
64 |
tinyMCEPopup.editor.execCommand('mceRepaint');
|
65 |
tinyMCEPopup.close();
|
66 |
}
|
67 |
return;
|
68 |
}
|
69 |
+
jQuery(function($) {
|
70 |
+
$('#wp_user_avatar_link').change(function() {
|
71 |
+
$('#wp_user_avatar_link_external_section').toggle($('#wp_user_avatar_link').val() == 'custom-url');
|
72 |
});
|
73 |
+
$('#wp_user_avatar_size').change(function() {
|
74 |
+
$('#wp_user_avatar_size_number_section').toggle($('#wp_user_avatar_size').val() == 'custom');
|
75 |
});
|
76 |
+
$('#wpua-tabs').tabs();
|
77 |
});
|
78 |
</script>
|
79 |
<style type="text/css">
|
80 |
+
ul { margin: 0; padding: 0; list-style: none; }
|
81 |
+
ul li { float: left; }
|
82 |
+
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; }
|
83 |
+
ul li.ui-tabs-active a { background: #fff; }
|
84 |
+
form { clear: both; background: #fff; border: 1px solid #eee; }
|
85 |
p, h4 { margin: 0; padding: 12px 0 0; }
|
86 |
h4.center { text-align: center; }
|
87 |
+
label { width: 150px; margin-right: 3px; display: inline-block; text-align: right; vertical-align: top; }
|
88 |
.mceActionPanel { padding: 7px 0 12px; text-align: center; }
|
89 |
.mceActionPanel #insert { float: none; width: 180px; margin: 0 auto; }
|
90 |
#wp_user_avatar_size_number_section, #wp_user_avatar_link_external_section { display: none; }
|
91 |
</style>
|
92 |
</head>
|
93 |
+
<body id="link" class="wp-core-ui" onload="document.body.style.display='';" style="display:none;">
|
94 |
+
<div id="wpua-tabs">
|
95 |
+
<ul>
|
96 |
+
<li><a href="#wpua"><?php _e('Avatar'); ?></a></li>
|
97 |
+
<li><a href="#wpua-upload"><?php _e('Upload'); ?></a></li>
|
98 |
+
</ul>
|
99 |
+
<form name="wpUserAvatar" action="#">
|
100 |
+
<div id="wpua">
|
101 |
+
<p>
|
102 |
+
<label for="<?php esc_attr_e('wp_user_avatar_user'); ?>"><strong><?php _e('User Name'); ?>:</strong></label>
|
103 |
+
<select id="<?php esc_attr_e('wp_user_avatar_user'); ?>" name="<?php esc_attr_e('wp_user_avatar_user'); ?>">
|
104 |
+
<option value=""></option>
|
105 |
+
<?php $users = get_users(); foreach($users as $user) : ?>
|
106 |
+
<option value="<?php echo $user->user_login; ?>"><?php echo $user->display_name; ?></option>
|
107 |
+
<?php endforeach; ?>
|
108 |
+
</select>
|
109 |
+
</p>
|
110 |
+
|
111 |
+
<p>
|
112 |
+
<label for="<?php esc_attr_e('wp_user_avatar_size'); ?>"><strong><?php _e('Size'); ?>:</strong></label>
|
113 |
+
<select id="<?php esc_attr_e('wp_user_avatar_size'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>">
|
114 |
+
<option value=""></option>
|
115 |
+
<option value="original"><?php _e('Original Size'); ?></option>
|
116 |
+
<option value="large"><?php _e('Large'); ?></option>
|
117 |
+
<option value="medium"><?php _e('Medium'); ?></option>
|
118 |
+
<option value="thumbnail"><?php _e('Thumbnail'); ?></option>
|
119 |
+
<option value="custom"><?php _e('Custom'); ?></option>
|
120 |
+
</select>
|
121 |
+
</p>
|
122 |
+
|
123 |
+
<p id="<?php esc_attr_e('wp_user_avatar_size_number_section'); ?>">
|
124 |
+
<label for="<?php esc_attr_e('wp_user_avatar_size_number'); ?>"><?php _e('Size'); ?>:</label>
|
125 |
+
<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="" />
|
126 |
+
</p>
|
127 |
|
128 |
+
<p>
|
129 |
+
<label for="<?php esc_attr_e('wp_user_avatar_align'); ?>"><strong><?php _e('Alignment'); ?>:</strong></label>
|
130 |
+
<select id="<?php esc_attr_e('wp_user_avatar_align'); ?>" name="<?php esc_attr_e('wp_user_avatar_align'); ?>">
|
131 |
+
<option value=""></option>
|
132 |
+
<option value="center"><?php _e('Center'); ?></option>
|
133 |
+
<option value="left"><?php _e('Left'); ?></option>
|
134 |
+
<option value="right"><?php _e('Right'); ?></option>
|
135 |
+
</select>
|
136 |
+
</p>
|
|
|
|
|
137 |
|
138 |
+
<p>
|
139 |
+
<label for="<?php esc_attr_e('wp_user_avatar_link'); ?>"><strong><?php _e('Link To'); ?>:</strong></label>
|
140 |
+
<select id="<?php esc_attr_e('wp_user_avatar_link'); ?>" name="<?php esc_attr_e('wp_user_avatar_link'); ?>">
|
141 |
+
<option value=""></option>
|
142 |
+
<option value="file"><?php _e('Image File'); ?></option>
|
143 |
+
<option value="attachment"><?php _e('Attachment Page'); ?></option>
|
144 |
+
<option value="custom-url"><?php _e('Custom URL'); ?></option>
|
145 |
+
</select>
|
146 |
+
</p>
|
147 |
|
148 |
+
<p id="<?php esc_attr_e('wp_user_avatar_link_external_section'); ?>">
|
149 |
+
<label for="<?php esc_attr_e('wp_user_avatar_link_external'); ?>"><?php _e('URL'); ?>:</label>
|
150 |
+
<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="" />
|
151 |
+
</p>
|
|
|
|
|
|
|
152 |
|
153 |
+
<p>
|
154 |
+
<label for="<?php esc_attr_e('wp_user_avatar_target'); ?>"></label>
|
155 |
+
<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>
|
156 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
+
<p>
|
159 |
+
<label for="<?php esc_attr_e('wp_user_avatar_caption'); ?>"><strong><?php _e('Caption'); ?>:</strong></label>
|
160 |
+
<textarea cols="36" rows="2" id="<?php esc_attr_e('wp_user_avatar_caption'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>"></textarea>
|
161 |
+
</p>
|
162 |
|
163 |
+
<div class="mceActionPanel">
|
164 |
+
<input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatar();" />
|
165 |
+
</div>
|
166 |
+
</div>
|
167 |
+
<div id="wpua-upload">
|
168 |
+
<p id="<?php esc_attr_e('wp_user_avatar_upload'); ?>">
|
169 |
+
<label for="<?php esc_attr_e('wp_user_avatar_upload'); ?>"><strong><?php _e('Upload'); ?>:</strong></label>
|
170 |
+
<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" />
|
171 |
+
</p>
|
172 |
|
173 |
+
<div class="mceActionPanel">
|
174 |
+
<input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatarUpload();" />
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
</form>
|
178 |
+
</div>
|
179 |
</body>
|
180 |
</html>
|
includes/wpua-functions.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Public user functions.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
function has_wp_user_avatar($id_or_email="", $has_wpua="", $user="", $user_id="") {
|
10 |
+
global $wpua_functions;
|
11 |
+
return $wpua_functions->has_wp_user_avatar($id_or_email, $has_wpua, $user, $user_id);
|
12 |
+
}
|
13 |
+
|
14 |
+
function get_wp_user_avatar($id_or_email="", $size="", $align="", $alt="") {
|
15 |
+
global $wpua_functions;
|
16 |
+
return $wpua_functions->get_wp_user_avatar($id_or_email, $size, $align, $alt);
|
17 |
+
}
|
18 |
+
|
19 |
+
function get_wp_user_avatar_src($id_or_email="", $size="", $align="") {
|
20 |
+
global $wpua_functions;
|
21 |
+
return $wpua_functions->get_wp_user_avatar_src($id_or_email, $size, $align);
|
22 |
+
}
|
23 |
+
|
24 |
+
// Before wrapper for profile
|
25 |
+
function wpua_before_avatar() {
|
26 |
+
do_action('wpua_before_avatar');
|
27 |
+
}
|
28 |
+
|
29 |
+
// After wrapper for profile
|
30 |
+
function wpua_after_avatar() {
|
31 |
+
do_action('wpua_after_avatar');
|
32 |
+
}
|
33 |
+
|
34 |
+
// Before avatar container
|
35 |
+
function wpua_do_before_avatar() {
|
36 |
+
global $wpua_functions;
|
37 |
+
?>
|
38 |
+
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
39 |
+
<h2 class="entry-title"><?php _e('Avatar'); ?></h2>
|
40 |
+
<fieldset class="bbp-form">
|
41 |
+
<legend><?php _e('Image'); ?></legend>
|
42 |
+
<?php elseif(class_exists('WPUF_Main') && wpuf_has_shortcode('wpuf_editprofile')) : // Add to WP User Frontend profile with same style ?>
|
43 |
+
<fieldset>
|
44 |
+
<legend><?php _e('Avatar') ?></legend>
|
45 |
+
<table class="wpuf-table">
|
46 |
+
<tr>
|
47 |
+
<th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
|
48 |
+
<td>
|
49 |
+
<?php elseif($wpua_functions->wpua_has_shortcode()) : // Add to profile without table ?>
|
50 |
+
<div class="wpua-edit-container">
|
51 |
+
<h3><?php _e('Avatar') ?></h3>
|
52 |
+
<?php else : // Add to profile with admin style ?>
|
53 |
+
<h3><?php _e('Avatar') ?></h3>
|
54 |
+
<table class="form-table">
|
55 |
+
<tr>
|
56 |
+
<th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
|
57 |
+
<td>
|
58 |
+
<?php endif; ?>
|
59 |
+
<?php
|
60 |
+
}
|
61 |
+
add_action('wpua_before_avatar', 'wpua_do_before_avatar');
|
62 |
+
|
63 |
+
// After avatar container
|
64 |
+
function wpua_do_after_avatar() {
|
65 |
+
global $wpua_functions;
|
66 |
+
?>
|
67 |
+
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
68 |
+
</fieldset>
|
69 |
+
<?php elseif(class_exists('WPUF_Main') && wpuf_has_shortcode('wpuf_editprofile')) : // Add to WP User Frontend profile with same style ?>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
</table>
|
73 |
+
</fieldset>
|
74 |
+
<?php elseif($wpua_functions->wpua_has_shortcode()) : // Add to profile without table ?>
|
75 |
+
</div>
|
76 |
+
<?php else : // Add to profile with admin style ?>
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
+
</table>
|
80 |
+
<?php endif; ?>
|
81 |
+
<?php
|
82 |
+
}
|
83 |
+
add_action('wpua_after_avatar', 'wpua_do_after_avatar');
|
84 |
+
|
85 |
+
// Filter for the inevitable complaints about the donation message :(
|
86 |
+
function wpua_donation_message() {
|
87 |
+
do_action('wpua_donation_message');
|
88 |
+
}
|
89 |
+
// Donation message
|
90 |
+
function wpua_do_donation_message() { ?>
|
91 |
+
<div class="updated">
|
92 |
+
<p><?php _e('Do you like WP User Avatar?', 'wp-user-avatar'); ?> <a href="http://siboliban.org/donate" target="_blank"><?php _e('Make a donation.', 'wp-user-avatar'); ?></a></p>
|
93 |
+
</div>
|
94 |
+
<?php
|
95 |
+
}
|
96 |
+
add_action('wpua_donation_message', 'wpua_do_donation_message');
|
includes/wpua-globals.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Global variables used in plugin.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Define global variables
|
10 |
+
global $avatar_default,
|
11 |
+
$show_avatars,
|
12 |
+
$wpua_allow_upload,
|
13 |
+
$wpua_avatar_default,
|
14 |
+
$wpua_disable_gravatar,
|
15 |
+
$wpua_edit_avatar,
|
16 |
+
$wpua_resize_crop,
|
17 |
+
$wpua_resize_h,
|
18 |
+
$wpua_resize_upload,
|
19 |
+
$wpua_resize_w,
|
20 |
+
$wpua_tinymce,
|
21 |
+
$mustache_original,
|
22 |
+
$mustache_medium,
|
23 |
+
$mustache_thumbnail,
|
24 |
+
$mustache_avatar,
|
25 |
+
$mustache_admin,
|
26 |
+
$wpua_default_avatar_updated,
|
27 |
+
$wpua_users_updated,
|
28 |
+
$wpua_media_updated,
|
29 |
+
$upload_size_limit,
|
30 |
+
$upload_size_limit_with_units,
|
31 |
+
$wpua_user_upload_size_limit,
|
32 |
+
$wpua_upload_size_limit,
|
33 |
+
$wpua_upload_size_limit_with_units,
|
34 |
+
$all_sizes;
|
35 |
+
|
36 |
+
$avatar_default = get_option('avatar_default');
|
37 |
+
$show_avatars = get_option('show_avatars');
|
38 |
+
$wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
|
39 |
+
$wpua_avatar_default = get_option('avatar_default_wp_user_avatar');
|
40 |
+
$wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
|
41 |
+
$wpua_edit_avatar = get_option('wp_user_avatar_edit_avatar');
|
42 |
+
$wpua_resize_crop = get_option('wp_user_avatar_resize_crop');
|
43 |
+
$wpua_resize_h = get_option('wp_user_avatar_resize_h');
|
44 |
+
$wpua_resize_upload = get_option('wp_user_avatar_resize_upload');
|
45 |
+
$wpua_resize_w = get_option('wp_user_avatar_resize_w');
|
46 |
+
$wpua_tinymce = get_option('wp_user_avatar_tinymce');
|
47 |
+
$mustache_original = WPUA_URL.'images/wpua.png';
|
48 |
+
$mustache_medium = WPUA_URL.'images/wpua-300x300.png';
|
49 |
+
$mustache_thumbnail = WPUA_URL.'images/wpua-150x150.png';
|
50 |
+
$mustache_avatar = WPUA_URL.'images/wpua-96x96.png';
|
51 |
+
$mustache_admin = WPUA_URL.'images/wpua-32x32.png';
|
52 |
+
|
53 |
+
// Check for updates
|
54 |
+
$wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
|
55 |
+
$wpua_users_updated = get_option('wp_user_avatar_users_updated');
|
56 |
+
$wpua_media_updated = get_option('wp_user_avatar_media_updated');
|
57 |
+
|
58 |
+
// Server upload size limit
|
59 |
+
$upload_size_limit = wp_max_upload_size();
|
60 |
+
// Convert to KB
|
61 |
+
if($upload_size_limit > 1024) {
|
62 |
+
$upload_size_limit /= 1024;
|
63 |
+
}
|
64 |
+
$upload_size_limit_with_units = (int) $upload_size_limit.'KB';
|
65 |
+
|
66 |
+
// User upload size limit
|
67 |
+
$wpua_user_upload_size_limit = get_option('wp_user_avatar_upload_size_limit');
|
68 |
+
if($wpua_user_upload_size_limit == 0 || $wpua_user_upload_size_limit > wp_max_upload_size()) {
|
69 |
+
$wpua_user_upload_size_limit = wp_max_upload_size();
|
70 |
+
}
|
71 |
+
// Value in bytes
|
72 |
+
$wpua_upload_size_limit = $wpua_user_upload_size_limit;
|
73 |
+
// Convert to KB
|
74 |
+
if($wpua_user_upload_size_limit > 1024) {
|
75 |
+
$wpua_user_upload_size_limit /= 1024;
|
76 |
+
}
|
77 |
+
$wpua_upload_size_limit_with_units = (int) $wpua_user_upload_size_limit.'KB';
|
78 |
+
|
79 |
+
// Check for custom image sizes
|
80 |
+
$all_sizes = array_merge(get_intermediate_image_sizes(), array('original'));
|
includes/wpua-media-page.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Media Library view of all avatars in use.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
/** WordPress Administration Bootstrap */
|
9 |
+
require_once(ABSPATH.'wp-admin/admin.php');
|
10 |
+
|
11 |
+
if(!current_user_can('upload_files'))
|
12 |
+
wp_die(__('You do not have permission to upload files.'));
|
13 |
+
|
14 |
+
global $wpua_admin;
|
15 |
+
|
16 |
+
$wp_list_table = $wpua_admin->_wpua_get_list_table('WP_User_Avatar_List_Table');
|
17 |
+
$pagenum = $wp_list_table->get_pagenum();
|
18 |
+
|
19 |
+
// Handle bulk actions
|
20 |
+
$doaction = $wp_list_table->current_action();
|
21 |
+
|
22 |
+
if($doaction) {
|
23 |
+
check_admin_referer('bulk-media');
|
24 |
+
|
25 |
+
if(isset($_REQUEST['media'])) {
|
26 |
+
$post_ids = $_REQUEST['media'];
|
27 |
+
} elseif(isset($_REQUEST['ids'])) {
|
28 |
+
$post_ids = explode(',', $_REQUEST['ids']);
|
29 |
+
}
|
30 |
+
|
31 |
+
$location = esc_url(add_query_arg(array('page' => 'wp-user-avatar-library'), 'admin.php'));
|
32 |
+
if($referer = wp_get_referer()) {
|
33 |
+
if(false !== strpos($referer, 'admin.php'))
|
34 |
+
$location = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted'), $referer);
|
35 |
+
}
|
36 |
+
switch($doaction) {
|
37 |
+
case 'delete':
|
38 |
+
if(!isset($post_ids))
|
39 |
+
break;
|
40 |
+
foreach((array) $post_ids as $post_id_del) {
|
41 |
+
if(!current_user_can( 'delete_post', $post_id_del))
|
42 |
+
wp_die(__( 'You are not allowed to delete this post.'));
|
43 |
+
if(!wp_delete_attachment($post_id_del))
|
44 |
+
wp_die(__('Error in deleting.'));
|
45 |
+
}
|
46 |
+
$location = add_query_arg('deleted', count($post_ids), $location);
|
47 |
+
break;
|
48 |
+
}
|
49 |
+
wp_redirect($location);
|
50 |
+
exit;
|
51 |
+
} elseif(!empty($_GET['_wp_http_referer'])) {
|
52 |
+
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
|
53 |
+
exit;
|
54 |
+
}
|
55 |
+
$wp_list_table->prepare_items();
|
56 |
+
wp_enqueue_script('wp-ajax-response');
|
57 |
+
wp_enqueue_script('jquery-ui-draggable');
|
58 |
+
wp_enqueue_script('media');
|
59 |
+
?>
|
60 |
+
<div class="wrap">
|
61 |
+
<h2>
|
62 |
+
<?php _e('Avatars');
|
63 |
+
if(!empty($_REQUEST['s'])) {
|
64 |
+
printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', get_search_query());
|
65 |
+
}
|
66 |
+
?>
|
67 |
+
</h2>
|
68 |
+
<?php
|
69 |
+
$message = '';
|
70 |
+
if(!empty($_GET['deleted']) && $deleted = absint($_GET['deleted'])) {
|
71 |
+
$message = sprintf(_n('Media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted), number_format_i18n($_GET['deleted']));
|
72 |
+
$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
|
73 |
+
}
|
74 |
+
if(!empty($message)) : ?>
|
75 |
+
<div id="message" class="updated"><p><?php echo $message; ?></p></div>
|
76 |
+
<?php endif; ?>
|
77 |
+
<?php $wp_list_table->views(); ?>
|
78 |
+
<form id="posts-filter" action="" method="get">
|
79 |
+
<?php $wp_list_table->search_box(__('Search'), 'media' ); ?>
|
80 |
+
<?php $wp_list_table->display(); ?>
|
81 |
+
<div id="ajax-response"></div>
|
82 |
+
<?php find_posts_div(); ?>
|
83 |
+
<br class="clear" />
|
84 |
+
</form>
|
85 |
+
</div>
|
includes/wpua-options-page.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin page to change plugin options.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
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;
|
10 |
+
$updated = false;
|
11 |
+
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') {
|
12 |
+
$updated = true;
|
13 |
+
}
|
14 |
+
$hide_size = (bool) $wpua_allow_upload != 1 ? ' style="display:none;"' : "";
|
15 |
+
$hide_resize = (bool) $wpua_resize_upload != 1 ? ' style="display:none;"' : "";
|
16 |
+
$wpua_options_page_title = __('WP User Avatar', 'wp-user-avatar');
|
17 |
+
$wpua_options_page_title = apply_filters('wpua_options_page_title', $wpua_options_page_title);
|
18 |
+
?>
|
19 |
+
|
20 |
+
<?php if($updated) : ?>
|
21 |
+
<div id="message" class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
|
22 |
+
<?php endif; ?>
|
23 |
+
|
24 |
+
<div class="wrap">
|
25 |
+
<h2><?php echo $wpua_options_page_title; ?></h2>
|
26 |
+
<form method="post" action="<?php echo admin_url('options.php'); ?>">
|
27 |
+
<?php settings_fields('wpua-settings-group'); ?>
|
28 |
+
<?php do_settings_fields('wpua-settings-group', ""); ?>
|
29 |
+
<?php do_action('wpua_donation_message'); ?>
|
30 |
+
<table class="form-table">
|
31 |
+
<?php
|
32 |
+
// Format settings in table rows
|
33 |
+
$wpua_before_settings = array();
|
34 |
+
$wpua_before_settings = apply_filters('wpua_before_settings', $wpua_before_settings);
|
35 |
+
echo implode("", $wpua_before_settings);
|
36 |
+
?>
|
37 |
+
<tr valign="top">
|
38 |
+
<th scope="row"><?php _e('Settings'); ?></th>
|
39 |
+
<td>
|
40 |
+
<?php
|
41 |
+
// Format settings in fieldsets
|
42 |
+
$wpua_settings = array();
|
43 |
+
$wpua_settings['tinymce'] = '<fieldset>
|
44 |
+
<label for="wp_user_avatar_tinymce">
|
45 |
+
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" '.checked($wpua_tinymce, 1, 0).' />'
|
46 |
+
.__('Add avatar button to Visual Editor', 'wp-user-avatar').'
|
47 |
+
</label>
|
48 |
+
</fieldset>';
|
49 |
+
$wpua_settings['upload'] ='<fieldset>
|
50 |
+
<label for="wp_user_avatar_allow_upload">
|
51 |
+
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" '.checked($wpua_allow_upload, 1, 0).' />'
|
52 |
+
.__('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar').'
|
53 |
+
</label>
|
54 |
+
</fieldset>';
|
55 |
+
$wpua_settings['gravatar'] ='<fieldset>
|
56 |
+
<label for="wp_user_avatar_disable_gravatar">
|
57 |
+
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" '.checked($wpua_disable_gravatar, 1, 0).' />'
|
58 |
+
.__('Disable Gravatar and use only local avatars', 'wp-user-avatar').'
|
59 |
+
</label>
|
60 |
+
</fieldset>';
|
61 |
+
$wpua_settings = apply_filters('wpua_settings', $wpua_settings);
|
62 |
+
echo implode("", $wpua_settings);
|
63 |
+
?>
|
64 |
+
</td>
|
65 |
+
</tr>
|
66 |
+
</table>
|
67 |
+
<?php
|
68 |
+
// Format settings in table
|
69 |
+
$wpua_subscriber_settings = array();
|
70 |
+
$wpua_subscriber_settings['subscriber-settings'] = '<div id="wpua-contributors-subscribers"'.$hide_size.'>
|
71 |
+
<table class="form-table">
|
72 |
+
<tr valign="top">
|
73 |
+
<th scope="row">
|
74 |
+
<label for="wp_user_avatar_upload_size_limit">'
|
75 |
+
.__('Upload Size Limit', 'wp-user-avatar').' '.__('(only for Contributors & Subscribers)', 'wp-user-avatar').'
|
76 |
+
</label>
|
77 |
+
</th>
|
78 |
+
<td>
|
79 |
+
<fieldset>
|
80 |
+
<legend class="screen-reader-text"><span>'.__('Upload Size Limit', 'wp-user-avatar').' '. __('(only for Contributors & Subscribers)', 'wp-user-avatar').'</span></legend>
|
81 |
+
<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" />
|
82 |
+
<span id="wpua-readable-size">'.$wpua_upload_size_limit_with_units.'</span>
|
83 |
+
<span id="wpua-readable-size-error">'.sprintf(__('%s exceeds the maximum upload size for this site.'), "").'</span>
|
84 |
+
<div id="wpua-slider"></div>
|
85 |
+
<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>
|
86 |
+
</fieldset>
|
87 |
+
<fieldset>
|
88 |
+
<label for="wp_user_avatar_edit_avatar">
|
89 |
+
<input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" '.checked($wpua_edit_avatar, 1, 0).' />'
|
90 |
+
.__('Allow users to edit avatars', 'wp-user-avatar').'
|
91 |
+
</label>
|
92 |
+
</fieldset>
|
93 |
+
<fieldset>
|
94 |
+
<label for="wp_user_avatar_resize_upload">
|
95 |
+
<input name="wp_user_avatar_resize_upload" type="checkbox" id="wp_user_avatar_resize_upload" value="1" '.checked($wpua_resize_upload, 1, 0).' />'
|
96 |
+
.__('Resize avatars on upload', 'wp-user-avatar').'
|
97 |
+
</label>
|
98 |
+
</fieldset>
|
99 |
+
<fieldset id="wpua-resize-sizes"'.$hide_resize.'>
|
100 |
+
<label for="wp_user_avatar_resize_w">'.__('Width').'</label>
|
101 |
+
<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" />
|
102 |
+
<label for="wp_user_avatar_resize_h">'.__('Height').'</label>
|
103 |
+
<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" />
|
104 |
+
<br />
|
105 |
+
<input name="wp_user_avatar_resize_crop" type="checkbox" id="wp_user_avatar_resize_crop" value="1" '.checked('1', $wpua_resize_crop, 0).' />
|
106 |
+
<label for="wp_user_avatar_resize_crop">'.__('Crop avatars to exact dimensions', 'wp-user-avatar').'</label>
|
107 |
+
</fieldset>
|
108 |
+
</td>
|
109 |
+
</tr>
|
110 |
+
</table>
|
111 |
+
</div>';
|
112 |
+
$wpua_subscriber_settings = apply_filters('wpua_subscriber_settings', $wpua_subscriber_settings);
|
113 |
+
echo implode("", $wpua_subscriber_settings);
|
114 |
+
?>
|
115 |
+
<table class="form-table">
|
116 |
+
<tr valign="top">
|
117 |
+
<th scope="row"><?php _e('Avatar Display'); ?></th>
|
118 |
+
<td>
|
119 |
+
<fieldset>
|
120 |
+
<legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
|
121 |
+
<label for="show_avatars">
|
122 |
+
<input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> />
|
123 |
+
<?php _e('Show Avatars'); ?>
|
124 |
+
</label>
|
125 |
+
</fieldset>
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
<?php if((bool) $wpua_disable_gravatar != 1) : ?>
|
129 |
+
<tr valign="top" id="avatar-rating">
|
130 |
+
<th scope="row"><?php _e('Maximum Rating'); ?></th>
|
131 |
+
<td>
|
132 |
+
<fieldset>
|
133 |
+
<legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
|
134 |
+
<?php
|
135 |
+
$ratings = array(
|
136 |
+
'G' => __('G — Suitable for all audiences'),
|
137 |
+
'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'),
|
138 |
+
'R' => __('R — Intended for adult audiences above 17'),
|
139 |
+
'X' => __('X — Even more mature than above')
|
140 |
+
);
|
141 |
+
foreach ($ratings as $key => $rating) :
|
142 |
+
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
|
143 |
+
echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
|
144 |
+
endforeach;
|
145 |
+
?>
|
146 |
+
</fieldset>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
<?php else : ?>
|
150 |
+
<input type="hidden" id="avatar_rating" name="avatar_rating" value="<?php echo get_option('avatar_rating'); ?>" />
|
151 |
+
<?php endif; ?>
|
152 |
+
<tr valign="top">
|
153 |
+
<th scope="row"><?php _e('Default Avatar') ?></th>
|
154 |
+
<td class="defaultavatarpicker">
|
155 |
+
<fieldset>
|
156 |
+
<legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
|
157 |
+
<?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 />
|
158 |
+
<?php echo $wpua_admin->wpua_add_default_avatar(); ?>
|
159 |
+
</fieldset>
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
</table>
|
163 |
+
<?php submit_button(); ?>
|
164 |
+
</form>
|
165 |
+
</div>
|
includes/{tinymce.php → wpua-tinymce.php}
RENAMED
@@ -1,21 +1,18 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
-
|
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 |
}
|
@@ -23,25 +20,23 @@ function wpua_myplugin_addbuttons(){
|
|
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'] =
|
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(
|
44 |
die();
|
45 |
}
|
46 |
add_action('wp_ajax_wp_user_avatar_tinymce', 'wpua_ajax_tinymce');
|
47 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* TinyMCE button for Visual Editor.
|
4 |
+
*
|
5 |
* @package WP User Avatar
|
6 |
+
* @version 1.9.3
|
7 |
*/
|
8 |
|
9 |
+
function wpua_myplugin_addbuttons() {
|
|
|
|
|
|
|
|
|
|
|
10 |
// Don't bother doing this stuff if the current user lacks permissions
|
11 |
+
if(!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
|
12 |
return;
|
13 |
}
|
14 |
// Add only in Rich Editor mode
|
15 |
+
if(get_user_option('rich_editing') == 'true') {
|
16 |
add_filter('mce_external_plugins', 'wpua_add_myplugin_tinymce_plugin');
|
17 |
add_filter('mce_buttons', 'wpua_register_myplugin_button');
|
18 |
}
|
20 |
// init process for button control
|
21 |
add_action('init', 'wpua_myplugin_addbuttons');
|
22 |
|
23 |
+
function wpua_register_myplugin_button($buttons) {
|
|
|
24 |
array_push($buttons, 'separator', 'wpUserAvatar');
|
25 |
return $buttons;
|
26 |
}
|
27 |
|
28 |
// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
|
29 |
+
function wpua_add_myplugin_tinymce_plugin($plugin_array) {
|
30 |
+
$plugin_array['wpUserAvatar'] = WPUA_INC_URL.'tinymce/editor_plugin.js';
|
31 |
return $plugin_array;
|
32 |
}
|
33 |
|
34 |
// Call TinyMCE window content via admin-ajax
|
35 |
+
function wpua_ajax_tinymce() {
|
36 |
+
if(!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
|
37 |
die('You are not allowed to call this page directly.');
|
38 |
}
|
39 |
+
include_once(WPUA_INC.'tinymce/window.php');
|
40 |
die();
|
41 |
}
|
42 |
add_action('wp_ajax_wp_user_avatar_tinymce', 'wpua_ajax_tinymce');
|
|
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" style="max-height:96px;" />');
|
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}('(4($){2.5.m={J:4(){I 2.5.U.Z.7.z},10:4(a){B b=2.5.U.Z;b.7.z=a;b.7.F=3(\'R.i-19\').j(\'g\').h(\'s\');C(b.7.z&&b.7.F){3(\'#2-x-n\',d.9.8).r(b.7.z);3(\'#0-Y\',d.9.8).t();3(\'#0-u\',d.9.8).j(\'g\').h(\'s\',b.7.F).X(\'O\',"");3(\'#0-y-k\',d.9.8).t();3(\'#0-l-k\',d.9.8).v();3(\'#0-M\',d.9.8).v();3(\'#D\',d.9.8).A(\'c\')}2.5.m.H().1k()},H:4(){C(6.f){I 6.f}6.f=2.5({S:{12:\'14\'},1o:17,V:3(\'#0-N\').P(\'V\')});6.f.q(\'Q\',4(){w=3(\'#2-x-n\').r();C(w==""){3(\'R.5-18\').j(\'a:K\').A(\'c\')}1i{B a=6.T().J(\'o\');i=2.5.i(w);i.13();a.N(i?[i]:[])}},6.f);6.f.T(\'S\').q(\'L\',6.L);I 6.f},L:4(a){o=6.J(\'o\').15();2.5.m.10(o?o.w:-1)},W:4(){3(\'G\').q(\'c\',\'#0-N\',4(e){e.E();e.1a();2.5.m.H().Q()})}}})(3);3(4($){C(1b(2)!=\'1c\'){2.5.m.W()}$(\'#1d-1e\').h(\'1f\',\'1g/1h-P\');B a=$(\'#2-x-n\').r();B b=$(\'#0-u\').j(\'g\').h(\'s\');$(\'G\').q(\'c\',\'#0-l\',4(e){e.E();$(\'#0-p\').l();$(\'#0-l-k, #0-M\').v();$(\'#0-u\').j(\'g:K\').v();$(\'#0-u\').1j(\'<g w="0-p" 11="1l-O:1m;" />\');$(\'#0-p\').h(\'s\',1n.16);$(\'#2-x-n\').r("");$(\'#0-p, #0-y-k\').t();$(\'#D\').A(\'c\')});$(\'G\').q(\'c\',\'#0-y\',4(e){e.E();$(\'#0-p\').l();$(\'#0-Y\').X(\'11\');$(\'#0-y-k\').v();$(\'#0-l-k, #0-M\').t();$(\'#0-u\').j(\'g:K\').h(\'s\',b).t();$(\'#2-x-n\').r(a);$(\'#D\').A(\'c\')})});',62,87,'wpua||wp|jQuery|function|media|this|post|document|parent|||click|window||_frame|img|attr|attachment|find|button|remove|wpUserAvatar|avatar|selection|original|on|val|src|show|preview|hide|id|user|undo|wpUserAvatarId|trigger|var|if|wp_user_avatar_radio|preventDefault|wpUserAvatarSrc|body|frame|return|get|first|select|thumbnail|add|height|data|open|div|library|state|view|title|init|removeAttr|images|settings|set|style|type|fetch|image|single|avatar_thumb|false|router|info|stopPropagation|typeof|undefined|your|profile|enctype|multipart|form|else|prepend|close|max|96px|wpua_custom|multiple'.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.3\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2014-04-16 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:208
|
18 |
+
msgid "Donate"
|
19 |
+
msgstr "Spenden"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:92
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Bist Du mit WP-Benutzer-Avatar zufrieden?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:92
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Spenden"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:46
|
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:52
|
34 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
35 |
msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
|
36 |
|
37 |
+
#: includes/wpua-options-page.php:58
|
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:75
|
42 |
+
#: includes/wpua-options-page.php:80
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Dateigrößenbeschränkung"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:75
|
47 |
+
#: includes/wpua-options-page.php:80
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(nur für Mitarbeiter und Abonnenten)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:90
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Benutzer erlauben, Avatare bearbeiten"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:96
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Resize Avatare beim Upload"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:106
|
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.3\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2014-04-16 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:208
|
18 |
+
msgid "Donate"
|
19 |
+
msgstr "Donar"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:92
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "¿Está satisfecho con WP-Usuario-Avatar?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:92
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Donar"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:46
|
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:52
|
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:58
|
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:75
|
42 |
+
#: includes/wpua-options-page.php:80
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Sube límite de tamaño"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:75
|
47 |
+
#: includes/wpua-options-page.php:80
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(para colaboradores y suscriptores)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:90
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Permitir a los usuarios editar avatar"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:96
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Cambiar el tamaño de avatares en carga"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:106
|
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.3\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2014-04-16 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:208
|
18 |
+
msgid "Donate"
|
19 |
+
msgstr "Faites un don"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:92
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Etes-vous satisfait avec WP-Utilisateur-Avatar?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:92
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Faites un don"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:46
|
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:52
|
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:58
|
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:75
|
42 |
+
#: includes/wpua-options-page.php:80
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Taille limite d'envoi de fichiers"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:75
|
47 |
+
#: includes/wpua-options-page.php:80
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(pour contributeurs et abonnés)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:90
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Permettre aux utilisateurs de modifier avatar"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:96
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Redimensionner avatars lors du téléchargement"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:106
|
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.3\n"
|
8 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2014-04-16 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:208
|
18 |
+
msgid "Donate"
|
19 |
+
msgstr "Dotuj"
|
20 |
+
|
21 |
+
#: includes/wpua-functions.php:92
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Jesteś zadowolony z Wp User Avatar"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:92
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Dokonaj dotacji"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:46
|
30 |
+
msgid "Add avatar button to Visual Editor"
|
31 |
+
msgstr "Dodaj przycisk avatara do edytora wizualnego"
|
32 |
+
|
33 |
+
#: includes/wpua-options-page.php:52
|
34 |
+
msgid "Allow Contributors & Subscribers to upload avatars"
|
35 |
+
msgstr "Pozwalaj kontrybutorom oraz subskrynentom przesyłać awatary"
|
36 |
+
|
37 |
+
#: includes/wpua-options-page.php:58
|
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:75
|
42 |
+
#: includes/wpua-options-page.php:80
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Limit wielkości pliku"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:75
|
47 |
+
#: includes/wpua-options-page.php:80
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(tylko dla subskrynentów i kontrybutorów)"
|
50 |
+
|
51 |
+
#: includes/wpua-options-page.php:90
|
52 |
+
msgid "Allow users to edit avatars"
|
53 |
+
msgstr "Pozwalaj użytkownikom edytować awatary"
|
54 |
+
|
55 |
+
#: includes/wpua-options-page.php:96
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Zmieniaj rozmiar po przesłaniu"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:106
|
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.3\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2014-04-16 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:208
|
18 |
+
msgid "Donate"
|
19 |
+
msgstr "Donera"
|
|
|
20 |
|
21 |
+
#: includes/wpua-functions.php:92
|
22 |
+
msgid "Do you like WP User Avatar?"
|
23 |
+
msgstr "Är du nöjd med Visningsbild (avatar)?"
|
24 |
+
|
25 |
+
#: includes/wpua-functions.php:92
|
26 |
+
msgid "Make a donation."
|
27 |
+
msgstr "Donera"
|
28 |
+
|
29 |
+
#: includes/wpua-options-page.php:46
|
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:52
|
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:58
|
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:75
|
42 |
+
#: includes/wpua-options-page.php:80
|
43 |
+
msgid "Upload Size Limit"
|
44 |
+
msgstr "Storleksgräns för uppladdningar"
|
45 |
+
|
46 |
+
#: includes/wpua-options-page.php:75
|
47 |
+
#: includes/wpua-options-page.php:80
|
48 |
+
msgid "(only for Contributors & Subscribers)"
|
49 |
+
msgstr "(endast för medarbetare & prenumeranter)"
|
50 |
|
51 |
+
#: includes/wpua-options-page.php:90
|
52 |
msgid "Allow users to edit avatars"
|
53 |
msgstr "Tillåt användare att redigera avatarer"
|
54 |
|
55 |
+
#: includes/wpua-options-page.php:96
|
56 |
+
msgid "Resize avatars on upload"
|
57 |
+
msgstr "Ändra storlek på avatarer på uppladdning"
|
58 |
+
|
59 |
+
#: includes/wpua-options-page.php:106
|
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
@@ -3,9 +3,9 @@
|
|
3 |
Contributors: bangbay
|
4 |
Donate link: http://siboliban.org/donate
|
5 |
Tags: author image, author photo, author avatar, avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo
|
6 |
-
Requires at least: 3.
|
7 |
-
Tested up to: 3.
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -13,16 +13,17 @@ 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 |
-
WP User Avatar also lets you:
|
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 |
|
@@ -32,7 +33,7 @@ WP User Avatar also lets you:
|
|
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 +91,21 @@ 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 |
|
@@ -126,9 +137,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 +155,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 +166,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 +182,37 @@ 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 +241,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,19 +254,255 @@ 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.4 =
|
234 |
-
* Add: Option to enable avatar editing privilege for Subscribers
|
235 |
* Add: Swedish translation
|
236 |
* Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
|
237 |
* Update: Load JavaScript in footer
|
@@ -263,7 +534,7 @@ Outputs:
|
|
263 |
* Bug Fix: Use wp_die for errors
|
264 |
|
265 |
= 1.4 =
|
266 |
-
* Add: Uploader for
|
267 |
* Add: Media states for avatar images
|
268 |
* Add: Plugin admin settings
|
269 |
* Update: Change support only to WP 3.4+
|
@@ -323,7 +594,7 @@ Outputs:
|
|
323 |
= 1.2 =
|
324 |
* Add: Default Avatar setting
|
325 |
|
326 |
-
= 1.1.
|
327 |
* Bug Fix: Change update_usermeta to update_user_meta
|
328 |
|
329 |
= 1.1.6 =
|
@@ -367,6 +638,10 @@ Outputs:
|
|
367 |
|
368 |
== Upgrade Notice ==
|
369 |
|
|
|
|
|
|
|
|
|
370 |
= 1.5.3 =
|
371 |
* 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.
|
372 |
|
3 |
Contributors: bangbay
|
4 |
Donate link: http://siboliban.org/donate
|
5 |
Tags: author image, author photo, author avatar, avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo
|
6 |
+
Requires at least: 3.6
|
7 |
+
Tested up to: 3.9
|
8 |
+
Stable tag: 1.9.3
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
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 |
+
**WP User Avatar** also lets you:
|
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>[avatar_upload]</code> shortcode to add a standalone uploader to a front page. This uploader is only visible to logged-in users.
|
24 |
+
* Use the <code>[avatar]</code> shortcode in your posts. These shortcodes will work with any theme, whether it has avatar support or not.
|
25 |
* Allow Contributors and Subscribers to upload their own avatars.
|
26 |
+
* Limit upload file size and image dimensions for Contributors and Subscribers.
|
27 |
|
28 |
== Installation ==
|
29 |
|
33 |
4. Click "Update Profile".
|
34 |
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.
|
35 |
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/).
|
36 |
+
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.
|
37 |
|
38 |
**Example Usage**
|
39 |
|
91 |
|
92 |
**Other Available Functions**
|
93 |
|
94 |
+
= [avatar_upload] shortcode =
|
95 |
+
|
96 |
+
You can use the <code>[avatar_upload]</code> shortcode to add a standalone uploader to a front page. 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/).
|
97 |
+
|
98 |
= [avatar] shortcode =
|
99 |
|
100 |
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.
|
101 |
|
102 |
+
`[avatar user="admin" size="medium" align="left" link="file" /]`
|
103 |
+
|
104 |
+
You can also add a caption to the shortcode:
|
105 |
+
|
106 |
+
`[avatar user="admin" size="medium" align="left" link="file"]Photo Credit: Your Name[/avatar]`
|
107 |
+
|
108 |
+
**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>
|
109 |
|
110 |
= get_wp_user_avatar_src =
|
111 |
|
137 |
|
138 |
1. Allows you to use the values "original", "large", "medium", or "thumbnail" for your avatar size.
|
139 |
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.
|
140 |
+
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).
|
141 |
+
4. Optionally adds CSS classes "alignleft", "alignright", or "aligncenter" to position your avatar.
|
142 |
+
5. Shows nothing if the user has no WP User Avatar image.
|
143 |
+
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.
|
144 |
|
145 |
= get_avatar =
|
146 |
|
155 |
= Can I create a custom Default Avatar? =
|
156 |
In your WP User Avatar settings, you can upload your own Default Avatar.
|
157 |
|
158 |
+
= Can I disable all Gravatar avatars? =
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
+
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.
|
|
|
|
|
161 |
|
162 |
= Can Contributors or Subscribers choose their own WP User Avatar image? =
|
163 |
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.
|
166 |
|
167 |
Yes, for registered users. Non-registered comment authors will show their [Gravatar](http://gravatar.com/) avatars or Default Avatar.
|
168 |
|
|
|
|
|
|
|
|
|
169 |
= Will WP User Avatar work with bbPress? =
|
170 |
|
171 |
Yes!
|
172 |
|
173 |
+
= Will WP User Avatar work with BuddyPress? =
|
174 |
+
|
175 |
+
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.
|
176 |
+
|
177 |
= Will WP User Avatar work with WordPress Multisite? =
|
178 |
|
179 |
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.
|
182 |
|
183 |
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.
|
184 |
|
185 |
+
= Can I use the WP User Avatar uploader in a front page? =
|
186 |
+
|
187 |
+
Yes, you can use the <code>[avatar_upload]</code> shortcode to put a standalone uploader in a front page. 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/).
|
188 |
+
|
189 |
+
= Can I insert WP User Avatar directly into a post? =
|
190 |
+
|
191 |
+
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.
|
192 |
+
|
193 |
+
`[avatar user="admin" size="96" align="left" link="file" /]`
|
194 |
+
|
195 |
+
Outputs:
|
196 |
+
|
197 |
+
`<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
|
198 |
+
<img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96 alignleft" />
|
199 |
+
</a>`
|
200 |
+
|
201 |
+
If you have a caption, the output will be similar to how WordPress adds captions to other images.
|
202 |
+
|
203 |
+
`[avatar user="admin" size="96" align="left" link="file"]Photo Credit: Your Name[/avatar]`
|
204 |
+
|
205 |
+
Outputs:
|
206 |
+
|
207 |
+
`<div style="width: 106px" class="wp-caption alignleft">
|
208 |
+
<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
|
209 |
+
<img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96" />
|
210 |
+
</a>
|
211 |
+
<p class="wp-caption-text">Photo Credit: Your Name</p>
|
212 |
+
</div>`
|
213 |
+
|
214 |
+
**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>
|
215 |
+
|
216 |
= What CSS can I use with WP User Avatar? =
|
217 |
|
218 |
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:
|
241 |
* Attachment: wp-user-avatar-attachment
|
242 |
* Custom URL: wp-user-avatar-custom
|
243 |
|
244 |
+
`[avatar user="admin" size="96" align="left" link="attachment" /]`
|
245 |
|
246 |
Outputs:
|
247 |
|
254 |
* <code>has_wp_user_avatar</code>: checks if the user has a WP User Avatar image
|
255 |
* [See example usage here](http://wordpress.org/extend/plugins/wp-user-avatar/installation/)
|
256 |
|
257 |
+
= There's a call for donations in the WP User Avatar settings. How can I remove it? =
|
258 |
+
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:
|
259 |
+
|
260 |
+
`remove_action('wpua_donation_message', 'wpua_do_donation_message');`
|
261 |
+
|
262 |
+
== Advanced Settings ==
|
263 |
+
|
264 |
+
= Add WP User Avatar to your own profile edit page =
|
265 |
+
|
266 |
+
If you're building your own profile edit page, 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:
|
267 |
+
|
268 |
+
`do_action('edit_user_avatar', $current_user);`
|
269 |
+
|
270 |
+
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:
|
271 |
+
|
272 |
+
`function my_avatar_filter() {
|
273 |
+
// Remove from show_user_profile hook
|
274 |
+
remove_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
275 |
+
remove_action('show_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
276 |
+
|
277 |
+
// Remove from edit_user_profile hook
|
278 |
+
remove_action('edit_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
279 |
+
remove_action('edit_user_profile', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
280 |
+
|
281 |
+
// Add to edit_user_avatar hook
|
282 |
+
add_action('edit_user_avatar', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
283 |
+
add_action('edit_user_avatar', array('wp_user_avatar', 'wpua_media_upload_scripts'));
|
284 |
+
}
|
285 |
+
|
286 |
+
// Loads only outside of administration panel
|
287 |
+
if(!is_admin()) {
|
288 |
+
add_action('init','my_avatar_filter');`
|
289 |
+
}`
|
290 |
+
|
291 |
+
= HTML Wrapper =
|
292 |
+
|
293 |
+
You can change the HTML wrapper of the WP User Avatar section on your profile edit page by using the functions <code>wpua_before_avatar</code> and <code>wpua_after_avatar</code>. By default, the avatar code is structured like this:
|
294 |
+
|
295 |
+
`<h3>Avatar</h3>
|
296 |
+
<table class="form-table">
|
297 |
+
<tr>
|
298 |
+
<th><label for="wp_user_avatar">Image</label></th>
|
299 |
+
<td>
|
300 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
|
301 |
+
<p id="wpua-add-button">
|
302 |
+
<button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
|
303 |
+
</p>
|
304 |
+
<p id="wpua-preview">
|
305 |
+
<img src="{imageURL}" alt="" />
|
306 |
+
Original Size
|
307 |
+
</p>
|
308 |
+
<p id="wpua-thumbnail">
|
309 |
+
<img src="{imageURL}" alt="" />
|
310 |
+
Thumbnail
|
311 |
+
</p>
|
312 |
+
<p id="wpua-remove-button">
|
313 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove">Default Avatar</button>
|
314 |
+
</p>
|
315 |
+
<p id="wpua-undo-button">
|
316 |
+
<button type="button" class="button" id="wpua-undo" name="wpua-undo">Undo</button>
|
317 |
+
</p>
|
318 |
+
</td>
|
319 |
+
</tr>
|
320 |
+
</table>`
|
321 |
+
|
322 |
+
To strip out the table, you would add the following filters to the <code>functions.php</code> file in your theme:
|
323 |
+
|
324 |
+
`remove_action('wpua_before_avatar', 'wpua_do_before_avatar');
|
325 |
+
remove_action('wpua_after_avatar', 'wpua_do_after_avatar');`
|
326 |
+
|
327 |
+
To add your own wrapper, you could create something like this:
|
328 |
+
|
329 |
+
`function my_before_avatar() {
|
330 |
+
echo '<div id="my-avatar">';
|
331 |
+
}
|
332 |
+
add_action('wpua_before_avatar', 'my_before_avatar');
|
333 |
+
|
334 |
+
function my_after_avatar() {
|
335 |
+
echo '</div>';
|
336 |
+
}
|
337 |
+
add_action('wpua_after_avatar', 'my_after_avatar');`
|
338 |
+
|
339 |
+
This would output:
|
340 |
+
|
341 |
+
`<div id="my-avatar">
|
342 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
|
343 |
+
<p id="wpua-add-button">
|
344 |
+
<button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
|
345 |
+
</p>
|
346 |
+
<p id="wpua-preview">
|
347 |
+
<img src="{imageURL}" alt="" />
|
348 |
+
<span class="description">Original Size</span>
|
349 |
+
</p>
|
350 |
+
<p id="wpua-thumbnail">
|
351 |
+
<img src="{imageURL}" alt="" />
|
352 |
+
<span class="description">Thumbnail</span>
|
353 |
+
</p>
|
354 |
+
<p id="wpua-remove-button">
|
355 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove">Default Avatar</button>
|
356 |
+
</p>
|
357 |
+
<p id="wpua-undo-button">
|
358 |
+
<button type="button" class="button" id="wpua-undo" name="wpua-undo">Undo</button>
|
359 |
+
</p>
|
360 |
+
</div>`
|
361 |
+
|
362 |
== Screenshots ==
|
363 |
|
364 |
1. WP User Avatar admin settings.
|
365 |
2. WP User Avatar lets you upload your own Default Avatar.
|
366 |
3. WP User Avatar adds a field to your profile edit page.
|
367 |
4. After you've chosen a WP User Avatar image, you will see the option to remove it.
|
|
|
|
|
368 |
|
369 |
== Changelog ==
|
370 |
|
371 |
+
= 1.9.3 =
|
372 |
+
* Bug Fix: Missing php
|
373 |
+
|
374 |
+
= 1.9.2 =
|
375 |
+
* Add: Setup class
|
376 |
+
* Bug Fix: Give wpua_attachment_is_image filter two variables
|
377 |
+
* Bug Fix: Return [avatar_upload] instead of echo
|
378 |
+
* Remove: Unneccessary filters
|
379 |
+
* Update: Allow upload to overwrite avatar for Contributors & Subscribers
|
380 |
+
* Update: Move Edit Image link for Contributors & Subscribers
|
381 |
+
* Update: Move text from localize script to data attribute
|
382 |
+
* Update: Shorten variable names
|
383 |
+
* Update: Wrap all classes in init
|
384 |
+
|
385 |
+
= 1.9.1 =
|
386 |
+
* Bug Fix: Double underscore for options page title
|
387 |
+
* Bug Fix: Remove TinyMCE language pack
|
388 |
+
* Bug Fix: Wrong variables in get_wp_user_avatar filter
|
389 |
+
|
390 |
+
= 1.9 =
|
391 |
+
* Add: Filters throughout plugin
|
392 |
+
* Bug Fix: Die messages
|
393 |
+
* Update: Move public functions to class
|
394 |
+
|
395 |
+
= 1.8.10 =
|
396 |
+
* Add: Search and screen option in Media Library view
|
397 |
+
* Bug Fix: Bulk delete in Media Library view
|
398 |
+
* Bug Fix: Hide captions if "Show Avatars" is off
|
399 |
+
* Bug Fix: Update avatar metadata on removal
|
400 |
+
* Update: Choose Image text
|
401 |
+
* Update: Show only images in Media Library modal
|
402 |
+
* Update: Show upload tab if no WP User Avatar image has been selected yet
|
403 |
+
|
404 |
+
= 1.8.9 =
|
405 |
+
* Bug Fix: Check for post object
|
406 |
+
|
407 |
+
= 1.8.8 =
|
408 |
+
* Bug Fix: Media upload scripts
|
409 |
+
|
410 |
+
= 1.8.7 =
|
411 |
+
* Bug Fix: Bad reference to wpua_is_author_or_above
|
412 |
+
|
413 |
+
= 1.8.6 =
|
414 |
+
* Bug Fix: Check for media upload scripts before setting post parent
|
415 |
+
|
416 |
+
= 1.8.5 =
|
417 |
+
* Add: Capability check in one function
|
418 |
+
|
419 |
+
= 1.8.4 =
|
420 |
+
* Bug Fix: Set avatar post parent to 0
|
421 |
+
|
422 |
+
= 1.8.3 =
|
423 |
+
* Bug Fix: Prevent attachment insert without image
|
424 |
+
* Update: Check for delete_posts capability instead of user role for Subscribers
|
425 |
+
* Update: Refactor and clean up
|
426 |
+
|
427 |
+
= 1.8.2 =
|
428 |
+
* Bug Fix: Edit avatar setting
|
429 |
+
|
430 |
+
= 1.8.1 =
|
431 |
+
* Bug Fix: Reattach scripts to profile action
|
432 |
+
|
433 |
+
= 1.8 =
|
434 |
+
* Add: Front page uploader
|
435 |
+
* Add: Media Library view of all avatars
|
436 |
+
* Bug Fix: Identify public static functions
|
437 |
+
* Update: Refactor code into separate classes
|
438 |
+
* Update: Translations
|
439 |
+
|
440 |
+
= 1.7.2 =
|
441 |
+
* Bug Fix: Files not committed properly in previous release
|
442 |
+
|
443 |
+
= 1.7.1 =
|
444 |
+
* Update: Error message handling for front pages
|
445 |
+
|
446 |
+
= 1.7 =
|
447 |
+
* Add: Caption for avatar
|
448 |
+
* Add: Polish translation
|
449 |
+
* Update: Error message handling
|
450 |
+
|
451 |
+
= 1.6.8 =
|
452 |
+
* Bug Fix: Shortcode without user
|
453 |
+
|
454 |
+
= 1.6.7 =
|
455 |
+
* Add: Undo button
|
456 |
+
* Bug Fix: Get original avatar
|
457 |
+
|
458 |
+
= 1.6.6 =
|
459 |
+
* Add: Donation message
|
460 |
+
* Bug Fix: Die page when image is too large
|
461 |
+
* Bug Fix: Resize images uploaded through plugin only
|
462 |
+
* Remove: Unused function
|
463 |
+
* Update: Refactor JavaScript
|
464 |
+
|
465 |
+
= 1.6.5 =
|
466 |
+
* Bug Fix: Use entire comment object instead of just e-mail address
|
467 |
+
|
468 |
+
= 1.6.4 =
|
469 |
+
* Bug Fix: Correct avatar not showing in widget
|
470 |
+
* Update: Check compatibility to 3.7.1
|
471 |
+
|
472 |
+
= 1.6.3 =
|
473 |
+
* Bug Fix: Checkbox value for "Crop avatars to exact dimensions"
|
474 |
+
|
475 |
+
= 1.6.2 =
|
476 |
+
* Bug Fix: Show Default Avatar if attachment doesn't exist
|
477 |
+
* Bug Fix: manage_users_custom_column not returning values
|
478 |
+
|
479 |
+
= 1.6.1 =
|
480 |
+
* Bug Fix: Profile not saving without an avatar for Contributors & Subscribers
|
481 |
+
|
482 |
+
= 1.6.0 =
|
483 |
+
* Add: Filters to change profile HTML structure
|
484 |
+
* Add: Recognition of sizes registered with add_image_size
|
485 |
+
* Add: Resize image options for Contributors & Subscribers
|
486 |
+
* Bug Fix: Rerrange CSS class names
|
487 |
+
|
488 |
+
= 1.5.8 =
|
489 |
+
* Bug Fix: Add function exists checks to prevent redeclare errors
|
490 |
+
* Bug Fix: Page die if file upload is too big
|
491 |
+
* Bug Fix: Upload file with submit
|
492 |
+
|
493 |
+
= 1.5.7 =
|
494 |
+
* Bug Fix: Separate out JavaScript for Contributors & Subscribers
|
495 |
+
* Bug Fix: Subscriber uploader not finding error type
|
496 |
+
|
497 |
+
= 1.5.6 =
|
498 |
+
* Update: Use cache for wpua_has_gravatar
|
499 |
+
|
500 |
+
= 1.5.5 =
|
501 |
+
* Bug Fix: Hide "Edit Image" button if Contributors & Subscribers can't edit avatar
|
502 |
+
* Bug Fix: Remove edit_posts capability if Subscribers can't edit avatar
|
503 |
+
|
504 |
= 1.5.4 =
|
505 |
+
* Add: Option to enable avatar editing privilege for Contributors & Subscribers
|
506 |
* Add: Swedish translation
|
507 |
* Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
|
508 |
* Update: Load JavaScript in footer
|
534 |
* Bug Fix: Use wp_die for errors
|
535 |
|
536 |
= 1.4 =
|
537 |
+
* Add: Uploader for Contributors & Subscribers
|
538 |
* Add: Media states for avatar images
|
539 |
* Add: Plugin admin settings
|
540 |
* Update: Change support only to WP 3.4+
|
594 |
= 1.2 =
|
595 |
* Add: Default Avatar setting
|
596 |
|
597 |
+
= 1.1.8 =
|
598 |
* Bug Fix: Change update_usermeta to update_user_meta
|
599 |
|
600 |
= 1.1.6 =
|
638 |
|
639 |
== Upgrade Notice ==
|
640 |
|
641 |
+
= 1.8 =
|
642 |
+
* New Feature: Front page uploader
|
643 |
+
* New Feature: Media Library view of all avatars
|
644 |
+
|
645 |
= 1.5.3 =
|
646 |
* 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.
|
647 |
|
uninstall.php
CHANGED
@@ -1,31 +1,36 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
// Remove user metadata and options on plugin delete
|
8 |
-
if(!defined('WP_UNINSTALL_PLUGIN')){
|
9 |
-
die(
|
10 |
}
|
11 |
|
12 |
global $wpdb, $blog_id, $switched;
|
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 +38,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 +46,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 |
* @package WP User Avatar
|
4 |
+
* @version 1.9.3
|
5 |
*/
|
6 |
|
7 |
// Remove user metadata and options on plugin delete
|
8 |
+
if(!defined('WP_UNINSTALL_PLUGIN')) {
|
9 |
+
die('You are not allowed to call this page directly.');
|
10 |
}
|
11 |
|
12 |
global $wpdb, $blog_id, $switched;
|
13 |
$users = get_users();
|
14 |
+
|
15 |
// Remove settings for all sites in multisite
|
16 |
+
if(is_multisite()) {
|
17 |
+
$blogs = wp_get_sites();
|
18 |
+
foreach($users as $user) {
|
19 |
+
foreach($blogs as $blog) {
|
20 |
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog->blog_id).'user_avatar');
|
21 |
}
|
22 |
}
|
23 |
+
foreach($blogs as $blog) {
|
24 |
switch_to_blog($blog->blog_id);
|
25 |
delete_option('avatar_default_wp_user_avatar');
|
26 |
delete_option('wp_user_avatar_allow_upload');
|
27 |
delete_option('wp_user_avatar_disable_gravatar');
|
28 |
delete_option('wp_user_avatar_edit_avatar');
|
29 |
delete_option('wp_user_avatar_load_scripts');
|
30 |
+
delete_option('wp_user_avatar_resize_crop');
|
31 |
+
delete_option('wp_user_avatar_resize_h');
|
32 |
+
delete_option('wp_user_avatar_resize_upload');
|
33 |
+
delete_option('wp_user_avatar_resize_w');
|
34 |
delete_option('wp_user_avatar_tinymce');
|
35 |
delete_option('wp_user_avatar_upload_size_limit');
|
36 |
delete_option('wp_user_avatar_default_avatar_updated');
|
38 |
delete_option('wp_user_avatar_users_updated');
|
39 |
}
|
40 |
} else {
|
41 |
+
foreach($users as $user) {
|
42 |
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar');
|
43 |
}
|
44 |
delete_option('avatar_default_wp_user_avatar');
|
46 |
delete_option('wp_user_avatar_disable_gravatar');
|
47 |
delete_option('wp_user_avatar_edit_avatar');
|
48 |
delete_option('wp_user_avatar_load_scripts');
|
49 |
+
delete_option('wp_user_avatar_resize_crop');
|
50 |
+
delete_option('wp_user_avatar_resize_h');
|
51 |
+
delete_option('wp_user_avatar_resize_upload');
|
52 |
+
delete_option('wp_user_avatar_resize_w');
|
53 |
delete_option('wp_user_avatar_tinymce');
|
54 |
delete_option('wp_user_avatar_upload_size_limit');
|
55 |
delete_option('wp_user_avatar_default_avatar_updated');
|
56 |
delete_option('wp_user_avatar_media_updated');
|
57 |
delete_option('wp_user_avatar_users_updated');
|
58 |
}
|
59 |
+
|
60 |
// Delete post meta
|
61 |
delete_post_meta_by_key('_wp_attachment_wp_user_avatar');
|
62 |
+
|
63 |
// Reset all default avatars to Mystery Man
|
64 |
update_option('avatar_default', 'mystery');
|
|
wp-user-avatar.php
CHANGED
@@ -1,986 +1,61 @@
|
|
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: Bangbay Siboliban
|
11 |
Author URI: http://siboliban.org/
|
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.4');
|
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 |
-
$ssl = is_ssl() ? 's' : "";
|
42 |
-
|
43 |
-
// Check for updates
|
44 |
-
$wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
|
45 |
-
$wpua_users_updated = get_option('wp_user_avatar_users_updated');
|
46 |
-
$wpua_media_updated = get_option('wp_user_avatar_media_updated');
|
47 |
-
|
48 |
-
// Max upload size
|
49 |
-
if(!function_exists('wp_max_upload_size')){
|
50 |
-
require_once(ABSPATH.'wp-admin/includes/template.php');
|
51 |
-
}
|
52 |
-
|
53 |
-
// Server upload size limit
|
54 |
-
$upload_size_limit = wp_max_upload_size();
|
55 |
-
// Convert to KB
|
56 |
-
if($upload_size_limit > 1024){
|
57 |
-
$upload_size_limit /= 1024;
|
58 |
-
}
|
59 |
-
$upload_size_limit_with_units = (int) $upload_size_limit.'KB';
|
60 |
-
|
61 |
-
// User upload size limit
|
62 |
-
$wpua_user_upload_size_limit = get_option('wp_user_avatar_upload_size_limit');
|
63 |
-
if($wpua_user_upload_size_limit == 0 || $wpua_user_upload_size_limit > wp_max_upload_size()){
|
64 |
-
$wpua_user_upload_size_limit = wp_max_upload_size();
|
65 |
-
}
|
66 |
-
// Value in bytes
|
67 |
-
$wpua_upload_size_limit = $wpua_user_upload_size_limit;
|
68 |
-
// Convert to KB
|
69 |
-
if($wpua_user_upload_size_limit > 1024){
|
70 |
-
$wpua_user_upload_size_limit /= 1024;
|
71 |
-
}
|
72 |
-
$wpua_upload_size_limit_with_units = (int) $wpua_user_upload_size_limit.'KB';
|
73 |
-
|
74 |
-
// Load add-ons
|
75 |
-
if((bool) $wpua_tinymce == 1){
|
76 |
-
include_once(WPUA_ABSPATH.'includes/tinymce.php');
|
77 |
-
}
|
78 |
-
|
79 |
-
// Load translations
|
80 |
-
load_plugin_textdomain('wp-user-avatar', "", WPUA_FOLDER.'/lang');
|
81 |
-
|
82 |
-
// Initialize default settings
|
83 |
-
register_activation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_options');
|
84 |
-
|
85 |
-
// Remove subscribers edit_posts capability
|
86 |
-
register_deactivation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_deactivate');
|
87 |
-
|
88 |
-
// Settings saved to wp_options
|
89 |
-
function wpua_options(){
|
90 |
-
add_option('avatar_default_wp_user_avatar', "");
|
91 |
-
add_option('wp_user_avatar_allow_upload', '0');
|
92 |
-
add_option('wp_user_avatar_disable_gravatar', '0');
|
93 |
-
add_option('wp_user_avatar_edit_avatar', '1');
|
94 |
-
add_option('wp_user_avatar_tinymce', '1');
|
95 |
-
add_option('wp_user_avatar_upload_size_limit', '0');
|
96 |
-
}
|
97 |
-
add_action('admin_init', 'wpua_options');
|
98 |
-
|
99 |
-
// Update default avatar to new format
|
100 |
-
if(empty($wpua_default_avatar_updated)){
|
101 |
-
function wpua_default_avatar(){
|
102 |
-
global $avatar_default, $mustache_original, $wpua_avatar_default;
|
103 |
-
// If default avatar is the old mustache URL, update it
|
104 |
-
if($avatar_default == $mustache_original){
|
105 |
-
update_option('avatar_default', 'wp_user_avatar');
|
106 |
-
}
|
107 |
-
// If user had an image URL as the default avatar, replace with ID instead
|
108 |
-
if(!empty($wpua_avatar_default)){
|
109 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, 'medium');
|
110 |
-
if($avatar_default == $wpua_avatar_default_image[0]){
|
111 |
-
update_option('avatar_default', 'wp_user_avatar');
|
112 |
-
}
|
113 |
-
}
|
114 |
-
update_option('wp_user_avatar_default_avatar_updated', '1');
|
115 |
-
}
|
116 |
-
add_action('admin_init', 'wpua_default_avatar');
|
117 |
-
}
|
118 |
-
|
119 |
-
// Rename user meta to match database settings
|
120 |
-
if(empty($wpua_users_updated)){
|
121 |
-
function wpua_user_meta(){
|
122 |
-
global $blog_id, $wpdb;
|
123 |
-
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
124 |
-
// If database tables start with something other than wp_
|
125 |
-
if($wpua_metakey != 'wp_user_avatar'){
|
126 |
-
$users = get_users();
|
127 |
-
// Move current user metakeys to new metakeys
|
128 |
-
foreach($users as $user){
|
129 |
-
$wpua = get_user_meta($user->ID, 'wp_user_avatar', true);
|
130 |
-
if(!empty($wpua)){
|
131 |
-
update_user_meta($user->ID, $wpua_metakey, $wpua);
|
132 |
-
delete_user_meta($user->ID, 'wp_user_avatar');
|
133 |
-
}
|
134 |
-
}
|
135 |
-
}
|
136 |
-
update_option('wp_user_avatar_users_updated', '1');
|
137 |
-
}
|
138 |
-
add_action('admin_init', 'wpua_user_meta');
|
139 |
-
}
|
140 |
-
|
141 |
-
// Add media state to existing avatars
|
142 |
-
if(empty($wpua_media_updated)){
|
143 |
-
function wpua_media_state(){
|
144 |
-
global $blog_id, $wpdb;
|
145 |
-
// Find all users with WPUA
|
146 |
-
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
147 |
-
$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, ""));
|
148 |
-
foreach($wpuas as $usermeta){
|
149 |
-
add_post_meta($usermeta->meta_value, '_wp_attachment_wp_user_avatar', $usermeta->user_id);
|
150 |
-
}
|
151 |
-
update_option('wp_user_avatar_media_updated', '1');
|
152 |
-
}
|
153 |
-
add_action('admin_init', 'wpua_media_state');
|
154 |
}
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
}
|
162 |
-
add_action('user_edit_form_tag', 'wpua_add_edit_form_multipart_encoding');
|
163 |
-
|
164 |
-
// Check user role
|
165 |
-
function check_user_role($role, $user_id=null){
|
166 |
-
global $current_user;
|
167 |
-
$user = is_numeric($user_id) ? get_userdata($user_id) : $current_user->ID;
|
168 |
-
if(empty($user)){
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
return in_array($role, (array) $user->roles);
|
172 |
-
}
|
173 |
-
|
174 |
-
// Remove menu items
|
175 |
-
function wpua_subscriber_remove_menu_pages(){
|
176 |
-
global $current_user;
|
177 |
-
if(check_user_role('subscriber', $current_user->ID)){
|
178 |
-
remove_menu_page('edit.php');
|
179 |
-
remove_menu_page('edit-comments.php');
|
180 |
-
remove_menu_page('tools.php');
|
181 |
-
}
|
182 |
}
|
183 |
-
add_action('admin_menu', 'wpua_subscriber_remove_menu_pages');
|
184 |
|
185 |
-
//
|
186 |
-
function
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
192 |
}
|
193 |
-
add_action('wp_before_admin_bar_render', 'wpua_subscriber_remove_menu_bar_items');
|
194 |
|
195 |
-
//
|
196 |
-
function
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
}
|
203 |
}
|
204 |
-
add_action('wp_dashboard_setup', 'wpua_subscriber_remove_dashboard_widgets');
|
205 |
|
206 |
-
//
|
207 |
-
function
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
do_action('admin_page_access_denied');
|
217 |
-
wp_die(__('You do not have sufficient permissions to access this page.'));
|
218 |
-
}
|
219 |
-
}
|
220 |
}
|
221 |
-
add_action('admin_init', 'wpua_subscriber_offlimits');
|
222 |
-
}
|
223 |
-
|
224 |
-
if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1){
|
225 |
-
// Give subscribers edit_posts capability
|
226 |
-
function wpua_subscriber_add_cap(){
|
227 |
-
global $blog_id, $wpdb;
|
228 |
-
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
229 |
-
$user_roles = get_option($wp_user_roles);
|
230 |
-
$user_roles['subscriber']['capabilities']['edit_posts'] = true;
|
231 |
-
update_option($wp_user_roles, $user_roles);
|
232 |
-
}
|
233 |
-
add_action('admin_init', 'wpua_subscriber_add_cap');
|
234 |
-
}
|
235 |
-
|
236 |
-
// Remove subscribers edit_posts capability
|
237 |
-
function wpua_subscriber_remove_cap(){
|
238 |
-
global $blog_id, $wpdb;
|
239 |
-
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
240 |
-
$user_roles = get_option($wp_user_roles);
|
241 |
-
unset($user_roles['subscriber']['capabilities']['edit_posts']);
|
242 |
-
update_option($wp_user_roles, $user_roles);
|
243 |
-
}
|
244 |
-
|
245 |
-
// On deactivation
|
246 |
-
function wpua_deactivate(){
|
247 |
-
// Remove subscribers edit_posts capability
|
248 |
-
wpua_subscriber_remove_cap();
|
249 |
-
// Reset all default avatar to Mystery Man
|
250 |
-
update_option('avatar_default', 'mystery');
|
251 |
}
|
252 |
|
253 |
-
|
254 |
-
if(!class_exists('wp_user_avatar')){
|
255 |
-
class wp_user_avatar{
|
256 |
-
function wp_user_avatar(){
|
257 |
-
global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_upload_size_limit;
|
258 |
-
// Add WPUA to profile
|
259 |
-
if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
|
260 |
-
// For themes that use this function
|
261 |
-
if(!function_exists('get_current_screen')){
|
262 |
-
require_once(ABSPATH.'wp-admin/includes/screen.php');
|
263 |
-
}
|
264 |
-
// Profile functions and scripts
|
265 |
-
add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
266 |
-
add_action('edit_user_profile', array($this, 'wpua_action_show_user_profile'));
|
267 |
-
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
268 |
-
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
269 |
-
add_action('show_user_profile', array($this, 'wpua_media_upload_scripts'));
|
270 |
-
add_action('edit_user_profile', array($this, 'wpua_media_upload_scripts'));
|
271 |
-
// Admin scripts
|
272 |
-
if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
|
273 |
-
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
274 |
-
}
|
275 |
-
// Prefilter upload size
|
276 |
-
if(!current_user_can('upload_files')){
|
277 |
-
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'), 10, 1);
|
278 |
-
}
|
279 |
-
// Admin menu settings
|
280 |
-
add_action('admin_menu', 'wpua_admin');
|
281 |
-
add_filter('plugin_action_links', array($this, 'wpua_plugin_settings_links'), 10, 2);
|
282 |
-
// Hide column in Users table if default avatars are enabled
|
283 |
-
if((bool) $show_avatars == 0 && is_admin()){
|
284 |
-
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
285 |
-
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
|
286 |
-
}
|
287 |
-
}
|
288 |
-
}
|
289 |
-
|
290 |
-
// Add to edit user profile
|
291 |
-
function wpua_action_show_user_profile($user){
|
292 |
-
global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_edit_avatar, $wpua_upload_size_limit_with_units;
|
293 |
-
// Get WPUA attachment ID
|
294 |
-
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
295 |
-
// Show remove button if WPUA is set
|
296 |
-
$hide_remove = !has_wp_user_avatar($user->ID) ? ' wpua-hide' : "";
|
297 |
-
// If avatars are enabled, get original avatar image or show blank
|
298 |
-
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
299 |
-
// Check if user has wp_user_avatar, if not show image from above
|
300 |
-
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
|
301 |
-
// Check if user has wp_user_avatar, if not show image from above
|
302 |
-
$avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
|
303 |
-
// Change text on message based on current user
|
304 |
-
$profile = ($current_user->ID == $user->ID) ? '“'.__('Update Profile').'”' : '“'.__('Update User').'”';
|
305 |
-
?>
|
306 |
-
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
307 |
-
<h2 class="entry-title"><?php _e('Avatar'); ?></h2>
|
308 |
-
<fieldset class="bbp-form">
|
309 |
-
<legend><?php _e('Image'); ?></legend>
|
310 |
-
<?php else : // Add to profile with admin style ?>
|
311 |
-
<h3><?php _e('Avatar') ?></h3>
|
312 |
-
<table class="form-table">
|
313 |
-
<tr>
|
314 |
-
<th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
|
315 |
-
<td>
|
316 |
-
<?php endif; ?>
|
317 |
-
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
318 |
-
<?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
|
319 |
-
<p><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
|
320 |
-
<?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
|
321 |
-
<input name="wp-user-avatar-file" id="wpua-file" type="file" />
|
322 |
-
<button type="submit" class="button" id="upload-wp-user-avatar" name="upload-wp-user-avatar" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
|
323 |
-
<p>
|
324 |
-
<?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?>
|
325 |
-
<br />
|
326 |
-
<?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?>
|
327 |
-
</p>
|
328 |
-
<?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 ?>
|
329 |
-
<?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
|
330 |
-
<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>
|
331 |
-
<?php endif; ?>
|
332 |
-
<p id="wpua-preview">
|
333 |
-
<img src="<?php echo $avatar_medium; ?>" alt="" />
|
334 |
-
<?php _e('Original Size'); ?>
|
335 |
-
</p>
|
336 |
-
<p id="wpua-thumbnail">
|
337 |
-
<img src="<?php echo $avatar_thumbnail; ?>" alt="" />
|
338 |
-
<?php _e('Thumbnail'); ?>
|
339 |
-
</p>
|
340 |
-
<p><button type="button" class="button<?php echo $hide_remove; ?>" id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?></button></p>
|
341 |
-
<p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
|
342 |
-
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
343 |
-
</fieldset>
|
344 |
-
<?php else : // Add to profile with admin style ?>
|
345 |
-
</td>
|
346 |
-
</tr>
|
347 |
-
</table>
|
348 |
-
<?php endif; ?>
|
349 |
-
<?php
|
350 |
-
}
|
351 |
-
|
352 |
-
// Set upload size limit for users without upload_files capability
|
353 |
-
function wpua_handle_upload_prefilter($file){
|
354 |
-
global $wpua_upload_size_limit;
|
355 |
-
$size = $file['size'];
|
356 |
-
if($size > $wpua_upload_size_limit){
|
357 |
-
$file['error'] = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
|
358 |
-
}
|
359 |
-
return $file;
|
360 |
-
}
|
361 |
-
|
362 |
-
// Update user meta
|
363 |
-
function wpua_action_process_option_update($user_id){
|
364 |
-
global $blog_id, $wpdb;
|
365 |
-
// Check if user has upload_files capability
|
366 |
-
if(current_user_can('upload_files')){
|
367 |
-
$wpua_id = isset($_POST['wp-user-avatar']) ? intval($_POST['wp-user-avatar']) : "";
|
368 |
-
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
|
369 |
-
add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
370 |
-
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
371 |
-
} else {
|
372 |
-
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
|
373 |
-
// Uploads by user
|
374 |
-
$attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, 'attachment'));
|
375 |
-
foreach($attachments as $attachment){
|
376 |
-
// Delete attachment if not used by another user
|
377 |
-
if(!wpua_image($attachment->ID, $user_id)){
|
378 |
-
wp_delete_post($attachment->ID);
|
379 |
-
}
|
380 |
-
}
|
381 |
-
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
382 |
-
}
|
383 |
-
// Create attachment from upload
|
384 |
-
if(isset($_POST['upload-wp-user-avatar']) && $_POST['upload-wp-user-avatar']){
|
385 |
-
if(!function_exists('wp_handle_upload')){
|
386 |
-
require_once(ABSPATH.'wp-admin/includes/admin.php');
|
387 |
-
require_once(ABSPATH.'wp-admin/includes/file.php');
|
388 |
-
}
|
389 |
-
$name = $_FILES['wp-user-avatar-file']['name'];
|
390 |
-
$file = wp_handle_upload($_FILES['wp-user-avatar-file'], array('test_form' => false));
|
391 |
-
$type = $file['type'];
|
392 |
-
// Allow only JPG, GIF, PNG
|
393 |
-
if($file['error'] || !preg_match('/(jpe?g|gif|png)$/i', $type)){
|
394 |
-
if($file['error']){
|
395 |
-
wp_die($file['error']);
|
396 |
-
} else {
|
397 |
-
wp_die(__('Sorry, this file type is not permitted for security reasons.'));
|
398 |
-
}
|
399 |
-
}
|
400 |
-
// Break out file info
|
401 |
-
$name_parts = pathinfo($name);
|
402 |
-
$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
|
403 |
-
$url = $file['url'];
|
404 |
-
$file = $file['file'];
|
405 |
-
$title = $name;
|
406 |
-
// Use image exif/iptc data for title if possible
|
407 |
-
if($image_meta = @wp_read_image_metadata($file)){
|
408 |
-
if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))){
|
409 |
-
$title = $image_meta['title'];
|
410 |
-
}
|
411 |
-
}
|
412 |
-
// Construct the attachment array
|
413 |
-
$attachment = array(
|
414 |
-
'guid' => $url,
|
415 |
-
'post_mime_type' => $type,
|
416 |
-
'post_title' => $title
|
417 |
-
);
|
418 |
-
// This should never be set as it would then overwrite an existing attachment
|
419 |
-
if(isset($attachment['ID'])){
|
420 |
-
unset($attachment['ID']);
|
421 |
-
}
|
422 |
-
// Save the attachment metadata
|
423 |
-
$attachment_id = wp_insert_attachment($attachment, $file);
|
424 |
-
if(!is_wp_error($attachment_id)){
|
425 |
-
require_once(ABSPATH.'wp-admin/includes/image.php');
|
426 |
-
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
427 |
-
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
|
428 |
-
add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
|
429 |
-
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
|
430 |
-
}
|
431 |
-
}
|
432 |
-
}
|
433 |
-
}
|
434 |
-
|
435 |
-
// Add button to attach image for WP 3.4 and older
|
436 |
-
function wpua_add_attachment_field_to_edit($fields, $post){
|
437 |
-
$image = wp_get_attachment_image_src($post->ID, "medium");
|
438 |
-
$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>';
|
439 |
-
$fields['wp-user-avatar'] = array(
|
440 |
-
'label' => __('WP User Avatar', 'wp-user-avatar'),
|
441 |
-
'input' => 'html',
|
442 |
-
'html' => $button
|
443 |
-
);
|
444 |
-
return $fields;
|
445 |
-
}
|
446 |
-
|
447 |
-
// Add settings link on plugin page
|
448 |
-
function wpua_plugin_settings_links($links, $file){
|
449 |
-
if(basename($file) == basename(plugin_basename(__FILE__))){
|
450 |
-
$settings_link = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('options-general.php')).'">'.__('Settings').'</a>';
|
451 |
-
$links = array_merge($links, array($settings_link));
|
452 |
-
}
|
453 |
-
return $links;
|
454 |
-
}
|
455 |
-
|
456 |
-
// Add column to Users table
|
457 |
-
function wpua_add_column($columns){
|
458 |
-
return $columns + array('wp-user-avatar' => __('WP User Avatar', 'wp-user-avatar'));
|
459 |
-
}
|
460 |
-
|
461 |
-
// Show thumbnail in Users table
|
462 |
-
function wpua_show_column($value, $column_name, $user_id){
|
463 |
-
global $blog_id, $wpdb;
|
464 |
-
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
465 |
-
$wpua_image = wp_get_attachment_image($wpua, array(32,32));
|
466 |
-
if($column_name == 'wp-user-avatar'){
|
467 |
-
return $wpua_image;
|
468 |
-
}
|
469 |
-
}
|
470 |
-
|
471 |
-
// Media uploader
|
472 |
-
function wpua_media_upload_scripts($user=""){
|
473 |
-
global $mustache_admin, $pagenow, $show_avatars, $wpua_upload_size_limit;
|
474 |
-
wp_enqueue_script('jquery');
|
475 |
-
if(current_user_can('upload_files')){
|
476 |
-
wp_enqueue_script('admin-bar');
|
477 |
-
wp_enqueue_media();
|
478 |
-
}
|
479 |
-
wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION, true);
|
480 |
-
wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
|
481 |
-
// Admin scripts
|
482 |
-
if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
|
483 |
-
// Size limit slider
|
484 |
-
wp_enqueue_script('jquery-ui-slider');
|
485 |
-
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URLPATH.'css/jquery.ui.slider.css', "", null);
|
486 |
-
// Remove/edit settings
|
487 |
-
$wpua_custom_scripts = array('section' => __('Default Avatar'), 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $mustache_admin);
|
488 |
-
wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
|
489 |
-
// Settings control
|
490 |
-
wp_enqueue_script('wp-user-avatar-admin', WPUA_URLPATH.'js/wp-user-avatar-admin.js', array('wp-user-avatar'), WPUA_VERSION, true);
|
491 |
-
$wpua_admin_scripts = array('upload_size_limit' => $wpua_upload_size_limit, 'max_upload_size' => wp_max_upload_size());
|
492 |
-
wp_localize_script('wp-user-avatar-admin', 'wpua_admin', $wpua_admin_scripts);
|
493 |
-
} else {
|
494 |
-
// User remove/edit settings
|
495 |
-
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
496 |
-
$wpua_custom_scripts = array('section' => $user->display_name, 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $avatar_medium_src);
|
497 |
-
wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
|
498 |
-
}
|
499 |
-
}
|
500 |
-
}
|
501 |
-
|
502 |
-
// Returns true if user has Gravatar-hosted image
|
503 |
-
function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
|
504 |
-
global $ssl;
|
505 |
-
if(!is_object($id_or_email) && !empty($id_or_email)){
|
506 |
-
// Find user by ID or e-mail address
|
507 |
-
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
508 |
-
// Get registered user e-mail address
|
509 |
-
$email = !empty($user) ? $user->user_email : "";
|
510 |
-
}
|
511 |
-
// Check if Gravatar image returns 200 (OK) or 404 (Not Found)
|
512 |
-
if(!empty($email)){
|
513 |
-
$hash = md5(strtolower(trim($email)));
|
514 |
-
$gravatar = 'http'.$ssl.'://www.gravatar.com/avatar/'.$hash.'?d=404';
|
515 |
-
$headers = @get_headers($gravatar);
|
516 |
-
$has_gravatar = !preg_match("|200|", $headers[0]) ? false : true;
|
517 |
-
}
|
518 |
-
return $has_gravatar;
|
519 |
-
}
|
520 |
-
|
521 |
-
// Returns true if user has wp_user_avatar
|
522 |
-
function has_wp_user_avatar($id_or_email="", $has_wpua=false, $user="", $user_id=""){
|
523 |
-
global $blog_id, $wpdb;
|
524 |
-
if(!is_object($id_or_email) && !empty($id_or_email)){
|
525 |
-
// Find user by ID or e-mail address
|
526 |
-
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
527 |
-
// Get registered user ID
|
528 |
-
$user_id = !empty($user) ? $user->ID : "";
|
529 |
-
}
|
530 |
-
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
531 |
-
$has_wpua = !empty($wpua) ? true : false;
|
532 |
-
return $has_wpua;
|
533 |
-
}
|
534 |
-
|
535 |
-
// Replace get_avatar only in get_wp_user_avatar
|
536 |
-
function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt=""){
|
537 |
-
global $avatar_default, $comment, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar;
|
538 |
-
// User has WPUA
|
539 |
-
if(is_object($id_or_email)){
|
540 |
-
if(!empty($comment->comment_author_email)){
|
541 |
-
$avatar = get_wp_user_avatar($comment, $size, $default, $alt);
|
542 |
-
} else {
|
543 |
-
$avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
|
544 |
-
}
|
545 |
-
} else {
|
546 |
-
if(has_wp_user_avatar($id_or_email)){
|
547 |
-
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
|
548 |
-
// User has Gravatar and Gravatar is not disabled
|
549 |
-
} elseif((bool) $wpua_disable_gravatar != 1 && wpua_has_gravatar($id_or_email)){
|
550 |
-
$avatar = $avatar;
|
551 |
-
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
552 |
-
} elseif($avatar_default == 'wp_user_avatar'){
|
553 |
-
// Show custom Default Avatar
|
554 |
-
if(!empty($wpua_avatar_default)){
|
555 |
-
// Get image
|
556 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
557 |
-
// Image src
|
558 |
-
$default = $wpua_avatar_default_image[0];
|
559 |
-
// Add dimensions if numeric size
|
560 |
-
$dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
|
561 |
-
$defaultcss = "";
|
562 |
-
} else {
|
563 |
-
// Get mustache image based on numeric size comparison
|
564 |
-
if($size > get_option('medium_size_w')){
|
565 |
-
$default = $mustache_original;
|
566 |
-
} elseif($size <= get_option('medium_size_w') && $size > get_option('thumbnail_size_w')){
|
567 |
-
$default = $mustache_medium;
|
568 |
-
} elseif($size <= get_option('thumbnail_size_w') && $size > 96){
|
569 |
-
$default = $mustache_thumbnail;
|
570 |
-
} elseif($size <= 96 && $size > 32){
|
571 |
-
$default = $mustache_avatar;
|
572 |
-
} elseif($size <= 32){
|
573 |
-
$default = $mustache_admin;
|
574 |
-
}
|
575 |
-
// Add dimensions if numeric size
|
576 |
-
$dimensions = ' width="'.$size.'" height="'.$size.'"';
|
577 |
-
$defaultcss = ' avatar-default';
|
578 |
-
}
|
579 |
-
// Construct the img tag
|
580 |
-
$avatar = "<img src='".$default."'".$dimensions." alt='".$alt."' class='wp-user-avatar wp-user-avatar-".$size." avatar avatar-".$size." photo'".$defaultcss." />";
|
581 |
-
}
|
582 |
-
}
|
583 |
-
return $avatar;
|
584 |
-
}
|
585 |
-
add_filter('get_avatar', 'wpua_get_avatar_filter', 10, 6);
|
586 |
-
|
587 |
-
// Get original avatar, for when user removes wp_user_avatar
|
588 |
-
function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt=""){
|
589 |
-
global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar;
|
590 |
-
// Remove get_avatar filter only in admin
|
591 |
-
if(is_admin()){
|
592 |
-
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
593 |
-
}
|
594 |
-
if((bool) $wpua_disable_gravatar != 1){
|
595 |
-
// User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
596 |
-
if(!wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar'){
|
597 |
-
// Show custom Default Avatar
|
598 |
-
if(!empty($wpua_avatar_default)){
|
599 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
600 |
-
$default = $wpua_avatar_default_image[0];
|
601 |
-
} else {
|
602 |
-
$default = $mustache_avatar;
|
603 |
-
}
|
604 |
-
} else {
|
605 |
-
// Get image from Gravatar, whether it's the user's image or default image
|
606 |
-
$wpua_image = get_avatar($id_or_email, $size);
|
607 |
-
// Takes the img tag, extracts the src
|
608 |
-
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
609 |
-
$default = $matches [0] [1];
|
610 |
-
}
|
611 |
-
} else {
|
612 |
-
if(!empty($wpua_avatar_default)){
|
613 |
-
$wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
|
614 |
-
$default = $wpua_avatar_default_image[0];
|
615 |
-
} else {
|
616 |
-
$default = $mustache_avatar;
|
617 |
-
}
|
618 |
-
}
|
619 |
-
return $default;
|
620 |
-
}
|
621 |
-
|
622 |
-
// Find WPUA, show get_avatar if empty
|
623 |
-
function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt=""){
|
624 |
-
global $avatar_default, $blog_id, $comment, $post, $wpdb;
|
625 |
-
// Checks if comment
|
626 |
-
if(is_object($id_or_email)){
|
627 |
-
// Checks if comment author is registered user by user ID
|
628 |
-
if($comment->user_id != 0){
|
629 |
-
$id_or_email = $comment->user_id;
|
630 |
-
// Checks that comment author isn't anonymous
|
631 |
-
} elseif(!empty($comment->comment_author_email)){
|
632 |
-
// Checks if comment author is registered user by e-mail address
|
633 |
-
$user = get_user_by('email', $comment->comment_author_email);
|
634 |
-
// Get registered user info from profile, otherwise e-mail address should be value
|
635 |
-
$id_or_email = !empty($user) ? $user->ID : $comment->comment_author_email;
|
636 |
-
}
|
637 |
-
$alt = $comment->comment_author;
|
638 |
-
} else {
|
639 |
-
if(!empty($id_or_email)){
|
640 |
-
// Find user by ID or e-mail address
|
641 |
-
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
642 |
-
} else {
|
643 |
-
// Find author's name if id_or_email is empty
|
644 |
-
$author_name = get_query_var('author_name');
|
645 |
-
if(is_author()){
|
646 |
-
// On author page, get user by page slug
|
647 |
-
$user = get_user_by('slug', $author_name);
|
648 |
-
} else {
|
649 |
-
// On post, get user by author meta
|
650 |
-
$user_id = get_the_author_meta('ID');
|
651 |
-
$user = get_user_by('id', $user_id);
|
652 |
-
}
|
653 |
-
}
|
654 |
-
// Set user's ID and name
|
655 |
-
if(!empty($user)){
|
656 |
-
$id_or_email = $user->ID;
|
657 |
-
$alt = $user->display_name;
|
658 |
-
}
|
659 |
-
}
|
660 |
-
// Checks if user has WPUA
|
661 |
-
$wpua_meta = !empty($id_or_email) ? get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email) : "";
|
662 |
-
// Add alignment class
|
663 |
-
$alignclass = !empty($align) ? ' align'.$align : "";
|
664 |
-
// User has WPUA, bypass get_avatar
|
665 |
-
if(!empty($wpua_meta)){
|
666 |
-
// Numeric size use size array
|
667 |
-
$get_size = is_numeric($size) ? array($size,$size) : $size;
|
668 |
-
// Get image src
|
669 |
-
$wpua_image = wp_get_attachment_image_src($wpua_meta, $get_size);
|
670 |
-
// Add dimensions to img only if numeric size was specified
|
671 |
-
$dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
|
672 |
-
// Construct the img tag
|
673 |
-
$avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="wp-user-avatar wp-user-avatar-'.$size.$alignclass.' avatar avatar avatar-'.$size.' photo" />';
|
674 |
-
} else {
|
675 |
-
// Get numeric sizes for non-numeric sizes based on media options
|
676 |
-
if($size == 'original' || $size == 'large' || $size == 'medium' || $size == 'thumbnail'){
|
677 |
-
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
678 |
-
} else {
|
679 |
-
// Numeric sizes leave as-is
|
680 |
-
$get_size = $size;
|
681 |
-
}
|
682 |
-
// User with no WPUA uses get_avatar
|
683 |
-
$avatar = get_avatar($id_or_email, $get_size, $default="", $alt="");
|
684 |
-
// Remove width and height for non-numeric sizes
|
685 |
-
if(!is_numeric($size)){
|
686 |
-
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
|
687 |
-
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
|
688 |
-
$avatar = str_replace('wp-user-avatar wp-user-avatar-'.$get_size.' ', "", $avatar);
|
689 |
-
$avatar = str_replace("class='", "class='wp-user-avatar wp-user-avatar-".$size.$alignclass." ", $avatar);
|
690 |
-
}
|
691 |
-
}
|
692 |
-
return $avatar;
|
693 |
-
}
|
694 |
-
|
695 |
-
// Return just the image src
|
696 |
-
function get_wp_user_avatar_src($id_or_email, $size="", $align=""){
|
697 |
-
$wpua_image_src = "";
|
698 |
-
// Gets the avatar img tag
|
699 |
-
$wpua_image = get_wp_user_avatar($id_or_email, $size, $align);
|
700 |
-
// Takes the img tag, extracts the src
|
701 |
-
if(!empty($wpua_image)){
|
702 |
-
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
703 |
-
$wpua_image_src = $matches [0] [1];
|
704 |
-
}
|
705 |
-
return $wpua_image_src;
|
706 |
-
}
|
707 |
-
|
708 |
-
// Shortcode
|
709 |
-
function wpua_shortcode($atts, $content){
|
710 |
-
global $blog_id, $wpdb;
|
711 |
-
// Set shortcode attributes
|
712 |
-
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
|
713 |
-
// Find user by ID, login, slug, or e-mail address
|
714 |
-
if(!empty($user)){
|
715 |
-
$user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
|
716 |
-
$user = empty($user) ? get_user_by('slug', $user) : $user;
|
717 |
-
$user = empty($user) ? get_user_by('email', $user) : $user;
|
718 |
-
}
|
719 |
-
// Get user ID
|
720 |
-
$id_or_email = !empty($user) ? $user->ID : "";
|
721 |
-
// Check if link is set
|
722 |
-
if(!empty($link)){
|
723 |
-
// CSS class is same as link type, except for URL
|
724 |
-
$link_class = $link;
|
725 |
-
// Open in new window
|
726 |
-
$target_link = !empty($target) ? ' target="'.$target.'"' : "";
|
727 |
-
if($link == 'file'){
|
728 |
-
// Get image src
|
729 |
-
$image_link = get_wp_user_avatar_src($id_or_email, 'original', $align);
|
730 |
-
} elseif($link == 'attachment'){
|
731 |
-
// Get attachment URL
|
732 |
-
$image_link = get_attachment_link(get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email));
|
733 |
-
} else {
|
734 |
-
// URL
|
735 |
-
$image_link = $link;
|
736 |
-
$link_class = 'custom';
|
737 |
-
}
|
738 |
-
// Wrap the avatar inside the link
|
739 |
-
$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>';
|
740 |
-
} else {
|
741 |
-
// Get WPUA as normal
|
742 |
-
$avatar = get_wp_user_avatar($id_or_email, $size, $align);
|
743 |
-
}
|
744 |
-
return $avatar;
|
745 |
-
}
|
746 |
-
add_shortcode('avatar', 'wpua_shortcode');
|
747 |
-
|
748 |
-
// Add default avatar
|
749 |
-
function wpua_add_default_avatar($avatar_list=null){
|
750 |
-
global $avatar_default, $mustache_admin, $mustache_medium, $wpua_avatar_default, $wpua_disable_gravatar;
|
751 |
-
// Remove get_avatar filter
|
752 |
-
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
753 |
-
// Set avatar_list variable
|
754 |
-
$avatar_list = "";
|
755 |
-
// Set avatar defaults
|
756 |
-
$avatar_defaults = array(
|
757 |
-
'mystery' => __('Mystery Man'),
|
758 |
-
'blank' => __('Blank'),
|
759 |
-
'gravatar_default' => __('Gravatar Logo'),
|
760 |
-
'identicon' => __('Identicon (Generated)'),
|
761 |
-
'wavatar' => __('Wavatar (Generated)'),
|
762 |
-
'monsterid' => __('MonsterID (Generated)'),
|
763 |
-
'retro' => __('Retro (Generated)')
|
764 |
-
);
|
765 |
-
// No Default Avatar, set to Mystery Man
|
766 |
-
if(empty($avatar_default)){
|
767 |
-
$avatar_default = 'mystery';
|
768 |
-
}
|
769 |
-
// Take avatar_defaults and get examples for unknown@gravatar.com
|
770 |
-
foreach($avatar_defaults as $default_key => $default_name){
|
771 |
-
$avatar = get_avatar('unknown@gravatar.com', 32, $default_key);
|
772 |
-
$selected = ($avatar_default == $default_key) ? 'checked="checked" ' : "";
|
773 |
-
$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='".esc_attr($default_key)."' {$selected}/> ";
|
774 |
-
$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&forcedefault=1'", $avatar);
|
775 |
-
$avatar_list .= ' '.$default_name.'</label>';
|
776 |
-
$avatar_list .= '<br />';
|
777 |
-
}
|
778 |
-
// Show remove link if custom Default Avatar is set
|
779 |
-
if(!empty($wpua_avatar_default)){
|
780 |
-
$avatar_thumb_src = wp_get_attachment_image_src($wpua_avatar_default, array(32,32));
|
781 |
-
$avatar_thumb = $avatar_thumb_src[0];
|
782 |
-
$hide_remove = "";
|
783 |
-
} else {
|
784 |
-
$avatar_thumb = $mustache_admin;
|
785 |
-
$hide_remove = ' class="wpua-hide"';
|
786 |
-
}
|
787 |
-
// Default Avatar is wp_user_avatar, check the radio button next to it
|
788 |
-
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
789 |
-
// Wrap WPUA in div
|
790 |
-
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
|
791 |
-
// Add WPUA to list
|
792 |
-
$wpua_list = "\n\t<label><input type='radio' name='avatar_default' id='wp_user_avatar_radio' value='wp_user_avatar'$selected_avatar /> ";
|
793 |
-
$wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
|
794 |
-
$wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
|
795 |
-
$wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add">'.__('Edit Image').'</button>';
|
796 |
-
$wpua_list .= '<a href="#" id="wpua-remove"'.$hide_remove.'>'.__('Remove').'</a></p>';
|
797 |
-
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
|
798 |
-
$wpua_list .= '<p id="wpua-message">'.sprintf(__('Click %s to save your changes', 'wp-user-avatar'), '“'.__('Save Changes').'”').'</p>';
|
799 |
-
if((bool) $wpua_disable_gravatar != 1){
|
800 |
-
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
|
801 |
-
} else {
|
802 |
-
return $wpua_list;
|
803 |
-
}
|
804 |
-
}
|
805 |
-
add_filter('default_avatar_select', 'wpua_add_default_avatar', 10);
|
806 |
-
|
807 |
-
// Add default avatar_default to whitelist
|
808 |
-
function wpua_whitelist_options($whitelist_options){
|
809 |
-
$whitelist_options['discussion'][] = 'avatar_default_wp_user_avatar';
|
810 |
-
return $whitelist_options;
|
811 |
-
}
|
812 |
-
add_filter('whitelist_options', 'wpua_whitelist_options', 10);
|
813 |
-
|
814 |
-
// Add media state
|
815 |
-
function wpua_add_media_state($media_states){
|
816 |
-
global $post, $wpua_avatar_default;
|
817 |
-
$is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
|
818 |
-
if(!empty($is_wpua)){
|
819 |
-
$media_states[] = __('Avatar');
|
820 |
-
}
|
821 |
-
if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)){
|
822 |
-
$media_states[] = __('Default Avatar');
|
823 |
-
}
|
824 |
-
return apply_filters('wpua_add_media_state', $media_states);
|
825 |
-
}
|
826 |
-
add_filter('display_media_states', 'wpua_add_media_state', 10, 1);
|
827 |
-
|
828 |
-
// Check if image is used as WPUA
|
829 |
-
function wpua_image($attachment_id, $user_id, $wpua_image=false){
|
830 |
-
global $wpdb;
|
831 |
-
$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));
|
832 |
-
if(!empty($wpua)){
|
833 |
-
$wpua_image = true;
|
834 |
-
}
|
835 |
-
return $wpua_image;
|
836 |
-
}
|
837 |
-
|
838 |
-
// Check who owns image
|
839 |
-
function wpua_author($attachment_id, $user_id, $wpua_author=false){
|
840 |
-
$attachment = get_post($attachment_id);
|
841 |
-
if(!empty($attachment) && $attachment->post_author == $user_id){
|
842 |
-
$wpua_author = true;
|
843 |
-
}
|
844 |
-
return $wpua_author;
|
845 |
-
}
|
846 |
-
|
847 |
-
// Admin page
|
848 |
-
function wpua_options_page(){
|
849 |
-
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;
|
850 |
-
// Give subscribers edit_posts capability
|
851 |
-
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && (empty($wpua_allow_upload) || empty($wpua_edit_avatar))){
|
852 |
-
wpua_subscriber_remove_cap();
|
853 |
-
}
|
854 |
-
$hide_size = (bool) $wpua_allow_upload != 1 ? ' class="wpua-hide"' : "";
|
855 |
-
?>
|
856 |
-
<div class="wrap">
|
857 |
-
<?php screen_icon(); ?>
|
858 |
-
<h2><?php _e('WP User Avatar', 'wp-user-avatar'); ?></h2>
|
859 |
-
<form method="post" action="options.php">
|
860 |
-
<?php settings_fields('wpua-settings-group'); ?>
|
861 |
-
<?php do_settings_fields('wpua-settings-group', ""); ?>
|
862 |
-
<table class="form-table">
|
863 |
-
<tr valign="top">
|
864 |
-
<th scope="row"><?php _e('Settings'); ?></th>
|
865 |
-
<td>
|
866 |
-
<fieldset>
|
867 |
-
<legend class="screen-reader-text"><span><?php _e('Settings'); ?></span></legend>
|
868 |
-
<label for="wp_user_avatar_tinymce">
|
869 |
-
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" <?php checked($wpua_tinymce, 1); ?> />
|
870 |
-
<?php _e('Add avatar button to Visual Editor', 'wp-user-avatar'); ?>
|
871 |
-
</label>
|
872 |
-
<br />
|
873 |
-
<label for="wp_user_avatar_allow_upload">
|
874 |
-
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" <?php checked($wpua_allow_upload, 1); ?> />
|
875 |
-
<?php _e('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar'); ?>
|
876 |
-
</label>
|
877 |
-
<br />
|
878 |
-
<label for="wp_user_avatar_disable_gravatar">
|
879 |
-
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
|
880 |
-
<?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
|
881 |
-
</label>
|
882 |
-
</fieldset>
|
883 |
-
</td>
|
884 |
-
</tr>
|
885 |
-
<tr id="wpua-size-limit" valign="top"<?php echo $hide_size; ?>>
|
886 |
-
<th scope="row">
|
887 |
-
<label for="wp_user_avatar_upload_size_limit">
|
888 |
-
<?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
|
889 |
-
</label>
|
890 |
-
</th>
|
891 |
-
<td>
|
892 |
-
<fieldset>
|
893 |
-
<legend class="screen-reader-text"><span><?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?></span></legend>
|
894 |
-
<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" />
|
895 |
-
<span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
|
896 |
-
<span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ""); ?></span>
|
897 |
-
<div id="wpua-slider"></div>
|
898 |
-
<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>
|
899 |
-
<br />
|
900 |
-
<label for="wp_user_avatar_edit_avatar">
|
901 |
-
<input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" <?php checked($wpua_edit_avatar, 1); ?> />
|
902 |
-
<?php _e('Allow users to edit avatars', 'wp-user-avatar'); ?>
|
903 |
-
</label>
|
904 |
-
</fieldset>
|
905 |
-
</td>
|
906 |
-
</tr>
|
907 |
-
</table>
|
908 |
-
<h3 class="title"><?php _e('Avatars'); ?></h3>
|
909 |
-
<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>
|
910 |
-
<table class="form-table">
|
911 |
-
<tr valign="top">
|
912 |
-
<th scope="row"><?php _e('Avatar Display'); ?></th>
|
913 |
-
<td>
|
914 |
-
<fieldset>
|
915 |
-
<legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
|
916 |
-
<label for="show_avatars">
|
917 |
-
<input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked($show_avatars, 1); ?> />
|
918 |
-
<?php _e('Show Avatars'); ?>
|
919 |
-
</label>
|
920 |
-
</fieldset>
|
921 |
-
</td>
|
922 |
-
</tr>
|
923 |
-
<tr valign="top">
|
924 |
-
<th scope="row"><?php _e('Maximum Rating'); ?></th>
|
925 |
-
<td>
|
926 |
-
<fieldset>
|
927 |
-
<legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
|
928 |
-
<?php
|
929 |
-
$ratings = array(
|
930 |
-
'G' => __('G — Suitable for all audiences'),
|
931 |
-
'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'),
|
932 |
-
'R' => __('R — Intended for adult audiences above 17'),
|
933 |
-
'X' => __('X — Even more mature than above')
|
934 |
-
);
|
935 |
-
foreach ($ratings as $key => $rating) :
|
936 |
-
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : "";
|
937 |
-
echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
|
938 |
-
endforeach;
|
939 |
-
?>
|
940 |
-
</fieldset>
|
941 |
-
</td>
|
942 |
-
</tr>
|
943 |
-
<tr valign="top">
|
944 |
-
<th scope="row"><?php _e('Default Avatar') ?></th>
|
945 |
-
<td class="defaultavatarpicker">
|
946 |
-
<fieldset>
|
947 |
-
<legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
|
948 |
-
<?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 />
|
949 |
-
<?php echo wpua_add_default_avatar(); ?>
|
950 |
-
</fieldset>
|
951 |
-
</td>
|
952 |
-
</tr>
|
953 |
-
</table>
|
954 |
-
<?php submit_button(); ?>
|
955 |
-
</form>
|
956 |
-
</div>
|
957 |
-
<?php
|
958 |
-
}
|
959 |
-
|
960 |
-
// Whitelist settings
|
961 |
-
function wpua_admin_settings(){
|
962 |
-
register_setting('wpua-settings-group', 'avatar_rating');
|
963 |
-
register_setting('wpua-settings-group', 'avatar_default');
|
964 |
-
register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar', 'intval');
|
965 |
-
register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
966 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
967 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
968 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
969 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
|
970 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
971 |
-
}
|
972 |
-
|
973 |
-
// Add options page and settings
|
974 |
-
function wpua_admin(){
|
975 |
-
add_options_page(__('WP User Avatar', 'wp-user-avatar'), __('WP User Avatar', 'wp-user-avatar'), 'manage_options', 'wp-user-avatar', 'wpua_options_page');
|
976 |
-
add_action('admin_init', 'wpua_admin_settings');
|
977 |
-
}
|
978 |
-
|
979 |
-
// Initialize WPUA after other plugins are loaded
|
980 |
-
function wpua_load(){
|
981 |
-
global $wpua_instance;
|
982 |
-
$wpua_instance = new wp_user_avatar();
|
983 |
-
}
|
984 |
-
add_action('plugins_loaded', 'wpua_load');
|
985 |
-
}
|
986 |
-
?>
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.9.3
|
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: Bangbay Siboliban
|
12 |
Author URI: http://siboliban.org/
|
13 |
+
Version: 1.9.3
|
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 |
+
class WP_User_Avatar_Setup {
|
23 |
+
function __construct() {
|
24 |
+
$this->_define_constants();
|
25 |
+
$this->_load_wp_includes();
|
26 |
+
$this->_load_wpua();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
|
|
28 |
|
29 |
+
// Define paths
|
30 |
+
function _define_constants() {
|
31 |
+
define('WPUA_VERSION', '1.9.3');
|
32 |
+
define('WPUA_FOLDER', basename(dirname(__FILE__)));
|
33 |
+
define('WPUA_DIR', plugin_dir_path(__FILE__));
|
34 |
+
define('WPUA_INC', WPUA_DIR.'includes'.'/');
|
35 |
+
define('WPUA_URL', plugin_dir_url(WPUA_FOLDER).WPUA_FOLDER.'/');
|
36 |
+
define('WPUA_INC_URL', WPUA_URL.'includes'.'/');
|
37 |
}
|
|
|
38 |
|
39 |
+
// WordPress includes used in plugin
|
40 |
+
function _load_wp_includes() {
|
41 |
+
require_once(ABSPATH.'wp-admin/includes/file.php');
|
42 |
+
require_once(ABSPATH.'wp-admin/includes/image.php');
|
43 |
+
require_once(ABSPATH.'wp-admin/includes/media.php');
|
44 |
+
require_once(ABSPATH.'wp-admin/includes/screen.php');
|
45 |
+
require_once(ABSPATH.'wp-admin/includes/template.php');
|
|
|
46 |
}
|
|
|
47 |
|
48 |
+
// WP User Avatar
|
49 |
+
function _load_wpua() {
|
50 |
+
require_once(WPUA_INC.'wpua-globals.php');
|
51 |
+
require_once(WPUA_INC.'wpua-functions.php');
|
52 |
+
require_once(WPUA_INC.'class-wp-user-avatar-admin.php');
|
53 |
+
require_once(WPUA_INC.'class-wp-user-avatar.php');
|
54 |
+
require_once(WPUA_INC.'class-wp-user-avatar-functions.php');
|
55 |
+
require_once(WPUA_INC.'class-wp-user-avatar-shortcode.php');
|
56 |
+
require_once(WPUA_INC.'class-wp-user-avatar-subscriber.php');
|
57 |
+
require_once(WPUA_INC.'class-wp-user-avatar-update.php');
|
|
|
|
|
|
|
|
|
58 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
+
$wpua_setup = new WP_User_Avatar_Setup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|