Version Description
- Bug Fix: Profile not saving without an avatar for Contributors & Subscribers
Download this release
Release Info
Developer | bangbay |
Plugin | WP User Avatar |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.5.4 to 1.6.1
- css/wp-user-avatar.css +1 -1
- includes/tinymce.php +1 -1
- includes/tinymce/editor_plugin.js +1 -1
- includes/tinymce/window.php +1 -1
- js/wp-user-avatar-admin.js +8 -3
- js/wp-user-avatar-user.js +19 -0
- js/wp-user-avatar.js +1 -1
- lang/wp-user-avatar-de_DE.mo +0 -0
- lang/wp-user-avatar-de_DE.po +25 -12
- lang/wp-user-avatar-es_ES.mo +0 -0
- lang/wp-user-avatar-es_ES.po +25 -12
- lang/wp-user-avatar-fr_FR.mo +0 -0
- lang/wp-user-avatar-fr_FR.po +25 -12
- lang/wp-user-avatar-sv_SE.mo +0 -0
- lang/wp-user-avatar-sv_SE.po +25 -12
- readme.txt +128 -23
- uninstall.php +9 -1
- wp-user-avatar.php +232 -122
css/wp-user-avatar.css
CHANGED
@@ -1,7 +1,6 @@
|
|
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; }
|
@@ -9,3 +8,4 @@
|
|
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 { display: none; }
|
3 |
#wpua-preview, #wpua-thumbnail { display: inline-block; text-align: center; vertical-align: top; }
|
|
|
4 |
#wpua-preview img, #wpua-thumbnail img { max-height: 96px; border: 1px solid #dfdfdf; display: block; }
|
5 |
.defaultavatarpicker #wpua-preview { width: 32px; height: 32px; margin-right: 0; display: inline-block; overflow: hidden; vertical-align: middle; }
|
6 |
.defaultavatarpicker #wpua-preview img { width: 32px; height: auto; border: 0; }
|
8 |
#wpua-edit #wpua-remove { margin-left: 10px !important; }
|
9 |
#wpua-slider { width: 22.75em; }
|
10 |
.wpua-hide { display: none !important; }
|
11 |
+
#wpua-upload-messages span { display: block; }
|
includes/tinymce.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
5 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.6.1
|
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.
|
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.1"}}});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 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
+
* @version 1.6.1
|
5 |
*/
|
6 |
|
7 |
if(!defined('ABSPATH')){
|
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-
|
|
|
|
|
|
|
|
|
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').
|
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,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Remove WP User Avatar
|
2 |
+
function wpuaRemoveAvatar(avatar_thumb){
|
3 |
+
jQuery('body').on('click', '#wpua-remove', function(e){
|
4 |
+
e.preventDefault();
|
5 |
+
jQuery(this).hide();
|
6 |
+
jQuery('#wpua-edit, #wpua-thumbnail').hide();
|
7 |
+
jQuery('#wpua-preview').find('img').attr('src', avatar_thumb).removeAttr('width', "").removeAttr('height', "");
|
8 |
+
jQuery('#wp-user-avatar').val("");
|
9 |
+
jQuery('#wpua-message').show();
|
10 |
+
jQuery('#wp_user_avatar_radio').trigger('click');
|
11 |
+
});
|
12 |
+
}
|
13 |
+
|
14 |
+
jQuery(function(){
|
15 |
+
// Add enctype to form with JavaScript as backup
|
16 |
+
jQuery('#your-profile').attr('enctype', 'multipart/form-data');
|
17 |
+
// Remove settings
|
18 |
+
wpuaRemoveAvatar(wpua_custom.avatar_thumb);
|
19 |
+
});
|
js/wp-user-avatar.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function wpuaMediaUploader(
|
1 |
+
function wpuaMediaUploader(section,edit_text,insert_text){wp.media.wpUserAvatar={get:function(){return wp.media.view.settings.post.wpUserAvatarId},set:function(id){var settings=wp.media.view.settings;settings.post.wpUserAvatarId=id;settings.post.wpUserAvatarSrc=jQuery('div.attachment-info').find('img').attr('src');if(settings.post.wpUserAvatarId){wpuaSetAvatar(settings.post.wpUserAvatarId,settings.post.wpUserAvatarSrc);jQuery('#wp_user_avatar_radio').trigger('click')}},frame:function(){if(this._frame){return this._frame}this._frame=wp.media({state:'library',states:[new wp.media.controller.Library({title:edit_text+": "+section})]});this._frame.on('open',function(){var selection=this.state().get('selection');id=jQuery('#wp-user-avatar').val();attachment=wp.media.attachment(id);attachment.fetch();selection.add(attachment?[attachment]:[])},this._frame);this._frame.on('toolbar:create:select',function(toolbar){this.createSelectToolbar(toolbar,{text:insert_text})},this._frame);this._frame.state('library').on('select',this.select);return this._frame},select:function(id){var settings=wp.media.view.settings,selection=this.get('selection').single();wp.media.wpUserAvatar.set(selection?selection.id:-1)},init:function(){jQuery('body').on('click','#wpua-add',function(e){e.preventDefault();e.stopPropagation();wp.media.wpUserAvatar.frame().open()})}};jQuery(wp.media.wpUserAvatar.init)}function wpuaSetAvatar(attachment,imageURL){jQuery('#wp-user-avatar',window.parent.document).val(attachment);jQuery('#wpua-preview',window.parent.document).find('img').attr('src',imageURL).removeAttr('width',"").removeAttr('height',"");jQuery('#wpua-message',window.parent.document).show();jQuery('#wpua-remove',window.parent.document).removeClass('wpua-hide').show();jQuery('#wpua-thumbnail',window.parent.document).hide();jQuery('#wp_user_avatar_radio',window.parent.document).trigger('click');wp.media.wpUserAvatar.frame().close()}function wpuaRemoveAvatar(avatar_thumb){jQuery('body').on('click','#wpua-remove',function(e){e.preventDefault();jQuery(this).hide();jQuery('#wpua-edit, #wpua-thumbnail').hide();jQuery('#wpua-preview').find('img').attr('src',avatar_thumb).removeAttr('width',"").removeAttr('height',"");jQuery('#wp-user-avatar').val("");jQuery('#wpua-message').show();jQuery('#wp_user_avatar_radio').trigger('click')})}jQuery(function(){jQuery('#your-profile').attr('enctype','multipart/form-data');if(typeof(wp)!='undefined'){wpuaMediaUploader(wpua_custom.section,wpua_custom.edit_image,wpua_custom.select_image)}wpuaRemoveAvatar(wpua_custom.avatar_thumb)});
|
lang/wp-user-avatar-de_DE.mo
CHANGED
Binary file
|
lang/wp-user-avatar-de_DE.po
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
#
|
5 |
msgid ""
|
6 |
msgstr ""
|
7 |
-
"Project-Id-Version: WP User Avatar 1.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date: 2013-
|
10 |
"Language: de_DE\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\n"
|
@@ -14,32 +14,45 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
#: wp-user-avatar.php:
|
19 |
msgid "Click %s to save your changes"
|
20 |
msgstr "Klicken Sie %s, um Ihre Änderungen zu speichern"
|
21 |
|
22 |
-
#: wp-user-avatar.php:
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
|
25 |
|
26 |
-
#: wp-user-avatar.php:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
|
29 |
|
30 |
-
#: wp-user-avatar.php:
|
31 |
msgid "Disable Gravatar and use only local avatars"
|
32 |
msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
|
33 |
|
34 |
-
#: wp-user-avatar.php:
|
35 |
-
#: wp-user-avatar.php:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Dateigrößenbeschränkung
|
38 |
|
39 |
-
#: wp-user-avatar.php:
|
|
|
|
|
|
|
|
|
|
|
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.1\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2013-09-25 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:395
|
18 |
+
#: wp-user-avatar.php:878
|
19 |
msgid "Click %s to save your changes"
|
20 |
msgstr "Klicken Sie %s, um Ihre Änderungen zu speichern"
|
21 |
|
22 |
+
#: wp-user-avatar.php:951
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Einen Avatar-Knopf zum WYSIWYG-Editor hinzufügen"
|
25 |
|
26 |
+
#: wp-user-avatar.php:957
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Mitarbeiter und Abonnenten erlauben, Avatare hochzuladen"
|
29 |
|
30 |
+
#: wp-user-avatar.php:963
|
31 |
msgid "Disable Gravatar and use only local avatars"
|
32 |
msgstr "Gravatar deaktivieren und nur lokale Avatare verwenden"
|
33 |
|
34 |
+
#: wp-user-avatar.php:974
|
35 |
+
#: wp-user-avatar.php:979
|
36 |
+
msgid "Upload Size Limit"
|
37 |
+
msgstr "Dateigrößenbeschränkung"
|
38 |
|
39 |
+
#: wp-user-avatar.php:974
|
40 |
+
#: wp-user-avatar.php:979
|
41 |
+
msgid "(only for Contributors & Subscribers)"
|
42 |
+
msgstr "(nur für Mitarbeiter und Abonnenten)"
|
43 |
+
|
44 |
+
#: wp-user-avatar.php:989
|
45 |
msgid "Allow users to edit avatars"
|
46 |
msgstr "Benutzer erlauben, Avatare bearbeiten"
|
47 |
|
48 |
+
#: wp-user-avatar.php:995
|
49 |
+
msgid "Resize avatars on upload"
|
50 |
+
msgstr "Resize Avatare beim Upload"
|
51 |
+
|
52 |
+
#: wp-user-avatar.php:1007
|
53 |
+
msgid "Crop avatars to exact dimensions"
|
54 |
+
msgstr "Avatare auf exakte Größe beschneiden"
|
55 |
+
|
56 |
#. Plugin Name of the plugin/theme
|
57 |
msgid "WP User Avatar"
|
58 |
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date: 2013-
|
10 |
"Language: es_ES\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\n"
|
@@ -14,32 +14,45 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
#: wp-user-avatar.php:
|
19 |
msgid "Click %s to save your changes"
|
20 |
msgstr "Haz clic %s para guardar los cambios"
|
21 |
|
22 |
-
#: wp-user-avatar.php:
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Añadir botón avatar al editor visual"
|
25 |
|
26 |
-
#: wp-user-avatar.php:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Permitir los colaboradores y los suscriptores subir avatares"
|
29 |
|
30 |
-
#: wp-user-avatar.php:
|
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:
|
35 |
-
#: wp-user-avatar.php:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Sube límite de tamaño
|
38 |
|
39 |
-
#: wp-user-avatar.php:
|
|
|
|
|
|
|
|
|
|
|
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.1\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2013-09-25 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:395
|
18 |
+
#: wp-user-avatar.php:878
|
19 |
msgid "Click %s to save your changes"
|
20 |
msgstr "Haz clic %s para guardar los cambios"
|
21 |
|
22 |
+
#: wp-user-avatar.php:951
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Añadir botón avatar al editor visual"
|
25 |
|
26 |
+
#: wp-user-avatar.php:957
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Permitir los colaboradores y los suscriptores subir avatares"
|
29 |
|
30 |
+
#: wp-user-avatar.php:963
|
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:974
|
35 |
+
#: wp-user-avatar.php:979
|
36 |
+
msgid "Upload Size Limit"
|
37 |
+
msgstr "Sube límite de tamaño"
|
38 |
|
39 |
+
#: wp-user-avatar.php:974
|
40 |
+
#: wp-user-avatar.php:979
|
41 |
+
msgid "(only for Contributors & Subscribers)"
|
42 |
+
msgstr "(para colaboradores y suscriptores)"
|
43 |
+
|
44 |
+
#: wp-user-avatar.php:989
|
45 |
msgid "Allow users to edit avatars"
|
46 |
msgstr "Permitir a los usuarios editar avatar"
|
47 |
|
48 |
+
#: wp-user-avatar.php:995
|
49 |
+
msgid "Resize avatars on upload"
|
50 |
+
msgstr "Cambiar el tamaño de avatares en carga"
|
51 |
+
|
52 |
+
#: wp-user-avatar.php:1007
|
53 |
+
msgid "Crop avatars to exact dimensions"
|
54 |
+
msgstr "Recortar los avatares a sus dimensiones exactas"
|
55 |
+
|
56 |
#. Plugin Name of the plugin/theme
|
57 |
msgid "WP User Avatar"
|
58 |
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date: 2013-
|
10 |
"Language: fr_FR\n"
|
11 |
"Last-Translator: WP User Avatar\n"
|
12 |
"Language-Team: WP User Avatar\n"
|
@@ -14,32 +14,45 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
#: wp-user-avatar.php:
|
19 |
msgid "Click %s to save your changes"
|
20 |
msgstr "Cliquez sur %s pour enregistrer vos modifications"
|
21 |
|
22 |
-
#: wp-user-avatar.php:
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
|
25 |
|
26 |
-
#: wp-user-avatar.php:
|
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:
|
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:
|
35 |
-
#: wp-user-avatar.php:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Taille limite d'envoi de fichiers
|
38 |
|
39 |
-
#: wp-user-avatar.php:
|
|
|
|
|
|
|
|
|
|
|
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.1\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2013-09-25 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:395
|
18 |
+
#: wp-user-avatar.php:878
|
19 |
msgid "Click %s to save your changes"
|
20 |
msgstr "Cliquez sur %s pour enregistrer vos modifications"
|
21 |
|
22 |
+
#: wp-user-avatar.php:951
|
23 |
msgid "Add avatar button to Visual Editor"
|
24 |
msgstr "Ajouter le bouton avatar sur l'éditeur visuel"
|
25 |
|
26 |
+
#: wp-user-avatar.php:957
|
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:963
|
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:974
|
35 |
+
#: wp-user-avatar.php:979
|
36 |
+
msgid "Upload Size Limit"
|
37 |
+
msgstr "Taille limite d'envoi de fichiers"
|
38 |
|
39 |
+
#: wp-user-avatar.php:974
|
40 |
+
#: wp-user-avatar.php:979
|
41 |
+
msgid "(only for Contributors & Subscribers)"
|
42 |
+
msgstr "(pour contributeurs et abonnés)"
|
43 |
+
|
44 |
+
#: wp-user-avatar.php:989
|
45 |
msgid "Allow users to edit avatars"
|
46 |
msgstr "Permettre aux utilisateurs de modifier avatar"
|
47 |
|
48 |
+
#: wp-user-avatar.php:995
|
49 |
+
msgid "Resize avatars on upload"
|
50 |
+
msgstr "Redimensionner avatars lors du téléchargement"
|
51 |
+
|
52 |
+
#: wp-user-avatar.php:1007
|
53 |
+
msgid "Crop avatars to exact dimensions"
|
54 |
+
msgstr "Recadrer les avatars pour parvenir aux dimensions exactes"
|
55 |
+
|
56 |
#. Plugin Name of the plugin/theme
|
57 |
msgid "WP User Avatar"
|
58 |
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.
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
-
"PO-Revision-Date: 2013-
|
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,45 @@ msgstr ""
|
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
-
#: wp-user-avatar.php:
|
18 |
-
#: wp-user-avatar.php:
|
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:
|
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:
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
|
29 |
|
30 |
-
#: wp-user-avatar.php:
|
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:
|
35 |
-
#: wp-user-avatar.php:
|
36 |
-
msgid "Upload Size Limit
|
37 |
-
msgstr "Storleksgräns för uppladdningar
|
38 |
|
39 |
-
#: wp-user-avatar.php:
|
|
|
|
|
|
|
|
|
|
|
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.1\n"
|
8 |
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/wp-user-avatar/\n"
|
9 |
+
"PO-Revision-Date: 2013-09-25 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:395
|
18 |
+
#: wp-user-avatar.php:878
|
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:951
|
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:957
|
27 |
msgid "Allow Contributors & Subscribers to upload avatars"
|
28 |
msgstr "Tillåt medarbetare & prenumeranter att ladda upp avatarer"
|
29 |
|
30 |
+
#: wp-user-avatar.php:963
|
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:974
|
35 |
+
#: wp-user-avatar.php:979
|
36 |
+
msgid "Upload Size Limit"
|
37 |
+
msgstr "Storleksgräns för uppladdningar"
|
38 |
|
39 |
+
#: wp-user-avatar.php:974
|
40 |
+
#: wp-user-avatar.php:979
|
41 |
+
msgid "(only for Contributors & Subscribers)"
|
42 |
+
msgstr "(endast för medarbetare & prenumeranter)"
|
43 |
+
|
44 |
+
#: wp-user-avatar.php:989
|
45 |
msgid "Allow users to edit avatars"
|
46 |
msgstr "Tillåt användare att redigera avatarer"
|
47 |
|
48 |
+
#: wp-user-avatar.php:995
|
49 |
+
msgid "Resize avatars on upload"
|
50 |
+
msgstr "Ändra storlek på avatarer på uppladdning"
|
51 |
+
|
52 |
+
#: wp-user-avatar.php:1007
|
53 |
+
msgid "Crop avatars to exact dimensions"
|
54 |
+
msgstr "Beskär avatarer till exakta dimensioner"
|
55 |
+
|
56 |
#. Plugin Name of the plugin/theme
|
57 |
msgid "WP User Avatar"
|
58 |
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.
|
8 |
-
Stable tag: 1.
|
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.
|
130 |
-
4.
|
131 |
-
5. Shows
|
|
|
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
|
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 |
-
|
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,10 +155,6 @@ 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!
|
@@ -178,6 +167,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 +220,85 @@ 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 +310,33 @@ 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 +368,7 @@ Outputs:
|
|
263 |
* Bug Fix: Use wp_die for errors
|
264 |
|
265 |
= 1.4 =
|
266 |
-
* Add: Uploader for
|
267 |
* Add: Media states for avatar images
|
268 |
* Add: Plugin admin settings
|
269 |
* Update: Change support only to WP 3.4+
|
@@ -326,7 +431,7 @@ Outputs:
|
|
326 |
= 1.1.7 =
|
327 |
* Bug Fix: Change update_usermeta to update_user_meta
|
328 |
|
329 |
-
= 1.1.6 =
|
330 |
* Bug Fix: Image not showing in user profile edit
|
331 |
|
332 |
= 1.1.5a =
|
4 |
Donate link: http://siboliban.org/donate
|
5 |
Tags: author image, author photo, author avatar, avatar, bbPress, profile avatar, profile image, user avatar, user image, user photo
|
6 |
Requires at least: 3.5
|
7 |
+
Tested up to: 3.6.1
|
8 |
+
Stable tag: 1.6.1
|
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!
|
167 |
|
168 |
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.
|
169 |
|
170 |
+
= Can I insert WP User Avatar directly into a post? =
|
171 |
+
|
172 |
+
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.
|
173 |
+
|
174 |
+
`[avatar user="admin" size="96" align="left" link="file"]`
|
175 |
+
|
176 |
+
Outputs:
|
177 |
+
|
178 |
+
`<a href="{fileURL}" class="wp-user-avatar-link wp-user-avatar-file">
|
179 |
+
<img src="{imageURL}" width="96" height="96" class="wp-user-avatar wp-user-avatar-96 alignleft" />
|
180 |
+
</a>`
|
181 |
+
|
182 |
= What CSS can I use with WP User Avatar? =
|
183 |
|
184 |
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:
|
220 |
* <code>has_wp_user_avatar</code>: checks if the user has a WP User Avatar image
|
221 |
* [See example usage here](http://wordpress.org/extend/plugins/wp-user-avatar/installation/)
|
222 |
|
223 |
+
== Advanced Settings ==
|
224 |
+
|
225 |
+
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 the default, the avatar code is structured like this:
|
226 |
+
|
227 |
+
`
|
228 |
+
<h3>Avatar</h3>
|
229 |
+
<table class="form-table">
|
230 |
+
<tr>
|
231 |
+
<th><label for="wp_user_avatar">Image</label></th>
|
232 |
+
<td>
|
233 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
|
234 |
+
<p id="wpua-add-button">
|
235 |
+
<button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
|
236 |
+
</p>
|
237 |
+
<p id="wpua-preview">
|
238 |
+
<img src="{imageURL}" alt="" />
|
239 |
+
Original Size
|
240 |
+
</p>
|
241 |
+
<p id="wpua-thumbnail">
|
242 |
+
<img src="{imageURL}" alt="" />
|
243 |
+
Thumbnail
|
244 |
+
</p>
|
245 |
+
<p id="wpua-remove-button">
|
246 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove">Remove</button>
|
247 |
+
</p>
|
248 |
+
<p id="wpua-message">
|
249 |
+
Click “Update Profile” to save your changes
|
250 |
+
</p>
|
251 |
+
</td>
|
252 |
+
</tr>
|
253 |
+
</table>
|
254 |
+
`
|
255 |
+
|
256 |
+
To strip out the table, you would add the following filters to the <code>functions.php</code> file in your theme:
|
257 |
+
|
258 |
+
`
|
259 |
+
remove_action('wpua_before_avatar', 'wpua_do_before_avatar');
|
260 |
+
remove_action('wpua_after_avatar', 'wpua_do_after_avatar');
|
261 |
+
`
|
262 |
+
|
263 |
+
To add your own wrapper, you could create something like this:
|
264 |
+
|
265 |
+
`
|
266 |
+
function my_before_avatar(){
|
267 |
+
echo '<div id="my-avatar">';
|
268 |
+
}
|
269 |
+
add_action('wpua_before_avatar', 'my_before_avatar');
|
270 |
+
|
271 |
+
function my_after_avatar(){
|
272 |
+
echo '</div>';
|
273 |
+
}
|
274 |
+
add_action('wpua_after_avatar', 'my_after_avatar');
|
275 |
+
`
|
276 |
+
|
277 |
+
This would output:
|
278 |
+
|
279 |
+
`
|
280 |
+
<div id="my-avatar">
|
281 |
+
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="{attachmentID}" />
|
282 |
+
<p id="wpua-add-button">
|
283 |
+
<button type="button" class="button" id="wpua-add" name="wpua-add">Edit Image</button>
|
284 |
+
</p>
|
285 |
+
<p id="wpua-preview">
|
286 |
+
<img src="{imageURL}" alt="" />
|
287 |
+
Original Size
|
288 |
+
</p>
|
289 |
+
<p id="wpua-thumbnail">
|
290 |
+
<img src="{imageURL}" alt="" />
|
291 |
+
Thumbnail
|
292 |
+
</p>
|
293 |
+
<p id="wpua-remove-button">
|
294 |
+
<button type="button" class="button" id="wpua-remove" name="wpua-remove">Remove</button>
|
295 |
+
</p>
|
296 |
+
<p id="wpua-message">
|
297 |
+
Click “Update Profile” to save your changes
|
298 |
+
</p>
|
299 |
+
</div>
|
300 |
+
`
|
301 |
+
|
302 |
== Screenshots ==
|
303 |
|
304 |
1. WP User Avatar admin settings.
|
310 |
|
311 |
== Changelog ==
|
312 |
|
313 |
+
= 1.6.1 =
|
314 |
+
* Bug Fix: Profile not saving without an avatar for Contributors & Subscribers
|
315 |
+
|
316 |
+
= 1.6.0 =
|
317 |
+
* Add: Filters to change profile HTML structure
|
318 |
+
* Add: Recognition of sizes registered with add_image_size
|
319 |
+
* Add: Resize image options for Contributors & Subscribers
|
320 |
+
* Bug Fix: Rerrange CSS class names
|
321 |
+
|
322 |
+
= 1.5.8 =
|
323 |
+
* Bug Fix: Add function exists checks to prevent redeclare errors
|
324 |
+
* Bug Fix: Page die if file upload is too big
|
325 |
+
* Bug Fix: Upload file with submit
|
326 |
+
|
327 |
+
= 1.5.7 =
|
328 |
+
* Bug Fix: Separate out JavaScript for Contributors & Subscribers
|
329 |
+
* Bug Fix: Subscriber uploader not finding error type
|
330 |
+
|
331 |
+
= 1.5.6 =
|
332 |
+
* Update: Use cache for wpua_has_gravatar
|
333 |
+
|
334 |
+
= 1.5.5 =
|
335 |
+
* Bug Fix: Hide "Edit Image" button if Contributors & Subscribers can't edit avatar
|
336 |
+
* Bug Fix: Remove edit_posts capability if Subscribers can't edit avatar
|
337 |
+
|
338 |
= 1.5.4 =
|
339 |
+
* Add: Option to enable avatar editing privilege for Contributors & Subscribers
|
340 |
* Add: Swedish translation
|
341 |
* Update: Move inline JavaScript to wp-user-avatar.js and wp-user-avatar-admin.js
|
342 |
* Update: Load JavaScript in footer
|
368 |
* Bug Fix: Use wp_die for errors
|
369 |
|
370 |
= 1.4 =
|
371 |
+
* Add: Uploader for Contributors & Subscribers
|
372 |
* Add: Media states for avatar images
|
373 |
* Add: Plugin admin settings
|
374 |
* Update: Change support only to WP 3.4+
|
431 |
= 1.1.7 =
|
432 |
* Bug Fix: Change update_usermeta to update_user_meta
|
433 |
|
434 |
+
= 1.1.6.1 =
|
435 |
* Bug Fix: Image not showing in user profile edit
|
436 |
|
437 |
= 1.1.5a =
|
uninstall.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* @package WP User Avatar
|
4 |
-
* @version 1.
|
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.1
|
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 |
*/
|
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.
|
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.
|
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 |
}
|
@@ -250,11 +257,61 @@ 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,7 +331,10 @@ 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')
|
|
|
|
|
|
|
278 |
}
|
279 |
// Admin menu settings
|
280 |
add_action('admin_menu', 'wpua_admin');
|
@@ -284,6 +344,9 @@ if(!class_exists('wp_user_avatar')){
|
|
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 |
|
@@ -303,31 +366,22 @@ if(!class_exists('wp_user_avatar')){
|
|
303 |
// Change text on message based on current user
|
304 |
$profile = ($current_user->ID == $user->ID) ? '“'.__('Update Profile').'”' : '“'.__('Update User').'”';
|
305 |
?>
|
306 |
-
<?php
|
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 |
-
<
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
|
|
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 +391,9 @@ 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
|
343 |
-
</fieldset>
|
344 |
-
<?php else : // Add to profile with admin style ?>
|
345 |
-
</td>
|
346 |
-
</tr>
|
347 |
-
</table>
|
348 |
-
<?php endif; ?>
|
349 |
<?php
|
350 |
}
|
351 |
|
@@ -354,7 +402,25 @@ if(!class_exists('wp_user_avatar')){
|
|
354 |
global $wpua_upload_size_limit;
|
355 |
$size = $file['size'];
|
356 |
if($size > $wpua_upload_size_limit){
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
return $file;
|
360 |
}
|
@@ -369,6 +435,7 @@ if(!class_exists('wp_user_avatar')){
|
|
369 |
add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
370 |
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
371 |
} else {
|
|
|
372 |
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
|
373 |
// Uploads by user
|
374 |
$attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, 'attachment'));
|
@@ -381,53 +448,54 @@ if(!class_exists('wp_user_avatar')){
|
|
381 |
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
382 |
}
|
383 |
// Create attachment from upload
|
384 |
-
if(isset($_POST['
|
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 |
-
|
390 |
-
|
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 |
-
|
401 |
-
$
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
}
|
@@ -475,8 +543,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 +571,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 +578,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 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
$
|
|
|
|
|
517 |
}
|
|
|
518 |
return $has_gravatar;
|
519 |
}
|
520 |
|
@@ -558,7 +630,6 @@ if(!class_exists('wp_user_avatar')){
|
|
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 +645,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 =
|
581 |
}
|
582 |
}
|
583 |
return $avatar;
|
@@ -606,7 +676,7 @@ if(!class_exists('wp_user_avatar')){
|
|
606 |
$wpua_image = get_avatar($id_or_email, $size);
|
607 |
// Takes the img tag, extracts the src
|
608 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
609 |
-
$default = $matches [0] [1];
|
610 |
}
|
611 |
} else {
|
612 |
if(!empty($wpua_avatar_default)){
|
@@ -621,7 +691,7 @@ if(!class_exists('wp_user_avatar')){
|
|
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
|
@@ -670,11 +740,20 @@ 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.'
|
674 |
} else {
|
675 |
// Get numeric sizes for non-numeric sizes based on media options
|
676 |
-
if(
|
677 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
} else {
|
679 |
// Numeric sizes leave as-is
|
680 |
$get_size = $size;
|
@@ -682,12 +761,13 @@ if(!class_exists('wp_user_avatar')){
|
|
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(
|
686 |
-
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
|
687 |
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
|
688 |
-
$avatar =
|
689 |
-
$avatar = str_replace("class='", "class='wp-user-avatar wp-user-avatar-".$size.$alignclass." ", $avatar);
|
690 |
}
|
|
|
|
|
|
|
691 |
}
|
692 |
return $avatar;
|
693 |
}
|
@@ -700,7 +780,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 |
}
|
@@ -782,7 +862,7 @@ if(!class_exists('wp_user_avatar')){
|
|
782 |
$hide_remove = "";
|
783 |
} else {
|
784 |
$avatar_thumb = $mustache_admin;
|
785 |
-
$hide_remove = '
|
786 |
}
|
787 |
// Default Avatar is wp_user_avatar, check the radio button next to it
|
788 |
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
@@ -846,12 +926,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 ? '
|
|
|
855 |
?>
|
856 |
<div class="wrap">
|
857 |
<?php screen_icon(); ?>
|
@@ -869,12 +950,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 |
-
|
|
|
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 |
-
|
|
|
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 +965,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 +1072,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 +1092,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.1
|
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.1
|
13 |
Text Domain: wp-user-avatar
|
14 |
Domain Path: /lang/
|
15 |
*/
|
20 |
}
|
21 |
|
22 |
// Define paths and variables
|
23 |
+
define('WPUA_VERSION', ' 1.6.1');
|
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 |
}
|
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 |
// WP User Avatar
|
311 |
if(!class_exists('wp_user_avatar')){
|
312 |
class wp_user_avatar{
|
313 |
function wp_user_avatar(){
|
314 |
+
global $current_screen, $current_user, $pagenow, $show_avatars, $wpua_allow_upload, $wpua_resize_upload, $wpua_upload_size_limit;
|
315 |
// Add WPUA to profile
|
316 |
if(current_user_can('upload_files') || ((bool) $wpua_allow_upload == 1 && is_user_logged_in())){
|
317 |
// For themes that use this function
|
331 |
}
|
332 |
// Prefilter upload size
|
333 |
if(!current_user_can('upload_files')){
|
334 |
+
add_filter('wp_handle_upload_prefilter', array($this, 'wpua_handle_upload_prefilter'));
|
335 |
+
if((bool) $wpua_resize_upload == 1){
|
336 |
+
add_filter('wp_handle_upload', array($this, 'wpua_resize_upload'));
|
337 |
+
}
|
338 |
}
|
339 |
// Admin menu settings
|
340 |
add_action('admin_menu', 'wpua_admin');
|
344 |
add_filter('manage_users_columns', array($this, 'wpua_add_column'), 10, 1);
|
345 |
add_filter('manage_users_custom_column', array($this, 'wpua_show_column'), 10, 3);
|
346 |
}
|
347 |
+
// Profile wrappers
|
348 |
+
add_action('wpua_before_avatar', 'wpua_do_before_avatar');
|
349 |
+
add_action('wpua_after_avatar', 'wpua_do_after_avatar');
|
350 |
}
|
351 |
}
|
352 |
|
366 |
// Change text on message based on current user
|
367 |
$profile = ($current_user->ID == $user->ID) ? '“'.__('Update Profile').'”' : '“'.__('Update User').'”';
|
368 |
?>
|
369 |
+
<?php do_action('wpua_before_avatar'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
<input type="hidden" name="wp-user-avatar" id="wp-user-avatar" value="<?php echo $wpua; ?>" />
|
371 |
<?php if(current_user_can('upload_files')) : // Button to launch Media uploader ?>
|
372 |
+
<p id="wpua-add-button"><button type="button" class="button" id="wpua-add" name="wpua-add"><?php _e('Edit Image'); ?></button></p>
|
373 |
<?php elseif(!current_user_can('upload_files') && !has_wp_user_avatar($current_user->ID)) : // Upload button ?>
|
374 |
+
<p id="wpua-upload-button">
|
375 |
+
<input name="wpua-file" id="wpua-file" type="file" />
|
376 |
+
<button type="submit" class="button" id="wpua-upload" name="submit" value="<?php _e('Upload'); ?>"><?php _e('Upload'); ?></button>
|
377 |
+
</p>
|
378 |
+
<p id="wpua-upload-messages">
|
379 |
+
<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>
|
380 |
+
<span id="wpua-allowed-files"><?php _e('Allowed Files'); ?>: <?php _e('<code>jpg jpeg png gif</code>'); ?></span>
|
381 |
</p>
|
382 |
<?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 ?>
|
383 |
<?php $edit_attachment_link = add_query_arg(array('post' => $wpua, 'action' => 'edit'), admin_url('post.php')); ?>
|
384 |
+
<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>
|
385 |
<?php endif; ?>
|
386 |
<p id="wpua-preview">
|
387 |
<img src="<?php echo $avatar_medium; ?>" alt="" />
|
391 |
<img src="<?php echo $avatar_thumbnail; ?>" alt="" />
|
392 |
<?php _e('Thumbnail'); ?>
|
393 |
</p>
|
394 |
+
<p id="wpua-remove-button"><button type="button" class="button<?php echo $hide_remove; ?>" id="wpua-remove" name="wpua-remove"><?php _e('Remove'); ?></button></p>
|
395 |
<p id="wpua-message"><?php printf(__('Click %s to save your changes', 'wp-user-avatar'), $profile); ?></p>
|
396 |
+
<?php do_action('wpua_after_avatar'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
<?php
|
398 |
}
|
399 |
|
402 |
global $wpua_upload_size_limit;
|
403 |
$size = $file['size'];
|
404 |
if($size > $wpua_upload_size_limit){
|
405 |
+
wp_die(__('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'));
|
406 |
+
}
|
407 |
+
return $file;
|
408 |
+
}
|
409 |
+
|
410 |
+
// Resize uploaded image
|
411 |
+
function wpua_resize_upload($file){
|
412 |
+
global $wpua_resize_h, $wpua_resize_w, $wpua_resize_crop;
|
413 |
+
// Only for JPG, GIF, PNG
|
414 |
+
if(preg_match('/(jpe?g|gif|png)$/i', $file['type'])){
|
415 |
+
// Original image
|
416 |
+
$uploaded_image = wp_get_image_editor($file['file']);
|
417 |
+
// Check for errors
|
418 |
+
if(!is_wp_error($uploaded_image)){
|
419 |
+
// Resize image
|
420 |
+
$uploaded_image->resize($wpua_resize_w, $wpua_resize_h, $wpua_resize_crop);
|
421 |
+
// Save image
|
422 |
+
$resized_image = $uploaded_image->save($file['file']);
|
423 |
+
}
|
424 |
}
|
425 |
return $file;
|
426 |
}
|
435 |
add_post_meta($wpua_id, '_wp_attachment_wp_user_avatar', $user_id);
|
436 |
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $wpua_id);
|
437 |
} else {
|
438 |
+
// Remove attachment info if avatar is blank
|
439 |
if(isset($_POST['wp-user-avatar']) && empty($_POST['wp-user-avatar'])){
|
440 |
// Uploads by user
|
441 |
$attachments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_type = %s", $user_id, 'attachment'));
|
448 |
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', "");
|
449 |
}
|
450 |
// Create attachment from upload
|
451 |
+
if(isset($_POST['submit']) && $_POST['submit'] && !empty($_FILES['wpua-file'])){
|
452 |
if(!function_exists('wp_handle_upload')){
|
|
|
453 |
require_once(ABSPATH.'wp-admin/includes/file.php');
|
454 |
}
|
455 |
+
if(!function_exists('wp_generate_attachment_metadata')){
|
456 |
+
require_once(ABSPATH.'wp-admin/includes/image.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
}
|
458 |
+
$name = $_FILES['wpua-file']['name'];
|
459 |
+
$file = wp_handle_upload($_FILES['wpua-file'], array('test_form' => false));
|
460 |
+
if(!empty($_FILES['wpua-file']['type'])){
|
461 |
+
$type = $_FILES['wpua-file']['type'];
|
462 |
+
// Allow only JPG, GIF, PNG
|
463 |
+
if(!preg_match('/(jpe?g|gif|png)$/i', $type)){
|
464 |
+
wp_die(__('Sorry, this file type is not permitted for security reasons.'));
|
465 |
+
} else {
|
466 |
+
// Break out file info
|
467 |
+
$name_parts = pathinfo($name);
|
468 |
+
$name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
|
469 |
+
$url = $file['url'];
|
470 |
+
$file = $file['file'];
|
471 |
+
$title = $name;
|
472 |
+
// Use image exif/iptc data for title if possible
|
473 |
+
if($image_meta = @wp_read_image_metadata($file)){
|
474 |
+
if(trim($image_meta['title']) && !is_numeric(sanitize_title($image_meta['title']))){
|
475 |
+
$title = $image_meta['title'];
|
476 |
+
}
|
477 |
+
}
|
478 |
+
// Construct the attachment array
|
479 |
+
$attachment = array(
|
480 |
+
'guid' => $url,
|
481 |
+
'post_mime_type' => $type,
|
482 |
+
'post_title' => $title,
|
483 |
+
'post_content' => ""
|
484 |
+
);
|
485 |
+
// This should never be set as it would then overwrite an existing attachment
|
486 |
+
if(isset($attachment['ID'])){
|
487 |
+
unset($attachment['ID']);
|
488 |
+
}
|
489 |
+
// Save the attachment metadata
|
490 |
+
$attachment_id = wp_insert_attachment($attachment, $file);
|
491 |
+
if(!is_wp_error($attachment_id)){
|
492 |
+
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
493 |
+
$wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_wp_attachment_wp_user_avatar', $user_id));
|
494 |
+
add_post_meta($attachment_id, '_wp_attachment_wp_user_avatar', $user_id);
|
495 |
+
update_user_meta($user_id, $wpdb->get_blog_prefix($blog_id).'user_avatar', $attachment_id);
|
496 |
+
}
|
497 |
}
|
498 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
}
|
500 |
}
|
501 |
}
|
543 |
if(current_user_can('upload_files')){
|
544 |
wp_enqueue_script('admin-bar');
|
545 |
wp_enqueue_media();
|
546 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar.js', array('jquery'), WPUA_VERSION, true);
|
547 |
+
} else {
|
548 |
+
wp_enqueue_script('wp-user-avatar', WPUA_URLPATH.'js/wp-user-avatar-user.js', array('jquery'), WPUA_VERSION, true);
|
549 |
}
|
|
|
550 |
wp_enqueue_style('wp-user-avatar', WPUA_URLPATH.'css/wp-user-avatar.css', "", WPUA_VERSION);
|
551 |
// Admin scripts
|
552 |
if($pagenow == 'options-discussion.php' || ($pagenow == 'options-general.php' && isset($_GET['page']) && $_GET['page'] == 'wp-user-avatar')){
|
571 |
|
572 |
// Returns true if user has Gravatar-hosted image
|
573 |
function wpua_has_gravatar($id_or_email, $has_gravatar=false, $user="", $email=""){
|
|
|
574 |
if(!is_object($id_or_email) && !empty($id_or_email)){
|
575 |
// Find user by ID or e-mail address
|
576 |
$user = is_numeric($id_or_email) ? get_user_by('id', $id_or_email) : get_user_by('email', $id_or_email);
|
578 |
$email = !empty($user) ? $user->user_email : "";
|
579 |
}
|
580 |
// Check if Gravatar image returns 200 (OK) or 404 (Not Found)
|
581 |
+
$hash = md5(strtolower(trim($email)));
|
582 |
+
$gravatar = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
|
583 |
+
$data = wp_cache_get($hash);
|
584 |
+
if(false === $data){
|
585 |
+
$response = wp_remote_head($gravatar);
|
586 |
+
$data = is_wp_error($response) ? 'not200' : $response['response']['code'];
|
587 |
+
wp_cache_set($hash, $data, $group="", $expire=60*5);
|
588 |
}
|
589 |
+
$has_gravatar = ($data == '200') ? true : false;
|
590 |
return $has_gravatar;
|
591 |
}
|
592 |
|
630 |
$default = $wpua_avatar_default_image[0];
|
631 |
// Add dimensions if numeric size
|
632 |
$dimensions = ' width="'.$wpua_avatar_default_image[1].'" height="'.$wpua_avatar_default_image[2].'"';
|
|
|
633 |
} else {
|
634 |
// Get mustache image based on numeric size comparison
|
635 |
if($size > get_option('medium_size_w')){
|
645 |
}
|
646 |
// Add dimensions if numeric size
|
647 |
$dimensions = ' width="'.$size.'" height="'.$size.'"';
|
|
|
648 |
}
|
649 |
// Construct the img tag
|
650 |
+
$avatar = '<img src="'.$default.'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.' photo avatar-default" />';
|
651 |
}
|
652 |
}
|
653 |
return $avatar;
|
676 |
$wpua_image = get_avatar($id_or_email, $size);
|
677 |
// Takes the img tag, extracts the src
|
678 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
679 |
+
$default = !empty($matches) ? $matches [0] [1] : "";
|
680 |
}
|
681 |
} else {
|
682 |
if(!empty($wpua_avatar_default)){
|
691 |
|
692 |
// Find WPUA, show get_avatar if empty
|
693 |
function get_wp_user_avatar($id_or_email="", $size='96', $align="", $alt=""){
|
694 |
+
global $avatar_default, $blog_id, $comment, $post, $wpdb, $_wp_additional_image_sizes;
|
695 |
// Checks if comment
|
696 |
if(is_object($id_or_email)){
|
697 |
// Checks if comment author is registered user by user ID
|
740 |
// Add dimensions to img only if numeric size was specified
|
741 |
$dimensions = is_numeric($size) ? ' width="'.$wpua_image[1].'" height="'.$wpua_image[2].'"' : "";
|
742 |
// Construct the img tag
|
743 |
+
$avatar = '<img src="'.$wpua_image[0].'"'.$dimensions.' alt="'.$alt.'" class="avatar avatar-'.$size.' wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo" />';
|
744 |
} else {
|
745 |
// Get numeric sizes for non-numeric sizes based on media options
|
746 |
+
if(!function_exists('get_intermediate_image_sizes')){
|
747 |
+
require_once(ABSPATH.'wp-admin/includes/media.php');
|
748 |
+
}
|
749 |
+
// Check for custom image sizes
|
750 |
+
$all_sizes = array_merge(get_intermediate_image_sizes(), array('original'));
|
751 |
+
if(in_array($size, $all_sizes)){
|
752 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))){
|
753 |
+
$get_size = ($size == 'original') ? get_option('large_size_w') : get_option($size.'_size_w');
|
754 |
+
} else {
|
755 |
+
$get_size = $_wp_additional_image_sizes[$size]['width'];
|
756 |
+
}
|
757 |
} else {
|
758 |
// Numeric sizes leave as-is
|
759 |
$get_size = $size;
|
761 |
// User with no WPUA uses get_avatar
|
762 |
$avatar = get_avatar($id_or_email, $get_size, $default="", $alt="");
|
763 |
// Remove width and height for non-numeric sizes
|
764 |
+
if(in_array($size, array('original', 'large', 'medium', 'thumbnail'))){
|
|
|
765 |
$avatar = preg_replace('/(width|height)=\"\d*\"\s/', "", $avatar);
|
766 |
+
$avatar = preg_replace("/(width|height)=\'\d*\'\s/", "", $avatar);
|
|
|
767 |
}
|
768 |
+
$str_replacemes = array('wp-user-avatar ', 'wp-user-avatar-'.$get_size.' ', 'wp-user-avatar-'.$size.' ', 'avatar-'.$get_size, 'photo');
|
769 |
+
$str_replacements = array("", "", "", 'avatar-'.$size, 'wp-user-avatar wp-user-avatar-'.$size.$alignclass.' photo');
|
770 |
+
$avatar = str_replace($str_replacemes, $str_replacements, $avatar);
|
771 |
}
|
772 |
return $avatar;
|
773 |
}
|
780 |
// Takes the img tag, extracts the src
|
781 |
if(!empty($wpua_image)){
|
782 |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $wpua_image, $matches, PREG_SET_ORDER);
|
783 |
+
$wpua_image_src = !empty($matches) ? $matches [0] [1] : "";
|
784 |
}
|
785 |
return $wpua_image_src;
|
786 |
}
|
862 |
$hide_remove = "";
|
863 |
} else {
|
864 |
$avatar_thumb = $mustache_admin;
|
865 |
+
$hide_remove = ' style="display:none;"';
|
866 |
}
|
867 |
// Default Avatar is wp_user_avatar, check the radio button next to it
|
868 |
$selected_avatar = ((bool) $wpua_disable_gravatar == 1 || $avatar_default == 'wp_user_avatar') ? ' checked="checked" ' : "";
|
926 |
|
927 |
// Admin page
|
928 |
function wpua_options_page(){
|
929 |
+
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;
|
930 |
// Give subscribers edit_posts capability
|
931 |
if(isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && (empty($wpua_allow_upload) || empty($wpua_edit_avatar))){
|
932 |
wpua_subscriber_remove_cap();
|
933 |
}
|
934 |
+
$hide_size = (bool) $wpua_allow_upload != 1 ? ' style="display:none;"' : "";
|
935 |
+
$hide_resize = (bool) $wpua_resize_upload != 1 ? ' style="display:none;"' : "";
|
936 |
?>
|
937 |
<div class="wrap">
|
938 |
<?php screen_icon(); ?>
|
950 |
<input name="wp_user_avatar_tinymce" type="checkbox" id="wp_user_avatar_tinymce" value="1" <?php checked($wpua_tinymce, 1); ?> />
|
951 |
<?php _e('Add avatar button to Visual Editor', 'wp-user-avatar'); ?>
|
952 |
</label>
|
953 |
+
</fieldset>
|
954 |
+
<fieldset>
|
955 |
<label for="wp_user_avatar_allow_upload">
|
956 |
<input name="wp_user_avatar_allow_upload" type="checkbox" id="wp_user_avatar_allow_upload" value="1" <?php checked($wpua_allow_upload, 1); ?> />
|
957 |
<?php _e('Allow Contributors & Subscribers to upload avatars', 'wp-user-avatar'); ?>
|
958 |
</label>
|
959 |
+
</fieldset>
|
960 |
+
<fieldset>
|
961 |
<label for="wp_user_avatar_disable_gravatar">
|
962 |
<input name="wp_user_avatar_disable_gravatar" type="checkbox" id="wp_user_avatar_disable_gravatar" value="1" <?php checked($wpua_disable_gravatar, 1); ?> />
|
963 |
<?php _e('Disable Gravatar and use only local avatars', 'wp-user-avatar'); ?>
|
965 |
</fieldset>
|
966 |
</td>
|
967 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
968 |
</table>
|
969 |
+
<div id="wpua-contributors-subscribers"<?php echo $hide_size; ?>>
|
970 |
+
<table class="form-table">
|
971 |
+
<tr valign="top">
|
972 |
+
<th scope="row">
|
973 |
+
<label for="wp_user_avatar_upload_size_limit">
|
974 |
+
<?php _e('Upload Size Limit', 'wp-user-avatar'); ?> <?php _e('(only for Contributors & Subscribers)', 'wp-user-avatar'); ?>
|
975 |
+
</label>
|
976 |
+
</th>
|
977 |
+
<td>
|
978 |
+
<fieldset>
|
979 |
+
<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>
|
980 |
+
<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" />
|
981 |
+
<span id="wpua-readable-size"><?php echo $wpua_upload_size_limit_with_units; ?></span>
|
982 |
+
<span id="wpua-readable-size-error"><?php printf(__('%s exceeds the maximum upload size for this site.'), ""); ?></span>
|
983 |
+
<div id="wpua-slider"></div>
|
984 |
+
<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>
|
985 |
+
</fieldset>
|
986 |
+
<fieldset>
|
987 |
+
<label for="wp_user_avatar_edit_avatar">
|
988 |
+
<input name="wp_user_avatar_edit_avatar" type="checkbox" id="wp_user_avatar_edit_avatar" value="1" <?php checked($wpua_edit_avatar, 1); ?> />
|
989 |
+
<?php _e('Allow users to edit avatars', 'wp-user-avatar'); ?>
|
990 |
+
</label>
|
991 |
+
</fieldset>
|
992 |
+
<fieldset>
|
993 |
+
<label for="wp_user_avatar_resize_upload">
|
994 |
+
<input name="wp_user_avatar_resize_upload" type="checkbox" id="wp_user_avatar_resize_upload" value="1" <?php checked($wpua_resize_upload, 1); ?> />
|
995 |
+
<?php _e('Resize avatars on upload', 'wp-user-avatar'); ?>
|
996 |
+
</label>
|
997 |
+
</fieldset>
|
998 |
+
<fieldset id="wpua-resize-sizes"<?php echo $hide_resize; ?>
|
999 |
+
<br />
|
1000 |
+
<br />
|
1001 |
+
<label for="wp_user_avatar_resize_w"><?php _e('Width'); ?></label>
|
1002 |
+
<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" />
|
1003 |
+
<label for="wp_user_avatar_resize_h"><?php _e('Height'); ?></label>
|
1004 |
+
<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" />
|
1005 |
+
<br />
|
1006 |
+
<input name="wp_user_avatar_resize_crop" type="checkbox" id="wp_user_avatar_resize_crop" value="1" <?php checked('1', $wp_user_avatar_resize_crop); ?> />
|
1007 |
+
<label for="wp_user_avatar_resize_crop"><?php _e('Crop avatars to exact dimensions', 'wp-user-avatar'); ?></label>
|
1008 |
+
</fieldset>
|
1009 |
+
</td>
|
1010 |
+
</tr>
|
1011 |
+
</table>
|
1012 |
+
</div>
|
1013 |
<h3 class="title"><?php _e('Avatars'); ?></h3>
|
1014 |
<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>
|
1015 |
<table class="form-table">
|
1072 |
register_setting('wpua-settings-group', 'wp_user_avatar_allow_upload', 'intval');
|
1073 |
register_setting('wpua-settings-group', 'wp_user_avatar_disable_gravatar', 'intval');
|
1074 |
register_setting('wpua-settings-group', 'wp_user_avatar_edit_avatar', 'intval');
|
1075 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_crop', 'intval');
|
1076 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_h', 'intval');
|
1077 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_upload', 'intval');
|
1078 |
+
register_setting('wpua-settings-group', 'wp_user_avatar_resize_w', 'intval');
|
1079 |
register_setting('wpua-settings-group', 'wp_user_avatar_upload_size_limit', 'intval');
|
1080 |
}
|
1081 |
|
1092 |
}
|
1093 |
add_action('plugins_loaded', 'wpua_load');
|
1094 |
}
|
1095 |
+
|
1096 |
?>
|