Version Description
- Bug Fix: Bad reference to wpua_is_author_or_above
Download this release
Release Info
Developer | bangbay |
Plugin | WP User Avatar |
Version | 1.8.7 |
Comparing to | |
See all releases |
Code changes from version 1.5.4 to 1.8.7
- css/wp-user-avatar.css +5 -5
- images/{wp-user-avatar-150x150.png → wpua-150x150.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 +223 -0
- includes/class-wp-user-avatar-list-table.php +278 -0
- includes/class-wp-user-avatar-shortcode.php +143 -0
- includes/class-wp-user-avatar-subscriber.php +83 -0
- includes/class-wp-user-avatar-update.php +72 -0
- includes/class-wp-user-avatar.php +281 -0
- includes/tinymce/editor_plugin.js +1 -1
- includes/tinymce/window.php +121 -69
- includes/wpua-functions.php +297 -0
- includes/wpua-globals.php +54 -0
- includes/wpua-media-page.php +66 -0
- includes/wpua-options-page.php +150 -0
- includes/{tinymce.php → wpua-tinymce.php} +12 -17
- js/wp-user-avatar-admin.js +25 -22
- js/wp-user-avatar-user.js +30 -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 +268 -32
- uninstall.php +19 -9
- wp-user-avatar.php +23 -964
css/wp-user-avatar.css
CHANGED
@@ -1,11 +1,11 @@
|
|
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 { margin-left: 10px !important; }
|
|
|
9 |
#wpua-slider { width: 22.75em; }
|
10 |
+
#wpua-upload-messages span { display: block; }
|
11 |
.wpua-hide { display: none !important; }
|
images/{wp-user-avatar-150x150.png → wpua-150x150.png}
RENAMED
File without changes
|
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,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines all of administrative, activation, and deactivation settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.8.7
|
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(__FILE__, 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(__FILE__, 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 |
+
// Default avatar
|
23 |
+
add_filter('default_avatar_select', array($this, 'wpua_add_default_avatar'), 10);
|
24 |
+
add_filter('whitelist_options', array($this, 'wpua_whitelist_options'), 10);
|
25 |
+
// Additional plugin info
|
26 |
+
add_filter('plugin_action_links', array($this, 'wpua_action_links'), 10, 2);
|
27 |
+
add_filter('plugin_row_meta', array($this, 'wpua_row_meta'), 10, 2);
|
28 |
+
// Hide column in Users table if default avatars are enabled
|
29 |
+
if((bool) $show_avatars == 0 && is_admin()){
|
30 |
+
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
31 |
+
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
|
32 |
+
}
|
33 |
+
// Media states
|
34 |
+
add_filter('display_media_states', array($this, 'wpua_add_media_state'), 10, 1);
|
35 |
+
// Load TinyMCE only if enabled
|
36 |
+
if((bool) $wpua_tinymce == 1){
|
37 |
+
include_once(WPUA_INC.'wpua-tinymce.php');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
// Settings saved to wp_options
|
42 |
+
public function wpua_options() {
|
43 |
+
add_option('avatar_default_wp_user_avatar', "");
|
44 |
+
add_option('wp_user_avatar_allow_upload', '0');
|
45 |
+
add_option('wp_user_avatar_disable_gravatar', '0');
|
46 |
+
add_option('wp_user_avatar_edit_avatar', '1');
|
47 |
+
add_option('wp_user_avatar_resize_crop', '0');
|
48 |
+
add_option('wp_user_avatar_resize_h', '96');
|
49 |
+
add_option('wp_user_avatar_resize_upload', '0');
|
50 |
+
add_option('wp_user_avatar_resize_w', '96');
|
51 |
+
add_option('wp_user_avatar_tinymce', '1');
|
52 |
+
add_option('wp_user_avatar_upload_size_limit', '0');
|
53 |
+
}
|
54 |
+
|
55 |
+
// On deactivation
|
56 |
+
public function wpua_deactivate() {
|
57 |
+
global $wpua_subscriber;
|
58 |
+
// Remove subscribers edit_posts capability
|
59 |
+
$wpua_subscriber->wpua_subscriber_remove_cap();
|
60 |
+
// Reset all default avatar to Mystery Man
|
61 |
+
update_option('avatar_default', 'mystery');
|
62 |
+
}
|
63 |
+
|
64 |
+
// Add options page and settings
|
65 |
+
public function wpua_admin() {
|
66 |
+
add_menu_page(__('WP User Avatar', 'wp-user-avatar'), __('WP User Avatar', 'wp-user-avatar'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'), WPUA_URL.'images/wpua-icon.png');
|
67 |
+
add_submenu_page('wp-user-avatar', __('Settings'), __('Settings'), 'manage_options', 'wp-user-avatar', array($this, 'wpua_options_page'));
|
68 |
+
add_submenu_page('wp-user-avatar', __('Library'), __('Library'), 'manage_options', 'wp-user-avatar-library', array($this, 'wpua_media_page'));
|
69 |
+
add_action('admin_init', array($this, 'wpua_admin_settings'));
|
70 |
+
}
|
71 |
+
|
72 |
+
// Checks if current page is settings page
|
73 |
+
public function wpua_is_menu_page() {
|
74 |
+
global $pagenow;
|
75 |
+
$is_menu_page = ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar') ? true : false;
|
76 |
+
return $is_menu_page;
|
77 |
+
}
|
78 |
+
|
79 |
+
// Media page
|
80 |
+
public function wpua_media_page() {
|
81 |
+
require_once(WPUA_INC.'wpua-media-page.php');
|
82 |
+
}
|
83 |
+
|
84 |
+
// Options page
|
85 |
+
public function wpua_options_page() {
|
86 |
+
require_once(WPUA_INC.'wpua-options-page.php');
|
87 |
+
}
|
88 |
+
|
89 |
+
// Whitelist settings
|
90 |
+
public function wpua_admin_settings() {
|
91 |
+
register_setting('wpua-settings-group', 'avatar_rating');
|
92 |
+
register_setting('wpua-settings-group', 'avatar_default');
|
93 |
+
register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar', 'intval');
|
94 |
+
register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
95 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
96 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
97 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
98 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
|
99 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_crop', 'intval');
|
100 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_h', 'intval');
|
101 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_upload', 'intval');
|
102 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_w', 'intval');
|
103 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
104 |
+
}
|
105 |
+
|
106 |
+
// Add default avatar
|
107 |
+
public function wpua_add_default_avatar($avatar_list=null){
|
108 |
+
global $avatar_default, $mustache_admin, $mustache_medium, $wpua_avatar_default, $wpua_disable_gravatar;
|
109 |
+
// Remove get_avatar filter
|
110 |
+
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
111 |
+
// Set avatar_list variable
|
112 |
+
$avatar_list = "";
|
113 |
+
// Set avatar defaults
|
114 |
+
$avatar_defaults = array(
|
115 |
+
'mystery' => __('Mystery Man'),
|
116 |
+
'blank' => __('Blank'),
|
117 |
+
'gravatar_default' => __('Gravatar Logo'),
|
118 |
+
'identicon' => __('Identicon (Generated)'),
|
119 |
+
'wavatar' => __('Wavatar (Generated)'),
|
120 |
+
'monsterid' => __('MonsterID (Generated)'),
|
121 |
+
'retro' => __('Retro (Generated)')
|
122 |
+
);
|
123 |
+
// No Default Avatar, set to Mystery Man
|
124 |
+
if(empty($avatar_default)){
|
125 |
+
$avatar_default = 'mystery';
|
126 |
+
}
|
127 |
+
// Take avatar_defaults and get examples for unknown@gravatar.com
|
128 |
+
foreach($avatar_defaults as $default_key => $default_name){
|
129 |
+
$avatar = get_avatar('unknown@gravatar.com', 32, $default_key);
|
130 |
+
$selected = ($avatar_default == $default_key) ? 'checked="checked" ' : "";
|
131 |
+
$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='".esc_attr($default_key)."' {$selected}/> ";
|
132 |
+
$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&forcedefault=1'", $avatar);
|
133 |
+
$avatar_list .= ' '.$default_name.'</label>';
|
134 |
+
$avatar_list .= '<br />';
|
135 |
+
}
|
136 |
+
// Show remove link if custom Default Avatar is set
|
137 |
+
if(!empty($wpua_avatar_default) && wp_attachment_is_image($wpua_avatar_default)){
|
138 |
+
$avatar_thumb_src = wp_get_attachment_image_src($wpua_avatar_default, array(32,32));
|
139 |
+
$avatar_thumb = $avatar_thumb_src[0];
|
140 |
+
$hide_remove = "";
|
141 |
+
} else {
|
142 |
+
$avatar_thumb = $mustache_admin;
|
143 |
+
$hide_remove = ' class="wpua-hide"';
|
144 |
+
}
|
145 |
+
// Default Avatar is wp_user_avatar, check the radio button next to it
|
146 |
+
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
147 |
+
// Wrap WPUA in div
|
148 |
+
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
|
149 |
+
// Add WPUA to list
|
150 |
+
$wpua_list = "\n\t<label><input type='radio' name='avatar_default' id='wp_user_avatar_radio' value='wp_user_avatar'$selected_avatar /> ";
|
151 |
+
$wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
|
152 |
+
$wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
|
153 |
+
$wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add">'.__('Choose Image').'</button>';
|
154 |
+
$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>';
|
155 |
+
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
|
156 |
+
if((bool) $wpua_disable_gravatar != 1){
|
157 |
+
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
|
158 |
+
} else {
|
159 |
+
return $wpua_list;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
// Add default avatar_default to whitelist
|
164 |
+
public function wpua_whitelist_options($whitelist_options){
|
165 |
+
$whitelist_options['discussion'][] = 'avatar_default_wp_user_avatar';
|
166 |
+
return $whitelist_options;
|
167 |
+
}
|
168 |
+
|
169 |
+
// Add actions links on plugin page
|
170 |
+
public function wpua_action_links($links, $file){
|
171 |
+
if(basename($file) == basename(plugin_basename(__FILE__))){
|
172 |
+
$settings_link = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('admin.php')).'">'.__('Settings').'</a>';
|
173 |
+
$links = array_merge($links, array($settings_link));
|
174 |
+
}
|
175 |
+
return $links;
|
176 |
+
}
|
177 |
+
|
178 |
+
// Add row meta on plugin page
|
179 |
+
public function wpua_row_meta($links, $file){
|
180 |
+
if(basename($file) == basename(plugin_basename(__FILE__))){
|
181 |
+
$support_link = '<a href="http://wordpress.org/support/plugin/wp-user-avatar" target="_blank">'.__('Support Forums').'</a>';
|
182 |
+
$donate_link = '<a href="http://siboliban.org/donate" target="_blank">'.__('Donate', 'wp-user-avatar').'</a>';
|
183 |
+
$links = array_merge($links, array($support_link, $donate_link));
|
184 |
+
}
|
185 |
+
return $links;
|
186 |
+
}
|
187 |
+
|
188 |
+
// Add column to Users table
|
189 |
+
public function wpua_add_column($columns){
|
190 |
+
return $columns + array('wp-user-avatar' => __('WP User Avatar', 'wp-user-avatar'));
|
191 |
+
}
|
192 |
+
|
193 |
+
// Show thumbnail in Users table
|
194 |
+
public function wpua_show_column($value, $column_name, $user_id){
|
195 |
+
global $blog_id, $wpdb;
|
196 |
+
$wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
197 |
+
$wpua_image = wp_get_attachment_image($wpua, array(32,32));
|
198 |
+
if($column_name == 'wp-user-avatar'){ $value = $wpua_image; }
|
199 |
+
return $value;
|
200 |
+
}
|
201 |
+
|
202 |
+
// Get list table
|
203 |
+
public function _wpua_get_list_table($class, $args = array()){
|
204 |
+
require_once(WPUA_INC.'class-wp-user-avatar-list-table.php');
|
205 |
+
$args['screen'] = 'wp-user-avatar';
|
206 |
+
return new $class($args);
|
207 |
+
}
|
208 |
+
|
209 |
+
// Add media states
|
210 |
+
public function wpua_add_media_state($media_states) {
|
211 |
+
global $post, $wpua_avatar_default;
|
212 |
+
$is_wpua = get_post_custom_values('_wp_attachment_wp_user_avatar', $post->ID);
|
213 |
+
if(!empty($is_wpua)) {
|
214 |
+
$media_states[] = __('Avatar');
|
215 |
+
}
|
216 |
+
if(!empty($wpua_avatar_default) && ($wpua_avatar_default == $post->ID)) {
|
217 |
+
$media_states[] = __('Default Avatar');
|
218 |
+
}
|
219 |
+
return apply_filters('wpua_add_media_state', $media_states);
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
$wpua_admin = new WP_User_Avatar_Admin();
|
includes/class-wp-user-avatar-list-table.php
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Based on WP_Media_List_Table class.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.8.7
|
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 |
+
$q = array(
|
13 |
+
'post_type' => 'attachment',
|
14 |
+
'post_status' => 'inherit',
|
15 |
+
'posts_per_page' => '-1',
|
16 |
+
'meta_query' => array(
|
17 |
+
array(
|
18 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
19 |
+
'value' => '',
|
20 |
+
'compare' => '!='
|
21 |
+
)
|
22 |
+
)
|
23 |
+
);
|
24 |
+
$avatars_wp_query = new WP_Query($q);
|
25 |
+
$avatars_array = array();
|
26 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
27 |
+
$avatars_array[] = $post->ID;
|
28 |
+
endwhile;
|
29 |
+
wp_reset_query();
|
30 |
+
// Include default avatar
|
31 |
+
$avatars_array[] = $wpua_avatar_default;
|
32 |
+
parent::__construct(array(
|
33 |
+
'plural' => 'media',
|
34 |
+
'screen' => isset($args['screen']) ? $args['screen'] : null
|
35 |
+
));
|
36 |
+
}
|
37 |
+
|
38 |
+
function ajax_user_can() {
|
39 |
+
return current_user_can('upload_files');
|
40 |
+
}
|
41 |
+
|
42 |
+
function prepare_items() {
|
43 |
+
global $avatars_array, $lost, $wpdb, $wp_query, $post_mime_types, $avail_post_mime_types, $post;
|
44 |
+
$q = $_REQUEST;
|
45 |
+
$q['post__in'] = $avatars_array;
|
46 |
+
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
|
47 |
+
$this->is_trash = isset($_REQUEST['status']) && 'trash' == $_REQUEST['status'];
|
48 |
+
$this->set_pagination_args(array(
|
49 |
+
'total_items' => $wp_query->found_posts,
|
50 |
+
'total_pages' => $wp_query->max_num_pages,
|
51 |
+
'per_page' => $wp_query->query_vars['posts_per_page'],
|
52 |
+
));
|
53 |
+
}
|
54 |
+
|
55 |
+
function get_views() {
|
56 |
+
global $avatars_array;
|
57 |
+
$type_links = array();
|
58 |
+
$_total_posts = count($avatars_array);
|
59 |
+
$class = (empty($_GET['post_mime_type']) && !isset($_GET['status'])) ? ' class="current"' : '';
|
60 |
+
$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>';
|
61 |
+
return $type_links;
|
62 |
+
}
|
63 |
+
|
64 |
+
function get_bulk_actions() {
|
65 |
+
$actions = array();
|
66 |
+
$actions['delete'] = __('Delete Permanently');
|
67 |
+
return $actions;
|
68 |
+
}
|
69 |
+
|
70 |
+
function extra_tablenav($which) { ?>
|
71 |
+
<div class="alignleft actions">
|
72 |
+
<?php
|
73 |
+
if($this->is_trash && current_user_can('edit_others_posts')) {
|
74 |
+
submit_button(__('Empty Trash'), 'apply', 'delete_all', false );
|
75 |
+
}
|
76 |
+
?>
|
77 |
+
</div>
|
78 |
+
<?php
|
79 |
+
}
|
80 |
+
|
81 |
+
function current_action() {
|
82 |
+
if(isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) {
|
83 |
+
return 'delete_all';
|
84 |
+
}
|
85 |
+
return parent::current_action();
|
86 |
+
}
|
87 |
+
|
88 |
+
function has_items() {
|
89 |
+
return have_posts();
|
90 |
+
}
|
91 |
+
|
92 |
+
function no_items() {
|
93 |
+
_e('No media attachments found.');
|
94 |
+
}
|
95 |
+
|
96 |
+
function get_columns() {
|
97 |
+
$posts_columns = array();
|
98 |
+
$posts_columns['cb'] = '<input type="checkbox" />';
|
99 |
+
$posts_columns['icon'] = '';
|
100 |
+
$posts_columns['title'] = _x('File', 'column name');
|
101 |
+
$posts_columns['author'] = __('Author');
|
102 |
+
$posts_columns['parent'] = _x('Uploaded to', 'column name');
|
103 |
+
$posts_columns['date'] = _x('Date', 'column name');
|
104 |
+
return $posts_columns;
|
105 |
+
}
|
106 |
+
|
107 |
+
function get_sortable_columns() {
|
108 |
+
return array(
|
109 |
+
'title' => 'title',
|
110 |
+
'author' => 'author',
|
111 |
+
'date' => array('date', true),
|
112 |
+
);
|
113 |
+
}
|
114 |
+
|
115 |
+
function display_rows() {
|
116 |
+
global $post, $wpdb;
|
117 |
+
add_filter('the_title','esc_html');
|
118 |
+
$alt = '';
|
119 |
+
while (have_posts()) : the_post();
|
120 |
+
$user_can_edit = current_user_can('edit_post', $post->ID);
|
121 |
+
|
122 |
+
if($this->is_trash && $post->post_status != 'trash' || !$this->is_trash && $post->post_status == 'trash')
|
123 |
+
continue;
|
124 |
+
|
125 |
+
$alt = ('alternate' == $alt) ? '' : 'alternate';
|
126 |
+
$post_owner = (get_current_user_id() == $post->post_author) ? 'self' : 'other';
|
127 |
+
$att_title = _draft_or_post_title();
|
128 |
+
?>
|
129 |
+
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim($alt.' author-'.$post_owner.' status-'.$post->post_status); ?>' valign="top">
|
130 |
+
<?php
|
131 |
+
list( $columns, $hidden ) = $this->get_column_info();
|
132 |
+
foreach($columns as $column_name => $column_display_name) {
|
133 |
+
$class = "class='$column_name column-$column_name'";
|
134 |
+
$style = '';
|
135 |
+
if(in_array($column_name, $hidden)) {
|
136 |
+
$style = ' style="display:none;"';
|
137 |
+
}
|
138 |
+
$attributes = $class.$style;
|
139 |
+
switch($column_name) {
|
140 |
+
case 'cb':
|
141 |
+
?>
|
142 |
+
<th scope="row" class="check-column">
|
143 |
+
<?php if ( $user_can_edit ) { ?>
|
144 |
+
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php echo sprintf( __( 'Select %s' ), $att_title );?></label>
|
145 |
+
<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
|
146 |
+
<?php } ?>
|
147 |
+
</th>
|
148 |
+
<?php
|
149 |
+
break;
|
150 |
+
case 'icon':
|
151 |
+
$attributes = 'class="column-icon media-icon"'.$style;
|
152 |
+
?>
|
153 |
+
<td <?php echo $attributes ?>><?php
|
154 |
+
if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
|
155 |
+
if ( $this->is_trash || ! $user_can_edit ) {
|
156 |
+
echo $thumb;
|
157 |
+
} else {
|
158 |
+
?>
|
159 |
+
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
|
160 |
+
<?php echo $thumb; ?>
|
161 |
+
</a>
|
162 |
+
<?php } }
|
163 |
+
?>
|
164 |
+
</td>
|
165 |
+
<?php
|
166 |
+
break;
|
167 |
+
case 'title':
|
168 |
+
?>
|
169 |
+
<td <?php echo $attributes ?>><strong>
|
170 |
+
<?php if ( $this->is_trash || ! $user_can_edit ) {
|
171 |
+
echo $att_title;
|
172 |
+
} else { ?>
|
173 |
+
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>"
|
174 |
+
title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
|
175 |
+
<?php echo $att_title; ?></a>
|
176 |
+
<?php };
|
177 |
+
_media_states( $post ); ?></strong>
|
178 |
+
<p>
|
179 |
+
<?php
|
180 |
+
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
|
181 |
+
echo esc_html( strtoupper( $matches[1] ) );
|
182 |
+
else
|
183 |
+
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
|
184 |
+
?>
|
185 |
+
</p>
|
186 |
+
<?php echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); ?>
|
187 |
+
</td>
|
188 |
+
<?php
|
189 |
+
break;
|
190 |
+
case 'author':
|
191 |
+
?>
|
192 |
+
<td <?php echo $attributes ?>>
|
193 |
+
<?php
|
194 |
+
printf( '<a href="%s">%s</a>',
|
195 |
+
esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
|
196 |
+
get_the_author()
|
197 |
+
); ?>
|
198 |
+
</td>
|
199 |
+
<?php
|
200 |
+
break;
|
201 |
+
case 'date':
|
202 |
+
if ( '0000-00-00 00:00:00' == $post->post_date ) {
|
203 |
+
$h_time = __( 'Unpublished' );
|
204 |
+
} else {
|
205 |
+
$m_time = $post->post_date;
|
206 |
+
$time = get_post_time( 'G', true, $post, false );
|
207 |
+
if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
|
208 |
+
if ( $t_diff < 0 )
|
209 |
+
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
|
210 |
+
else
|
211 |
+
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
|
212 |
+
} else {
|
213 |
+
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
|
214 |
+
}
|
215 |
+
}
|
216 |
+
?>
|
217 |
+
<td <?php echo $attributes ?>><?php echo $h_time ?></td>
|
218 |
+
<?php
|
219 |
+
break;
|
220 |
+
case 'parent':
|
221 |
+
global $blog_id, $wpdb;
|
222 |
+
// Find all users with this WPUA
|
223 |
+
$wpua_metakey = $wpdb->get_blog_prefix($blog_id).'user_avatar';
|
224 |
+
$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));
|
225 |
+
// Find users without WPUA
|
226 |
+
$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, ""));
|
227 |
+
$user_array = array();
|
228 |
+
?>
|
229 |
+
<td <?php echo $attributes ?>>
|
230 |
+
<strong>
|
231 |
+
<?php
|
232 |
+
if(!empty($wpuas)){
|
233 |
+
foreach($wpuas as $usermeta) {
|
234 |
+
$user = get_userdata($usermeta->user_id);
|
235 |
+
$user_array[] = '<a href="'.get_edit_user_link($user->ID).'">'.$user->user_login.'</a>';
|
236 |
+
}
|
237 |
+
} else {
|
238 |
+
foreach($nowpuas as $usermeta) {
|
239 |
+
$user = get_userdata($usermeta->ID);
|
240 |
+
$user_array[] = '<a href="'.get_edit_user_link($user->ID).'">'.$user->user_login.'</a>';
|
241 |
+
}
|
242 |
+
}
|
243 |
+
?>
|
244 |
+
<?php echo implode(', ', array_filter($user_array)); ?>
|
245 |
+
</strong>
|
246 |
+
</td>
|
247 |
+
<?php
|
248 |
+
break;
|
249 |
+
}
|
250 |
+
}
|
251 |
+
?>
|
252 |
+
</tr>
|
253 |
+
<?php endwhile;
|
254 |
+
}
|
255 |
+
|
256 |
+
function _get_row_actions($post, $att_title) {
|
257 |
+
$actions = array();
|
258 |
+
if(current_user_can('edit_post', $post->ID) && !$this->is_trash) {
|
259 |
+
$actions['edit'] = '<a href="'.get_edit_post_link($post->ID, true).'">'.__('Edit').'</a>';
|
260 |
+
}
|
261 |
+
if(current_user_can('delete_post', $post->ID)) {
|
262 |
+
if($this->is_trash) {
|
263 |
+
$actions['untrash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_'.$post->ID)."'>".__('Restore')."</a>";
|
264 |
+
} elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
|
265 |
+
$actions['trash'] = "<a class='submitdelete' href='".wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_'. $post->ID)."'>".__('Trash')."</a>";
|
266 |
+
}
|
267 |
+
if($this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH) {
|
268 |
+
$delete_ays = (!$this->is_trash && !MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : '';
|
269 |
+
$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>";
|
270 |
+
}
|
271 |
+
}
|
272 |
+
if(!$this->is_trash) {
|
273 |
+
$title =_draft_or_post_title($post->post_parent);
|
274 |
+
$actions['view'] = '<a href="'.get_permalink($post->ID).'" title="'.esc_attr(sprintf(__('View “%s”'), $title)).'" rel="permalink">'.__('View').'</a>';
|
275 |
+
}
|
276 |
+
return $actions;
|
277 |
+
}
|
278 |
+
}
|
includes/class-wp-user-avatar-shortcode.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines shortcodes.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.8.7
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Shortcode {
|
10 |
+
public function __construct() {
|
11 |
+
add_shortcode('avatar', array($this, 'wpua_shortcode'));
|
12 |
+
add_shortcode('avatar_upload', array($this, 'wpua_edit_shortcode'));
|
13 |
+
// Add avatar and scripts to avatar_upload
|
14 |
+
add_action('wpua_show_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
15 |
+
add_action('wpua_update', array('wp_user_avatar', 'wpua_action_process_option_update'));
|
16 |
+
// Add error messages to avatar_upload
|
17 |
+
add_action('wpua_update_errors', array('wp_user_avatar', 'wpua_upload_errors'), 10, 3);
|
18 |
+
}
|
19 |
+
|
20 |
+
// Display shortcode
|
21 |
+
public function wpua_shortcode($atts, $content=null) {
|
22 |
+
global $all_sizes, $blog_id, $post, $wpdb;
|
23 |
+
// Set shortcode attributes
|
24 |
+
extract(shortcode_atts(array('user' => "", 'size' => '96', 'align' => "", 'link' => "", 'target' => ""), $atts));
|
25 |
+
// Find user by ID, login, slug, or e-mail address
|
26 |
+
if(!empty($user)) {
|
27 |
+
$user = is_numeric($user) ? get_user_by('id', $user) : get_user_by('login', $user);
|
28 |
+
$user = empty($user) ? get_user_by('slug', $user) : $user;
|
29 |
+
$user = empty($user) ? get_user_by('email', $user) : $user;
|
30 |
+
} else {
|
31 |
+
// Find author's name if id_or_email is empty
|
32 |
+
$author_name = get_query_var('author_name');
|
33 |
+
if(is_author()) {
|
34 |
+
// On author page, get user by page slug
|
35 |
+
$user = get_user_by('slug', $author_name);
|
36 |
+
} else {
|
37 |
+
// On post, get user by author meta
|
38 |
+
$user_id = get_the_author_meta('ID');
|
39 |
+
$user = get_user_by('id', $user_id);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
// Numeric sizes leave as-is
|
43 |
+
$get_size = $size;
|
44 |
+
// Check for custom image sizes if there are captions
|
45 |
+
if(!empty($content)) {
|
46 |
+
if(in_array($size, $all_sizes)) {
|
47 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))) {
|
48 |
+
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
49 |
+
} else {
|
50 |
+
$get_size = $_wp_additional_image_sizes[$size]['width'];
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
// Get user ID
|
55 |
+
$id_or_email = !empty($user) ? $user->ID : 'unknown@gravatar.com';
|
56 |
+
// Check if link is set
|
57 |
+
if(!empty($link)) {
|
58 |
+
// CSS class is same as link type, except for URL
|
59 |
+
$link_class = $link;
|
60 |
+
if($link == 'file') {
|
61 |
+
// Get image src
|
62 |
+
$link = get_wp_user_avatar_src($id_or_email, 'original');
|
63 |
+
} elseif($link == 'attachment') {
|
64 |
+
// Get attachment URL
|
65 |
+
$link = get_attachment_link(get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email));
|
66 |
+
} else {
|
67 |
+
// URL
|
68 |
+
$link_class = 'custom';
|
69 |
+
}
|
70 |
+
// Open in new window
|
71 |
+
$target_link = !empty($target) ? ' target="'.$target.'"' : "";
|
72 |
+
// Wrap the avatar inside the link
|
73 |
+
$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>';
|
74 |
+
} else {
|
75 |
+
$html = get_wp_user_avatar($id_or_email, $get_size, $align);
|
76 |
+
}
|
77 |
+
// Check if caption is set
|
78 |
+
if(!empty($content)) {
|
79 |
+
// Get attachment ID
|
80 |
+
$wpua = get_user_meta($id_or_email, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
81 |
+
// Clean up caption
|
82 |
+
$content = trim($content);
|
83 |
+
$content = preg_replace('/\r|\n/', "", $content);
|
84 |
+
$content = preg_replace('/<\/p><p>/', "", $content, 1);
|
85 |
+
$content = preg_replace('/<\/p><p>$/', "", $content);
|
86 |
+
$content = str_replace('</p><p>', "<br /><br />", $content);
|
87 |
+
$avatar = do_shortcode(image_add_caption($html, $wpua, $content, $title="", $align, $link, $get_size, $alt=""));
|
88 |
+
} else {
|
89 |
+
$avatar = $html;
|
90 |
+
}
|
91 |
+
return $avatar;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Update user
|
95 |
+
private function wpua_edit_user($user_id = 0){
|
96 |
+
$user = new stdClass;
|
97 |
+
if($user_id){
|
98 |
+
$update = true;
|
99 |
+
$user->ID = (int) $user_id;
|
100 |
+
} else {
|
101 |
+
$update = false;
|
102 |
+
}
|
103 |
+
$errors = new WP_Error();
|
104 |
+
do_action_ref_array('wpua_update_errors', array(&$errors, $update, &$user));
|
105 |
+
if($errors->get_error_codes()){
|
106 |
+
return $errors;
|
107 |
+
}
|
108 |
+
if($update){
|
109 |
+
$user_id = wp_update_user($user);
|
110 |
+
}
|
111 |
+
return $user_id;
|
112 |
+
}
|
113 |
+
|
114 |
+
// Edit shortcode
|
115 |
+
public function wpua_edit_shortcode($atts) {
|
116 |
+
global $current_user, $errors;
|
117 |
+
// Shortcode only works with logged in user
|
118 |
+
if(is_user_logged_in()){
|
119 |
+
// Save
|
120 |
+
if(isset($_POST['submit']) && $_POST['submit'] && $_POST['action'] == 'update'){
|
121 |
+
do_action('wpua_update', $current_user->ID);
|
122 |
+
// Check for errors
|
123 |
+
$errors = $this->wpua_edit_user($current_user->ID);
|
124 |
+
}
|
125 |
+
// Errors
|
126 |
+
if(isset($errors) && is_wp_error($errors)) {
|
127 |
+
echo '<div class="error"><p>'.implode( "</p>\n<p>", $errors->get_error_messages()).'</p></div>';
|
128 |
+
} elseif(isset($errors) && !is_wp_error($errors)) {
|
129 |
+
echo '<div class="updated"><p><strong>'.__('Profile updated.').'</strong></p></div>';
|
130 |
+
}
|
131 |
+
// Form
|
132 |
+
echo '<form id="wpua-edit-'.$current_user->ID.'" class="wpua-edit" action="'.get_permalink().'" method="post" enctype="multipart/form-data">';
|
133 |
+
do_action('wpua_show_profile', $current_user);
|
134 |
+
echo '<input type="hidden" name="action" value="update" />';
|
135 |
+
echo '<input type="hidden" name="user_id" id="user_id" value="'.esc_attr($current_user->ID).'" />';
|
136 |
+
wp_nonce_field('update-user_'.$current_user->ID);
|
137 |
+
submit_button(__('Save'));
|
138 |
+
echo '</form>';
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
$wpua_shortcode = new WP_User_Avatar_Shortcode();
|
includes/class-wp-user-avatar-subscriber.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Settings only for subscribers and contributors.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.8.7
|
7 |
+
*/
|
8 |
+
|
9 |
+
class WP_User_Avatar_Subscriber {
|
10 |
+
public function __construct() {
|
11 |
+
global $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')) {
|
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 |
+
if(in_array($pagenow, $offlimits)) {
|
59 |
+
do_action('admin_page_access_denied');
|
60 |
+
wp_die(__('You do not have sufficient permissions to access this page.'));
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// Give subscribers edit_posts capability
|
65 |
+
public function wpua_subscriber_capability() {
|
66 |
+
global $blog_id, $wpdb, $wpua_allow_upload, $wpua_edit_avatar;;
|
67 |
+
$wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
|
68 |
+
$user_roles = get_option($wp_user_roles);
|
69 |
+
if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1) {
|
70 |
+
$user_roles['subscriber']['capabilities']['edit_posts'] = true;
|
71 |
+
} else {
|
72 |
+
unset($user_roles['subscriber']['capabilities']['edit_posts']);
|
73 |
+
}
|
74 |
+
update_option($wp_user_roles, $user_roles);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
// Initialize WP_User_Avatar_Subscriber
|
79 |
+
function wpua_subcriber_init() {
|
80 |
+
global $wpua_subscriber;
|
81 |
+
$wpua_subscriber = new WP_User_Avatar_Subscriber();
|
82 |
+
}
|
83 |
+
add_action('init', 'wpua_subcriber_init');
|
includes/class-wp-user-avatar-update.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Updates for legacy settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.8.7
|
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 |
+
update_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 |
+
$wpua_update = new WP_User_Avatar_Update();
|
includes/class-wp-user-avatar.php
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Defines all profile and upload settings.
|
4 |
+
*
|
5 |
+
* @package WP User Avatar
|
6 |
+
* @version 1.8.7
|
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('edit_user_profile', array($this, 'wpua_action_show_user_profile'));
|
17 |
+
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
18 |
+
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
19 |
+
if(!is_admin()) {
|
20 |
+
add_action('show_user_profile', array($this, 'wpua_media_upload_scripts'));
|
21 |
+
add_action('edit_user_profile', array($this, 'wpua_media_upload_scripts'));
|
22 |
+
}
|
23 |
+
// Admin scripts
|
24 |
+
$pages = array('profile.php', 'options-discussion.php', 'user-edit.php');
|
25 |
+
if(in_array($pagenow, $pages) || $wpua_admin->wpua_is_menu_page()) {
|
26 |
+
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
27 |
+
}
|
28 |
+
if(!$this->wpua_is_author_or_above()) {
|
29 |
+
// Upload errors
|
30 |
+
add_action('user_profile_update_errors', array($this, 'wpua_upload_errors'), 10, 3);
|
31 |
+
// Prefilter upload size
|
32 |
+
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'));
|
33 |
+
}
|
34 |
+
}
|
35 |
+
add_filter('media_view_settings', array($this, 'wpua_media_view_settings'), 10, 1);
|
36 |
+
}
|
37 |
+
|
38 |
+
// Avatars have no parent posts
|
39 |
+
public function wpua_media_view_settings($settings) {
|
40 |
+
global $post, $is_wpua_page;
|
41 |
+
$settings['post']['id'] = !is_admin() && (bool) $is_wpua_page == 1 ? 0 : $post->ID;
|
42 |
+
return $settings;
|
43 |
+
}
|
44 |
+
|
45 |
+
// Media Uploader
|
46 |
+
public static function wpua_media_upload_scripts($user="") {
|
47 |
+
global $current_user, $is_wpua_page, $mustache_admin, $pagenow, $post, $show_avatars, $wp_user_avatar, $wpua_admin, $wpua_upload_size_limit;
|
48 |
+
$user = ($pagenow == 'user-edit.php' && isset($_GET['user_id'])) ? get_user_by('id', $_GET['user_id']) : $current_user;
|
49 |
+
$is_wpua_page = true;
|
50 |
+
wp_enqueue_script('jquery');
|
51 |
+
if($wp_user_avatar->wpua_is_author_or_above()) {
|
52 |
+
wp_enqueue_script('admin-bar');
|
53 |
+
wp_enqueue_media(array('post' => $post));
|
54 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URL.'js/wp-user-avatar.js', array('jquery', 'media-editor'), WPUA_VERSION, true);
|
55 |
+
} else {
|
56 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URL.'js/wp-user-avatar-user.js', array('jquery'), WPUA_VERSION, true);
|
57 |
+
}
|
58 |
+
wp_enqueue_style('wp-user-avatar', WPUA_URL.'css/wp-user-avatar.css', array('media-views'), WPUA_VERSION);
|
59 |
+
// Admin scripts
|
60 |
+
if($pagenow == 'options-discussion.php' || $wpua_admin->wpua_is_menu_page()) {
|
61 |
+
// Size limit slider
|
62 |
+
wp_enqueue_script('jquery-ui-slider');
|
63 |
+
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URL.'css/jquery.ui.slider.css', "", null);
|
64 |
+
// Remove/edit settings
|
65 |
+
$wpua_custom_scripts = array('section' => __('Default Avatar'), 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $mustache_admin);
|
66 |
+
wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
|
67 |
+
// Settings control
|
68 |
+
wp_enqueue_script('wp-user-avatar-admin', WPUA_URL.'js/wp-user-avatar-admin.js', array('wp-user-avatar'), WPUA_VERSION, true);
|
69 |
+
$wpua_admin_scripts = array('upload_size_limit' => $wpua_upload_size_limit, 'max_upload_size' => wp_max_upload_size());
|
70 |
+
wp_localize_script('wp-user-avatar-admin', 'wpua_admin', $wpua_admin_scripts);
|
71 |
+
} else {
|
72 |
+
// User remove/edit settings
|
73 |
+
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
74 |
+
$wpua_custom_scripts = array('section' => $user->display_name, 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $avatar_medium_src);
|
75 |
+
wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
// Add to edit user profile
|
80 |
+
public static function wpua_action_show_user_profile($user) {
|
81 |
+
global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wp_user_avatar, $wpua_allow_upload, $wpua_edit_avatar, $wpua_upload_size_limit_with_units;
|
82 |
+
// Get WPUA attachment ID
|
83 |
+
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
84 |
+
// Show remove button if WPUA is set
|
85 |
+
$hide_remove = !has_wp_user_avatar($user->ID) ? 'wpua-hide' : "";
|
86 |
+
// If avatars are enabled, get original avatar image or show blank
|
87 |
+
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
88 |
+
// Check if user has wp_user_avatar, if not show image from above
|
89 |
+
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
|
90 |
+
// Check if user has wp_user_avatar, if not show image from above
|
91 |
+
$avatar_thumbnail = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 96) : $avatar_medium_src;
|
92 |
+
$edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php'));
|
93 |
+
?>
|
94 |
+
<?php do_action('wpua_before_avatar'); ?>
|
95 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
96 |
+
<?php if($wp_user_avatar->wpua_is_author_or_above()) : // Button to launch Media Uploader ?>
|
97 |
+
<p id="wpua-add-button"><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Choose Image'); ?></button></p>
|
98 |
+
<?php elseif(!$wp_user_avatar->wpua_is_author_or_above() && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
|
99 |
+
<p id="wpua-upload-button">
|
100 |
+
<input name="wpua-file" id="wpua-file" type="file" />
|
101 |
+
<button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
|
102 |
+
</p>
|
103 |
+
<p id="wpua-upload-messages">
|
104 |
+
<span id="wpua-max-upload"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?></span>
|
105 |
+
<span id="wpua-allowed-files"><?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?></span>
|
106 |
+
</p>
|
107 |
+
<?php elseif((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 ?>
|
108 |
+
<p id="wpua-edit-button"><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>
|
109 |
+
<?php endif; ?>
|
110 |
+
<p id="wpua-preview">
|
111 |
+
<img src="<?php echo $avatar_medium; ?>" alt="" />
|
112 |
+
<?php _e('Original Size'); ?>
|
113 |
+
</p>
|
114 |
+
<p id="wpua-thumbnail">
|
115 |
+
<img src="<?php echo $avatar_thumbnail; ?>" alt="" />
|
116 |
+
<?php _e('Thumbnail'); ?>
|
117 |
+
</p>
|
118 |
+
<p id="wpua-remove-button" class="<?php echo $hide_remove; ?>"><button type="button" class="button" id="wpua-remove" name="wpua-remove"><?php _e('Remove Image'); ?></button></p>
|
119 |
+
<p id="wpua-undo-button"><button type="button" class="button" id="wpua-undo" name="wpua-undo"><?php _e('Undo'); ?></button></p>
|
120 |
+
<?php do_action('wpua_after_avatar'); ?>
|
121 |
+
<?php
|
122 |
+
}
|
123 |
+
|
124 |
+
// Add upload error messages
|
125 |
+
public static function wpua_upload_errors($errors, $update, $user) {
|
126 |
+
global $wpua_upload_size_limit;
|
127 |
+
if($update && !empty($_FILES['wpua-file'])) {
|
128 |
+
$size = $_FILES['wpua-file']['size'];
|
129 |
+
$type = $_FILES['wpua-file']['type'];
|
130 |
+
$upload_dir = wp_upload_dir();
|
131 |
+
// Allow only JPG, GIF, PNG
|
132 |
+
if(!empty($type) && !preg_match('/(jpe?g|gif|png)$/i', $type)) {
|
133 |
+
$errors->add('wpua_file_type', __('This file is not an image. Please try another.'));
|
134 |
+
}
|
135 |
+
// Upload size limit
|
136 |
+
if(!empty($size) && $size > $wpua_upload_size_limit) {
|
137 |
+
$errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.'));
|
138 |
+
}
|
139 |
+
// Check if directory is writeable
|
140 |
+
if(!is_writeable($upload_dir['path'])) {
|
141 |
+
$errors->add('wpua_file_directory', sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $upload_dir['path']));
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
// Set upload size limit
|
147 |
+
public function wpua_handle_upload_prefilter($file) {
|
148 |
+
global $wpua_upload_size_limit;
|
149 |
+
$size = $file['size'];
|
150 |
+
if(!empty($size) && $size > $wpua_upload_size_limit) {
|
151 |
+
function wpua_file_size_error($errors, $update, $user) {
|
152 |
+
$errors->add('wpua_file_size', __('Memory exceeded. Please try another smaller file.'));
|
153 |
+
}
|
154 |
+
add_action('user_profile_update_errors', 'wpua_file_size_error', 10, 3);
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
return $file;
|
158 |
+
}
|
159 |
+
|
160 |
+
// Update user meta
|
161 |
+
public static function wpua_action_process_option_update($user_id) {
|
162 |
+
global $blog_id, $post, $wpdb, $wp_user_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w;
|
163 |
+
// Check if user has publish_posts capability
|
164 |
+
if($wp_user_avatar->wpua_is_author_or_above()) {
|
165 |
+
$wpua_id = isset($_POST['wp-user-avatar']) ? intval($_POST['wp-user-avatar']) : "";
|
166 |
+
// Remove old attachment postmeta
|
167 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
168 |
+
// Create new attachment postmeta
|
169 |
+
update_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
170 |
+
// Update usermeta
|
171 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
172 |
+
} else {
|
173 |
+
// Remove attachment info if avatar is blank
|
174 |
+
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])) {
|
175 |
+
// Uploads by user
|
176 |
+
$q = array(
|
177 |
+
'author' => $user_id,
|
178 |
+
'post_type' => 'attachment',
|
179 |
+
'post_status' => 'inherit',
|
180 |
+
'posts_per_page' => '-1',
|
181 |
+
'meta_query' => array(
|
182 |
+
array(
|
183 |
+
'key' => '_wp_attachment_wp_user_avatar',
|
184 |
+
'value' => '',
|
185 |
+
'compare' => '!='
|
186 |
+
)
|
187 |
+
)
|
188 |
+
);
|
189 |
+
$avatars_wp_query = new WP_Query($q);
|
190 |
+
while($avatars_wp_query->have_posts()) : $avatars_wp_query->the_post();
|
191 |
+
wp_delete_attachment($post->ID);
|
192 |
+
endwhile;
|
193 |
+
wp_reset_query();
|
194 |
+
// Remove attachment postmeta
|
195 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
196 |
+
// Remove usermeta
|
197 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
198 |
+
}
|
199 |
+
// Create attachment from upload
|
200 |
+
if(isset($_POST['submit']) && $_POST['submit'] && !empty($_FILES['wpua-file'])) {
|
201 |
+
$name = $_FILES['wpua-file']['name'];
|
202 |
+
$file = wp_handle_upload($_FILES['wpua-file'], array('test_form' => false));
|
203 |
+
$type = $_FILES['wpua-file']['type'];
|
204 |
+
$upload_dir = wp_upload_dir();
|
205 |
+
if(is_writeable($upload_dir['path'])) {
|
206 |
+
if(!empty($type) && preg_match('/(jpe?g|gif|png)$/i', $type)) {
|
207 |
+
// Resize uploaded image
|
208 |
+
if((bool) $wpua_resize_upload == 1) {
|
209 |
+
// Original image
|
210 |
+
$uploaded_image = wp_get_image_editor($file['file']);
|
211 |
+
// Check for errors
|
212 |
+
if(!is_wp_error($uploaded_image)) {
|
213 |
+
// Resize image
|
214 |
+
$uploaded_image->resize($wpua_resize_w, $wpua_resize_h, $wpua_resize_crop);
|
215 |
+
// Save image
|
216 |
+
$resized_image = $uploaded_image->save($file['file']);
|
217 |
+
}
|
218 |
+
}
|
219 |
+
// Break out file info
|
220 |
+
$name_parts = pathinfo($name);
|
221 |
+
$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
|
222 |
+
$url = $file['url'];
|
223 |
+
$file = $file['file'];
|
224 |
+
$title = $name;
|
225 |
+
// Use image exif/iptc data for title if possible
|
226 |
+
if($image_meta = @wp_read_image_metadata($file)) {
|
227 |
+
if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))) {
|
228 |
+
$title = $image_meta['title'];
|
229 |
+
}
|
230 |
+
}
|
231 |
+
// Construct the attachment array
|
232 |
+
$attachment = array(
|
233 |
+
'guid' => $url,
|
234 |
+
'post_mime_type' => $type,
|
235 |
+
'post_title' => $title,
|
236 |
+
'post_content' => ""
|
237 |
+
);
|
238 |
+
// This should never be set as it would then overwrite an existing attachment
|
239 |
+
if(isset($attachment['ID'])) {
|
240 |
+
unset($attachment['ID']);
|
241 |
+
}
|
242 |
+
// Save the attachment metadata
|
243 |
+
$attachment_id = wp_insert_attachment($attachment, $file);
|
244 |
+
if(!is_wp_error($attachment_id)) {
|
245 |
+
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
246 |
+
// Remove old attachment postmeta
|
247 |
+
delete_metadata('post', null, '_wp_attachment_wp_user_avatar', $user_id, true);
|
248 |
+
// Create new attachment postmeta
|
249 |
+
update_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
|
250 |
+
// Update usermeta
|
251 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
|
252 |
+
}
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
// Check who owns image
|
260 |
+
private function wpua_author($attachment_id, $user_id, $wpua_author=false) {
|
261 |
+
$attachment = get_post($attachment_id);
|
262 |
+
if(!empty($attachment) && $attachment->post_author == $user_id) {
|
263 |
+
$wpua_author = true;
|
264 |
+
}
|
265 |
+
return $wpua_author;
|
266 |
+
}
|
267 |
+
|
268 |
+
// Check if current user has at least Author privileges
|
269 |
+
private function wpua_is_author_or_above() {
|
270 |
+
$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;
|
271 |
+
return $is_author_or_above;
|
272 |
+
}
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
// Initialize WP_User_Avatar
|
277 |
+
function wpua_init() {
|
278 |
+
global $wp_user_avatar;
|
279 |
+
$wp_user_avatar = new WP_User_Avatar();
|
280 |
+
}
|
281 |
+
add_action('init', 'wpua_init');
|
includes/tinymce/editor_plugin.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(){tinymce.PluginManager.requireLangPack('wpUserAvatar');tinymce.create('tinymce.plugins.wpUserAvatar',{init:function(ed,url){ed.addCommand('mceWpUserAvatar',function(){ed.windowManager.open({file:ajaxurl+'?action=wp_user_avatar_tinymce',width:500,height:
|
1 |
+
(function() {tinymce.PluginManager.requireLangPack('wpUserAvatar');tinymce.create('tinymce.plugins.wpUserAvatar',{init:function(ed,url) {ed.addCommand('mceWpUserAvatar',function() {ed.windowManager.open({file:ajaxurl+'?action=wp_user_avatar_tinymce',width:500,height:360,inline:1},{plugin_url:url})});ed.addButton('wpUserAvatar',{title:'Insert WP User Avatar',cmd:'mceWpUserAvatar',image:url+'/../../images/wpua-32x32.png'});ed.onNodeChange.add(function(ed,cm,n) {cm.setActive('wpUserAvatar',n.nodeName=='IMG')})},createControl:function(n,cm) {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.8.7"}}});tinymce.PluginManager.add('wpUserAvatar',tinymce.plugins.wpUserAvatar)})();
|
includes/tinymce/window.php
CHANGED
@@ -1,26 +1,32 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
-
if(!defined('ABSPATH')){
|
8 |
die(__('You are not allowed to call this page directly.'));
|
9 |
@header('Content-Type:'.get_option('html_type').';charset='.get_option('blog_charset'));
|
10 |
}
|
11 |
?>
|
12 |
-
|
|
|
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 +34,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.8.7
|
7 |
*/
|
8 |
|
9 |
+
if(!defined('ABSPATH')) {
|
10 |
die(__('You are not allowed to call this page directly.'));
|
11 |
@header('Content-Type:'.get_option('html_type').';charset='.get_option('blog_charset'));
|
12 |
}
|
13 |
?>
|
14 |
+
<!DOCTYPE html>
|
15 |
+
<html>
|
16 |
<head>
|
17 |
<title><?php _e('WP User Avatar', 'wp-user-avatar'); ?></title>
|
18 |
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
19 |
<base target="_self" />
|
20 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/jquery.js"></script>
|
21 |
+
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.core.min.js"></script>
|
22 |
+
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.widget.min.js"></script>
|
23 |
+
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js"></script>
|
24 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
|
25 |
<script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
|
26 |
<script type="text/javascript">
|
27 |
+
function wpuaInsertAvatar() {
|
28 |
// Custom shortcode values
|
29 |
+
var shortcode, closing_tag;
|
30 |
var user = document.getElementById('wp_user_avatar_user').value;
|
31 |
var size = document.getElementById('wp_user_avatar_size').value;
|
32 |
var size_number = document.getElementById('wp_user_avatar_size_number').value;
|
34 |
var link = document.getElementById('wp_user_avatar_link').value;
|
35 |
var link_external = document.getElementById('wp_user_avatar_link_external').value;
|
36 |
var target = document.getElementById('wp_user_avatar_target').value;
|
37 |
+
var caption = document.getElementById('wp_user_avatar_caption').value;
|
38 |
|
39 |
// Add tag to shortcode only if not blank
|
40 |
var user_tag = (user != "") ? ' user="' + user + '"' : "";
|
41 |
var size_tag = (size != "" && size_number == "") ? ' size="' + size + '"' : "";
|
42 |
+
size_tag = (size_number != "") ? ' size="' + size_number + '"' : size_tag;
|
43 |
var align_tag = (align != "") ? ' align="' + align + '"' : "";
|
44 |
var link_tag = (link != "" && link != 'custom-url' && link_external == "") ? ' link="' + link + '"' : "";
|
45 |
+
link_tag = (link_external != "") ? ' link="' + link_external + '"' : link_tag;
|
46 |
var target_tag = document.getElementById('wp_user_avatar_target').checked && (link_tag != "") ? ' target="' + target + '"' : "";
|
|
|
|
|
47 |
|
48 |
+
// Assemble the shortcode
|
49 |
+
closing_tag = (caption != "") ? "]" + caption + "[/avatar]" : " /]";
|
50 |
+
shortcode = "<p>[avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + closing_tag + "</p>";
|
51 |
+
|
52 |
+
if(window.tinyMCE) {
|
53 |
+
window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
|
54 |
+
tinyMCEPopup.editor.execCommand('mceRepaint');
|
55 |
+
tinyMCEPopup.close();
|
56 |
+
}
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
function wpuaInsertAvatarUpload() {
|
60 |
+
// Upload shortcode
|
61 |
+
var shortcode = "<p>[avatar_upload]</p>";
|
62 |
+
|
63 |
+
if(window.tinyMCE) {
|
64 |
window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode);
|
65 |
tinyMCEPopup.editor.execCommand('mceRepaint');
|
66 |
tinyMCEPopup.close();
|
67 |
}
|
68 |
return;
|
69 |
}
|
70 |
+
jQuery(function($) {
|
71 |
+
$('#wp_user_avatar_link').change(function() {
|
72 |
+
$('#wp_user_avatar_link_external_section').toggle($('#wp_user_avatar_link').val() == 'custom-url');
|
73 |
});
|
74 |
+
$('#wp_user_avatar_size').change(function() {
|
75 |
+
$('#wp_user_avatar_size_number_section').toggle($('#wp_user_avatar_size').val() == 'custom');
|
76 |
});
|
77 |
+
$('#wpua-tabs').tabs();
|
78 |
});
|
79 |
</script>
|
80 |
<style type="text/css">
|
81 |
+
ul { margin: 0; padding: 0; list-style: none; }
|
82 |
+
ul li { float: left; }
|
83 |
+
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; }
|
84 |
+
ul li.ui-tabs-active a { background: #fff; }
|
85 |
+
form { clear: both; background: #fff; border: 1px solid #eee; }
|
86 |
p, h4 { margin: 0; padding: 12px 0 0; }
|
87 |
h4.center { text-align: center; }
|
88 |
+
label { width: 150px; margin-right: 3px; display: inline-block; text-align: right; vertical-align: top; }
|
89 |
.mceActionPanel { padding: 7px 0 12px; text-align: center; }
|
90 |
.mceActionPanel #insert { float: none; width: 180px; margin: 0 auto; }
|
91 |
#wp_user_avatar_size_number_section, #wp_user_avatar_link_external_section { display: none; }
|
92 |
</style>
|
93 |
</head>
|
94 |
+
<body id="link" class="wp-core-ui" onload="document.body.style.display='';" style="display:none;">
|
95 |
+
<div id="wpua-tabs">
|
96 |
+
<ul>
|
97 |
+
<li><a href="#wpua"><?php _e('Avatar'); ?></a></li>
|
98 |
+
<li><a href="#wpua-upload"><?php _e('Upload'); ?></a></li>
|
99 |
+
</ul>
|
100 |
+
<form name="wpUserAvatar" action="#">
|
101 |
+
<div id="wpua">
|
102 |
+
<p>
|
103 |
+
<label for="<?php esc_attr_e('wp_user_avatar_user'); ?>"><strong><?php _e('User Name'); ?>:</strong></label>
|
104 |
+
<select id="<?php esc_attr_e('wp_user_avatar_user'); ?>" name="<?php esc_attr_e('wp_user_avatar_user'); ?>">
|
105 |
+
<option value=""></option>
|
106 |
+
<?php $users = get_users(); foreach($users as $user) : ?>
|
107 |
+
<option value="<?php echo $user->user_login; ?>"><?php echo $user->display_name; ?></option>
|
108 |
+
<?php endforeach; ?>
|
109 |
+
</select>
|
110 |
+
</p>
|
111 |
+
|
112 |
+
<p>
|
113 |
+
<label for="<?php esc_attr_e('wp_user_avatar_size'); ?>"><strong><?php _e('Size'); ?>:</strong></label>
|
114 |
+
<select id="<?php esc_attr_e('wp_user_avatar_size'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>">
|
115 |
+
<option value=""></option>
|
116 |
+
<option value="original"><?php _e('Original Size'); ?></option>
|
117 |
+
<option value="large"><?php _e('Large'); ?></option>
|
118 |
+
<option value="medium"><?php _e('Medium'); ?></option>
|
119 |
+
<option value="thumbnail"><?php _e('Thumbnail'); ?></option>
|
120 |
+
<option value="custom"><?php _e('Custom'); ?></option>
|
121 |
+
</select>
|
122 |
+
</p>
|
123 |
+
|
124 |
+
<p id="<?php esc_attr_e('wp_user_avatar_size_number_section'); ?>">
|
125 |
+
<label for="<?php esc_attr_e('wp_user_avatar_size_number'); ?>"><?php _e('Size'); ?>:</label>
|
126 |
+
<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="" />
|
127 |
+
</p>
|
128 |
|
129 |
+
<p>
|
130 |
+
<label for="<?php esc_attr_e('wp_user_avatar_align'); ?>"><strong><?php _e('Alignment'); ?>:</strong></label>
|
131 |
+
<select id="<?php esc_attr_e('wp_user_avatar_align'); ?>" name="<?php esc_attr_e('wp_user_avatar_align'); ?>">
|
132 |
+
<option value=""></option>
|
133 |
+
<option value="center"><?php _e('Center'); ?></option>
|
134 |
+
<option value="left"><?php _e('Left'); ?></option>
|
135 |
+
<option value="right"><?php _e('Right'); ?></option>
|
136 |
+
</select>
|
137 |
+
</p>
|
|
|
|
|
138 |
|
139 |
+
<p>
|
140 |
+
<label for="<?php esc_attr_e('wp_user_avatar_link'); ?>"><strong><?php _e('Link To'); ?>:</strong></label>
|
141 |
+
<select id="<?php esc_attr_e('wp_user_avatar_link'); ?>" name="<?php esc_attr_e('wp_user_avatar_link'); ?>">
|
142 |
+
<option value=""></option>
|
143 |
+
<option value="file"><?php _e('Image File'); ?></option>
|
144 |
+
<option value="attachment"><?php _e('Attachment Page'); ?></option>
|
145 |
+
<option value="custom-url"><?php _e('Custom URL'); ?></option>
|
146 |
+
</select>
|
147 |
+
</p>
|
148 |
|
149 |
+
<p id="<?php esc_attr_e('wp_user_avatar_link_external_section'); ?>">
|
150 |
+
<label for="<?php esc_attr_e('wp_user_avatar_link_external'); ?>"><?php _e('URL'); ?>:</label>
|
151 |
+
<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="" />
|
152 |
+
</p>
|
|
|
|
|
|
|
153 |
|
154 |
+
<p>
|
155 |
+
<label for="<?php esc_attr_e('wp_user_avatar_target'); ?>"></label>
|
156 |
+
<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>
|
157 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
+
<p>
|
160 |
+
<label for="<?php esc_attr_e('wp_user_avatar_caption'); ?>"><strong><?php _e('Caption'); ?>:</strong></label>
|
161 |
+
<textarea cols="36" rows="2" id="<?php esc_attr_e('wp_user_avatar_caption'); ?>" name="<?php esc_attr_e('wp_user_avatar_size'); ?>"></textarea>
|
162 |
+
</p>
|
163 |
|
164 |
+
<div class="mceActionPanel">
|
165 |
+
<input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatar();" />
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
<div id="wpua-upload">
|
169 |
+
<p id="<?php esc_attr_e('wp_user_avatar_upload'); ?>">
|
170 |
+
<label for="<?php esc_attr_e('wp_user_avatar_upload'); ?>"><strong><?php _e('Upload'); ?>:</strong></label>
|
171 |
+
<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" />
|
172 |
+
</p>
|
173 |
|
174 |
+
<div class="mceActionPanel">
|
175 |
+
<input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatarUpload();" />
|
176 |
+
</div>
|
177 |
+
</div>
|
178 |
+
</form>
|
179 |
+
</div>
|
180 |
</body>
|
181 |
</html>
|
includes/wpua-functions.php
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|