WP User Avatar - Version 1.6.7

Version Description

  • Add: Undo button
  • Bug Fix: Get original avatar
Download this release

Release Info

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

Code changes from version 1.5.4 to 1.6.7

css/wp-user-avatar.css CHANGED
@@ -1,11 +1,12 @@
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; }
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, #wpua-undo-button { display: none; }
3
+ #wpua-preview { margin-right: 10px; }
4
  #wpua-preview, #wpua-thumbnail { display: inline-block; text-align: center; vertical-align: top; }
 
5
  #wpua-preview img, #wpua-thumbnail img { max-height: 96px; border: 1px solid #dfdfdf; display: block; }
6
  .defaultavatarpicker #wpua-preview { width: 32px; height: 32px; margin-right: 0; display: inline-block; overflow: hidden; vertical-align: middle; }
7
  .defaultavatarpicker #wpua-preview img { width: 32px; height: auto; border: 0; }
8
  #wpua-edit { padding-left: 15px !important; }
9
+ #wpua-edit #wpua-remove, #wpua-edit #wpua-undo { margin-left: 10px !important; }
10
  #wpua-slider { width: 22.75em; }
11
+ #wpua-upload-messages span { display: block; }
12
  .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.4
5
  */
6
 
7
  if(!defined('ABSPATH')){
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.6.7
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.6.7"}}});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')){
@@ -18,7 +18,7 @@ if(!defined('ABSPATH')){
18
  <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
19
  <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
20
  <script type="text/javascript">
21
- function insert_wp_user_avatar(){
22
  // Custom shortcode values
23
  var shortcode;
24
  var user = document.getElementById('wp_user_avatar_user').value;
@@ -122,7 +122,7 @@ if(!defined('ABSPATH')){
122
  </p>
123
 
124
  <div class="mceActionPanel">
125
- <input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="insert_wp_user_avatar();" />
126
  </div>
127
  </form>
128
  </body>
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.6.7
5
  */
6
 
7
  if(!defined('ABSPATH')){
18
  <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
19
  <script type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
20
  <script type="text/javascript">
21
+ function wpuaInsertAvatar(){
22
  // Custom shortcode values
23
  var shortcode;
24
  var user = document.getElementById('wp_user_avatar_user').value;
122
  </p>
123
 
124
  <div class="mceActionPanel">
125
+ <input type="submit" id="insert" class="button-primary" name="insert" value="<?php _e('Insert into Post'); ?>" onclick="wpuaInsertAvatar();" />
126
  </div>
127
  </form>
128
  </body>
js/wp-user-avatar-admin.js CHANGED
@@ -1,15 +1,20 @@
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({
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-contributors-subscribers').slideToggle(jQuery('#wp_user_avatar_allow_upload').is(':checked'));
5
+ });
6
+ // Show resize info only if resize uploads is checked
7
+ jQuery('#wp_user_avatar_resize_upload').change(function(){
8
+ jQuery('#wpua-resize-sizes').slideToggle(jQuery('#wp_user_avatar_resize_upload').is(':checked'));
9
  });
10
  // Hide Gravatars if disable Gravatars is checked
11
  jQuery('#wp_user_avatar_disable_gravatar').change(function(){
12
  if(jQuery('#wp-avatars').length){
13
+ jQuery('#wp-avatars').slideToggle(!jQuery('#wp_user_avatar_disable_gravatar').is(':checked'));
14
  jQuery('#wp_user_avatar_radio').trigger('click');
15
+ } else {
16
+ jQuery('#wpua-message').show();
17
  }
 
18
  });
19
  // Add size slider
20
  jQuery('#wpua-slider').slider({
js/wp-user-avatar-user.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function(){
2
+ // Add enctype to form with JavaScript as backup
3
+ jQuery('#your-profile').attr('enctype', 'multipart/form-data');
4
+ // Store WP User Avatar ID
5
+ var wpuaID = jQuery('#wp-user-avatar').val();
6
+ // Store WP User Avatar src
7
+ var wpuaSrc = jQuery('#wpua-preview').find('img').attr('src');
8
+ // Remove WP User Avatar
9
+ jQuery('body').on('click', '#wpua-remove', function(e){
10
+ e.preventDefault();
11
+ jQuery('#wpua-original').remove();
12
+ jQuery('#wpua-remove-button, #wpua-thumbnail').hide();
13
+ jQuery('#wpua-preview').find('img:first').hide();
14
+ jQuery('#wpua-preview').prepend('<img id="wpua-original" height="98" />');
15
+ jQuery('#wpua-original').attr('src', wpua_custom.avatar_thumb);
16
+ jQuery('#wp-user-avatar').val("");
17
+ jQuery('#wpua-message, #wpua-original, #wpua-undo-button').show();
18
+ jQuery('#wp_user_avatar_radio').trigger('click');
19
+ });
20
+ // Undo WP User Avatar
21
+ jQuery('body').on('click', '#wpua-undo', function(e){
22
+ e.preventDefault();
23
+ jQuery('#wpua-original').remove();
24
+ jQuery('#wpua-message, #wpua-undo-button').hide();
25
+ jQuery('#wpua-remove-button, #wpua-thumbnail').show();
26
+ jQuery('#wpua-preview').find('img:first').attr('src', wpuaSrc).show();
27
+ jQuery('#wp-user-avatar').val(wpuaID);
28
+ jQuery('#wp_user_avatar_radio').trigger('click');
29
+ });
30
+ });
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
+ eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5 10(c,d,f){3.6.x={R:5(){J 3.6.K.M.o.E},X:5(a){u b=3.6.K.M;b.o.E=a;b.o.U=0(\'1r.j-1n\').q(\'k\').l(\'p\');L(b.o.E){0(\'#3-r-s\',9.8.h).w(b.o.E);0(\'#2-y\',9.8.h).q(\'k\').l(\'p\',b.o.U).1s(\'Z\',"");0(\'#2-O\',9.8.h).A();0(\'#2-D-n\',9.8.h).A();0(\'#2-i-n\',9.8.h).t();0(\'#2-N\',9.8.h).t();0(\'#B\',9.8.h).C(\'g\');3.6.x.I().13();0(\'#B\').C(\'g\')}},I:5(){L(4.7){J 4.7}4.7=3.6({S:\'Y\',1v:[16 3.6.1a.1b({1c:d+": "+c})]});4.7.m(\'T\',5(){u a=4.S().R(\'v\');F=0(\'#3-r-s\').w();j=3.6.j(F);j.12();a.V(j?[j]:[])},4.7);4.7.m(\'14:15:G\',5(a){4.17(a,{18:f})},4.7);4.7.S(\'Y\').m(\'G\',4.G);J 4.7},G:5(a){u b=3.6.K.M,v=4.R(\'v\').19();3.6.x.X(v?v.F:-1)},W:5(){0(\'P\').m(\'g\',\'#2-V\',5(e){e.Q();e.1e();3.6.x.I().T()})}};0(3.6.x.W)}0(5(){0(\'#1f-1g\').l(\'1h\',\'1i/1j-1k\');L(1l(3)!=\'1m\'){10(H.1o,H.1p,H.1q)}u a=0(\'#3-r-s\').w();u b=0(\'#2-y\').q(\'k\').l(\'p\');0(\'P\').m(\'g\',\'#2-i\',5(e){e.Q();0(\'#2-z\').i();0(\'#2-i-n, #2-N\').t();0(\'#2-y\').q(\'k:11\').t();0(\'#2-y\').1t(\'<k F="2-z" Z="1u" />\');0(\'#2-z\').l(\'p\',H.1d);0(\'#3-r-s\').w("");0(\'#2-O, #2-z, #2-D-n\').A();0(\'#B\').C(\'g\')});0(\'P\').m(\'g\',\'#2-D\',5(e){e.Q();0(\'#2-z\').i();0(\'#2-O, #2-D-n\').t();0(\'#2-i-n, #2-N\').A();0(\'#2-y\').q(\'k:11\').l(\'p\',b).A();0(\'#3-r-s\').w(a);0(\'#B\').C(\'g\')})});',62,94,'jQuery||wpua|wp|this|function|media|_frame|parent|window|||||||click|document|remove|attachment|img|attr|on|button|post|src|find|user|avatar|hide|var|selection|val|wpUserAvatar|preview|original|show|wp_user_avatar_radio|trigger|undo|wpUserAvatarId|id|select|wpua_custom|frame|return|view|if|settings|thumbnail|message|body|preventDefault|get|state|open|wpUserAvatarSrc|add|init|set|library|height|wpuaMediaUploader|first|fetch|close|toolbar|create|new|createSelectToolbar|text|single|controller|Library|title|avatar_thumb|stopPropagation|your|profile|enctype|multipart|form|data|typeof|undefined|info|section|edit_image|select_image|div|removeAttr|prepend|98|states'.split('|'),0,{}))
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,32 +14,57 @@ 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
 
 
 
 
 
 
 
 
 
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.6.7\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-12-13 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:313
18
+ msgid "Do you like WP User Avatar?"
19
+ msgstr "Bist Du mit WP-Benutzer-Avatar zufrieden?"
20
+
21
+ #: wp-user-avatar.php:313
22
+ msgid "Make a donation"
23
+ msgstr "Spenden"
24
+
25
+ #: wp-user-avatar.php:408
26
+ #: wp-user-avatar.php:882
27
  msgid "Click %s to save your changes"
28
  msgstr "Klicken Sie %s, um Ihre Änderungen zu speichern"
29
 
30
+ #: wp-user-avatar.php:523
31
+ msgid "Donate"
32
+ msgstr "Spenden"
33
+
34
+ #: wp-user-avatar.php:956
35
  msgid "Add avatar button to Visual Editor"
36
  msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
37
 
38
+ #: wp-user-avatar.php:962
39
  msgid "Allow Contributors & Subscribers to upload avatars"
40
  msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
41
 
42
+ #: wp-user-avatar.php:968
43
  msgid "Disable Gravatar and use only local avatars"
44
  msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
45
 
46
+ #: wp-user-avatar.php:979
47
+ #: wp-user-avatar.php:984
48
+ msgid "Upload Size Limit"
49
+ msgstr "Dateigrößenbeschränkung"
50
 
51
+ #: wp-user-avatar.php:979
52
+ #: wp-user-avatar.php:984
53
+ msgid "(only for Contributors & Subscribers)"
54
+ msgstr "(nur für Mitarbeiter und Abonnenten)"
55
+
56
+ #: wp-user-avatar.php:994
57
  msgid "Allow users to edit avatars"
58
  msgstr "Benutzer erlauben, Avatare bearbeiten"
59
 
60
+ #: wp-user-avatar.php:1000
61
+ msgid "Resize avatars on upload"
62
+ msgstr "Resize Avatare beim Upload"
63
+
64
+ #: wp-user-avatar.php:1012
65
+ msgid "Crop avatars to exact dimensions"
66
+ msgstr "Avatare auf exakte Größe beschneiden"
67
+
68
  #. Plugin Name of the plugin/theme
69
  msgid "WP User Avatar"
70
  msgstr "WP-Benutzer-Avatar"
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,32 +14,57 @@ 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
 
 
 
 
 
 
 
 
 
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.6.7\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-12-13 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:313
18
+ msgid "Do you like WP User Avatar?"
19
+ msgstr "¿Está satisfecho con WP-Usuario-Avatar?"
20
+
21
+ #: wp-user-avatar.php:313
22
+ msgid "Make a donation"
23
+ msgstr "Donar"
24
+
25
+ #: wp-user-avatar.php:408
26
+ #: wp-user-avatar.php:882
27
  msgid "Click %s to save your changes"
28
  msgstr "Haz clic %s para guardar los cambios"
29
 
30
+ #: wp-user-avatar.php:523
31
+ msgid "Donate"
32
+ msgstr "Donar"
33
+
34
+ #: wp-user-avatar.php:956
35
  msgid "Add avatar button to Visual Editor"
36
  msgstr "Añadir botón avatar al editor visual"
37
 
38
+ #: wp-user-avatar.php:962
39
  msgid "Allow Contributors & Subscribers to upload avatars"
40
  msgstr "Permitir los colaboradores y los suscriptores subir avatares"
41
 
42
+ #: wp-user-avatar.php:968
43
  msgid "Disable Gravatar and use only local avatars"
44
  msgstr "Desactivar Gravatar y utilizar sólo los avatares locales"
45
 
46
+ #: wp-user-avatar.php:979
47
+ #: wp-user-avatar.php:984
48
+ msgid "Upload Size Limit"
49
+ msgstr "Sube límite de tamaño"
50
 
51
+ #: wp-user-avatar.php:979
52
+ #: wp-user-avatar.php:984
53
+ msgid "(only for Contributors & Subscribers)"
54
+ msgstr "(para colaboradores y suscriptores)"
55
+
56
+ #: wp-user-avatar.php:994
57
  msgid "Allow users to edit avatars"
58
  msgstr "Permitir a los usuarios editar avatar"
59
 
60
+ #: wp-user-avatar.php:1000
61
+ msgid "Resize avatars on upload"
62
+ msgstr "Cambiar el tamaño de avatares en carga"
63
+
64
+ #: wp-user-avatar.php:1012
65
+ msgid "Crop avatars to exact dimensions"
66
+ msgstr "Recortar los avatares a sus dimensiones exactas"
67
+
68
  #. Plugin Name of the plugin/theme
69
  msgid "WP User Avatar"
70
  msgstr "WP-Usuario-Avatar"
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,32 +14,57 @@ 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
 
 
 
 
 
 
 
 
 
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.6.7\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-12-13 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:313
18
+ msgid "Do you like WP User Avatar?"
19
+ msgstr "Etes-vous satisfait avec WP-Utilisateur-Avatar?"
20
+
21
+ #: wp-user-avatar.php:313
22
+ msgid "Make a donation"
23
+ msgstr "Faites un don"
24
+
25
+ #: wp-user-avatar.php:408
26
+ #: wp-user-avatar.php:882
27
  msgid "Click %s to save your changes"
28
  msgstr "Cliquez sur %s pour enregistrer vos modifications"
29
 
30
+ #: wp-user-avatar.php:523
31
+ msgid "Donate"
32
+ msgstr "Faites un don"
33
+
34
+ #: wp-user-avatar.php:956
35
  msgid "Add avatar button to Visual Editor"
36
  msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
37
 
38
+ #: wp-user-avatar.php:962
39
  msgid "Allow Contributors & Subscribers to upload avatars"
40
  msgstr "Permettre aux contributeurs et aux abonnés d'envoyer des avatars"
41
 
42
+ #: wp-user-avatar.php:968
43
  msgid "Disable Gravatar and use only local avatars"
44
  msgstr "Désactiver Gravatar et utiliser les avatars fournis"
45
 
46
+ #: wp-user-avatar.php:979
47
+ #: wp-user-avatar.php:984
48
+ msgid "Upload Size Limit"
49
+ msgstr "Taille limite d'envoi de fichiers"
50
 
51
+ #: wp-user-avatar.php:979
52
+ #: wp-user-avatar.php:984
53
+ msgid "(only for Contributors & Subscribers)"
54
+ msgstr "(pour contributeurs et abonnés)"
55
+
56
+ #: wp-user-avatar.php:994
57
  msgid "Allow users to edit avatars"
58
  msgstr "Permettre aux utilisateurs de modifier avatar"
59
 
60
+ #: wp-user-avatar.php:1000
61
+ msgid "Resize avatars on upload"
62
+ msgstr "Redimensionner avatars lors du téléchargement"
63
+
64
+ #: wp-user-avatar.php:1012
65
+ msgid "Crop avatars to exact dimensions"
66
+ msgstr "Recadrer les avatars pour parvenir aux dimensions exactes"
67
+
68
  #. Plugin Name of the plugin/theme
69
  msgid "WP User Avatar"
70
  msgstr "WP-Utilisateur-Avatar"
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,32 +14,57 @@ 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
 
 
 
 
 
 
 
 
 
43
  #. Plugin Name of the plugin/theme
44
  msgid "WP User Avatar"
45
  msgstr "Visningsbild (avatar)"
4
  #
5
  msgid ""
6
  msgstr ""
7
+ "Project-Id-Version: WP User Avatar 1.6.7\n"
8
  "Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
9
+ "PO-Revision-Date: 2013-12-13 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:313
18
+ msgid "Do you like WP User Avatar?"
19
+ msgstr "Är du nöjd med Visningsbild (avatar)?"
20
+
21
+ #: wp-user-avatar.php:313
22
+ msgid "Make a donation"
23
+ msgstr "Donera"
24
+
25
+ #: wp-user-avatar.php:408
26
+ #: wp-user-avatar.php:882
27
  msgid "Click %s to save your changes"
28
  msgstr "Klicka på %s för att spara dina ändringar"
29
 
30
+ #: wp-user-avatar.php:523
31
+ msgid "Donate"
32
+ msgstr "Donera"
33
+
34
+ #: wp-user-avatar.php:956
35
  msgid "Add avatar button to Visual Editor"
36
  msgstr "Lägg till knapp för avatarer i den visuella redigeraren"
37
 
38
+ #: wp-user-avatar.php:962
39
  msgid "Allow Contributors & Subscribers to upload avatars"
40
  msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
41
 
42
+ #: wp-user-avatar.php:968
43
  msgid "Disable Gravatar and use only local avatars"
44
  msgstr "Inaktivera Gravatar och använd endast lokala avatarer"
45
 
46
+ #: wp-user-avatar.php:979
47
+ #: wp-user-avatar.php:984
48
+ msgid "Upload Size Limit"
49
+ msgstr "Storleksgräns för uppladdningar"
50
 
51
+ #: wp-user-avatar.php:979
52
+ #: wp-user-avatar.php:984
53
+ msgid "(only for Contributors & Subscribers)"
54
+ msgstr "(endast för medarbetare & prenumeranter)"
55
+
56
+ #: wp-user-avatar.php:994
57
  msgid "Allow users to edit avatars"
58
  msgstr "Tillåt användare att redigera avatarer"
59
 
60
+ #: wp-user-avatar.php:1000
61
+ msgid "Resize avatars on upload"
62
+ msgstr "Ändra storlek på avatarer på uppladdning"
63
+
64
+ #: wp-user-avatar.php:1012
65
+ msgid "Crop avatars to exact dimensions"
66
+ msgstr "Beskär avatarer till exakta dimensioner"
67
+
68
  #. Plugin Name of the plugin/theme
69
  msgid "WP User Avatar"
70
  msgstr "Visningsbild (avatar)"
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.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
 
@@ -22,7 +22,7 @@ WP User Avatar also lets you:
22
  * Disable [Gravatar](http://gravatar.com/) avatars and use only local avatars.
23
  * Use the <code>[avatar]</code> shortcode in your posts. The shortcode will work with any theme, whether it has avatar support or not.
24
  * Allow Contributors and Subscribers to upload their own avatars.
25
- * Limit upload file size for Contributors and Subscribers.
26
 
27
  == Installation ==
28
 
@@ -126,9 +126,10 @@ First, choose a theme that has avatar support. In your theme, you have a choice
126
 
127
  1. Allows you to use the values "original", "large", "medium", or "thumbnail" for your avatar size.
128
  2. Doesn't add a fixed width and height to the image if you use the aforementioned values. This will give you more flexibility to resize the image with CSS.
129
- 3. Optionally adds CSS classes "alignleft", "alignright", or "aligncenter" to position your avatar.
130
- 4. Shows nothing if the user has no WP User Avatar image.
131
- 5. Shows the user's [Gravatar](http://gravatar.com/) avatar or Default Avatar only if "Show Avatars" is enabled in your WP User Avatar settings.
 
132
 
133
  = get_avatar =
134
 
@@ -143,17 +144,9 @@ First, choose a theme that has avatar support. In your theme, you have a choice
143
  = Can I create a custom Default Avatar? =
144
  In your WP User Avatar settings, you can upload your own Default Avatar.
145
 
146
- = Can I insert WP User Avatar directly into a post? =
147
-
148
- You can use the <code>[avatar]</code> shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.
149
-
150
- `[avatar user="admin" size="96" align="left" link="file"]`
151
-
152
- Outputs:
153
 
154
- `<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
155
- <img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96 alignleft" />
156
- </a>`
157
 
158
  = Can Contributors or Subscribers choose their own WP User Avatar image? =
159
  Yes, if you enable "Allow Contributors & Subscribers to upload avatars" in the WP User Avatar settings. These users will see a slightly different interface because they are allowed only one image upload.
@@ -162,14 +155,14 @@ Yes, if you enable "Allow Contributors & Subscribers to upload avatars" in the W
162
 
163
  Yes, for registered users. Non-registered comment authors will show their [Gravatar](http://gravatar.com/) avatars or Default Avatar.
164
 
165
- = Can I disable all Gravatar avatars? =
166
-
167
- In your WP User Avatar settings, you can select "Disable Gravatar — Use only local avatars" to disable all [Gravatar](http://gravatar.com/) avatars on your site and replace them with your Default Avatar. This will affect your registered users and non-registered comment authors.
168
-
169
  = Will WP User Avatar work with bbPress? =
170
 
171
  Yes!
172
 
 
 
 
 
173
  = Will WP User Avatar work with WordPress Multisite? =
174
 
175
  Yes, however, each site has its own avatar settings. If you set a WP User Avatar image on one site, you have to set it again for different sites in your network.
@@ -178,6 +171,18 @@ Yes, however, each site has its own avatar settings. If you set a WP User Avatar
178
 
179
  For Administrators, WP User Avatar adds a column with avatar thumbnails to your Users list table. If "Show Avatars" is enabled in your WP User Avatar settings, you will see avatars to the left of each username instead of in a new column.
180
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  = What CSS can I use with WP User Avatar? =
182
 
183
  WP User Avatar will add the CSS classes "wp-user-avatar" and "wp-user-avatar-{size}" to your image. If you add an alignment, the corresponding alignment class will be added:
@@ -219,6 +224,90 @@ Outputs:
219
  * <code>has_wp_user_avatar</code>: checks if the user has a WP User Avatar image
220
  * [See example usage here](http://wordpress.org/extend/plugins/wp-user-avatar/installation/)
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  == Screenshots ==
223
 
224
  1. WP User Avatar admin settings.
@@ -230,8 +319,58 @@ Outputs:
230
 
231
  == Changelog ==
232
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  = 1.5.4 =
234
- * Add: Option to enable avatar editing privilege for Subscribers
235
  * Add: Swedish translation
236
  * Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
237
  * Update: Load JavaScript in footer
@@ -263,7 +402,7 @@ Outputs:
263
  * Bug Fix: Use wp_die for errors
264
 
265
  = 1.4 =
266
- * Add: Uploader for Subscribers and Contributors
267
  * Add: Media states for avatar images
268
  * Add: Plugin admin settings
269
  * Update: Change support only to WP 3.4+
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.8
8
+ Stable tag: 1.6.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
22
  * Disable [Gravatar](http://gravatar.com/) avatars and use only local avatars.
23
  * Use the <code>[avatar]</code> shortcode in your posts. The shortcode will work with any theme, whether it has avatar support or not.
24
  * Allow Contributors and Subscribers to upload their own avatars.
25
+ * Limit upload file size and image dimensions for Contributors and Subscribers.
26
 
27
  == Installation ==
28
 
126
 
127
  1. Allows you to use the values "original", "large", "medium", or "thumbnail" for your avatar size.
128
  2. Doesn't add a fixed width and height to the image if you use the aforementioned values. This will give you more flexibility to resize the image with CSS.
129
+ 3. Allows you to use custom image sizes registered with [<code>add_image_size</code>](http://codex.wordpress.org/Function_Reference/add_image_size) (fixed width and height are added to the image).
130
+ 4. Optionally adds CSS classes "alignleft", "alignright", or "aligncenter" to position your avatar.
131
+ 5. Shows nothing if the user has no WP User Avatar image.
132
+ 6. Shows the user's [Gravatar](http://gravatar.com/) avatar or Default Avatar only if "Show Avatars" is enabled in your WP User Avatar settings.
133
 
134
  = get_avatar =
135
 
144
  = Can I create a custom Default Avatar? =
145
  In your WP User Avatar settings, you can upload your own Default Avatar.
146
 
147
+ = Can I disable all Gravatar avatars? =
 
 
 
 
 
 
148
 
149
+ In your WP User Avatar settings, you can select "Disable Gravatar — Use only local avatars" to disable all [Gravatar](http://gravatar.com/) avatars on your site and replace them with your Default Avatar. This will affect your registered users and non-registered comment authors.
 
 
150
 
151
  = Can Contributors or Subscribers choose their own WP User Avatar image? =
152
  Yes, if you enable "Allow Contributors & Subscribers to upload avatars" in the WP User Avatar settings. These users will see a slightly different interface because they are allowed only one image upload.
155
 
156
  Yes, for registered users. Non-registered comment authors will show their [Gravatar](http://gravatar.com/) avatars or Default Avatar.
157
 
 
 
 
 
158
  = Will WP User Avatar work with bbPress? =
159
 
160
  Yes!
161
 
162
+ = Will WP User Avatar work with BuddyPress? =
163
+
164
+ No, BuddyPress has its own custom avatar functions and WP User Avatar will override only some of them. It's best to use BuddyPress without WP User Avatar.
165
+
166
  = Will WP User Avatar work with WordPress Multisite? =
167
 
168
  Yes, however, each site has its own avatar settings. If you set a WP User Avatar image on one site, you have to set it again for different sites in your network.
171
 
172
  For Administrators, WP User Avatar adds a column with avatar thumbnails to your Users list table. If "Show Avatars" is enabled in your WP User Avatar settings, you will see avatars to the left of each username instead of in a new column.
173
 
174
+ = Can I insert WP User Avatar directly into a post? =
175
+
176
+ You can use the <code>[avatar]</code> shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.
177
+
178
+ `[avatar user="admin" size="96" align="left" link="file"]`
179
+
180
+ Outputs:
181
+
182
+ `<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
183
+ <img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96 alignleft" />
184
+ </a>`
185
+
186
  = What CSS can I use with WP User Avatar? =
187
 
188
  WP User Avatar will add the CSS classes "wp-user-avatar" and "wp-user-avatar-{size}" to your image. If you add an alignment, the corresponding alignment class will be added:
224
  * <code>has_wp_user_avatar</code>: checks if the user has a WP User Avatar image
225
  * [See example usage here](http://wordpress.org/extend/plugins/wp-user-avatar/installation/)
226
 
227
+ = There's a call for donations in the WP User Avatar settings. How can I remove it? =
228
+ I've spent countless hours developing this plugin for free. If you're able to give a donation I'd appreciate it, but it's by no means a requirement. You can remove the message by adding this to the <code>functions.php</code> file of your theme:
229
+
230
+ `remove_action('wpua_donation_message', 'wpua_do_donation_message');`
231
+
232
+ == Advanced Settings ==
233
+
234
+ You can change the HTML structure of the WP User Avatar section on your profile edit page by using the functions <code>wpua_before_avatar</code> and <code>wpua_after_avatar</code>. By default, the avatar code is structured like this:
235
+
236
+ `
237
+ <h3>Avatar</h3>
238
+ <table class="form-table">
239
+ <tr>
240
+ <th><label for="wp_user_avatar">Image</label></th>
241
+ <td>
242
+ <input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
243
+ <p id="wpua-add-button">
244
+ <button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
245
+ </p>
246
+ <p id="wpua-preview">
247
+ <img src="{imageURL}" alt="" />
248
+ Original Size
249
+ </p>
250
+ <p id="wpua-thumbnail">
251
+ <img src="{imageURL}" alt="" />
252
+ Thumbnail
253
+ </p>
254
+ <p id="wpua-remove-button">
255
+ <button type="button" class="button" id="wpua-remove" name="wpua-remove">Remove</button>
256
+ </p>
257
+ <p id="wpua-message">
258
+ Click &ldquo;Update Profile&rdquo; to save your changes
259
+ </p>
260
+ </td>
261
+ </tr>
262
+ </table>
263
+ `
264
+
265
+ To strip out the table, you would add the following filters to the <code>functions.php</code> file in your theme:
266
+
267
+ `
268
+ remove_action('wpua_before_avatar', 'wpua_do_before_avatar');
269
+ remove_action('wpua_after_avatar', 'wpua_do_after_avatar');
270
+ `
271
+
272
+ To add your own wrapper, you could create something like this:
273
+
274
+ `
275
+ function my_before_avatar(){
276
+ echo '<div id="my-avatar">';
277
+ }
278
+ add_action('wpua_before_avatar', 'my_before_avatar');
279
+
280
+ function my_after_avatar(){
281
+ echo '</div>';
282
+ }
283
+ add_action('wpua_after_avatar', 'my_after_avatar');
284
+ `
285
+
286
+ This would output:
287
+
288
+ `
289
+ <div id="my-avatar">
290
+ <input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
291
+ <p id="wpua-add-button">
292
+ <button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
293
+ </p>
294
+ <p id="wpua-preview">
295
+ <img src="{imageURL}" alt="" />
296
+ Original Size
297
+ </p>
298
+ <p id="wpua-thumbnail">
299
+ <img src="{imageURL}" alt="" />
300
+ Thumbnail
301
+ </p>
302
+ <p id="wpua-remove-button">
303
+ <button type="button" class="button" id="wpua-remove" name="wpua-remove">Remove</button>
304
+ </p>
305
+ <p id="wpua-message">
306
+ Click &ldquo;Update Profile&rdquo; to save your changes
307
+ </p>
308
+ </div>
309
+ `
310
+
311
  == Screenshots ==
312
 
313
  1. WP User Avatar admin settings.
319
 
320
  == Changelog ==
321
 
322
+ = 1.6.7 =
323
+ * Add: Undo button
324
+ * Bug Fix: Get original avatar
325
+
326
+ = 1.6.6 =
327
+ * Add: Donation message
328
+ * Bug Fix: Die page when image is too large
329
+ * Bug Fix: Resize images uploaded through plugin only
330
+ * Remove: Unused function
331
+ * Update: Refactor JavaScript
332
+
333
+ = 1.6.5 =
334
+ * Bug Fix: Use entire comment object instead of just e-mail address
335
+
336
+ = 1.6.4 =
337
+ * Bug Fix: Correct avatar not showing in widget
338
+ * Update: Check compatibility to 3.7.1
339
+
340
+ = 1.6.3 =
341
+ * Bug Fix: Checkbox value for "Crop avatars to exact dimensions"
342
+
343
+ = 1.6.2 =
344
+ * Bug Fix: Show Default Avatar if attachment doesn't exist
345
+ * Bug Fix: manage_users_custom_column not returning values
346
+
347
+ = 1.6.1 =
348
+ * Bug Fix: Profile not saving without an avatar for Contributors & Subscribers
349
+
350
+ = 1.6.0 =
351
+ * Add: Filters to change profile HTML structure
352
+ * Add: Recognition of sizes registered with add_image_size
353
+ * Add: Resize image options for Contributors & Subscribers
354
+ * Bug Fix: Rerrange CSS class names
355
+
356
+ = 1.5.8 =
357
+ * Bug Fix: Add function exists checks to prevent redeclare errors
358
+ * Bug Fix: Page die if file upload is too big
359
+ * Bug Fix: Upload file with submit
360
+
361
+ = 1.5.7 =
362
+ * Bug Fix: Separate out JavaScript for Contributors & Subscribers
363
+ * Bug Fix: Subscriber uploader not finding error type
364
+
365
+ = 1.5.6 =
366
+ * Update: Use cache for wpua_has_gravatar
367
+
368
+ = 1.5.5 =
369
+ * Bug Fix: Hide "Edit Image" button if Contributors & Subscribers can't edit avatar
370
+ * Bug Fix: Remove edit_posts capability if Subscribers can't edit avatar
371
+
372
  = 1.5.4 =
373
+ * Add: Option to enable avatar editing privilege for Contributors & Subscribers
374
  * Add: Swedish translation
375
  * Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
376
  * Update: Load JavaScript in footer
402
  * Bug Fix: Use wp_die for errors
403
 
404
  = 1.4 =
405
+ * Add: Uploader for Contributors & Subscribers
406
  * Add: Media states for avatar images
407
  * Add: Plugin admin settings
408
  * Update: Change support only to WP 3.4+
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
@@ -26,6 +26,10 @@ if(is_multisite()){
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');
@@ -41,6 +45,10 @@ if(is_multisite()){
41
  delete_option('wp_user_avatar_disable_gravatar');
42
  delete_option('wp_user_avatar_edit_avatar');
43
  delete_option('wp_user_avatar_load_scripts');
 
 
 
 
44
  delete_option('wp_user_avatar_tinymce');
45
  delete_option('wp_user_avatar_upload_size_limit');
46
  delete_option('wp_user_avatar_default_avatar_updated');
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.6.7
5
  */
6
 
7
  // Remove user metadata and options on plugin delete
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_resize_crop');
30
+ delete_option('wp_user_avatar_resize_h');
31
+ delete_option('wp_user_avatar_resize_upload');
32
+ delete_option('wp_user_avatar_resize_w');
33
  delete_option('wp_user_avatar_tinymce');
34
  delete_option('wp_user_avatar_upload_size_limit');
35
  delete_option('wp_user_avatar_default_avatar_updated');
45
  delete_option('wp_user_avatar_disable_gravatar');
46
  delete_option('wp_user_avatar_edit_avatar');
47
  delete_option('wp_user_avatar_load_scripts');
48
+ delete_option('wp_user_avatar_resize_crop');
49
+ delete_option('wp_user_avatar_resize_h');
50
+ delete_option('wp_user_avatar_resize_upload');
51
+ delete_option('wp_user_avatar_resize_w');
52
  delete_option('wp_user_avatar_tinymce');
53
  delete_option('wp_user_avatar_upload_size_limit');
54
  delete_option('wp_user_avatar_default_avatar_updated');
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)));
@@ -32,13 +32,16 @@ $wpua_allow_upload = get_option('wp_user_avatar_allow_upload');
32
  $wpua_avatar_default = get_option('avatar_default_wp_user_avatar');
33
  $wpua_disable_gravatar = get_option('wp_user_avatar_disable_gravatar');
34
  $wpua_edit_avatar = get_option('wp_user_avatar_edit_avatar');
 
 
 
 
35
  $wpua_tinymce = get_option('wp_user_avatar_tinymce');
36
  $mustache_original = WPUA_URLPATH.'images/wp-user-avatar.png';
37
  $mustache_medium = WPUA_URLPATH.'images/wp-user-avatar-300x300.png';
38
  $mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
39
  $mustache_avatar = WPUA_URLPATH.'images/wp-user-avatar-96x96.png';
40
  $mustache_admin = WPUA_URLPATH.'images/wp-user-avatar-32x32.png';
41
- $ssl = is_ssl() ? 's' : "";
42
 
43
  // Check for updates
44
  $wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
@@ -91,6 +94,10 @@ function wpua_options(){
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
  }
@@ -162,7 +169,7 @@ if((bool) $wpua_allow_upload == 1){
162
  add_action('user_edit_form_tag', 'wpua_add_edit_form_multipart_encoding');
163
 
164
  // Check user role
165
- function check_user_role($role, $user_id=null){
166
  global $current_user;
167
  $user = is_numeric($user_id) ? get_userdata($user_id) : $current_user->ID;
168
  if(empty($user)){
@@ -174,7 +181,7 @@ if((bool) $wpua_allow_upload == 1){
174
  // Remove menu items
175
  function wpua_subscriber_remove_menu_pages(){
176
  global $current_user;
177
- if(check_user_role('subscriber', $current_user->ID)){
178
  remove_menu_page('edit.php');
179
  remove_menu_page('edit-comments.php');
180
  remove_menu_page('tools.php');
@@ -185,7 +192,7 @@ if((bool) $wpua_allow_upload == 1){
185
  // Remove menu bar items
186
  function wpua_subscriber_remove_menu_bar_items(){
187
  global $current_user, $wp_admin_bar;
188
- if(check_user_role('subscriber', $current_user->ID)){
189
  $wp_admin_bar->remove_menu('comments');
190
  $wp_admin_bar->remove_menu('new-content');
191
  }
@@ -195,7 +202,7 @@ if((bool) $wpua_allow_upload == 1){
195
  // Remove dashboard items
196
  function wpua_subscriber_remove_dashboard_widgets(){
197
  global $current_user;
198
- if(check_user_role('subscriber', $current_user->ID)){
199
  remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
200
  remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
201
  remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
@@ -211,7 +218,7 @@ if((bool) $wpua_allow_upload == 1){
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');
217
  wp_die(__('You do not have sufficient permissions to access this page.'));
@@ -250,11 +257,74 @@ function wpua_deactivate(){
250
  update_option('avatar_default', 'mystery');
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  // WP User Avatar
254
  if(!class_exists('wp_user_avatar')){
255
  class wp_user_avatar{
256
  function wp_user_avatar(){
257
- global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_upload_size_limit;
258
  // Add WPUA to profile
259
  if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
260
  // For themes that use this function
@@ -274,19 +344,24 @@ 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');
281
- add_filter('plugin_action_links', array($this, 'wpua_plugin_settings_links'), 10, 2);
 
282
  // Hide column in Users table if default avatars are enabled
283
  if((bool) $show_avatars == 0 && is_admin()){
284
  add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
285
  add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
286
  }
 
 
 
 
 
287
  }
288
  }
289
-
290
  // Add to edit user profile
291
  function wpua_action_show_user_profile($user){
292
  global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_edit_avatar, $wpua_upload_size_limit_with_units;
@@ -303,31 +378,22 @@ if(!class_exists('wp_user_avatar')){
303
  // Change text on message based on current user
304
  $profile = ($current_user->ID == $user->ID) ? '&ldquo;'.__('Update Profile').'&rdquo;' : '&ldquo;'.__('Update User').'&rdquo;';
305
  ?>
306
- <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
307
- <h2 class="entry-title"><?php _e('Avatar'); ?></h2>
308
- <fieldset class="bbp-form">
309
- <legend><?php _e('Image'); ?></legend>
310
- <?php else : // Add to profile with admin style ?>
311
- <h3><?php _e('Avatar') ?></h3>
312
- <table class="form-table">
313
- <tr>
314
- <th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
315
- <td>
316
- <?php endif; ?>
317
  <input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
318
  <?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
319
- <p><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
320
  <?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
321
- <input name="wp-user-avatar-file" id="wpua-file" type="file" />
322
- <button type="submit" class="button" id="upload-wp-user-avatar" name="upload-wp-user-avatar" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
323
- <p>
324
- <?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?>
325
- <br />
326
- <?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?>
 
327
  </p>
328
  <?php elseif((bool) $wpua_edit_avatar == 1 && !current_user_can('upload_files') && has_wp_user_avatar($current_user->ID) && wpua_author($wpua, $current_user->ID)) : // Edit button ?>
329
  <?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
330
- <p><button type="button" class="button" id="wpua-edit" name="wpua-edit" onclick="window.open('<?php echo $edit_attachment_link; ?>', '_self');"><?php _e('Edit Image'); ?></button></p>
331
  <?php endif; ?>
332
  <p id="wpua-preview">
333
  <img src="<?php echo $avatar_medium; ?>" alt="" />
@@ -337,15 +403,10 @@ if(!class_exists('wp_user_avatar')){
337
  <img src="<?php echo $avatar_thumbnail; ?>" alt="" />
338
  <?php _e('Thumbnail'); ?>
339
  </p>
340
- <p><button type="button" class="button<?php echo $hide_remove; ?>" id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?></button></p>
 
341
  <p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
342
- <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
343
- </fieldset>
344
- <?php else : // Add to profile with admin style ?>
345
- </td>
346
- </tr>
347
- </table>
348
- <?php endif; ?>
349
  <?php
350
  }
351
 
@@ -353,15 +414,15 @@ if(!class_exists('wp_user_avatar')){
353
  function wpua_handle_upload_prefilter($file){
354
  global $wpua_upload_size_limit;
355
  $size = $file['size'];
356
- if($size > $wpua_upload_size_limit){
357
- $file['error'] = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
358
  }
359
  return $file;
360
  }
361
 
362
  // Update user meta
363
  function wpua_action_process_option_update($user_id){
364
- global $blog_id, $wpdb;
365
  // Check if user has upload_files capability
366
  if(current_user_can('upload_files')){
367
  $wpua_id = isset($_POST['wp-user-avatar']) ? intval($_POST['wp-user-avatar']) : "";
@@ -369,83 +430,85 @@ 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'));
375
  foreach($attachments as $attachment){
376
  // Delete attachment if not used by another user
377
  if(!wpua_image($attachment->ID, $user_id)){
378
- wp_delete_post($attachment->ID);
379
  }
380
  }
381
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
382
  }
383
  // Create attachment from upload
384
- if(isset($_POST['upload-wp-user-avatar']) && $_POST['upload-wp-user-avatar']){
385
  if(!function_exists('wp_handle_upload')){
386
- require_once(ABSPATH.'wp-admin/includes/admin.php');
387
  require_once(ABSPATH.'wp-admin/includes/file.php');
388
  }
389
- $name = $_FILES['wp-user-avatar-file']['name'];
390
- $file = wp_handle_upload($_FILES['wp-user-avatar-file'], array('test_form' => false));
391
- $type = $file['type'];
392
- // Allow only JPG, GIF, PNG
393
- if($file['error'] || !preg_match('/(jpe?g|gif|png)$/i', $type)){
394
- if($file['error']){
395
- wp_die($file['error']);
396
- } else {
397
- wp_die(__('Sorry, this file type is not permitted for security reasons.'));
398
- }
399
  }
400
- // Break out file info
401
- $name_parts = pathinfo($name);
402
- $name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
403
- $url = $file['url'];
404
- $file = $file['file'];
405
- $title = $name;
406
- // Use image exif/iptc data for title if possible
407
- if($image_meta = @wp_read_image_metadata($file)){
408
- if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))){
409
- $title = $image_meta['title'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  }
411
  }
412
- // Construct the attachment array
413
- $attachment = array(
414
- 'guid' => $url,
415
- 'post_mime_type' => $type,
416
- 'post_title' => $title
417
- );
418
- // This should never be set as it would then overwrite an existing attachment
419
- if(isset($attachment['ID'])){
420
- unset($attachment['ID']);
421
- }
422
- // Save the attachment metadata
423
- $attachment_id = wp_insert_attachment($attachment, $file);
424
- if(!is_wp_error($attachment_id)){
425
- require_once(ABSPATH.'wp-admin/includes/image.php');
426
- wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
427
- $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
428
- add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
429
- update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
430
- }
431
  }
432
  }
433
  }
434
 
435
- // Add button to attach image for WP 3.4 and older
436
- function wpua_add_attachment_field_to_edit($fields, $post){
437
- $image = wp_get_attachment_image_src($post->ID, "medium");
438
- $button = '<button type="button" class="button" id="set-wp-user-avatar-image" name="set-wp-user-avatar-image" onclick="wpuaSetAvatar(\''.$post->ID.'\', \''.$image[0].'\')">'.__('Select Image').'</button>';
439
- $fields['wp-user-avatar'] = array(
440
- 'label' => __('WP User Avatar', 'wp-user-avatar'),
441
- 'input' => 'html',
442
- 'html' => $button
443
- );
444
- return $fields;
445
- }
446
-
447
- // Add settings link on plugin page
448
- function wpua_plugin_settings_links($links, $file){
449
  if(basename($file) == basename(plugin_basename(__FILE__))){
450
  $settings_link = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('options-general.php')).'">'.__('Settings').'</a>';
451
  $links = array_merge($links, array($settings_link));
@@ -453,6 +516,16 @@ if(!class_exists('wp_user_avatar')){
453
  return $links;
454
  }
455
 
 
 
 
 
 
 
 
 
 
 
456
  // Add column to Users table
457
  function wpua_add_column($columns){
458
  return $columns + array('wp-user-avatar' => __('WP User Avatar', 'wp-user-avatar'));
@@ -463,9 +536,8 @@ if(!class_exists('wp_user_avatar')){
463
  global $blog_id, $wpdb;
464
  $wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
465
  $wpua_image = wp_get_attachment_image($wpua, array(32,32));
466
- if($column_name == 'wp-user-avatar'){
467
- return $wpua_image;
468
- }
469
  }
470
 
471
  // Media uploader
@@ -475,8 +547,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 +575,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 +582,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
 
@@ -528,17 +604,17 @@ if(!class_exists('wp_user_avatar')){
528
  $user_id = !empty($user) ? $user->ID : "";
529
  }
530
  $wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
531
- $has_wpua = !empty($wpua) ? true : false;
532
  return $has_wpua;
533
  }
534
 
535
  // Replace get_avatar only in get_wp_user_avatar
536
  function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt=""){
537
- global $avatar_default, $comment, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar;
538
  // User has WPUA
539
  if(is_object($id_or_email)){
540
- if(!empty($comment->comment_author_email)){
541
- $avatar = get_wp_user_avatar($comment, $size, $default, $alt);
542
  } else {
543
  $avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
544
  }
@@ -551,14 +627,13 @@ if(!class_exists('wp_user_avatar')){
551
  // User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
552
  } elseif($avatar_default == 'wp_user_avatar'){
553
  // Show custom Default Avatar
554
- if(!empty($wpua_avatar_default)){
555
  // Get image
556
  $wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
557
  // Image src
558
  $default = $wpua_avatar_default_image[0];
559
  // Add dimensions if numeric size
560
  $dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
561
- $defaultcss = "";
562
  } else {
563
  // Get mustache image based on numeric size comparison
564
  if($size > get_option('medium_size_w')){
@@ -574,10 +649,9 @@ if(!class_exists('wp_user_avatar')){
574
  }
575
  // Add dimensions if numeric size
576
  $dimensions = ' width="'.$size.'" height="'.$size.'"';
577
- $defaultcss = ' avatar-default';
578
  }
579
  // Construct the img tag
580
- $avatar = "<img src='".$default."'".$dimensions." alt='".$alt."' class='wp-user-avatar wp-user-avatar-".$size." avatar avatar-".$size." photo'".$defaultcss." />";
581
  }
582
  }
583
  return $avatar;
@@ -587,15 +661,13 @@ if(!class_exists('wp_user_avatar')){
587
  // Get original avatar, for when user removes wp_user_avatar
588
  function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt=""){
589
  global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar;
590
- // Remove get_avatar filter only in admin
591
- if(is_admin()){
592
- remove_filter('get_avatar', 'wpua_get_avatar_filter');
593
- }
594
  if((bool) $wpua_disable_gravatar != 1){
595
  // User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
596
  if(!wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar'){
597
  // Show custom Default Avatar
598
- if(!empty($wpua_avatar_default)){
599
  $wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
600
  $default = $wpua_avatar_default_image[0];
601
  } else {
@@ -606,35 +678,37 @@ 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)){
613
  $wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
614
  $default = $wpua_avatar_default_image[0];
615
  } else {
616
  $default = $mustache_avatar;
617
  }
618
  }
 
 
619
  return $default;
620
  }
621
 
622
  // Find WPUA, show get_avatar if empty
623
- function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt=""){
624
- global $avatar_default, $blog_id, $comment, $post, $wpdb;
625
  // Checks if comment
626
  if(is_object($id_or_email)){
627
  // Checks if comment author is registered user by user ID
628
- if($comment->user_id != 0){
629
- $id_or_email = $comment->user_id;
630
  // Checks that comment author isn't anonymous
631
- } elseif(!empty($comment->comment_author_email)){
632
  // Checks if comment author is registered user by e-mail address
633
- $user = get_user_by('email', $comment->comment_author_email);
634
  // Get registered user info from profile, otherwise e-mail address should be value
635
- $id_or_email = !empty($user) ? $user->ID : $comment->comment_author_email;
636
  }
637
- $alt = $comment->comment_author;
638
  } else {
639
  if(!empty($id_or_email)){
640
  // Find user by ID or e-mail address
@@ -653,14 +727,14 @@ if(!class_exists('wp_user_avatar')){
653
  }
654
  // Set user's ID and name
655
  if(!empty($user)){
656
- $id_or_email = $user->ID;
657
  $alt = $user->display_name;
658
  }
659
  }
660
  // Checks if user has WPUA
661
- $wpua_meta = !empty($id_or_email) ? get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $id_or_email) : "";
662
  // Add alignment class
663
- $alignclass = !empty($align) ? ' align'.$align : "";
664
  // User has WPUA, bypass get_avatar
665
  if(!empty($wpua_meta)){
666
  // Numeric size use size array
@@ -670,24 +744,34 @@ if(!class_exists('wp_user_avatar')){
670
  // Add dimensions to img only if numeric size was specified
671
  $dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
672
  // Construct the img tag
673
- $avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="wp-user-avatar wp-user-avatar-'.$size.$alignclass.' avatar avatar avatar-'.$size.' photo" />';
674
  } else {
675
  // Get numeric sizes for non-numeric sizes based on media options
676
- if($size == 'original' || $size == 'large' || $size == 'medium' || $size == 'thumbnail'){
677
- $get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
 
 
 
 
 
 
 
 
 
678
  } else {
679
  // Numeric sizes leave as-is
680
  $get_size = $size;
681
  }
682
  // User with no WPUA uses get_avatar
683
- $avatar = get_avatar($id_or_email, $get_size, $default="", $alt="");
684
  // Remove width and height for non-numeric sizes
685
- if(!is_numeric($size)){
686
- $avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
687
  $avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
688
- $avatar = str_replace('wp-user-avatar wp-user-avatar-'.$get_size.' ', "", $avatar);
689
- $avatar = str_replace("class='", "class='wp-user-avatar wp-user-avatar-".$size.$alignclass." ", $avatar);
690
  }
 
 
 
691
  }
692
  return $avatar;
693
  }
@@ -700,7 +784,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
  }
@@ -717,7 +801,7 @@ if(!class_exists('wp_user_avatar')){
717
  $user = empty($user) ? get_user_by('email', $user) : $user;
718
  }
719
  // Get user ID
720
- $id_or_email = !empty($user) ? $user->ID : "";
721
  // Check if link is set
722
  if(!empty($link)){
723
  // CSS class is same as link type, except for URL
@@ -776,7 +860,7 @@ if(!class_exists('wp_user_avatar')){
776
  $avatar_list .= '<br />';
777
  }
778
  // Show remove link if custom Default Avatar is set
779
- if(!empty($wpua_avatar_default)){
780
  $avatar_thumb_src = wp_get_attachment_image_src($wpua_avatar_default, array(32,32));
781
  $avatar_thumb = $avatar_thumb_src[0];
782
  $hide_remove = "";
@@ -793,7 +877,7 @@ if(!class_exists('wp_user_avatar')){
793
  $wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
794
  $wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
795
  $wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add">'.__('Edit Image').'</button>';
796
- $wpua_list .= '<a href="#" id="wpua-remove"'.$hide_remove.'>'.__('Remove').'</a></p>';
797
  $wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
798
  $wpua_list .= '<p id="wpua-message">'.sprintf(__('Click %s to save your changes', 'wp-user-avatar'), '&ldquo;'.__('Save Changes').'&rdquo;').'</p>';
799
  if((bool) $wpua_disable_gravatar != 1){
@@ -846,12 +930,13 @@ if(!class_exists('wp_user_avatar')){
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(); ?>
@@ -859,6 +944,7 @@ if(!class_exists('wp_user_avatar')){
859
  <form method="post" action="options.php">
860
  <?php settings_fields('wpua-settings-group'); ?>
861
  <?php do_settings_fields('wpua-settings-group', ""); ?>
 
862
  <table class="form-table">
863
  <tr valign="top">
864
  <th scope="row"><?php _e('Settings'); ?></th>
@@ -869,12 +955,14 @@ if(!class_exists('wp_user_avatar')){
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'); ?>
@@ -882,29 +970,51 @@ if(!class_exists('wp_user_avatar')){
882
  </fieldset>
883
  </td>
884
  </tr>
885
- <tr id="wpua-size-limit" valign="top"<?php echo $hide_size; ?>>
886
- <th scope="row">
887
- <label for="wp_user_avatar_upload_size_limit">
888
- <?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
889
- </label>
890
- </th>
891
- <td>
892
- <fieldset>
893
- <legend class="screen-reader-text"><span><?php _e('Upload Size Limit (only for Contributors & Subscribers)', 'wp-user-avatar'); ?></span></legend>
894
- <input name="wp_user_avatar_upload_size_limit" type="text" id="wp_user_avatar_upload_size_limit" value="<?php echo $wpua_upload_size_limit; ?>" class="regular-text" />
895
- <span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
896
- <span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ""); ?></span>
897
- <div id="wpua-slider"></div>
898
- <span class="description"><?php printf(__('Maximum upload file size: %d%s.'), esc_html(wp_max_upload_size()), esc_html(' bytes ('.$upload_size_limit_with_units.')')); ?></span>
899
- <br />
900
- <label for="wp_user_avatar_edit_avatar">
901
- <input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" <?php checked($wpua_edit_avatar, 1); ?> />
902
- <?php _e('Allow users to edit avatars', 'wp-user-avatar'); ?>
903
- </label>
904
- </fieldset>
905
- </td>
906
- </tr>
907
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
908
  <h3 class="title"><?php _e('Avatars'); ?></h3>
909
  <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
910
  <table class="form-table">
@@ -967,6 +1077,10 @@ if(!class_exists('wp_user_avatar')){
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
 
@@ -983,4 +1097,5 @@ if(!class_exists('wp_user_avatar')){
983
  }
984
  add_action('plugins_loaded', 'wpua_load');
985
  }
 
986
  ?>
1
  <?php
2
  /**
3
  * @package WP User Avatar
4
+ * @version 1.6.7
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.6.7
13
  Text Domain: wp-user-avatar
14
  Domain Path: /lang/
15
  */
20
  }
21
 
22
  // Define paths and variables
23
+ define('WPUA_VERSION', ' 1.6.7');
24
  define('WPUA_FOLDER', basename(dirname(__FILE__)));
25
  define('WPUA_ABSPATH', trailingslashit(str_replace('\\', '/', WP_PLUGIN_DIR.'/'.WPUA_FOLDER)));
26
  define('WPUA_URLPATH', trailingslashit(plugins_url(WPUA_FOLDER)));
32
  $wpua_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_resize_crop = get_option('wp_user_avatar_resize_crop');
36
+ $wpua_resize_h = get_option('wp_user_avatar_resize_h');
37
+ $wpua_resize_upload = get_option('wp_user_avatar_resize_upload');
38
+ $wpua_resize_w = get_option('wp_user_avatar_resize_w');
39
  $wpua_tinymce = get_option('wp_user_avatar_tinymce');
40
  $mustache_original = WPUA_URLPATH.'images/wp-user-avatar.png';
41
  $mustache_medium = WPUA_URLPATH.'images/wp-user-avatar-300x300.png';
42
  $mustache_thumbnail = WPUA_URLPATH.'images/wp-user-avatar-150x150.png';
43
  $mustache_avatar = WPUA_URLPATH.'images/wp-user-avatar-96x96.png';
44
  $mustache_admin = WPUA_URLPATH.'images/wp-user-avatar-32x32.png';
 
45
 
46
  // Check for updates
47
  $wpua_default_avatar_updated = get_option('wp_user_avatar_default_avatar_updated');
94
  add_option('wp_user_avatar_allow_upload', '0');
95
  add_option('wp_user_avatar_disable_gravatar', '0');
96
  add_option('wp_user_avatar_edit_avatar', '1');
97
+ add_option('wp_user_avatar_resize_crop', '0');
98
+ add_option('wp_user_avatar_resize_h', '96');
99
+ add_option('wp_user_avatar_resize_upload', '0');
100
+ add_option('wp_user_avatar_resize_w', '96');
101
  add_option('wp_user_avatar_tinymce', '1');
102
  add_option('wp_user_avatar_upload_size_limit', '0');
103
  }
169
  add_action('user_edit_form_tag', 'wpua_add_edit_form_multipart_encoding');
170
 
171
  // Check user role
172
+ function wpua_check_user_role($role, $user_id=null){
173
  global $current_user;
174
  $user = is_numeric($user_id) ? get_userdata($user_id) : $current_user->ID;
175
  if(empty($user)){
181
  // Remove menu items
182
  function wpua_subscriber_remove_menu_pages(){
183
  global $current_user;
184
+ if(wpua_check_user_role('subscriber', $current_user->ID)){
185
  remove_menu_page('edit.php');
186
  remove_menu_page('edit-comments.php');
187
  remove_menu_page('tools.php');
192
  // Remove menu bar items
193
  function wpua_subscriber_remove_menu_bar_items(){
194
  global $current_user, $wp_admin_bar;
195
+ if(wpua_check_user_role('subscriber', $current_user->ID)){
196
  $wp_admin_bar->remove_menu('comments');
197
  $wp_admin_bar->remove_menu('new-content');
198
  }
202
  // Remove dashboard items
203
  function wpua_subscriber_remove_dashboard_widgets(){
204
  global $current_user;
205
+ if(wpua_check_user_role('subscriber', $current_user->ID)){
206
  remove_meta_box('dashboard_quick_press', 'dashboard', 'side');
207
  remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');
208
  remove_meta_box('dashboard_right_now', 'dashboard', 'normal');
218
  } else {
219
  $offlimits = array('edit.php', 'edit-comments.php', 'post.php', 'post-new.php', 'tools.php');
220
  }
221
+ if(wpua_check_user_role('subscriber', $current_user->ID)){
222
  if(in_array($pagenow, $offlimits)){
223
  do_action('admin_page_access_denied');
224
  wp_die(__('You do not have sufficient permissions to access this page.'));
257
  update_option('avatar_default', 'mystery');
258
  }
259
 
260
+ // Before wrapper for profile
261
+ function wpua_before_avatar(){
262
+ do_action('wpua_before_avatar');
263
+ }
264
+
265
+ // After wrapper for profile
266
+ function wpua_after_avatar(){
267
+ do_action('wpua_after_avatar');
268
+ }
269
+
270
+ // Before avatar container
271
+ function wpua_do_before_avatar(){ ?>
272
+ <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
273
+ <h2 class="entry-title"><?php _e('Avatar'); ?></h2>
274
+ <fieldset class="bbp-form">
275
+ <legend><?php _e('Image'); ?></legend>
276
+ <?php elseif(class_exists('WPUF_Main') && is_page()) : // Add to WP User Frontend profile with same style ?>
277
+ <fieldset>
278
+ <legend><?php _e('Avatar') ?></legend>
279
+ <table class="wpuf-table">
280
+ <tr>
281
+ <th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
282
+ <td>
283
+ <?php else : // Add to profile with admin style ?>
284
+ <h3><?php _e('Avatar') ?></h3>
285
+ <table class="form-table">
286
+ <tr>
287
+ <th><label for="wp_user_avatar"><?php _e('Image'); ?></label></th>
288
+ <td>
289
+ <?php endif; ?>
290
+ <?php
291
+ }
292
+
293
+ // After avatar container
294
+ function wpua_do_after_avatar(){ ?>
295
+ <?php if(class_exists('bbPress') && bbp_is_edit()) : // Add to bbPress profile with same style ?>
296
+ </fieldset>
297
+ <?php elseif(class_exists('WPUF_Main') && is_page()) : // Add to WP User Frontend profile with same style ?>
298
+ </td>
299
+ </tr>
300
+ </table>
301
+ </fieldset>
302
+ <?php else : // Add to profile with admin style ?>
303
+ </td>
304
+ </tr>
305
+ </table>
306
+ <?php endif; ?>
307
+ <?php
308
+ }
309
+
310
+ // Donate message
311
+ function wpua_do_donation_message(){ ?>
312
+ <div class="updated">
313
+ <p><?php _e('Do you like WP User Avatar?', 'wp-user-avatar'); ?> <a href="http://siboliban.org/donate" target="_blank"><?php _e('Make a donation.', 'wp-user-avatar'); ?></a></p>
314
+ </div>
315
+ <?php
316
+ }
317
+
318
+ // Filter for the inevitable complaints about the donation message
319
+ function wpua_donation_message(){
320
+ do_action('wpua_donation_message');
321
+ }
322
+
323
  // WP User Avatar
324
  if(!class_exists('wp_user_avatar')){
325
  class wp_user_avatar{
326
  function wp_user_avatar(){
327
+ global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_resize_upload, $wpua_upload_size_limit;
328
  // Add WPUA to profile
329
  if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
330
  // For themes that use this function
344
  }
345
  // Prefilter upload size
346
  if(!current_user_can('upload_files')){
347
+ add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'));
348
  }
349
  // Admin menu settings
350
  add_action('admin_menu', 'wpua_admin');
351
+ add_filter('plugin_action_links', array($this, 'wpua_action_links'), 10, 2);
352
+ add_filter('plugin_row_meta', array($this, 'wpua_row_meta'), 10, 2);
353
  // Hide column in Users table if default avatars are enabled
354
  if((bool) $show_avatars == 0 && is_admin()){
355
  add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
356
  add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
357
  }
358
+ // Profile wrappers
359
+ add_action('wpua_before_avatar', 'wpua_do_before_avatar');
360
+ add_action('wpua_after_avatar', 'wpua_do_after_avatar');
361
+ // Donate message
362
+ add_action('wpua_donation_message', 'wpua_do_donation_message');
363
  }
364
  }
 
365
  // Add to edit user profile
366
  function wpua_action_show_user_profile($user){
367
  global $blog_id, $current_user, $post, $show_avatars, $wpdb, $wpua_allow_upload, $wpua_edit_avatar, $wpua_upload_size_limit_with_units;
378
  // Change text on message based on current user
379
  $profile = ($current_user->ID == $user->ID) ? '&ldquo;'.__('Update Profile').'&rdquo;' : '&ldquo;'.__('Update User').'&rdquo;';
380
  ?>
381
+ <?php do_action('wpua_before_avatar'); ?>
 
 
 
 
 
 
 
 
 
 
382
  <input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
383
  <?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
384
+ <p id="wpua-add-button"><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
385
  <?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
386
+ <p id="wpua-upload-button">
387
+ <input name="wpua-file" id="wpua-file" type="file" />
388
+ <button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
389
+ </p>
390
+ <p id="wpua-upload-messages">
391
+ <span id="wpua-max-upload"><?php printf(__('Maximum upload file size: %d%s.'), esc_html($wpua_upload_size_limit_with_units), esc_html('KB')); ?></span>
392
+ <span id="wpua-allowed-files"><?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?></span>
393
  </p>
394
  <?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 ?>
395
  <?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
396
+ <p id="wpua-edit-button"><button type="button" class="button" id="wpua-edit" name="wpua-edit" onclick="window.open('<?php echo $edit_attachment_link; ?>', '_self');"><?php _e('Edit Image'); ?></button></p>
397
  <?php endif; ?>
398
  <p id="wpua-preview">
399
  <img src="<?php echo $avatar_medium; ?>" alt="" />
403
  <img src="<?php echo $avatar_thumbnail; ?>" alt="" />
404
  <?php _e('Thumbnail'); ?>
405
  </p>
406
+ <p id="wpua-remove-button" class="<?php echo $hide_remove; ?>"><button type="button" class="button" id="wpua-remove" name="wpua-remove"><?php _e('Default Avatar'); ?></button></p>
407
+ <p id="wpua-undo-button"><button type="button" class="button" id="wpua-undo" name="wpua-undo"><?php _e('Undo'); ?></button></p>
408
  <p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
409
+ <?php do_action('wpua_after_avatar'); ?>
 
 
 
 
 
 
410
  <?php
411
  }
412
 
414
  function wpua_handle_upload_prefilter($file){
415
  global $wpua_upload_size_limit;
416
  $size = $file['size'];
417
+ if(!empty($size) && $size > $wpua_upload_size_limit){
418
+ wp_die(__('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'));
419
  }
420
  return $file;
421
  }
422
 
423
  // Update user meta
424
  function wpua_action_process_option_update($user_id){
425
+ global $blog_id, $wpdb, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w;
426
  // Check if user has upload_files capability
427
  if(current_user_can('upload_files')){
428
  $wpua_id = isset($_POST['wp-user-avatar']) ? intval($_POST['wp-user-avatar']) : "";
430
  add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
431
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
432
  } else {
433
+ // Remove attachment info if avatar is blank
434
  if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
435
  // Uploads by user
436
+ $attachments = $wpdb->get_results($wpdb->prepare("SELECT $wpdb->posts.ID FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_author = %d AND $wpdb->posts.post_type = %s AND $wpdb->postmeta.meta_key = %s AND $wpdb->postmeta.meta_value = $wpdb->posts.post_author", $user_id, 'attachment', '_wp_attachment_wp_user_avatar'));
437
  foreach($attachments as $attachment){
438
  // Delete attachment if not used by another user
439
  if(!wpua_image($attachment->ID, $user_id)){
440
+ wp_delete_attachment($attachment->ID);
441
  }
442
  }
443
  update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
444
  }
445
  // Create attachment from upload
446
+ if(isset($_POST['submit']) && $_POST['submit'] && !empty($_FILES['wpua-file'])){
447
  if(!function_exists('wp_handle_upload')){
 
448
  require_once(ABSPATH.'wp-admin/includes/file.php');
449
  }
450
+ if(!function_exists('wp_generate_attachment_metadata')){
451
+ require_once(ABSPATH.'wp-admin/includes/image.php');
 
 
 
 
 
 
 
 
452
  }
453
+ $name = $_FILES['wpua-file']['name'];
454
+ $file = wp_handle_upload($_FILES['wpua-file'], array('test_form' => false));
455
+ if(!empty($_FILES['wpua-file']['type'])){
456
+ $type = $_FILES['wpua-file']['type'];
457
+ // Allow only JPG, GIF, PNG
458
+ if(!preg_match('/(jpe?g|gif|png)$/i', $type)){
459
+ wp_die(__('Sorry, this file type is not permitted for security reasons.'));
460
+ } else {
461
+ // Resize uploaded image
462
+ if((bool) $wpua_resize_upload == 1){
463
+ // Original image
464
+ $uploaded_image = wp_get_image_editor($file['file']);
465
+ // Check for errors
466
+ if(!is_wp_error($uploaded_image)){
467
+ // Resize image
468
+ $uploaded_image->resize($wpua_resize_w, $wpua_resize_h, $wpua_resize_crop);
469
+ // Save image
470
+ $resized_image = $uploaded_image->save($file['file']);
471
+ }
472
+ }
473
+ // Break out file info
474
+ $name_parts = pathinfo($name);
475
+ $name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
476
+ $url = $file['url'];
477
+ $file = $file['file'];
478
+ $title = $name;
479
+ // Use image exif/iptc data for title if possible
480
+ if($image_meta = @wp_read_image_metadata($file)){
481
+ if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))){
482
+ $title = $image_meta['title'];
483
+ }
484
+ }
485
+ // Construct the attachment array
486
+ $attachment = array(
487
+ 'guid' => $url,
488
+ 'post_mime_type' => $type,
489
+ 'post_title' => $title,
490
+ 'post_content' => ""
491
+ );
492
+ // This should never be set as it would then overwrite an existing attachment
493
+ if(isset($attachment['ID'])){
494
+ unset($attachment['ID']);
495
+ }
496
+ // Save the attachment metadata
497
+ $attachment_id = wp_insert_attachment($attachment, $file);
498
+ if(!is_wp_error($attachment_id)){
499
+ wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
500
+ $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
501
+ add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
502
+ update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
503
+ }
504
  }
505
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  }
507
  }
508
  }
509
 
510
+ // Add actions links on plugin page
511
+ function wpua_action_links($links, $file){
 
 
 
 
 
 
 
 
 
 
 
 
512
  if(basename($file) == basename(plugin_basename(__FILE__))){
513
  $settings_link = '<a href="'.add_query_arg(array('page' => 'wp-user-avatar'), admin_url('options-general.php')).'">'.__('Settings').'</a>';
514
  $links = array_merge($links, array($settings_link));
516
  return $links;
517
  }
518
 
519
+ // Add row meta on plugin page
520
+ function wpua_row_meta($links, $file){
521
+ if(basename($file) == basename(plugin_basename(__FILE__))){
522
+ $support_link = '<a href="http://wordpress.org/support/plugin/wp-user-avatar" target="_blank">'.__('Support Forums').'</a>';
523
+ $donate_link = '<a href="http://siboliban.org/donate" target="_blank">'.__('Donate', 'wp-user-avatar').'</a>';
524
+ $links = array_merge($links, array($support_link, $donate_link));
525
+ }
526
+ return $links;
527
+ }
528
+
529
  // Add column to Users table
530
  function wpua_add_column($columns){
531
  return $columns + array('wp-user-avatar' => __('WP User Avatar', 'wp-user-avatar'));
536
  global $blog_id, $wpdb;
537
  $wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
538
  $wpua_image = wp_get_attachment_image($wpua, array(32,32));
539
+ if($column_name == 'wp-user-avatar'){ $value = $wpua_image; }
540
+ return $value;
 
541
  }
542
 
543
  // Media uploader
547
  if(current_user_can('upload_files')){
548
  wp_enqueue_script('admin-bar');
549
  wp_enqueue_media();
550
+ wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION, true);
551
+ } else {
552
+ wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar-user.js', array('jquery'), WPUA_VERSION, true);
553
  }
 
554
  wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
555
  // Admin scripts
556
  if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
575
 
576
  // Returns true if user has Gravatar-hosted image
577
  function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
 
578
  if(!is_object($id_or_email) && !empty($id_or_email)){
579
  // Find user by ID or e-mail address
580
  $user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
582
  $email = !empty($user) ? $user->user_email : "";
583
  }
584
  // Check if Gravatar image returns 200 (OK) or 404 (Not Found)
585
+ $hash = md5(strtolower(trim($email)));
586
+ $gravatar = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
587
+ $data = wp_cache_get($hash);
588
+ if(false === $data){
589
+ $response = wp_remote_head($gravatar);
590
+ $data = is_wp_error($response) ? 'not200' : $response['response']['code'];
591
+ wp_cache_set($hash, $data, $group="", $expire=60*5);
592
  }
593
+ $has_gravatar = ($data == '200') ? true : false;
594
  return $has_gravatar;
595
  }
596
 
604
  $user_id = !empty($user) ? $user->ID : "";
605
  }
606
  $wpua = get_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', true);
607
+ $has_wpua = !empty($wpua) && wp_attachment_is_image($wpua) ? true : false;
608
  return $has_wpua;
609
  }
610
 
611
  // Replace get_avatar only in get_wp_user_avatar
612
  function wpua_get_avatar_filter($avatar, $id_or_email="", $size="", $default="", $alt=""){
613
+ global $avatar_default, $mustache_admin, $mustache_avatar, $mustache_medium, $mustache_original, $mustache_thumbnail, $post, $wpua_avatar_default, $wpua_disable_gravatar;
614
  // User has WPUA
615
  if(is_object($id_or_email)){
616
+ if(!empty($id_or_email->comment_author_email)){
617
+ $avatar = get_wp_user_avatar($id_or_email, $size, $default, $alt);
618
  } else {
619
  $avatar = get_wp_user_avatar('unknown@gravatar.com', $size, $default, $alt);
620
  }
627
  // User doesn't have WPUA or Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
628
  } elseif($avatar_default == 'wp_user_avatar'){
629
  // Show custom Default Avatar
630
+ if(!empty($wpua_avatar_default) && wp_attachment_is_image($wpua_avatar_default)){
631
  // Get image
632
  $wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
633
  // Image src
634
  $default = $wpua_avatar_default_image[0];
635
  // Add dimensions if numeric size
636
  $dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
 
637
  } else {
638
  // Get mustache image based on numeric size comparison
639
  if($size > get_option('medium_size_w')){
649
  }
650
  // Add dimensions if numeric size
651
  $dimensions = ' width="'.$size.'" height="'.$size.'"';
 
652
  }
653
  // Construct the img tag
654
+ $avatar = '<img src="'.$default.'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.' photo avatar-default" />';
655
  }
656
  }
657
  return $avatar;
661
  // Get original avatar, for when user removes wp_user_avatar
662
  function wpua_get_avatar_original($id_or_email, $size="", $default="", $alt=""){
663
  global $avatar_default, $mustache_avatar, $wpua_avatar_default, $wpua_disable_gravatar;
664
+ // Remove get_avatar filter
665
+ remove_filter('get_avatar', 'wpua_get_avatar_filter');
 
 
666
  if((bool) $wpua_disable_gravatar != 1){
667
  // User doesn't have Gravatar and Default Avatar is wp_user_avatar, show custom Default Avatar
668
  if(!wpua_has_gravatar($id_or_email) && $avatar_default == 'wp_user_avatar'){
669
  // Show custom Default Avatar
670
+ if(!empty($wpua_avatar_default) && wp_attachment_is_image($wpua_avatar_default)){
671
  $wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
672
  $default = $wpua_avatar_default_image[0];
673
  } else {
678
  $wpua_image = get_avatar($id_or_email, $size);
679
  // Takes the img tag, extracts the src
680
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
681
+ $default = !empty($matches) ? $matches [0] [1] : "";
682
  }
683
  } else {
684
+ if(!empty($wpua_avatar_default) && wp_attachment_is_image($wpua_avatar_default)){
685
  $wpua_avatar_default_image = wp_get_attachment_image_src($wpua_avatar_default, array($size,$size));
686
  $default = $wpua_avatar_default_image[0];
687
  } else {
688
  $default = $mustache_avatar;
689
  }
690
  }
691
+ // Enable get_avatar filter
692
+ add_filter('get_avatar', 'wpua_get_avatar_filter', 10, 6);
693
  return $default;
694
  }
695
 
696
  // Find WPUA, show get_avatar if empty
697
+ function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt="", $email='unknown@gravatar.com'){
698
+ global $avatar_default, $blog_id, $post, $wpdb, $_wp_additional_image_sizes;
699
  // Checks if comment
700
  if(is_object($id_or_email)){
701
  // Checks if comment author is registered user by user ID
702
+ if($id_or_email->user_id != 0){
703
+ $email = $id_or_email->user_id;
704
  // Checks that comment author isn't anonymous
705
+ } elseif(!empty($id_or_email->comment_author_email)){
706
  // Checks if comment author is registered user by e-mail address
707
+ $user = get_user_by('email', $id_or_email->comment_author_email);
708
  // Get registered user info from profile, otherwise e-mail address should be value
709
+ $email = !empty($user) ? $user->ID : $id_or_email->comment_author_email;
710
  }
711
+ $alt = $id_or_email->comment_author;
712
  } else {
713
  if(!empty($id_or_email)){
714
  // Find user by ID or e-mail address
727
  }
728
  // Set user's ID and name
729
  if(!empty($user)){
730
+ $email = $user->ID;
731
  $alt = $user->display_name;
732
  }
733
  }
734
  // Checks if user has WPUA
735
+ $wpua_meta = get_the_author_meta($wpdb->get_blog_prefix($blog_id).'user_avatar', $email);
736
  // Add alignment class
737
+ $alignclass = !empty($align) && ($align == 'left' || $align == 'right' || $align == 'center') ? ' align'.$align : ' alignnone';
738
  // User has WPUA, bypass get_avatar
739
  if(!empty($wpua_meta)){
740
  // Numeric size use size array
744
  // Add dimensions to img only if numeric size was specified
745
  $dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
746
  // Construct the img tag
747
+ $avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo" />';
748
  } else {
749
  // Get numeric sizes for non-numeric sizes based on media options
750
+ if(!function_exists('get_intermediate_image_sizes')){
751
+ require_once(ABSPATH.'wp-admin/includes/media.php');
752
+ }
753
+ // Check for custom image sizes
754
+ $all_sizes = array_merge(get_intermediate_image_sizes(), array('original'));
755
+ if(in_array($size, $all_sizes)){
756
+ if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))){
757
+ $get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
758
+ } else {
759
+ $get_size = $_wp_additional_image_sizes[$size]['width'];
760
+ }
761
  } else {
762
  // Numeric sizes leave as-is
763
  $get_size = $size;
764
  }
765
  // User with no WPUA uses get_avatar
766
+ $avatar = get_avatar($email, $get_size, $default="", $alt="");
767
  // Remove width and height for non-numeric sizes
768
+ if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))){
 
769
  $avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
770
+ $avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
 
771
  }
772
+ $str_replacemes = array('wp-user-avatar ', 'wp-user-avatar-'.$get_size.' ', 'wp-user-avatar-'.$size.' ', 'avatar-'.$get_size, 'photo');
773
+ $str_replacements = array("", "", "", 'avatar-'.$size, 'wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo');
774
+ $avatar = str_replace($str_replacemes, $str_replacements, $avatar);
775
  }
776
  return $avatar;
777
  }
784
  // Takes the img tag, extracts the src
785
  if(!empty($wpua_image)){
786
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
787
+ $wpua_image_src = !empty($matches) ? $matches [0] [1] : "";
788
  }
789
  return $wpua_image_src;
790
  }
801
  $user = empty($user) ? get_user_by('email', $user) : $user;
802
  }
803
  // Get user ID
804
+ $id_or_email = !empty($user) ? $user->ID : 'unknown@gravatar.com';
805
  // Check if link is set
806
  if(!empty($link)){
807
  // CSS class is same as link type, except for URL
860
  $avatar_list .= '<br />';
861
  }
862
  // Show remove link if custom Default Avatar is set
863
+ if(!empty($wpua_avatar_default) && wp_attachment_is_image($wpua_avatar_default)){
864
  $avatar_thumb_src = wp_get_attachment_image_src($wpua_avatar_default, array(32,32));
865
  $avatar_thumb = $avatar_thumb_src[0];
866
  $hide_remove = "";
877
  $wpua_list .= preg_replace("/src='(.+?)'/", "src='\$1'", $avatar_thumb_img);
878
  $wpua_list .= ' '.__('WP User Avatar', 'wp-user-avatar').'</label>';
879
  $wpua_list .= '<p id="wpua-edit"><button type="button" class="button" id="wpua-add" name="wpua-add">'.__('Edit Image').'</button>';
880
+ $wpua_list .= '<span id="wpua-remove-button"'.$hide_remove.'><a href="#" id="wpua-remove">'.__('Remove').'</a></span><span id="wpua-undo-button"><a href="#" id="wpua-undo">'.__('Undo').'</a></span></p>';
881
  $wpua_list .= '<input type="hidden" id="wp-user-avatar" name="avatar_default_wp_user_avatar" value="'.$wpua_avatar_default.'">';
882
  $wpua_list .= '<p id="wpua-message">'.sprintf(__('Click %s to save your changes', 'wp-user-avatar'), '&ldquo;'.__('Save Changes').'&rdquo;').'</p>';
883
  if((bool) $wpua_disable_gravatar != 1){
930
 
931
  // Admin page
932
  function wpua_options_page(){
933
+ global $show_avatars, $upload_size_limit_with_units, $wpua_allow_upload, $wpua_disable_gravatar, $wpua_edit_avatar, $wpua_resize_crop, $wpua_resize_h, $wpua_resize_upload, $wpua_resize_w, $wpua_tinymce, $wpua_upload_size_limit, $wpua_upload_size_limit_with_units;
934
  // Give subscribers edit_posts capability
935
  if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && (empty($wpua_allow_upload) || empty($wpua_edit_avatar))){
936
  wpua_subscriber_remove_cap();
937
  }
938
+ $hide_size = (bool) $wpua_allow_upload != 1 ? ' style="display:none;"' : "";
939
+ $hide_resize = (bool) $wpua_resize_upload != 1 ? ' style="display:none;"' : "";
940
  ?>
941
  <div class="wrap">
942
  <?php screen_icon(); ?>
944
  <form method="post" action="options.php">
945
  <?php settings_fields('wpua-settings-group'); ?>
946
  <?php do_settings_fields('wpua-settings-group', ""); ?>
947
+ <?php do_action('wpua_donation_message'); ?>
948
  <table class="form-table">
949
  <tr valign="top">
950
  <th scope="row"><?php _e('Settings'); ?></th>
955
  <input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" <?php checked($wpua_tinymce, 1); ?> />
956
  <?php _e('Add avatar button to Visual Editor', 'wp-user-avatar'); ?>
957
  </label>
958
+ </fieldset>
959
+ <fieldset>
960
  <label for="wp_user_avatar_allow_upload">
961
  <input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" <?php checked($wpua_allow_upload, 1); ?> />
962
  <?php _e('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar'); ?>
963
  </label>
964
+ </fieldset>
965
+ <fieldset>
966
  <label for="wp_user_avatar_disable_gravatar">
967
  <input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
968
  <?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
970
  </fieldset>
971
  </td>
972
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
973
  </table>
974
+ <div id="wpua-contributors-subscribers"<?php echo $hide_size; ?>>
975
+ <table class="form-table">
976
+ <tr valign="top">
977
+ <th scope="row">
978
+ <label for="wp_user_avatar_upload_size_limit">
979
+ <?php _e('Upload Size Limit', 'wp-user-avatar'); ?> <?php _e('(only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
980
+ </label>
981
+ </th>
982
+ <td>
983
+ <fieldset>
984
+ <legend class="screen-reader-text"><span><?php _e('Upload Size Limit', 'wp-user-avatar'); ?> <?php _e('(only for Contributors & Subscribers)', 'wp-user-avatar'); ?></span></legend>
985
+ <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" />
986
+ <span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
987
+ <span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ""); ?></span>
988
+ <div id="wpua-slider"></div>
989
+ <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>
990
+ </fieldset>
991
+ <fieldset>
992
+ <label for="wp_user_avatar_edit_avatar">
993
+ <input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" <?php checked($wpua_edit_avatar, 1); ?> />
994
+ <?php _e('Allow users to edit avatars', 'wp-user-avatar'); ?>
995
+ </label>
996
+ </fieldset>
997
+ <fieldset>
998
+ <label for="wp_user_avatar_resize_upload">
999
+ <input name="wp_user_avatar_resize_upload" type="checkbox" id="wp_user_avatar_resize_upload" value="1" <?php checked($wpua_resize_upload, 1); ?> />
1000
+ <?php _e('Resize avatars on upload', 'wp-user-avatar'); ?>
1001
+ </label>
1002
+ </fieldset>
1003
+ <fieldset id="wpua-resize-sizes"<?php echo $hide_resize; ?>
1004
+ <br />
1005
+ <br />
1006
+ <label for="wp_user_avatar_resize_w"><?php _e('Width'); ?></label>
1007
+ <input name="wp_user_avatar_resize_w" type="number" step="1" min="0" id="wp_user_avatar_resize_w" value="<?php form_option('wp_user_avatar_resize_w'); ?>" class="small-text" />
1008
+ <label for="wp_user_avatar_resize_h"><?php _e('Height'); ?></label>
1009
+ <input name="wp_user_avatar_resize_h" type="number" step="1" min="0" id="wp_user_avatar_resize_h" value="<?php form_option('wp_user_avatar_resize_h'); ?>" class="small-text" />
1010
+ <br />
1011
+ <input name="wp_user_avatar_resize_crop" type="checkbox" id="wp_user_avatar_resize_crop" value="1" <?php checked('1', $wpua_resize_crop); ?> />
1012
+ <label for="wp_user_avatar_resize_crop"><?php _e('Crop avatars to exact dimensions', 'wp-user-avatar'); ?></label>
1013
+ </fieldset>
1014
+ </td>
1015
+ </tr>
1016
+ </table>
1017
+ </div>
1018
  <h3 class="title"><?php _e('Avatars'); ?></h3>
1019
  <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
1020
  <table class="form-table">
1077
  register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
1078
  register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
1079
  register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
1080
+ register_setting('wpua-settings-group', 'wp_user_avatar_resize_crop', 'intval');
1081
+ register_setting('wpua-settings-group', 'wp_user_avatar_resize_h', 'intval');
1082
+ register_setting('wpua-settings-group', 'wp_user_avatar_resize_upload', 'intval');
1083
+ register_setting('wpua-settings-group', 'wp_user_avatar_resize_w', 'intval');
1084
  register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
1085
  }
1086
 
1097
  }
1098
  add_action('plugins_loaded', 'wpua_load');
1099
  }
1100
+
1101
  ?>