WP User Avatar - Version 1.5.4

Version Description

  • Add: Option to enable avatar editing privilege for Subscribers
  • Add: Swedish translation
  • Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
  • Update: Load JavaScript in footer
  • Update: Translations
Download this release

Release Info

Developer bangbay
Plugin Icon 128x128 WP User Avatar
Version 1.5.4
Comparing to
See all releases

Code changes from version 1.5.3 to 1.5.4

css/wp-user-avatar.css CHANGED
@@ -1,12 +1,11 @@
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; }
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; 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 { padding-left: 15px !important; }
9
#wpua-edit #wpua-remove { margin-left: 10px !important; }
10
#wpua-slider { width: 22.75em; }
11
+ .wpua-hide { display: none !important; }
includes/tinymce.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* @package WP User Avatar
4
- * @version 1.5.3
5
*/
6
7
if(!defined('ABSPATH')){
1
<?php
2
/**
3
* @package WP User Avatar
4
+ * @version 1.5.4
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.3"}}});tinymce.PluginManager.add('wpUserAvatar',tinymce.plugins.wpUserAvatar)})();
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.4"}}});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.3
5
*/
6
7
if(!defined('ABSPATH')){
@@ -30,13 +30,13 @@ if(!defined('ABSPATH')){
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
- size_tag = (size_number != '') ? ' size="' + size_number + '"' : size_tag;
36
- var align_tag = (align != '') ? ' align="' + align + '"' : '';
37
- var link_tag = (link != '' && link != 'custom-url' && link_external == '') ? ' link="' + link + '"' : '';
38
- link_tag = (link_external != '') ? ' link="' + link_external + '"' : link_tag;
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
@@ -66,7 +66,7 @@ if(!defined('ABSPATH')){
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='';" style="display:none;">
70
<form name="wpUserAvatar" action="#">
71
<p><label for="<?php esc_attr_e('wp_user_avatar_user'); ?>"><strong><?php _e('User Name'); ?>:</strong></label>
72
<select id="<?php esc_attr_e('wp_user_avatar_user'); ?>" name="<?php esc_attr_e('wp_user_avatar_user'); ?>">
1
<?php
2
/**
3
* @package WP User Avatar
4
+ * @version 1.5.4
5
*/
6
7
if(!defined('ABSPATH')){
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
+ size_tag = (size_number != "") ? ' size="' + size_number + '"' : size_tag;
36
+ var align_tag = (align != "") ? ' align="' + align + '"' : "";
37
+ var link_tag = (link != "" && link != 'custom-url' && link_external == "") ? ' link="' + link + '"' : "";
38
+ link_tag = (link_external != "") ? ' link="' + link_external + '"' : link_tag;
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
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="";" style="display:none;">
70
<form name="wpUserAvatar" action="#">
71
<p><label for="<?php esc_attr_e('wp_user_avatar_user'); ?>"><strong><?php _e('User Name'); ?>:</strong></label>
72
<select id="<?php esc_attr_e('wp_user_avatar_user'); ?>" name="<?php esc_attr_e('wp_user_avatar_user'); ?>">
js/wp-user-avatar-admin.js ADDED
@@ -0,0 +1,37 @@
1
+ jQuery(function(){
2
+ // Show size info only if allow uploads is checked
3
+ jQuery('#wp_user_avatar_allow_upload').change(function(){
4
+ jQuery('#wpua-size-limit').removeClass('wpua-hide').toggle(jQuery('#wp_user_avatar_allow_upload').is(':checked'));
5
+ });
6
+ // Hide Gravatars if disable Gravatars is checked
7
+ jQuery('#wp_user_avatar_disable_gravatar').change(function(){
8
+ if(jQuery('#wp-avatars').length){
9
+ jQuery('#wp-avatars').toggle(!jQuery('#wp_user_avatar_disable_gravatar').is(':checked'));
10
+ jQuery('#wp_user_avatar_radio').trigger('click');
11
+ }
12
+ jQuery('#wpua-message').show();
13
+ });
14
+ // Add size slider
15
+ jQuery('#wpua-slider').slider({
16
+ value: parseInt(wpua_admin.upload_size_limit),
17
+ min: 0,
18
+ max: parseInt(wpua_admin.max_upload_size),
19
+ step: 1,
20
+ slide: function(event, ui){
21
+ jQuery('#wp_user_avatar_upload_size_limit').val(ui.value);
22
+ jQuery('#wpua-readable-size').html(Math.floor(ui.value / 1024) + 'KB');
23
+ jQuery('#wpua-readable-size-error').hide();
24
+ jQuery('#wpua-readable-size').removeClass('wpua-error');
25
+ }
26
+ });
27
+ // Update readable size on keyup
28
+ jQuery('#wp_user_avatar_upload_size_limit').keyup(function(){
29
+ var wpua_upload_size_limit = jQuery(this).val();
30
+ wpua_upload_size_limit = wpua_upload_size_limit.replace(/\D/g, '');
31
+ jQuery(this).val(wpua_upload_size_limit);
32
+ jQuery('#wpua-readable-size').html(Math.floor(wpua_upload_size_limit / 1024) + 'KB');
33
+ jQuery('#wpua-readable-size-error').toggle(wpua_upload_size_limit > parseInt(wpua_admin.max_upload_size));
34
+ jQuery('#wpua-readable-size').toggleClass('wpua-error', wpua_upload_size_limit > parseInt(wpua_admin.max_upload_size));
35
+ });
36
+ jQuery('#wp_user_avatar_upload_size_limit').val(jQuery('#wpua-slider').slider('value'));
37
+ });
js/wp-user-avatar.js CHANGED
@@ -1 +1 @@
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')})}
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).removeClass('wpua-hide').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')})}jQuery(function(){jQuery('#your-profile').attr('enctype','multipart/form-data');if(typeof(wp)!='undefined'){wpuaMediaUploader(wpua_custom.section,wpua_custom.edit_image,wpua_custom.select_image)}wpuaRemoveAvatar(wpua_custom.avatar_thumb)});
lang/wp-user-avatar-de_DE.mo CHANGED
Binary file
lang/wp-user-avatar-de_DE.po CHANGED
@@ -4,42 +4,42 @@
4
#
5
msgid ""
6
msgstr ""
7
- "Project-Id-Version: WP User Avatar 1.5.2\n"
8
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
- "POT-Creation-Date: 2013-06-17 00:00-0000\n"
10
- "PO-Revision-Date: 2013-06-25 00:00-0000\n"
11
"Last-Translator: WP User Avatar\n"
12
"Language-Team: WP User Avatar\n"
13
"MIME-Version: 1.0\n"
14
"Content-Type: text/plain; charset=UTF-8\n"
15
"Content-Transfer-Encoding: 8bit\n"
16
17
- #: wp-user-avatar.php:345
18
- #: wp-user-avatar.php:812
19
msgid "Click %s to save your changes"
20
msgstr "Klicken Sie %s, um Ihre Änderungen zu speichern"
21
22
- #: wp-user-avatar.php:886
23
msgid "Add avatar button to Visual Editor"
24
msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
25
26
- #: wp-user-avatar.php:890
27
msgid "Allow Contributors & Subscribers to upload avatars"
28
msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
29
30
- #: wp-user-avatar.php:894
31
msgid "Disable Gravatar and use only local avatars"
32
msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
33
34
- #: wp-user-avatar.php:898
35
- msgid "Allow users to upload avatars in front pages"
36
- msgstr "Benutzer erlaubt, Avatare im Front-End hochladen"
37
-
38
- #: wp-user-avatar.php:906
39
- #: wp-user-avatar.php:911
40
msgid "Upload Size Limit (only for Contributors & Subscribers)"
41
msgstr "Dateigrößenbeschränkung (nur für Mitarbeiter und Abonnenten)"
42
43
#. Plugin Name of the plugin/theme
44
msgid "WP User Avatar"
45
msgstr "WP-Benutzer-Avatar"
4
#
5
msgid ""
6
msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.4\n"
8
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-07-31 00:00-0000\n"
10
+ "Language: de_DE\n"
11
"Last-Translator: WP User Avatar\n"
12
"Language-Team: WP User Avatar\n"
13
"MIME-Version: 1.0\n"
14
"Content-Type: text/plain; charset=UTF-8\n"
15
"Content-Transfer-Encoding: 8bit\n"
16
17
+ #: wp-user-avatar.php:341
18
+ #: wp-user-avatar.php:798
19
msgid "Click %s to save your changes"
20
msgstr "Klicken Sie %s, um Ihre Änderungen zu speichern"
21
22
+ #: wp-user-avatar.php:870
23
msgid "Add avatar button to Visual Editor"
24
msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
25
26
+ #: wp-user-avatar.php:875
27
msgid "Allow Contributors & Subscribers to upload avatars"
28
msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
29
30
+ #: wp-user-avatar.php:880
31
msgid "Disable Gravatar and use only local avatars"
32
msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
33
34
+ #: wp-user-avatar.php:888
35
+ #: wp-user-avatar.php:893
36
msgid "Upload Size Limit (only for Contributors & Subscribers)"
37
msgstr "Dateigrößenbeschränkung (nur für Mitarbeiter und Abonnenten)"
38
39
+ #: wp-user-avatar.php:902
40
+ msgid "Allow users to edit avatars"
41
+ msgstr "Benutzer erlauben, Avatare bearbeiten"
42
+
43
#. Plugin Name of the plugin/theme
44
msgid "WP User Avatar"
45
msgstr "WP-Benutzer-Avatar"
lang/wp-user-avatar-es_ES.mo CHANGED
Binary file
lang/wp-user-avatar-es_ES.po CHANGED
@@ -4,42 +4,42 @@
4
#
5
msgid ""
6
msgstr ""
7
- "Project-Id-Version: WP User Avatar 1.5.2\n"
8
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
- "POT-Creation-Date: 2013-06-17 00:00-0000\n"
10
- "PO-Revision-Date: 2013-06-25 00:00-0000\n"
11
"Last-Translator: WP User Avatar\n"
12
"Language-Team: WP User Avatar\n"
13
"MIME-Version: 1.0\n"
14
"Content-Type: text/plain; charset=UTF-8\n"
15
"Content-Transfer-Encoding: 8bit\n"
16
17
- #: wp-user-avatar.php:345
18
- #: wp-user-avatar.php:812
19
msgid "Click %s to save your changes"
20
msgstr "Haz clic %s para guardar los cambios"
21
22
- #: wp-user-avatar.php:886
23
msgid "Add avatar button to Visual Editor"
24
msgstr "Añadir botón avatar al editor visual"
25
26
- #: wp-user-avatar.php:890
27
msgid "Allow Contributors & Subscribers to upload avatars"
28
msgstr "Permitir los colaboradores y los suscriptores subir avatares"
29
30
- #: wp-user-avatar.php:894
31
msgid "Disable Gravatar and use only local avatars"
32
msgstr "Desactivar Gravatar y utilizar sólo los avatares locales"
33
34
- #: wp-user-avatar.php:898
35
- msgid "Allow users to upload avatars in front pages"
36
- msgstr "Permitir a los usuarios subir avatares en el páginas frontales"
37
-
38
- #: wp-user-avatar.php:906
39
- #: wp-user-avatar.php:911
40
msgid "Upload Size Limit (only for Contributors & Subscribers)"
41
msgstr "Sube límite de tamaño (para colaboradores y suscriptores)"
42
43
#. Plugin Name of the plugin/theme
44
msgid "WP User Avatar"
45
msgstr "WP-Usuario-Avatar"
4
#
5
msgid ""
6
msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.4\n"
8
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-07-31 00:00-0000\n"
10
+ "Language: es_ES\n"
11
"Last-Translator: WP User Avatar\n"
12
"Language-Team: WP User Avatar\n"
13
"MIME-Version: 1.0\n"
14
"Content-Type: text/plain; charset=UTF-8\n"
15
"Content-Transfer-Encoding: 8bit\n"
16
17
+ #: wp-user-avatar.php:341
18
+ #: wp-user-avatar.php:798
19
msgid "Click %s to save your changes"
20
msgstr "Haz clic %s para guardar los cambios"
21
22
+ #: wp-user-avatar.php:870
23
msgid "Add avatar button to Visual Editor"
24
msgstr "Añadir botón avatar al editor visual"
25
26
+ #: wp-user-avatar.php:875
27
msgid "Allow Contributors & Subscribers to upload avatars"
28
msgstr "Permitir los colaboradores y los suscriptores subir avatares"
29
30
+ #: wp-user-avatar.php:880
31
msgid "Disable Gravatar and use only local avatars"
32
msgstr "Desactivar Gravatar y utilizar sólo los avatares locales"
33
34
+ #: wp-user-avatar.php:888
35
+ #: wp-user-avatar.php:893
36
msgid "Upload Size Limit (only for Contributors & Subscribers)"
37
msgstr "Sube límite de tamaño (para colaboradores y suscriptores)"
38
39
+ #: wp-user-avatar.php:902
40
+ msgid "Allow users to edit avatars"
41
+ msgstr "Permitir a los usuarios editar avatar"
42
+
43
#. Plugin Name of the plugin/theme
44
msgid "WP User Avatar"
45
msgstr "WP-Usuario-Avatar"
lang/wp-user-avatar-fr_FR.mo CHANGED
Binary file
lang/wp-user-avatar-fr_FR.po CHANGED
@@ -4,42 +4,42 @@
4
#
5
msgid ""
6
msgstr ""
7
- "Project-Id-Version: WP User Avatar 1.5.2\n"
8
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
- "POT-Creation-Date: 2013-06-17 00:00-0000\n"
10
- "PO-Revision-Date: 2013-06-25 00:00-0000\n"
11
"Last-Translator: WP User Avatar\n"
12
"Language-Team: WP User Avatar\n"
13
"MIME-Version: 1.0\n"
14
"Content-Type: text/plain; charset=UTF-8\n"
15
"Content-Transfer-Encoding: 8bit\n"
16
17
- #: wp-user-avatar.php:345
18
- #: wp-user-avatar.php:812
19
msgid "Click %s to save your changes"
20
msgstr "Cliquez sur %s pour enregistrer vos modifications"
21
22
- #: wp-user-avatar.php:886
23
msgid "Add avatar button to Visual Editor"
24
msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
25
26
- #: wp-user-avatar.php:890
27
msgid "Allow Contributors & Subscribers to upload avatars"
28
msgstr "Permettre aux contributeurs et aux abonnés d'envoyer des avatars"
29
30
- #: wp-user-avatar.php:894
31
msgid "Disable Gravatar and use only local avatars"
32
msgstr "Désactiver Gravatar et utiliser les avatars fournis"
33
34
- #: wp-user-avatar.php:898
35
- msgid "Allow users to upload avatars in front pages"
36
- msgstr "Permettre aux utilisateurs d'envoyer dans les pages frontales"
37
-
38
- #: wp-user-avatar.php:906
39
- #: wp-user-avatar.php:911
40
msgid "Upload Size Limit (only for Contributors & Subscribers)"
41
msgstr "Taille limite d'envoi de fichiers (pour contributeurs et abonnés)"
42
43
#. Plugin Name of the plugin/theme
44
msgid "WP User Avatar"
45
msgstr "WP-Utilisateur-Avatar"
4
#
5
msgid ""
6
msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.4\n"
8
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-07-31 00:00-0000\n"
10
+ "Language: fr_FR\n"
11
"Last-Translator: WP User Avatar\n"
12
"Language-Team: WP User Avatar\n"
13
"MIME-Version: 1.0\n"
14
"Content-Type: text/plain; charset=UTF-8\n"
15
"Content-Transfer-Encoding: 8bit\n"
16
17
+ #: wp-user-avatar.php:341
18
+ #: wp-user-avatar.php:798
19
msgid "Click %s to save your changes"
20
msgstr "Cliquez sur %s pour enregistrer vos modifications"
21
22
+ #: wp-user-avatar.php:870
23
msgid "Add avatar button to Visual Editor"
24
msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
25
26
+ #: wp-user-avatar.php:875
27
msgid "Allow Contributors & Subscribers to upload avatars"
28
msgstr "Permettre aux contributeurs et aux abonnés d'envoyer des avatars"
29
30
+ #: wp-user-avatar.php:880
31
msgid "Disable Gravatar and use only local avatars"
32
msgstr "Désactiver Gravatar et utiliser les avatars fournis"
33
34
+ #: wp-user-avatar.php:888
35
+ #: wp-user-avatar.php:893
36
msgid "Upload Size Limit (only for Contributors & Subscribers)"
37
msgstr "Taille limite d'envoi de fichiers (pour contributeurs et abonnés)"
38
39
+ #: wp-user-avatar.php:902
40
+ msgid "Allow users to edit avatars"
41
+ msgstr "Permettre aux utilisateurs de modifier avatar"
42
+
43
#. Plugin Name of the plugin/theme
44
msgid "WP User Avatar"
45
msgstr "WP-Utilisateur-Avatar"
lang/wp-user-avatar-sv_SE.mo ADDED
Binary file
lang/wp-user-avatar-sv_SE.po ADDED
@@ -0,0 +1,61 @@
1
+ # Swedish (sv_SE) translation for WP User Avatar.
2
+ # Copyright (C) 2013 Bangbay Siboliban.
3
+ # This file is distributed under the same license as the WP User Avatar package.
4
+ #
5
+ msgid ""
6
+ msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.4\n"
8
+ "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-07-31 00:00-0000\n"
10
+ "Language: sv_SE\n"
11
+ "Last-Translator: Mattias Tengblad <mst@eyesx.com>\n"
12
+ "Language-Team: WordPress Sverige <info@wpsv.se>\n"
13
+ "MIME-Version: 1.0\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+
17
+ #: wp-user-avatar.php:341
18
+ #: wp-user-avatar.php:798
19
+ msgid "Click %s to save your changes"
20
+ msgstr "Klicka på %s för att spara dina ändringar"
21
+
22
+ #: wp-user-avatar.php:870
23
+ msgid "Add avatar button to Visual Editor"
24
+ msgstr "Lägg till knapp för avatarer i den visuella redigeraren"
25
+
26
+ #: wp-user-avatar.php:875
27
+ msgid "Allow Contributors & Subscribers to upload avatars"
28
+ msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
29
+
30
+ #: wp-user-avatar.php:880
31
+ msgid "Disable Gravatar and use only local avatars"
32
+ msgstr "Inaktivera Gravatar och använd endast lokala avatarer"
33
+
34
+ #: wp-user-avatar.php:888
35
+ #: wp-user-avatar.php:893
36
+ msgid "Upload Size Limit (only for Contributors & Subscribers)"
37
+ msgstr "Storleksgräns för uppladdningar (endast för medarbetare & prenumeranter)"
38
+
39
+ #: wp-user-avatar.php:902
40
+ msgid "Allow users to edit avatars"
41
+ msgstr "Tillåt användare att redigera avatarer"
42
+
43
+ #. Plugin Name of the plugin/theme
44
+ msgid "WP User Avatar"
45
+ msgstr "Visningsbild (avatar)"
46
+
47
+ #. Plugin URI of the plugin/theme
48
+ msgid "http://wordpress.org/plugins/wp-user-avatar/"
49
+ msgstr "http://wordpress.org/plugins/wp-user-avatar/"
50
+
51
+ #. Description of the plugin/theme
52
+ msgid "Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar."
53
+ msgstr "Använd valfri bild från ditt mediabibliotek i WordPress som en anpassad visningsbild (avatar). Lägg till fördefinierad standardbild."
54
+
55
+ #. Author of the plugin/theme
56
+ msgid "Bangbay Siboliban"
57
+ msgstr "Bangbay Siboliban"
58
+
59
+ #. Author URI of the plugin/theme
60
+ msgid "http://siboliban.org/"
61
+ msgstr "http://siboliban.org/"
readme.txt CHANGED
@@ -4,8 +4,8 @@ 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
@@ -230,6 +230,13 @@ Outputs:
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
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.7-alpha-24927
8
+ Stable tag: 1.5.4
9
License: GPLv2 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
230
231
== Changelog ==
232
233
+ = 1.5.4 =
234
+ * Add: Option to enable avatar editing privilege for Subscribers
235
+ * Add: Swedish translation
236
+ * Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
237
+ * Update: Load JavaScript in footer
238
+ * Update: Translations
239
+
240
= 1.5.3 =
241
* Remove: Option to disable scripts in front pages
242
* Update: Load media upload scripts only on profile and avatar admin pages
uninstall.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* @package WP User Avatar
4
- * @version 1.5.3
5
*/
6
7
// Remove user metadata and options on plugin delete
@@ -22,28 +22,30 @@ if(is_multisite()){
22
foreach($blogs as $blog){
23
switch_to_blog($blog->blog_id);
24
delete_option('avatar_default_wp_user_avatar');
25
- delete_option('wp_user_avatar_tinymce');
26
delete_option('wp_user_avatar_allow_upload');
27
delete_option('wp_user_avatar_disable_gravatar');
28
delete_option('wp_user_avatar_load_scripts');
29
delete_option('wp_user_avatar_upload_size_limit');
30
delete_option('wp_user_avatar_default_avatar_updated');
31
- delete_option('wp_user_avatar_users_updated');
32
delete_option('wp_user_avatar_media_updated');
33
}
34
} else {
35
foreach($users as $user){
36
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar');
37
}
38
delete_option('avatar_default_wp_user_avatar');
39
- delete_option('wp_user_avatar_tinymce');
40
delete_option('wp_user_avatar_allow_upload');
41
delete_option('wp_user_avatar_disable_gravatar');
42
delete_option('wp_user_avatar_load_scripts');
43
delete_option('wp_user_avatar_upload_size_limit');
44
delete_option('wp_user_avatar_default_avatar_updated');
45
- delete_option('wp_user_avatar_users_updated');
46
delete_option('wp_user_avatar_media_updated');
47
}
48
// Delete post meta
49
delete_post_meta_by_key('_wp_attachment_wp_user_avatar');
1
<?php
2
/**
3
* @package WP User Avatar
4
+ * @version 1.5.4
5
*/
6
7
// Remove user metadata and options on plugin delete
22
foreach($blogs as $blog){
23
switch_to_blog($blog->blog_id);
24
delete_option('avatar_default_wp_user_avatar');
25
delete_option('wp_user_avatar_allow_upload');
26
delete_option('wp_user_avatar_disable_gravatar');
27
+ delete_option('wp_user_avatar_edit_avatar');
28
delete_option('wp_user_avatar_load_scripts');
29
+ delete_option('wp_user_avatar_tinymce');
30
delete_option('wp_user_avatar_upload_size_limit');
31
delete_option('wp_user_avatar_default_avatar_updated');
32
delete_option('wp_user_avatar_media_updated');
33
+ delete_option('wp_user_avatar_users_updated');
34
}
35
} else {
36
foreach($users as $user){
37
delete_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar');
38
}
39
delete_option('avatar_default_wp_user_avatar');
40
delete_option('wp_user_avatar_allow_upload');
41
delete_option('wp_user_avatar_disable_gravatar');
42
+ delete_option('wp_user_avatar_edit_avatar');
43
delete_option('wp_user_avatar_load_scripts');
44
+ delete_option('wp_user_avatar_tinymce');
45
delete_option('wp_user_avatar_upload_size_limit');
46
delete_option('wp_user_avatar_default_avatar_updated');
47
delete_option('wp_user_avatar_media_updated');
48
+ delete_option('wp_user_avatar_users_updated');
49
}
50
// Delete post meta
51
delete_post_meta_by_key('_wp_attachment_wp_user_avatar');
wp-user-avatar.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* @package WP User Avatar
4
- * @version 1.5.3
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.3
13
Text Domain: wp-user-avatar
14
Domain Path: /lang/
15
*/
@@ -20,18 +20,19 @@ if(!defined('ABSPATH')){
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)));
27
28
// Define global variables
29
$avatar_default = get_option('avatar_default');
30
- $wpua_avatar_default = get_option('avatar_default_wp_user_avatar');
31
$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
$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';
@@ -76,7 +77,7 @@ if((bool) $wpua_tinymce == 1){
76
}
77
78
// Load translations
79
- load_plugin_textdomain('wp-user-avatar', '', WPUA_FOLDER.'/lang');
80
81
// Initialize default settings
82
register_activation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_options');
@@ -89,6 +90,7 @@ 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
}
@@ -159,17 +161,6 @@ if((bool) $wpua_allow_upload == 1){
159
}
160
add_action('user_edit_form_tag', 'wpua_add_edit_form_multipart_encoding');
161
162
- // Add enctype with JavaScript as backup
163
- function wpua_add_edit_form_multipart_encoding_js(){ ?>
164
- <script type="text/javascript">
165
- jQuery(function(){
166
- jQuery('#your-profile').attr('enctype', 'multipart/form-data');
167
- });
168
- </script>
169
- <?php
170
- }
171
- add_action('wp_head', 'wpua_add_edit_form_multipart_encoding_js');
172
-
173
// Check user role
174
function check_user_role($role, $user_id=null){
175
global $current_user;
@@ -180,16 +171,6 @@ if((bool) $wpua_allow_upload == 1){
180
return in_array($role, (array) $user->roles);
181
}
182
183
- // Give subscribers edit_posts capability
184
- function wpua_subscriber_add_cap(){
185
- global $blog_id, $wpdb;
186
- $wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
187
- $user_roles = get_option($wp_user_roles);
188
- $user_roles['subscriber']['capabilities']['edit_posts'] = true;
189
- update_option($wp_user_roles, $user_roles);
190
- }
191
- add_action('admin_init', 'wpua_subscriber_add_cap');
192
-
193
// Remove menu items
194
function wpua_subscriber_remove_menu_pages(){
195
global $current_user;
@@ -224,8 +205,12 @@ if((bool) $wpua_allow_upload == 1){
224
225
// Restrict access to pages
226
function wpua_subscriber_offlimits(){
227
- global $current_user, $pagenow;
228
- $offlimits = array('edit.php', 'post-new.php', 'edit-comments.php', 'tools.php');
229
if(check_user_role('subscriber', $current_user->ID)){
230
if(in_array($pagenow, $offlimits)){
231
do_action('admin_page_access_denied');
@@ -236,6 +221,18 @@ if((bool) $wpua_allow_upload == 1){
236
add_action('admin_init', 'wpua_subscriber_offlimits');
237
}
238
239
// Remove subscribers edit_posts capability
240
function wpua_subscriber_remove_cap(){
241
global $blog_id, $wpdb;
@@ -260,19 +257,19 @@ if(!class_exists('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
@@ -283,7 +280,7 @@ if(!class_exists('wp_user_avatar')){
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);
288
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
289
}
@@ -292,7 +289,7 @@ if(!class_exists('wp_user_avatar')){
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
@@ -328,7 +325,7 @@ if(!class_exists('wp_user_avatar')){
328
<br />
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; ?>
@@ -349,13 +346,12 @@ if(!class_exists('wp_user_avatar')){
349
</tr>
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
357
function wpua_handle_upload_prefilter($file){
358
- global $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
359
$size = $file['size'];
360
if($size > $wpua_upload_size_limit){
361
$file['error'] = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
@@ -473,35 +469,36 @@ if(!class_exists('wp_user_avatar')){
473
}
474
475
// Media uploader
476
- function wpua_media_upload_scripts(){
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
}
490
}
491
492
- // Uploader scripts
493
- function wpua_js($section, $avatar_thumb){ ?>
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
503
- }
504
-
505
// Returns true if user has Gravatar-hosted image
506
function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
507
global $ssl;
@@ -536,7 +533,7 @@ if(!class_exists('wp_user_avatar')){
536
}
537
538
// Replace get_avatar only in get_wp_user_avatar
539
- function wpua_get_avatar_filter($avatar, $id_or_email, $size="", $default="", $alt=""){
540
global $avatar_default, $comment, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar;
541
// User has WPUA
542
if(is_object($id_or_email)){
@@ -549,7 +546,7 @@ if(!class_exists('wp_user_avatar')){
549
if(has_wp_user_avatar($id_or_email)){
550
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
551
// User has Gravatar and Gravatar is not disabled
552
- } elseif(wpua_has_gravatar($id_or_email) && $wpua_disable_gravatar != 1){
553
$avatar = $avatar;
554
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
555
} elseif($avatar_default == 'wp_user_avatar'){
@@ -788,7 +785,7 @@ if(!class_exists('wp_user_avatar')){
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" ' : "";
792
// Wrap WPUA in div
793
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
794
// Add WPUA to list
@@ -799,8 +796,7 @@ if(!class_exists('wp_user_avatar')){
799
$wpua_list .= '<a href="#" id="wpua-remove"'.$hide_remove.'>'.__('Remove').'</a></p>';
800
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
801
$wpua_list .= '<p id="wpua-message">'.sprintf(__('Click %s to save your changes', 'wp-user-avatar'), '&ldquo;'.__('Save Changes').'&rdquo;').'</p>';
802
- $wpua_list .= wpua_js(__('Default Avatar'), $mustache_admin);
803
- if($wpua_disable_gravatar != 1){
804
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
805
} else {
806
return $wpua_list;
@@ -850,13 +846,12 @@ if(!class_exists('wp_user_avatar')){
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">
862
<?php screen_icon(); ?>
@@ -870,15 +865,17 @@ if(!class_exists('wp_user_avatar')){
870
<td>
871
<fieldset>
872
<legend class="screen-reader-text"><span><?php _e('Settings'); ?></span></legend>
873
- <label for="wp_user_avatar_tinymce" class="wpua_label">
874
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" <?php checked($wpua_tinymce, 1); ?> />
875
<?php _e('Add avatar button to Visual Editor', 'wp-user-avatar'); ?>
876
</label>
877
- <label for="wp_user_avatar_allow_upload" class="wpua_label">
878
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" <?php checked($wpua_allow_upload, 1); ?> />
879
<?php _e('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar'); ?>
880
</label>
881
- <label for="wp_user_avatar_disable_gravatar" class="wpua_label">
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>
@@ -887,7 +884,7 @@ if(!class_exists('wp_user_avatar')){
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'); ?>
892
</label>
893
</th>
@@ -896,9 +893,14 @@ if(!class_exists('wp_user_avatar')){
896
<legend class="screen-reader-text"><span><?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?></span></legend>
897
<input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="<?php echo $wpua_upload_size_limit; ?>" class="regular-text" />
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,66 +954,20 @@ if(!class_exists('wp_user_avatar')){
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
1006
function wpua_admin_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');
1013
- register_setting('wpua-settings-group', 'avatar_default');
1014
- register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar', 'intval');
1015
}
1016
1017
// Add options page and settings
1
<?php
2
/**
3
* @package WP User Avatar
4
+ * @version 1.5.4
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.4
13
Text Domain: wp-user-avatar
14
Domain Path: /lang/
15
*/
20
}
21
22
// Define paths and variables
23
+ define('WPUA_VERSION', ' 1.5.4');
24
define('WPUA_FOLDER', basename(dirname(__FILE__)));
25
define('WPUA_ABSPATH', trailingslashit(str_replace('\\', '/', WP_PLUGIN_DIR.'/'.WPUA_FOLDER)));
26
define('WPUA_URLPATH', trailingslashit(plugins_url(WPUA_FOLDER)));
27
28
// Define global variables
29
$avatar_default = get_option('avatar_default');
30
$show_avatars = get_option('show_avatars');
31
$wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
32
+ $wpua_avatar_default = get_option('avatar_default_wp_user_avatar');
33
$wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
34
+ $wpua_edit_avatar = get_option('wp_user_avatar_edit_avatar');
35
+ $wpua_tinymce = get_option('wp_user_avatar_tinymce');
36
$mustache_original = WPUA_URLPATH.'images/wp-user-avatar.png';
37
$mustache_medium = WPUA_URLPATH.'images/wp-user-avatar-300x300.png';
38
$mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
77
}
78
79
// Load translations
80
+ load_plugin_textdomain('wp-user-avatar', "", WPUA_FOLDER.'/lang');
81
82
// Initialize default settings
83
register_activation_hook(WPUA_ABSPATH.'wp-user-avatar.php', 'wpua_options');
90
add_option('avatar_default_wp_user_avatar', "");
91
add_option('wp_user_avatar_allow_upload', '0');
92
add_option('wp_user_avatar_disable_gravatar', '0');
93
+ add_option('wp_user_avatar_edit_avatar', '1');
94
add_option('wp_user_avatar_tinymce', '1');
95
add_option('wp_user_avatar_upload_size_limit', '0');
96
}
161
}
162
add_action('user_edit_form_tag', 'wpua_add_edit_form_multipart_encoding');
163
164
// Check user role
165
function check_user_role($role, $user_id=null){
166
global $current_user;
171
return in_array($role, (array) $user->roles);
172
}
173
174
// Remove menu items
175
function wpua_subscriber_remove_menu_pages(){
176
global $current_user;
205
206
// Restrict access to pages
207
function wpua_subscriber_offlimits(){
208
+ global $current_user, $pagenow, $wpua_edit_avatar;
209
+ if((bool) $wpua_edit_avatar == 1){
210
+ $offlimits = array('edit.php', 'edit-comments.php', 'post-new.php', 'tools.php');
211
+ } else {
212
+ $offlimits = array('edit.php', 'edit-comments.php', 'post.php', 'post-new.php', 'tools.php');
213
+ }
214
if(check_user_role('subscriber', $current_user->ID)){
215
if(in_array($pagenow, $offlimits)){
216
do_action('admin_page_access_denied');
221
add_action('admin_init', 'wpua_subscriber_offlimits');
222
}
223
224
+ if((bool) $wpua_allow_upload == 1 && (bool) $wpua_edit_avatar == 1){
225
+ // Give subscribers edit_posts capability
226
+ function wpua_subscriber_add_cap(){
227
+ global $blog_id, $wpdb;
228
+ $wp_user_roles = $wpdb->get_blog_prefix($blog_id).'user_roles';
229
+ $user_roles = get_option($wp_user_roles);
230
+ $user_roles['subscriber']['capabilities']['edit_posts'] = true;
231
+ update_option($wp_user_roles, $user_roles);
232
+ }
233
+ add_action('admin_init', 'wpua_subscriber_add_cap');
234
+ }
235
+
236
// Remove subscribers edit_posts capability
237
function wpua_subscriber_remove_cap(){
238
global $blog_id, $wpdb;
257
global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_upload_size_limit;
258
// Add WPUA to profile
259
if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
260
// For themes that use this function
261
if(!function_exists('get_current_screen')){
262
require_once(ABSPATH.'wp-admin/includes/screen.php');
263
}
264
+ // Profile functions and scripts
265
+ add_action('show_user_profile', array('wp_user_avatar', 'wpua_action_show_user_profile'));
266
+ add_action('edit_user_profile', array($this, 'wpua_action_show_user_profile'));
267
+ add_action('personal_options_update', array($this, 'wpua_action_process_option_update'));
268
+ add_action('edit_user_profile_update', array($this, 'wpua_action_process_option_update'));
269
add_action('show_user_profile', array($this, 'wpua_media_upload_scripts'));
270
add_action('edit_user_profile', array($this, 'wpua_media_upload_scripts'));
271
+ // Admin scripts
272
+ if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
273
add_action('admin_enqueue_scripts', array($this, 'wpua_media_upload_scripts'));
274
}
275
// Prefilter upload size
280
add_action('admin_menu', 'wpua_admin');
281
add_filter('plugin_action_links', array($this, 'wpua_plugin_settings_links'), 10, 2);
282
// Hide column in Users table if default avatars are enabled
283
+ if((bool) $show_avatars == 0 && is_admin()){
284
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
285
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
286
}
289
290
// Add to edit user profile
291
function wpua_action_show_user_profile($user){
292
+ global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_edit_avatar, $wpua_upload_size_limit_with_units;
293
// Get WPUA attachment ID
294
$wpua = get_user_meta($user->ID, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
295
// Show remove button if WPUA is set
325
<br />
326
<?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?>
327
</p>
328
+ <?php elseif((bool) $wpua_edit_avatar == 1 && !current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) : // Edit button ?>
329
<?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
330
<p><button type="button" class="button" id="wpua-edit" name="wpua-edit" onclick="window.open('<?php echo $edit_attachment_link; ?>', '_self');"><?php _e('Edit Image'); ?></button></p>
331
<?php endif; ?>
346
</tr>
347
</table>
348
<?php endif; ?>
349
<?php
350
}
351
352
// Set upload size limit for users without upload_files capability
353
function wpua_handle_upload_prefilter($file){
354
+ global $wpua_upload_size_limit;
355
$size = $file['size'];
356
if($size > $wpua_upload_size_limit){
357
$file['error'] = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
469
}
470
471
// Media uploader
472
+ function wpua_media_upload_scripts($user=""){
473
+ global $mustache_admin, $pagenow, $show_avatars, $wpua_upload_size_limit;
474
wp_enqueue_script('jquery');
475
if(current_user_can('upload_files')){
476
wp_enqueue_script('admin-bar');
477
wp_enqueue_media();
478
}
479
+ wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION, true);
480
wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
481
+ // Admin scripts
482
+ if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
483
+ // Size limit slider
484
wp_enqueue_script('jquery-ui-slider');
485
wp_enqueue_style('wp-user-avatar-jqueryui', WPUA_URLPATH.'css/jquery.ui.slider.css', "", null);
486
+ // Remove/edit settings
487
+ $wpua_custom_scripts = array('section' => __('Default Avatar'), 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $mustache_admin);
488
+ wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
489
+ // Settings control
490
+ wp_enqueue_script('wp-user-avatar-admin', WPUA_URLPATH.'js/wp-user-avatar-admin.js', array('wp-user-avatar'), WPUA_VERSION, true);
491
+ $wpua_admin_scripts = array('upload_size_limit' => $wpua_upload_size_limit, 'max_upload_size' => wp_max_upload_size());
492
+ wp_localize_script('wp-user-avatar-admin', 'wpua_admin', $wpua_admin_scripts);
493
+ } else {
494
+ // User remove/edit settings
495
+ $avatar_medium_src = (bool) $show_avatars == 1 ? wpua_get_avatar_original($user->user_email, 96) : includes_url().'images/blank.gif';
496
+ $wpua_custom_scripts = array('section' => $user->display_name, 'edit_image' => __('Edit Image'), 'select_image' => __('Select Image'), 'avatar_thumb' => $avatar_medium_src);
497
+ wp_localize_script('wp-user-avatar', 'wpua_custom', $wpua_custom_scripts);
498
}
499
}
500
}
501
502
// Returns true if user has Gravatar-hosted image
503
function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
504
global $ssl;
533
}
534
535
// Replace get_avatar only in get_wp_user_avatar
536
+ function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt=""){
537
global $avatar_default, $comment, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar;
538
// User has WPUA
539
if(is_object($id_or_email)){
546
if(has_wp_user_avatar($id_or_email)){
547
$avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
548
// User has Gravatar and Gravatar is not disabled
549
+ } elseif((bool) $wpua_disable_gravatar != 1 && wpua_has_gravatar($id_or_email)){
550
$avatar = $avatar;
551
// User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
552
} elseif($avatar_default == 'wp_user_avatar'){
785
$hide_remove = ' class="wpua-hide"';
786
}
787
// Default Avatar is wp_user_avatar, check the radio button next to it
788
+ $selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
789
// Wrap WPUA in div
790
$avatar_thumb_img = '<div id="wpua-preview"><img src="'.$avatar_thumb.'" width="32" /></div>';
791
// Add WPUA to list
796
$wpua_list .= '<a href="#" id="wpua-remove"'.$hide_remove.'>'.__('Remove').'</a></p>';
797
$wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
798
$wpua_list .= '<p id="wpua-message">'.sprintf(__('Click %s to save your changes', 'wp-user-avatar'), '&ldquo;'.__('Save Changes').'&rdquo;').'</p>';
799
+ if((bool) $wpua_disable_gravatar != 1){
800
return $wpua_list.'<div id="wp-avatars">'.$avatar_list.'</div>';
801
} else {
802
return $wpua_list;
846
847
// Admin page
848
function wpua_options_page(){
849
+ global $show_avatars, $upload_size_limit_with_units, $wpua_allow_upload, $wpua_disable_gravatar, $wpua_edit_avatar, $wpua_tinymce, $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
850
// Give subscribers edit_posts capability
851
+ if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && (empty($wpua_allow_upload) || empty($wpua_edit_avatar))){
852
wpua_subscriber_remove_cap();
853
}
854
+ $hide_size = (bool) $wpua_allow_upload != 1 ? ' class="wpua-hide"' : "";
855
?>
856
<div class="wrap">
857
<?php screen_icon(); ?>
865
<td>
866
<fieldset>
867
<legend class="screen-reader-text"><span><?php _e('Settings'); ?></span></legend>
868
+ <label for="wp_user_avatar_tinymce">
869
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" <?php checked($wpua_tinymce, 1); ?> />
870
<?php _e('Add avatar button to Visual Editor', 'wp-user-avatar'); ?>
871
</label>
872
+ <br />
873
+ <label for="wp_user_avatar_allow_upload">
874
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" <?php checked($wpua_allow_upload, 1); ?> />
875
<?php _e('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar'); ?>
876
</label>
877
+ <br />
878
+ <label for="wp_user_avatar_disable_gravatar">
879
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
880
<?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
881
</label>
884
</tr>
885
<tr id="wpua-size-limit" valign="top"<?php echo $hide_size; ?>>
886
<th scope="row">
887
+ <label for="wp_user_avatar_upload_size_limit">
888
<?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
889
</label>
890
</th>
893
<legend class="screen-reader-text"><span><?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?></span></legend>
894
<input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="<?php echo $wpua_upload_size_limit; ?>" class="regular-text" />
895
<span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
896
+ <span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ""); ?></span>
897
<div id="wpua-slider"></div>
898
+ <span class="description"><?php printf(__('Maximum upload file size: %d%s.'), esc_html(wp_max_upload_size()), esc_html(' bytes ('.$upload_size_limit_with_units.')')); ?></span>
899
+ <br />
900
+ <label for="wp_user_avatar_edit_avatar">
901
+ <input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" <?php checked($wpua_edit_avatar, 1); ?> />
902
+ <?php _e('Allow users to edit avatars', 'wp-user-avatar'); ?>
903
+ </label>
904
</fieldset>
905
</td>
906
</tr>
954
<?php submit_button(); ?>
955
</form>
956
</div>
957
+ <?php
958
}
959
960
// Whitelist settings
961
function wpua_admin_settings(){
962
+ register_setting('wpua-settings-group', 'avatar_rating');
963
+ register_setting('wpua-settings-group', 'avatar_default');
964
+ register_setting('wpua-settings-group', 'avatar_default_wp_user_avatar', 'intval');
965
+ register_setting('wpua-settings-group', 'show_avatars', 'intval');
966
register_setting('wpua-settings-group', 'wp_user_avatar_tinymce', 'intval');
967
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
968
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
969
+ register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
970
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
971
}
972
973
// Add options page and settings