WP User Avatar - Version 1.5.8

Version Description

  • Bug Fix: Add function exists checks to prevent redeclare errors
  • Bug Fix: Page die if file upload is too big
  • Bug Fix: Upload file with submit
Download this release

Release Info

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

Code changes from version 1.5.4 to 1.5.8

includes/tinymce.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
- * @version 1.5.4
5
  */
6
 
7
  if(!defined('ABSPATH')){
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.5.8
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.4"}}});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.8"}}});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.4
5
  */
6
 
7
  if(!defined('ABSPATH')){
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.5.8
5
  */
6
 
7
  if(!defined('ABSPATH')){
js/wp-user-avatar-user.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Remove WP User Avatar
2
+ function wpuaRemoveAvatar(avatar_thumb){
3
+ jQuery('body').on('click', '#wpua-remove', function(e){
4
+ e.preventDefault();
5
+ jQuery(this).hide();
6
+ jQuery('#wpua-edit, #wpua-thumbnail').hide();
7
+ jQuery('#wpua-preview').find('img').attr('src', avatar_thumb).removeAttr('width', "").removeAttr('height', "");
8
+ jQuery('#wp-user-avatar').val("");
9
+ jQuery('#wpua-message').show();
10
+ jQuery('#wp_user_avatar_radio').trigger('click');
11
+ });
12
+ }
13
+
14
+ jQuery(function(){
15
+ // Add enctype to form with JavaScript as backup
16
+ jQuery('#your-profile').attr('enctype', 'multipart/form-data');
17
+ // Remove settings
18
+ wpuaRemoveAvatar(wpua_custom.avatar_thumb);
19
+ });
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).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)});
1
+ function wpuaMediaUploader(section,edit_text,insert_text){wp.media.wpUserAvatar={get:function(){return wp.media.view.settings.post.wpUserAvatarId},set:function(id){var settings=wp.media.view.settings;settings.post.wpUserAvatarId=id;settings.post.wpUserAvatarSrc=jQuery('div.attachment-info').find('img').attr('src');if(settings.post.wpUserAvatarId){wpuaSetAvatar(settings.post.wpUserAvatarId,settings.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:edit_text+": "+section})]});this._frame.on('open',function(){var selection=this.state().get('selection');id=jQuery('#wp-user-avatar').val();attachment=wp.media.attachment(id);attachment.fetch();selection.add(attachment?[attachment]:[])},this._frame);this._frame.on('toolbar:create:select',function(toolbar){this.createSelectToolbar(toolbar,{text:insert_text})},this._frame);this._frame.state('library').on('select',this.select);return this._frame},select:function(id){var settings=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(attachment,imageURL){jQuery('#wp-user-avatar',window.parent.document).val(attachment);jQuery('#wpua-preview',window.parent.document).find('img').attr('src',imageURL).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(avatar_thumb){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',avatar_thumb).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,9 +4,9 @@
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"
@@ -14,29 +14,29 @@ msgstr ""
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
 
4
  #
5
  msgid ""
6
  msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.8\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-09-07 00:00-0000\n"
10
  "Language: de_DE\n"
11
  "Last-Translator: WP User Avatar\n"
12
  "Language-Team: WP User Avatar\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
15
  "Content-Transfer-Encoding: 8bit\n"
16
 
17
+ #: wp-user-avatar.php:347
18
+ #: wp-user-avatar.php:814
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:891
27
  msgid "Allow Contributors & Subscribers to upload avatars"
28
  msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
29
 
30
+ #: wp-user-avatar.php:896
31
  msgid "Disable Gravatar and use only local avatars"
32
  msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
33
 
34
+ #: wp-user-avatar.php:904
35
+ #: wp-user-avatar.php:909
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:918
40
  msgid "Allow users to edit avatars"
41
  msgstr "Benutzer erlauben, Avatare bearbeiten"
42
 
lang/wp-user-avatar-es_ES.mo CHANGED
Binary file
lang/wp-user-avatar-es_ES.po CHANGED
@@ -4,9 +4,9 @@
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"
@@ -14,29 +14,29 @@ msgstr ""
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
 
4
  #
5
  msgid ""
6
  msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.8\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-09-07 00:00-0000\n"
10
  "Language: es_ES\n"
11
  "Last-Translator: WP User Avatar\n"
12
  "Language-Team: WP User Avatar\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
15
  "Content-Transfer-Encoding: 8bit\n"
16
 
17
+ #: wp-user-avatar.php:347
18
+ #: wp-user-avatar.php:814
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:891
27
  msgid "Allow Contributors & Subscribers to upload avatars"
28
  msgstr "Permitir los colaboradores y los suscriptores subir avatares"
29
 
30
+ #: wp-user-avatar.php:896
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:904
35
+ #: wp-user-avatar.php:909
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:918
40
  msgid "Allow users to edit avatars"
41
  msgstr "Permitir a los usuarios editar avatar"
42
 
lang/wp-user-avatar-fr_FR.mo CHANGED
Binary file
lang/wp-user-avatar-fr_FR.po CHANGED
@@ -4,9 +4,9 @@
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"
@@ -14,29 +14,29 @@ msgstr ""
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
 
4
  #
5
  msgid ""
6
  msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.8\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-09-07 00:00-0000\n"
10
  "Language: fr_FR\n"
11
  "Last-Translator: WP User Avatar\n"
12
  "Language-Team: WP User Avatar\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
15
  "Content-Transfer-Encoding: 8bit\n"
16
 
17
+ #: wp-user-avatar.php:347
18
+ #: wp-user-avatar.php:814
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:891
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:896
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:904
35
+ #: wp-user-avatar.php:909
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:918
40
  msgid "Allow users to edit avatars"
41
  msgstr "Permettre aux utilisateurs de modifier avatar"
42
 
lang/wp-user-avatar-sv_SE.mo CHANGED
Binary file
lang/wp-user-avatar-sv_SE.po CHANGED
@@ -4,9 +4,9 @@
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"
@@ -14,29 +14,29 @@ msgstr ""
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
 
4
  #
5
  msgid ""
6
  msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.5.8\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-09-07 00:00-0000\n"
10
  "Language: sv_SE\n"
11
  "Last-Translator: Mattias Tengblad <mst@eyesx.com>\n"
12
  "Language-Team: WordPress Sverige <info@wpsv.se>\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
15
  "Content-Transfer-Encoding: 8bit\n"
16
 
17
+ #: wp-user-avatar.php:347
18
+ #: wp-user-avatar.php:814
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:886
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:891
27
  msgid "Allow Contributors & Subscribers to upload avatars"
28
  msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
29
 
30
+ #: wp-user-avatar.php:896
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:904
35
+ #: wp-user-avatar.php:909
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:918
40
  msgid "Allow users to edit avatars"
41
  msgstr "Tillåt användare att redigera avatarer"
42
 
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
 
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.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,6 +230,22 @@ Outputs:
230
 
231
  == Changelog ==
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  = 1.5.4 =
234
  * Add: Option to enable avatar editing privilege for Subscribers
235
  * Add: Swedish translation
2
 
3
  Contributors: bangbay
4
  Donate link: http://siboliban.org/donate
5
+ Tags: author avatar, author image, author photo, avatar, avatars, bbPress, user avatar, user image, user photo
6
  Requires at least: 3.5
7
+ Tested up to: 3.6
8
+ Stable tag: 1.5.8
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.8 =
234
+ * Bug Fix: Add function exists checks to prevent redeclare errors
235
+ * Bug Fix: Page die if file upload is too big
236
+ * Bug Fix: Upload file with submit
237
+
238
+ = 1.5.7 =
239
+ * Bug Fix: Separate out JavaScript for Subscribers
240
+ * Bug Fix: Subscriber uploader not finding error type
241
+
242
+ = 1.5.6 =
243
+ * Update: Use cache for wpua_has_gravatar
244
+
245
+ = 1.5.5 =
246
+ * Bug Fix: Hide "Edit Image" button if Contributors & Subscribers can't edit avatar
247
+ * Bug Fix: Remove edit_posts capability if Subscribers can't edit avatar
248
+
249
  = 1.5.4 =
250
  * Add: Option to enable avatar editing privilege for Subscribers
251
  * Add: Swedish translation
uninstall.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
- * @version 1.5.4
5
  */
6
 
7
  // Remove user metadata and options on plugin delete
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.5.8
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.4
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.4
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.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)));
@@ -38,7 +38,6 @@ $mustache_medium = WPUA_URLPATH.'images/wp-user-avatar-300x300.png';
38
  $mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
39
  $mustache_avatar = WPUA_URLPATH.'images/wp-user-avatar-96x96.png';
40
  $mustache_admin = WPUA_URLPATH.'images/wp-user-avatar-32x32.png';
41
- $ssl = is_ssl() ? 's' : "";
42
 
43
  // Check for updates
44
  $wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
@@ -274,7 +273,7 @@ if(!class_exists('wp_user_avatar')){
274
  }
275
  // Prefilter upload size
276
  if(!current_user_can('upload_files')){
277
- add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'), 10, 1);
278
  }
279
  // Admin menu settings
280
  add_action('admin_menu', 'wpua_admin');
@@ -307,6 +306,13 @@ if(!class_exists('wp_user_avatar')){
307
  <h2 class="entry-title"><?php _e('Avatar'); ?></h2>
308
  <fieldset class="bbp-form">
309
  <legend><?php _e('Image'); ?></legend>
 
 
 
 
 
 
 
310
  <?php else : // Add to profile with admin style ?>
311
  <h3><?php _e('Avatar') ?></h3>
312
  <table class="form-table">
@@ -318,8 +324,8 @@ if(!class_exists('wp_user_avatar')){
318
  <?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
319
  <p><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
320
  <?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
321
- <input name="wp-user-avatar-file" id="wpua-file" type="file" />
322
- <button type="submit" class="button" id="upload-wp-user-avatar" name="upload-wp-user-avatar" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
323
  <p>
324
  <?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?>
325
  <br />
@@ -341,6 +347,11 @@ if(!class_exists('wp_user_avatar')){
341
  <p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
342
  <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
343
  </fieldset>
 
 
 
 
 
344
  <?php else : // Add to profile with admin style ?>
345
  </td>
346
  </tr>
@@ -354,7 +365,7 @@ if(!class_exists('wp_user_avatar')){
354
  global $wpua_upload_size_limit;
355
  $size = $file['size'];
356
  if($size > $wpua_upload_size_limit){
357
- $file['error'] = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
358
  }
359
  return $file;
360
  }
@@ -369,6 +380,7 @@ if(!class_exists('wp_user_avatar')){
369
  add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
370
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
371
  } else {
 
372
  if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
373
  // Uploads by user
374
  $attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, 'attachment'));
@@ -381,19 +393,19 @@ if(!class_exists('wp_user_avatar')){
381
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
382
  }
383
  // Create attachment from upload
384
- if(isset($_POST['upload-wp-user-avatar']) && $_POST['upload-wp-user-avatar']){
385
  if(!function_exists('wp_handle_upload')){
386
- require_once(ABSPATH.'wp-admin/includes/admin.php');
387
  require_once(ABSPATH.'wp-admin/includes/file.php');
388
  }
389
- $name = $_FILES['wp-user-avatar-file']['name'];
390
- $file = wp_handle_upload($_FILES['wp-user-avatar-file'], array('test_form' => false));
391
- $type = $file['type'];
392
- // Allow only JPG, GIF, PNG
393
- if($file['error'] || !preg_match('/(jpe?g|gif|png)$/i', $type)){
394
- if($file['error']){
395
- wp_die($file['error']);
396
- } else {
 
397
  wp_die(__('Sorry, this file type is not permitted for security reasons.'));
398
  }
399
  }
@@ -413,7 +425,8 @@ if(!class_exists('wp_user_avatar')){
413
  $attachment = array(
414
  'guid' => $url,
415
  'post_mime_type' => $type,
416
- 'post_title' => $title
 
417
  );
418
  // This should never be set as it would then overwrite an existing attachment
419
  if(isset($attachment['ID'])){
@@ -422,7 +435,6 @@ if(!class_exists('wp_user_avatar')){
422
  // Save the attachment metadata
423
  $attachment_id = wp_insert_attachment($attachment, $file);
424
  if(!is_wp_error($attachment_id)){
425
- require_once(ABSPATH.'wp-admin/includes/image.php');
426
  wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
427
  $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
428
  add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
@@ -475,8 +487,10 @@ if(!class_exists('wp_user_avatar')){
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')){
@@ -501,7 +515,6 @@ if(!class_exists('wp_user_avatar')){
501
 
502
  // Returns true if user has Gravatar-hosted image
503
  function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
504
- global $ssl;
505
  if(!is_object($id_or_email) && !empty($id_or_email)){
506
  // Find user by ID or e-mail address
507
  $user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
@@ -509,12 +522,15 @@ if(!class_exists('wp_user_avatar')){
509
  $email = !empty($user) ? $user->user_email : "";
510
  }
511
  // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
512
- if(!empty($email)){
513
- $hash = md5(strtolower(trim($email)));
514
- $gravatar = 'http'.$ssl.'://www.gravatar.com/avatar/'.$hash.'?d=404';
515
- $headers = @get_headers($gravatar);
516
- $has_gravatar = !preg_match("|200|", $headers[0]) ? false : true;
517
- }
 
 
 
518
  return $has_gravatar;
519
  }
520
 
@@ -606,7 +622,7 @@ if(!class_exists('wp_user_avatar')){
606
  $wpua_image = get_avatar($id_or_email, $size);
607
  // Takes the img tag, extracts the src
608
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
609
- $default = $matches [0] [1];
610
  }
611
  } else {
612
  if(!empty($wpua_avatar_default)){
@@ -700,7 +716,7 @@ if(!class_exists('wp_user_avatar')){
700
  // Takes the img tag, extracts the src
701
  if(!empty($wpua_image)){
702
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
703
- $wpua_image_src = $matches [0] [1];
704
  }
705
  return $wpua_image_src;
706
  }
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.5.8
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.8
13
  Text Domain: wp-user-avatar
14
  Domain Path: /lang/
15
  */
20
  }
21
 
22
  // Define paths and variables
23
+ define('WPUA_VERSION', ' 1.5.8');
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)));
38
  $mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
39
  $mustache_avatar = WPUA_URLPATH.'images/wp-user-avatar-96x96.png';
40
  $mustache_admin = WPUA_URLPATH.'images/wp-user-avatar-32x32.png';
 
41
 
42
  // Check for updates
43
  $wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
273
  }
274
  // Prefilter upload size
275
  if(!current_user_can('upload_files')){
276
+ add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'));
277
  }
278
  // Admin menu settings
279
  add_action('admin_menu', 'wpua_admin');
306
  <h2 class="entry-title"><?php _e('Avatar'); ?></h2>
307
  <fieldset class="bbp-form">
308
  <legend><?php _e('Image'); ?></legend>
309
+ <?php elseif(class_exists('WPUF_Main') && is_page()) : // Add to WP User Frontend profile with same style ?>
310
+ <fieldset>
311
+ <legend><?php _e('Avatar') ?></legend>
312
+ <table class="wpuf-table">
313
+ <tr>
314
+ <th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
315
+ <td>
316
  <?php else : // Add to profile with admin style ?>
317
  <h3><?php _e('Avatar') ?></h3>
318
  <table class="form-table">
324
  <?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
325
  <p><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
326
  <?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
327
+ <input name="wpua-file" id="wpua-file" type="file" />
328
+ <button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
329
  <p>
330
  <?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?>
331
  <br />
347
  <p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
348
  <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
349
  </fieldset>
350
+ <?php elseif(class_exists('WPUF_Main') && is_page()) : // Add to WP User Frontend profile with same style ?>
351
+ </td>
352
+ </tr>
353
+ </table>
354
+ </fieldset>
355
  <?php else : // Add to profile with admin style ?>
356
  </td>
357
  </tr>
365
  global $wpua_upload_size_limit;
366
  $size = $file['size'];
367
  if($size > $wpua_upload_size_limit){
368
+ wp_die(__('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'));
369
  }
370
  return $file;
371
  }
380
  add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
381
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
382
  } else {
383
+ // Remove attachment info if avatar is blank
384
  if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
385
  // Uploads by user
386
  $attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, 'attachment'));
393
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
394
  }
395
  // Create attachment from upload
396
+ if(isset($_POST['submit']) && $_POST['submit'] && isset($_FILES['wpua-file'])){
397
  if(!function_exists('wp_handle_upload')){
 
398
  require_once(ABSPATH.'wp-admin/includes/file.php');
399
  }
400
+ if(!function_exists('wp_generate_attachment_metadata')){
401
+ require_once(ABSPATH.'wp-admin/includes/image.php');
402
+ }
403
+ $name = $_FILES['wpua-file']['name'];
404
+ $file = wp_handle_upload($_FILES['wpua-file'], array('test_form' => false));
405
+ if(isset($_FILES['wpua-file']['type'])){
406
+ $type = $_FILES['wpua-file']['type'];
407
+ // Allow only JPG, GIF, PNG
408
+ if(!preg_match('/(jpe?g|gif|png)$/i', $type)){
409
  wp_die(__('Sorry, this file type is not permitted for security reasons.'));
410
  }
411
  }
425
  $attachment = array(
426
  'guid' => $url,
427
  'post_mime_type' => $type,
428
+ 'post_title' => $title,
429
+ 'post_content' => ""
430
  );
431
  // This should never be set as it would then overwrite an existing attachment
432
  if(isset($attachment['ID'])){
435
  // Save the attachment metadata
436
  $attachment_id = wp_insert_attachment($attachment, $file);
437
  if(!is_wp_error($attachment_id)){
 
438
  wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
439
  $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
440
  add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
487
  if(current_user_can('upload_files')){
488
  wp_enqueue_script('admin-bar');
489
  wp_enqueue_media();
490
+ wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION, true);
491
+ } else {
492
+ wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar-user.js', array('jquery'), WPUA_VERSION, true);
493
  }
 
494
  wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
495
  // Admin scripts
496
  if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
515
 
516
  // Returns true if user has Gravatar-hosted image
517
  function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
 
518
  if(!is_object($id_or_email) && !empty($id_or_email)){
519
  // Find user by ID or e-mail address
520
  $user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
522
  $email = !empty($user) ? $user->user_email : "";
523
  }
524
  // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
525
+ $hash = md5(strtolower(trim($email)));
526
+ $gravatar = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
527
+ $data = wp_cache_get($hash);
528
+ if(false === $data){
529
+ $response = wp_remote_head($gravatar);
530
+ $data = is_wp_error($response) ? 'not200' : $response['response']['code'];
531
+ wp_cache_set($hash, $data, $group="", $expire=60*5);
532
+ }
533
+ $has_gravatar = ($data == '200') ? true : false;
534
  return $has_gravatar;
535
  }
536
 
622
  $wpua_image = get_avatar($id_or_email, $size);
623
  // Takes the img tag, extracts the src
624
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
625
+ $default = !empty($matches) ? $matches [0] [1] : "";
626
  }
627
  } else {
628
  if(!empty($wpua_avatar_default)){
716
  // Takes the img tag, extracts the src
717
  if(!empty($wpua_image)){
718
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
719
+ $wpua_image_src = !empty($matches) ? $matches [0] [1] : "";
720
  }
721
  return $wpua_image_src;
722
  }