Version Description
- Remove: Option to disable scripts in front pages
- Update: Load media upload scripts only on profile and avatar admin pages
- Update: Translations
Download this release
Release Info
Developer | bangbay |
Plugin | ![]() |
Version | 1.5.3 |
Comparing to | |
See all releases |
Code changes from version 1.5.2 to 1.5.3
- css/wp-user-avatar.css +6 -6
- includes/tinymce.php +1 -1
- includes/tinymce/editor_plugin.js +1 -1
- includes/tinymce/window.php +1 -1
- js/wp-user-avatar.js +1 -1
- readme.txt +13 -7
- uninstall.php +1 -1
- wp-user-avatar.php +92 -109
css/wp-user-avatar.css
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
#wpua-errors, #wpua-message, #wpua-readable-size-error, .wpua-error { color: #c00; font-weight: 700; }
|
2 |
#wpua-message, #wpua-readable-size-error { display: none; }
|
3 |
-
#wpua-preview, #wpua-thumbnail { display: inline-block; text-align: center; vertical-align: top; }
|
4 |
-
#wpua-preview { margin-right: 10px; }
|
5 |
#wpua-preview img, #wpua-thumbnail img { 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 { padding-left: 15px; }
|
9 |
-
#wpua-edit #wpua-remove { margin-left: 10px; }
|
10 |
-
.hide
|
11 |
#wpua-slider { width: 22.75em; }
|
12 |
.wpua_label { display: block; }
|
1 |
+
#wpua-errors, #wpua-message, #wpua-readable-size-error, .wpua-error { color: #c00 !important; font-weight: 700 !important; }
|
2 |
#wpua-message, #wpua-readable-size-error { display: none; }
|
3 |
+
#wpua-preview, #wpua-thumbnail { display: inline-block !important; text-align: center; vertical-align: top; }
|
4 |
+
#wpua-preview { margin-right: 10px !important; }
|
5 |
#wpua-preview img, #wpua-thumbnail img { 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 { padding-left: 15px !important; }
|
9 |
+
#wpua-edit #wpua-remove { margin-left: 10px !important; }
|
10 |
+
.wpua-hide, .wp-core-ui .wpua-hide { display: none; }
|
11 |
#wpua-slider { width: 22.75em; }
|
12 |
.wpua_label { display: block; }
|
includes/tinymce.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.5.
|
5 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.5.3
|
5 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
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:265,inline:1},{plugin_url:url})});ed.addButton('wpUserAvatar',{title:'Insert WP User Avatar',cmd:'mceWpUserAvatar',image:url+'/../../images/wp-user-avatar-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/extend/plugins/wp-user-avatar/',version:"1.5.
|
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:265,inline:1},{plugin_url:url})});ed.addButton('wpUserAvatar',{title:'Insert WP User Avatar',cmd:'mceWpUserAvatar',image:url+'/../../images/wp-user-avatar-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/extend/plugins/wp-user-avatar/',version:"1.5.3"}}});tinymce.PluginManager.add('wpUserAvatar',tinymce.plugins.wpUserAvatar)})();
|
includes/tinymce/window.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.5.
|
5 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.5.3
|
5 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
js/wp-user-avatar.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function
|
1 |
+
function wpuaMediaUploader(c,d,f){wp.media.wpUserAvatar={get:function(){return wp.media.view.settings.post.wpUserAvatarId},set:function(a){var b=wp.media.view.settings;b.post.wpUserAvatarId=a;b.post.wpUserAvatarSrc=jQuery('div.attachment-info').find('img').attr('src');if(b.post.wpUserAvatarId){wpuaSetAvatar(b.post.wpUserAvatarId,b.post.wpUserAvatarSrc);jQuery('#wp_user_avatar_radio').trigger('click')}},frame:function(){if(this._frame){return this._frame}this._frame=wp.media({state:'library',states:[new wp.media.controller.Library({title:d+": "+c})]});this._frame.on('open',function(){var a=this.state().get('selection');id=jQuery('#wp-user-avatar').val();attachment=wp.media.attachment(id);attachment.fetch();a.add(attachment?[attachment]:[])},this._frame);this._frame.on('toolbar:create:select',function(a){this.createSelectToolbar(a,{text:f})},this._frame);this._frame.state('library').on('select',this.select);return this._frame},select:function(a){var b=wp.media.view.settings,selection=this.get('selection').single();wp.media.wpUserAvatar.set(selection?selection.id:-1)},init:function(){jQuery('body').on('click','#wpua-add',function(e){e.preventDefault();e.stopPropagation();wp.media.wpUserAvatar.frame().open()})}};jQuery(wp.media.wpUserAvatar.init)}function wpuaSetAvatar(a,b){jQuery('#wp-user-avatar',window.parent.document).val(a);jQuery('#wpua-preview',window.parent.document).find('img').attr('src',b).removeAttr('width','').removeAttr('height','');jQuery('#wpua-message',window.parent.document).show();jQuery('#wpua-remove',window.parent.document).show();jQuery('#wpua-thumbnail',window.parent.document).hide();jQuery('#wp_user_avatar_radio',window.parent.document).trigger('click');wp.media.wpUserAvatar.frame().close()}function wpuaRemoveAvatar(a){jQuery('body').on('click','#wpua-remove',function(e){e.preventDefault();jQuery(this).hide();jQuery('#wpua-edit, #wpua-thumbnail').hide();jQuery('#wpua-preview').find('img').attr('src',a).removeAttr('width','').removeAttr('height','');jQuery('#wp-user-avatar').val('');jQuery('#wpua-message').show();jQuery('#wp_user_avatar_radio').trigger('click')})}
|
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.5.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -24,13 +24,11 @@ WP User Avatar also lets you:
|
|
24 |
* Allow Contributors and Subscribers to upload their own avatars.
|
25 |
* Limit upload file size for Contributors and Subscribers.
|
26 |
|
27 |
-
This plugin uses the Media uploader introduced in WordPress 3.5, but is also backwards-compatible to WordPress 3.4. It is also compatible with WordPress Multisite.
|
28 |
-
|
29 |
== Installation ==
|
30 |
|
31 |
1. Download, install, and activate the WP User Avatar plugin.
|
32 |
-
2. On your profile edit page, click "Edit
|
33 |
-
3. Choose an image, then click "
|
34 |
4. Click "Update Profile".
|
35 |
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.
|
36 |
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/).
|
@@ -232,6 +230,11 @@ Outputs:
|
|
232 |
|
233 |
== Changelog ==
|
234 |
|
|
|
|
|
|
|
|
|
|
|
235 |
= 1.5.2 =
|
236 |
* Bug Fix: Ability to disable scripts in front pages
|
237 |
|
@@ -357,6 +360,9 @@ Outputs:
|
|
357 |
|
358 |
== Upgrade Notice ==
|
359 |
|
|
|
|
|
|
|
360 |
= 1.5 =
|
361 |
* New Feature: Ability to disable Gravatar avatars
|
362 |
* New Feature: Upload size limiter for Contributors & Subscribers
|
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.5
|
7 |
+
Tested up to: 3.6-beta4-24640
|
8 |
+
Stable tag: 1.5.3
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
24 |
* Allow Contributors and Subscribers to upload their own avatars.
|
25 |
* Limit upload file size for Contributors and Subscribers.
|
26 |
|
|
|
|
|
27 |
== Installation ==
|
28 |
|
29 |
1. Download, install, and activate the WP User Avatar plugin.
|
30 |
+
2. On your profile edit page, click "Edit Image".
|
31 |
+
3. Choose an image, then click "Select Image".
|
32 |
4. Click "Update Profile".
|
33 |
5. Upload your own Default Avatar in your WP User Avatar settings (optional). You can also allow Contributors & Subscribers to upload avatars and disable Gravatar.
|
34 |
6. Choose a theme that has avatar support. In your theme, manually replace <code>get_avatar</code> with <code>get_wp_user_avatar</code> or leave <code>get_avatar</code> as-is. [Read about the differences here](http://wordpress.org/extend/plugins/wp-user-avatar/faq/).
|
230 |
|
231 |
== Changelog ==
|
232 |
|
233 |
+
= 1.5.3 =
|
234 |
+
* Remove: Option to disable scripts in front pages
|
235 |
+
* Update: Load media upload scripts only on profile and avatar admin pages
|
236 |
+
* Update: Translations
|
237 |
+
|
238 |
= 1.5.2 =
|
239 |
* Bug Fix: Ability to disable scripts in front pages
|
240 |
|
360 |
|
361 |
== Upgrade Notice ==
|
362 |
|
363 |
+
= 1.5.3 =
|
364 |
+
* 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.
|
365 |
+
|
366 |
= 1.5 =
|
367 |
* New Feature: Ability to disable Gravatar avatars
|
368 |
* New Feature: Upload size limiter for Contributors & Subscribers
|
uninstall.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.5.
|
5 |
*/
|
6 |
|
7 |
// Remove user metadata and options on plugin delete
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.5.3
|
5 |
*/
|
6 |
|
7 |
// Remove user metadata and options on plugin delete
|
wp-user-avatar.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.5.
|
5 |
*/
|
6 |
/*
|
7 |
Plugin Name: WP User Avatar
|
@@ -9,7 +9,7 @@ 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.5.
|
13 |
Text Domain: wp-user-avatar
|
14 |
Domain Path: /lang/
|
15 |
*/
|
@@ -20,7 +20,7 @@ if(!defined('ABSPATH')){
|
|
20 |
}
|
21 |
|
22 |
// Define paths and variables
|
23 |
-
define('WPUA_VERSION', '1.5.
|
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)));
|
@@ -32,7 +32,6 @@ $show_avatars = get_option('show_avatars');
|
|
32 |
$wpua_tinymce = get_option('wp_user_avatar_tinymce');
|
33 |
$wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
|
34 |
$wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
|
35 |
-
$wpua_load_scripts = get_option('wp_user_avatar_load_scripts');
|
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';
|
@@ -88,14 +87,9 @@ register_deactivation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_deactivate')
|
|
88 |
// Settings saved to wp_options
|
89 |
function wpua_options(){
|
90 |
add_option('avatar_default_wp_user_avatar', "");
|
91 |
-
add_option('wp_user_avatar_tinymce', '1');
|
92 |
add_option('wp_user_avatar_allow_upload', '0');
|
93 |
-
if(class_exists('bbPress') || class_exists('theme_my_login')){
|
94 |
-
add_option('wp_user_avatar_load_scripts', '1');
|
95 |
-
} else {
|
96 |
-
add_option('wp_user_avatar_load_scripts', '0');
|
97 |
-
}
|
98 |
add_option('wp_user_avatar_disable_gravatar', '0');
|
|
|
99 |
add_option('wp_user_avatar_upload_size_limit', '0');
|
100 |
}
|
101 |
add_action('admin_init', 'wpua_options');
|
@@ -263,35 +257,31 @@ function wpua_deactivate(){
|
|
263 |
if(!class_exists('wp_user_avatar')){
|
264 |
class wp_user_avatar{
|
265 |
function wp_user_avatar(){
|
266 |
-
global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $
|
267 |
// Add WPUA to profile
|
268 |
if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
|
269 |
add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
270 |
add_action('edit_user_profile', array($this, 'wpua_action_show_user_profile'));
|
271 |
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
272 |
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
273 |
-
//
|
274 |
-
if(!
|
275 |
-
|
276 |
}
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
279 |
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
280 |
-
// Admin settings
|
281 |
-
add_action('admin_menu', 'wpua_admin');
|
282 |
-
add_filter('plugin_action_links', array($this, 'wpua_plugin_settings_links'), 10, 2);
|
283 |
-
}
|
284 |
-
// Add scripts to front pages
|
285 |
-
if(!is_admin() && (bool) $wpua_load_scripts == 1){
|
286 |
-
if(!function_exists('get_current_screen')){
|
287 |
-
require_once(ABSPATH.'wp-admin/includes/screen.php');
|
288 |
-
}
|
289 |
-
add_action('wp_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
290 |
}
|
291 |
-
//
|
292 |
-
if(!
|
293 |
-
add_filter('
|
294 |
}
|
|
|
|
|
|
|
295 |
// Hide column in Users table if default avatars are enabled
|
296 |
if(is_admin() && (bool) $show_avatars == 0){
|
297 |
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
@@ -302,13 +292,13 @@ if(!class_exists('wp_user_avatar')){
|
|
302 |
|
303 |
// Add to edit user profile
|
304 |
function wpua_action_show_user_profile($user){
|
305 |
-
global $blog_id, $current_user, $show_avatars, $wpdb, $wpua_upload_size_limit_with_units;
|
306 |
// Get WPUA attachment ID
|
307 |
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
308 |
// Show remove button if WPUA is set
|
309 |
-
$hide_remove = !has_wp_user_avatar($user->ID) ? ' hide
|
310 |
// If avatars are enabled, get original avatar image or show blank
|
311 |
-
$avatar_medium_src = (
|
312 |
// Check if user has wp_user_avatar, if not show image from above
|
313 |
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
|
314 |
// Check if user has wp_user_avatar, if not show image from above
|
@@ -316,15 +306,15 @@ if(!class_exists('wp_user_avatar')){
|
|
316 |
// Change text on message based on current user
|
317 |
$profile = ($current_user->ID == $user->ID) ? '“'.__('Update Profile').'”' : '“'.__('Update User').'”';
|
318 |
?>
|
319 |
-
<?php if(class_exists('bbPress') &&
|
320 |
-
<h2 class="entry-title"><?php _e('
|
321 |
<fieldset class="bbp-form">
|
322 |
-
<legend><?php _e('
|
323 |
<?php else : // Add to profile with admin style ?>
|
324 |
-
<h3><?php _e('
|
325 |
<table class="form-table">
|
326 |
<tr>
|
327 |
-
<th><label for="wp_user_avatar"><?php _e('
|
328 |
<td>
|
329 |
<?php endif; ?>
|
330 |
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
@@ -339,7 +329,7 @@ if(!class_exists('wp_user_avatar')){
|
|
339 |
<?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?>
|
340 |
</p>
|
341 |
<?php elseif(!current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) : // Edit button ?>
|
342 |
-
<?php $edit_attachment_link =
|
343 |
<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>
|
344 |
<?php endif; ?>
|
345 |
<p id="wpua-preview">
|
@@ -352,7 +342,7 @@ if(!class_exists('wp_user_avatar')){
|
|
352 |
</p>
|
353 |
<p><button type="button" class="button<?php echo $hide_remove; ?>" id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?></button></p>
|
354 |
<p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
|
355 |
-
<?php if(class_exists('bbPress') &&
|
356 |
</fieldset>
|
357 |
<?php else : // Add to profile with admin style ?>
|
358 |
</td>
|
@@ -360,7 +350,7 @@ if(!class_exists('wp_user_avatar')){
|
|
360 |
</table>
|
361 |
<?php endif; ?>
|
362 |
<?php echo wpua_js($user->display_name, $avatar_medium_src); // Add JS ?>
|
363 |
-
|
364 |
}
|
365 |
|
366 |
// Set upload size limit for users without upload_files capability
|
@@ -449,7 +439,7 @@ if(!class_exists('wp_user_avatar')){
|
|
449 |
// Add button to attach image for WP 3.4 and older
|
450 |
function wpua_add_attachment_field_to_edit($fields, $post){
|
451 |
$image = wp_get_attachment_image_src($post->ID, "medium");
|
452 |
-
$button = '<button type="button" class="button" id="set-wp-user-avatar-image" name="set-wp-user-avatar-image" onclick="
|
453 |
$fields['wp-user-avatar'] = array(
|
454 |
'label' => __('WP User Avatar', 'wp-user-avatar'),
|
455 |
'input' => 'html',
|
@@ -487,19 +477,13 @@ if(!class_exists('wp_user_avatar')){
|
|
487 |
global $pagenow;
|
488 |
wp_enqueue_script('jquery');
|
489 |
if(current_user_can('upload_files')){
|
490 |
-
|
491 |
-
|
492 |
-
wp_enqueue_media();
|
493 |
-
} else {
|
494 |
-
wp_enqueue_script('media-upload');
|
495 |
-
wp_enqueue_script('thickbox');
|
496 |
-
wp_enqueue_style('thickbox');
|
497 |
-
}
|
498 |
-
wp_enqueue_script('jquery-ui-slider');
|
499 |
}
|
500 |
wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION);
|
501 |
wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
|
502 |
-
if($pagenow == 'options-general.php'){
|
|
|
503 |
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URLPATH.'css/jquery.ui.slider.css', "", null);
|
504 |
}
|
505 |
}
|
@@ -510,13 +494,9 @@ if(!class_exists('wp_user_avatar')){
|
|
510 |
<script type="text/javascript">
|
511 |
jQuery(function(){
|
512 |
<?php if(current_user_can('upload_files')) : ?>
|
513 |
-
<?php
|
514 |
-
openMediaUploader('<?php echo $section; ?>', "<?php _e('Edit Image'); ?>", "<?php _e('Select Image'); ?>");
|
515 |
-
<?php else : // Fall back to Thickbox uploader ?>
|
516 |
-
openThickboxUploader('<?php echo $section; ?>', '<?php echo get_admin_url(); ?>media-upload.php?post_id=0&type=image&tab=library&TB_iframe=1');
|
517 |
-
<?php endif; ?>
|
518 |
<?php endif; ?>
|
519 |
-
|
520 |
});
|
521 |
</script>
|
522 |
<?php
|
@@ -610,11 +590,11 @@ if(!class_exists('wp_user_avatar')){
|
|
610 |
// Get original avatar, for when user removes wp_user_avatar
|
611 |
function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt=""){
|
612 |
global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar;
|
613 |
-
// Remove get_avatar filter
|
614 |
if(is_admin()){
|
615 |
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
616 |
}
|
617 |
-
if($wpua_disable_gravatar != 1){
|
618 |
// User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
619 |
if(!wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar'){
|
620 |
// Show custom Default Avatar
|
@@ -805,7 +785,7 @@ if(!class_exists('wp_user_avatar')){
|
|
805 |
$hide_remove = "";
|
806 |
} else {
|
807 |
$avatar_thumb = $mustache_admin;
|
808 |
-
$hide_remove = ' class="hide
|
809 |
}
|
810 |
// Default Avatar is wp_user_avatar, check the radio button next to it
|
811 |
$selected_avatar = ($avatar_default == 'wp_user_avatar' || (bool) $wpua_disable_gravatar == 1) ? ' checked="checked" ' : "";
|
@@ -870,12 +850,12 @@ if(!class_exists('wp_user_avatar')){
|
|
870 |
|
871 |
// Admin page
|
872 |
function wpua_options_page(){
|
873 |
-
global $show_avatars, $upload_size_limit_with_units, $wpua_allow_upload, $wpua_disable_gravatar, $
|
874 |
// Give subscribers edit_posts capability
|
875 |
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && empty($wpua_allow_upload)){
|
876 |
wpua_subscriber_remove_cap();
|
877 |
}
|
878 |
-
$hide_size = ($wpua_allow_upload != 1) ? ' class="hide
|
879 |
|
880 |
?>
|
881 |
<div class="wrap">
|
@@ -902,14 +882,10 @@ if(!class_exists('wp_user_avatar')){
|
|
902 |
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
|
903 |
<?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
|
904 |
</label>
|
905 |
-
<label for="wp_user_avatar_load_scripts" class="wpua_label">
|
906 |
-
<input name="wp_user_avatar_load_scripts" type="checkbox" id="wp_user_avatar_load_scripts" value="1" <?php checked($wpua_load_scripts, 1); ?> />
|
907 |
-
<?php _e('Allow users to upload avatars in front pages', 'wp-user-avatar'); ?>
|
908 |
-
</label>
|
909 |
</fieldset>
|
910 |
</td>
|
911 |
</tr>
|
912 |
-
<tr id="
|
913 |
<th scope="row">
|
914 |
<label for="wp_user_avatar_upload_size_limit" class="wpua_label">
|
915 |
<?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
|
@@ -922,46 +898,7 @@ if(!class_exists('wp_user_avatar')){
|
|
922 |
<span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
|
923 |
<span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ''); ?></span>
|
924 |
<div id="wpua-slider"></div>
|
925 |
-
|
926 |
-
jQuery(function(){
|
927 |
-
// Show size info only if allow uploads is checked
|
928 |
-
jQuery('#wp_user_avatar_allow_upload').change(function(){
|
929 |
-
jQuery('#wp-size-upload-limit-settings').toggle(jQuery('#wp_user_avatar_allow_upload').is(':checked'));
|
930 |
-
});
|
931 |
-
// Hide Gravatars if disable Gravatars is checked
|
932 |
-
jQuery('#wp_user_avatar_disable_gravatar').change(function(){
|
933 |
-
if(jQuery('#wp-avatars').length){
|
934 |
-
jQuery('#wp-avatars').toggle(!jQuery('#wp_user_avatar_disable_gravatar').is(':checked'));
|
935 |
-
jQuery('#wp_user_avatar_radio').trigger('click');
|
936 |
-
}
|
937 |
-
jQuery('#wpua-message').show();
|
938 |
-
});
|
939 |
-
// Add size slider
|
940 |
-
jQuery('#wpua-slider').slider({
|
941 |
-
value: <?php echo $wpua_upload_size_limit; ?>,
|
942 |
-
min: 0,
|
943 |
-
max: <?php echo wp_max_upload_size(); ?>,
|
944 |
-
step: 1,
|
945 |
-
slide: function(event, ui){
|
946 |
-
jQuery('#wp_user_avatar_upload_size_limit').val(ui.value);
|
947 |
-
jQuery('#wpua-readable-size').html(Math.floor(ui.value / 1024) + 'KB');
|
948 |
-
jQuery('#wpua-readable-size-error').hide();
|
949 |
-
jQuery('#wpua-readable-size').removeClass('wpua-error');
|
950 |
-
}
|
951 |
-
});
|
952 |
-
// Update readable size on keyup
|
953 |
-
jQuery('#wp_user_avatar_upload_size_limit').keyup(function(){
|
954 |
-
var wpua_upload_size_limit = jQuery(this).val();
|
955 |
-
wpua_upload_size_limit = wpua_upload_size_limit.replace(/\D/g, '');
|
956 |
-
// jQuery(this).val(wpua_upload_size_limit);
|
957 |
-
jQuery('#wpua-readable-size').html(Math.floor(wpua_upload_size_limit / 1024) + 'KB');
|
958 |
-
jQuery('#wpua-readable-size-error').toggle(wpua_upload_size_limit > <?php echo wp_max_upload_size(); ?>);
|
959 |
-
jQuery('#wpua-readable-size').toggleClass('wpua-error', wpua_upload_size_limit > <?php echo wp_max_upload_size(); ?>);
|
960 |
-
});
|
961 |
-
jQuery('#wp_user_avatar_upload_size_limit').val(jQuery('#wpua-slider').slider('value'));
|
962 |
-
});
|
963 |
-
</script>
|
964 |
-
<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>
|
965 |
</fieldset>
|
966 |
</td>
|
967 |
</tr>
|
@@ -1015,7 +952,54 @@ if(!class_exists('wp_user_avatar')){
|
|
1015 |
<?php submit_button(); ?>
|
1016 |
</form>
|
1017 |
</div>
|
1018 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1019 |
}
|
1020 |
|
1021 |
// Whitelist settings
|
@@ -1023,7 +1007,6 @@ if(!class_exists('wp_user_avatar')){
|
|
1023 |
register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
1024 |
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
1025 |
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
1026 |
-
register_setting('wpua-settings-group', 'wp_user_avatar_load_scripts', 'intval');
|
1027 |
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
1028 |
register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
1029 |
register_setting('wpua-settings-group', 'avatar_rating');
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.5.3
|
5 |
*/
|
6 |
/*
|
7 |
Plugin Name: 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.5.3
|
13 |
Text Domain: wp-user-avatar
|
14 |
Domain Path: /lang/
|
15 |
*/
|
20 |
}
|
21 |
|
22 |
// Define paths and variables
|
23 |
+
define('WPUA_VERSION', '1.5.3');
|
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)));
|
32 |
$wpua_tinymce = get_option('wp_user_avatar_tinymce');
|
33 |
$wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
|
34 |
$wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
|
|
|
35 |
$mustache_original = WPUA_URLPATH.'images/wp-user-avatar.png';
|
36 |
$mustache_medium = WPUA_URLPATH.'images/wp-user-avatar-300x300.png';
|
37 |
$mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
|
87 |
// Settings saved to wp_options
|
88 |
function wpua_options(){
|
89 |
add_option('avatar_default_wp_user_avatar', "");
|
|
|
90 |
add_option('wp_user_avatar_allow_upload', '0');
|
|
|
|
|
|
|
|
|
|
|
91 |
add_option('wp_user_avatar_disable_gravatar', '0');
|
92 |
+
add_option('wp_user_avatar_tinymce', '1');
|
93 |
add_option('wp_user_avatar_upload_size_limit', '0');
|
94 |
}
|
95 |
add_action('admin_init', 'wpua_options');
|
257 |
if(!class_exists('wp_user_avatar')){
|
258 |
class wp_user_avatar{
|
259 |
function wp_user_avatar(){
|
260 |
+
global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_upload_size_limit;
|
261 |
// Add WPUA to profile
|
262 |
if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
|
263 |
add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
|
264 |
add_action('edit_user_profile', array($this, 'wpua_action_show_user_profile'));
|
265 |
add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
|
266 |
add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
|
267 |
+
// For themes that use this function
|
268 |
+
if(!function_exists('get_current_screen')){
|
269 |
+
require_once(ABSPATH.'wp-admin/includes/screen.php');
|
270 |
}
|
271 |
+
// Load scripts only on profile pages
|
272 |
+
add_action('show_user_profile', array($this, 'wpua_media_upload_scripts'));
|
273 |
+
add_action('edit_user_profile', array($this, 'wpua_media_upload_scripts'));
|
274 |
+
// Add scripts to admin
|
275 |
+
if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && $_GET['page'] == 'wp-user-avatar')){
|
276 |
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
+
// Prefilter upload size
|
279 |
+
if(!current_user_can('upload_files')){
|
280 |
+
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'), 10, 1);
|
281 |
}
|
282 |
+
// Admin menu settings
|
283 |
+
add_action('admin_menu', 'wpua_admin');
|
284 |
+
add_filter('plugin_action_links', array($this, 'wpua_plugin_settings_links'), 10, 2);
|
285 |
// Hide column in Users table if default avatars are enabled
|
286 |
if(is_admin() && (bool) $show_avatars == 0){
|
287 |
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
292 |
|
293 |
// Add to edit user profile
|
294 |
function wpua_action_show_user_profile($user){
|
295 |
+
global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_upload_size_limit_with_units;
|
296 |
// Get WPUA attachment ID
|
297 |
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
|
298 |
// Show remove button if WPUA is set
|
299 |
+
$hide_remove = !has_wp_user_avatar($user->ID) ? ' wpua-hide' : "";
|
300 |
// If avatars are enabled, get original avatar image or show blank
|
301 |
+
$avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
|
302 |
// Check if user has wp_user_avatar, if not show image from above
|
303 |
$avatar_medium = has_wp_user_avatar($user->ID) ? get_wp_user_avatar_src($user->ID, 'medium') : $avatar_medium_src;
|
304 |
// Check if user has wp_user_avatar, if not show image from above
|
306 |
// Change text on message based on current user
|
307 |
$profile = ($current_user->ID == $user->ID) ? '“'.__('Update Profile').'”' : '“'.__('Update User').'”';
|
308 |
?>
|
309 |
+
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
310 |
+
<h2 class="entry-title"><?php _e('Avatar'); ?></h2>
|
311 |
<fieldset class="bbp-form">
|
312 |
+
<legend><?php _e('Image'); ?></legend>
|
313 |
<?php else : // Add to profile with admin style ?>
|
314 |
+
<h3><?php _e('Avatar') ?></h3>
|
315 |
<table class="form-table">
|
316 |
<tr>
|
317 |
+
<th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
|
318 |
<td>
|
319 |
<?php endif; ?>
|
320 |
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
329 |
<?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?>
|
330 |
</p>
|
331 |
<?php elseif(!current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) : // Edit button ?>
|
332 |
+
<?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
|
333 |
<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>
|
334 |
<?php endif; ?>
|
335 |
<p id="wpua-preview">
|
342 |
</p>
|
343 |
<p><button type="button" class="button<?php echo $hide_remove; ?>" id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?></button></p>
|
344 |
<p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
|
345 |
+
<?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
|
346 |
</fieldset>
|
347 |
<?php else : // Add to profile with admin style ?>
|
348 |
</td>
|
350 |
</table>
|
351 |
<?php endif; ?>
|
352 |
<?php echo wpua_js($user->display_name, $avatar_medium_src); // Add JS ?>
|
353 |
+
<?php
|
354 |
}
|
355 |
|
356 |
// Set upload size limit for users without upload_files capability
|
439 |
// Add button to attach image for WP 3.4 and older
|
440 |
function wpua_add_attachment_field_to_edit($fields, $post){
|
441 |
$image = wp_get_attachment_image_src($post->ID, "medium");
|
442 |
+
$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>';
|
443 |
$fields['wp-user-avatar'] = array(
|
444 |
'label' => __('WP User Avatar', 'wp-user-avatar'),
|
445 |
'input' => 'html',
|
477 |
global $pagenow;
|
478 |
wp_enqueue_script('jquery');
|
479 |
if(current_user_can('upload_files')){
|
480 |
+
wp_enqueue_script('admin-bar');
|
481 |
+
wp_enqueue_media();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
}
|
483 |
wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION);
|
484 |
wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
|
485 |
+
if($pagenow == 'options-general.php' && $_GET['page'] == 'wp-user-avatar'){
|
486 |
+
wp_enqueue_script('jquery-ui-slider');
|
487 |
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URLPATH.'css/jquery.ui.slider.css', "", null);
|
488 |
}
|
489 |
}
|
494 |
<script type="text/javascript">
|
495 |
jQuery(function(){
|
496 |
<?php if(current_user_can('upload_files')) : ?>
|
497 |
+
wpuaMediaUploader('<?php echo $section; ?>', "<?php _e('Edit Image'); ?>", "<?php _e('Select Image'); ?>");
|
|
|
|
|
|
|
|
|
498 |
<?php endif; ?>
|
499 |
+
wpuaRemoveAvatar('<?php echo htmlspecialchars_decode($avatar_thumb); ?>');
|
500 |
});
|
501 |
</script>
|
502 |
<?php
|
590 |
// Get original avatar, for when user removes wp_user_avatar
|
591 |
function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt=""){
|
592 |
global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar;
|
593 |
+
// Remove get_avatar filter only in admin
|
594 |
if(is_admin()){
|
595 |
remove_filter('get_avatar', 'wpua_get_avatar_filter');
|
596 |
}
|
597 |
+
if((bool) $wpua_disable_gravatar != 1){
|
598 |
// User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
|
599 |
if(!wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar'){
|
600 |
// Show custom Default Avatar
|
785 |
$hide_remove = "";
|
786 |
} else {
|
787 |
$avatar_thumb = $mustache_admin;
|
788 |
+
$hide_remove = ' class="wpua-hide"';
|
789 |
}
|
790 |
// Default Avatar is wp_user_avatar, check the radio button next to it
|
791 |
$selected_avatar = ($avatar_default == 'wp_user_avatar' || (bool) $wpua_disable_gravatar == 1) ? ' checked="checked" ' : "";
|
850 |
|
851 |
// Admin page
|
852 |
function wpua_options_page(){
|
853 |
+
global $show_avatars, $upload_size_limit_with_units, $wpua_allow_upload, $wpua_disable_gravatar, $wpua_tinymce, $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
|
854 |
// Give subscribers edit_posts capability
|
855 |
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && empty($wpua_allow_upload)){
|
856 |
wpua_subscriber_remove_cap();
|
857 |
}
|
858 |
+
$hide_size = ($wpua_allow_upload != 1) ? ' class="wpua-hide"' : "";
|
859 |
|
860 |
?>
|
861 |
<div class="wrap">
|
882 |
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
|
883 |
<?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
|
884 |
</label>
|
|
|
|
|
|
|
|
|
885 |
</fieldset>
|
886 |
</td>
|
887 |
</tr>
|
888 |
+
<tr id="wpua-size-limit" valign="top"<?php echo $hide_size; ?>>
|
889 |
<th scope="row">
|
890 |
<label for="wp_user_avatar_upload_size_limit" class="wpua_label">
|
891 |
<?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
|
898 |
<span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
|
899 |
<span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ''); ?></span>
|
900 |
<div id="wpua-slider"></div>
|
901 |
+
<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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
</fieldset>
|
903 |
</td>
|
904 |
</tr>
|
952 |
<?php submit_button(); ?>
|
953 |
</form>
|
954 |
</div>
|
955 |
+
<?php
|
956 |
+
add_action('admin_footer', 'wpua_options_page_scripts');
|
957 |
+
}
|
958 |
+
|
959 |
+
// Admin page scripts
|
960 |
+
function wpua_options_page_scripts(){
|
961 |
+
global $wpua_upload_size_limit;
|
962 |
+
?>
|
963 |
+
<script type="text/javascript">
|
964 |
+
jQuery(function(){
|
965 |
+
// Show size info only if allow uploads is checked
|
966 |
+
jQuery('#wp_user_avatar_allow_upload').change(function(){
|
967 |
+
jQuery('#wpua-size-limit').toggle(jQuery('#wp_user_avatar_allow_upload').is(':checked'));
|
968 |
+
});
|
969 |
+
// Hide Gravatars if disable Gravatars is checked
|
970 |
+
jQuery('#wp_user_avatar_disable_gravatar').change(function(){
|
971 |
+
if(jQuery('#wp-avatars').length){
|
972 |
+
jQuery('#wp-avatars').toggle(!jQuery('#wp_user_avatar_disable_gravatar').is(':checked'));
|
973 |
+
jQuery('#wp_user_avatar_radio').trigger('click');
|
974 |
+
}
|
975 |
+
jQuery('#wpua-message').show();
|
976 |
+
});
|
977 |
+
// Add size slider
|
978 |
+
jQuery('#wpua-slider').slider({
|
979 |
+
value: <?php echo $wpua_upload_size_limit; ?>,
|
980 |
+
min: 0,
|
981 |
+
max: <?php echo wp_max_upload_size(); ?>,
|
982 |
+
step: 1,
|
983 |
+
slide: function(event, ui){
|
984 |
+
jQuery('#wp_user_avatar_upload_size_limit').val(ui.value);
|
985 |
+
jQuery('#wpua-readable-size').html(Math.floor(ui.value / 1024) + 'KB');
|
986 |
+
jQuery('#wpua-readable-size-error').hide();
|
987 |
+
jQuery('#wpua-readable-size').removeClass('wpua-error');
|
988 |
+
}
|
989 |
+
});
|
990 |
+
// Update readable size on keyup
|
991 |
+
jQuery('#wp_user_avatar_upload_size_limit').keyup(function(){
|
992 |
+
var wpua_upload_size_limit = jQuery(this).val();
|
993 |
+
wpua_upload_size_limit = wpua_upload_size_limit.replace(/\D/g, '');
|
994 |
+
jQuery(this).val(wpua_upload_size_limit);
|
995 |
+
jQuery('#wpua-readable-size').html(Math.floor(wpua_upload_size_limit / 1024) + 'KB');
|
996 |
+
jQuery('#wpua-readable-size-error').toggle(wpua_upload_size_limit > <?php echo wp_max_upload_size(); ?>);
|
997 |
+
jQuery('#wpua-readable-size').toggleClass('wpua-error', wpua_upload_size_limit > <?php echo wp_max_upload_size(); ?>);
|
998 |
+
});
|
999 |
+
jQuery('#wp_user_avatar_upload_size_limit').val(jQuery('#wpua-slider').slider('value'));
|
1000 |
+
});
|
1001 |
+
</script>
|
1002 |
+
<?php
|
1003 |
}
|
1004 |
|
1005 |
// Whitelist settings
|
1007 |
register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
|
1008 |
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
1009 |
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
|
|
1010 |
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
1011 |
register_setting('wpua-settings-group', 'show_avatars', 'intval');
|
1012 |
register_setting('wpua-settings-group', 'avatar_rating');
|