Version Description
- Brazilian Portuguese and Belarusian translations
- Bug fixes (most notably correct naming of image files based on user display name)
- Optimization for WordPress 3.2 / 3.3 (substitutes deprecated function)
Download this release
Release Info
| Developer | jakemgold |
| Plugin | |
| Version | 1.3.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3 to 1.3.1
localization/simple-local-avatars-be_BY.mo
ADDED
|
Binary file
|
localization/simple-local-avatars-be_BY.po
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (C) 2010 Simple Local Avatars
|
| 2 |
+
# This file is distributed under the same license as the Simple Local Avatars package.
|
| 3 |
+
msgid ""
|
| 4 |
+
msgstr ""
|
| 5 |
+
"Project-Id-Version: Simple Local Avatars 1.1\n"
|
| 6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/simple-local-avatars\n"
|
| 7 |
+
"POT-Creation-Date: 2011-01-18 16:36:12+00:00\n"
|
| 8 |
+
"MIME-Version: 1.0\n"
|
| 9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
| 10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
| 11 |
+
"PO-Revision-Date: 2011-11-03 19:09+0200\n"
|
| 12 |
+
"Last-Translator: \n"
|
| 13 |
+
"Language-Team: Web Geeks\n"
|
| 14 |
+
"X-Poedit-Language: Belarusian\n"
|
| 15 |
+
"X-Poedit-Country: BELARUS\n"
|
| 16 |
+
|
| 17 |
+
#: simple-local-avatars.php:104
|
| 18 |
+
msgid "Local Avatar Permissions"
|
| 19 |
+
msgstr "Лакальныя налады аватара"
|
| 20 |
+
|
| 21 |
+
#: simple-local-avatars.php:120
|
| 22 |
+
msgid "Only allow users with file upload capabilities to upload local avatars (Authors and above)"
|
| 23 |
+
msgstr "Толькі карыстачы вызначанай катэгорыі могуць загружаць аватары (Аўтары і вышэй)"
|
| 24 |
+
|
| 25 |
+
#: simple-local-avatars.php:128
|
| 26 |
+
msgid "Avatar"
|
| 27 |
+
msgstr "Аватар"
|
| 28 |
+
|
| 29 |
+
#: simple-local-avatars.php:132
|
| 30 |
+
msgid "Upload Avatar"
|
| 31 |
+
msgstr "Загрузіць аватар"
|
| 32 |
+
|
| 33 |
+
#: simple-local-avatars.php:148
|
| 34 |
+
msgid "No local avatar is set. Use the upload field to add a local avatar."
|
| 35 |
+
msgstr "Няма установленого лакальнага аватара. Выкарыстоўвайце загрузку, каб дадаць аватар."
|
| 36 |
+
|
| 37 |
+
#: simple-local-avatars.php:151
|
| 38 |
+
msgid "Delete local avatar"
|
| 39 |
+
msgstr "Выдаліць лакальны аватар"
|
| 40 |
+
|
| 41 |
+
#: simple-local-avatars.php:152
|
| 42 |
+
msgid "Replace the local avatar by uploading a new avatar, or erase the local avatar (falling back to a gravatar) by checking the delete option."
|
| 43 |
+
msgstr "Замяніць лакальны аватар загрузіўшы новы малюнак ці сцерці лакальны аватар пазначыўшы опцыю выдалення. (па змаўчанні вернецца gravatar)"
|
| 44 |
+
|
| 45 |
+
#: simple-local-avatars.php:158
|
| 46 |
+
msgid "No local avatar is set. Set up your avatar at Gravatar.com."
|
| 47 |
+
msgstr "Лакальны аватар не ўсталяваны. Усталяваць ваш аватар на Gravatar.com"
|
| 48 |
+
|
| 49 |
+
#: simple-local-avatars.php:161
|
| 50 |
+
msgid "You do not have media management permissions. To change your local avatar, contact the blog administrator."
|
| 51 |
+
msgstr "Вашых паўнамоцтваў не досыць для змены аватара. Каб змяніць лакальны аватар, звяжыцеся з адміністратарам сайта."
|
| 52 |
+
|
| 53 |
+
#. Plugin Name of the plugin/theme
|
| 54 |
+
msgid "Simple Local Avatars"
|
| 55 |
+
msgstr "Лакальны аватар"
|
| 56 |
+
|
| 57 |
+
#. Description of the plugin/theme
|
| 58 |
+
msgid "Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar! Simple and lightweight."
|
| 59 |
+
msgstr "Дадаць запампоўку аватара да профіля карыстача, калі ў бягучага карыстача ёсць паўнамоцтвы. Генераваць такія ж памеры, як на Gravatar-е. Проста і лёгка."
|
| 60 |
+
|
localization/simple-local-avatars-pt_BR.mo
ADDED
|
Binary file
|
localization/simple-local-avatars-pt_BR.po
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (C) 2010 Simple Local Avatars
|
| 2 |
+
# This file is distributed under the same license as the Simple Local Avatars package.
|
| 3 |
+
msgid ""
|
| 4 |
+
msgstr ""
|
| 5 |
+
"Project-Id-Version: Simple Local Avatars 1.1\n"
|
| 6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/simple-local-avatars\n"
|
| 7 |
+
"POT-Creation-Date: 2011-01-18 16:36:12+00:00\n"
|
| 8 |
+
"MIME-Version: 1.0\n"
|
| 9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
| 10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
| 11 |
+
"PO-Revision-Date: 2011-12-28 13:18-0300\n"
|
| 12 |
+
"Last-Translator: Billy Blay <billy.blay@gmail.com>\n"
|
| 13 |
+
"Language-Team: Billy Blay <billy.blay@gmail.com>\n"
|
| 14 |
+
"X-Poedit-Language: Portuguese\n"
|
| 15 |
+
"X-Poedit-Country: BRAZIL\n"
|
| 16 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
| 17 |
+
|
| 18 |
+
#: simple-local-avatars.php:104
|
| 19 |
+
msgid "Local Avatar Permissions"
|
| 20 |
+
msgstr "Permissões do Local Avatar"
|
| 21 |
+
|
| 22 |
+
#: simple-local-avatars.php:120
|
| 23 |
+
msgid "Only allow users with file upload capabilities to upload local avatars (Authors and above)"
|
| 24 |
+
msgstr "Só aceitar usuarios com permisões para enviar avatares locais (Autores e superiores)"
|
| 25 |
+
|
| 26 |
+
#: simple-local-avatars.php:128
|
| 27 |
+
msgid "Avatar"
|
| 28 |
+
msgstr "Avatar"
|
| 29 |
+
|
| 30 |
+
#: simple-local-avatars.php:132
|
| 31 |
+
msgid "Upload Avatar"
|
| 32 |
+
msgstr "Enviar avatar"
|
| 33 |
+
|
| 34 |
+
#: simple-local-avatars.php:148
|
| 35 |
+
msgid "No local avatar is set. Use the upload field to add a local avatar."
|
| 36 |
+
msgstr "Não há nenhum avatar configurado. Use o formulário de envio para adicionar um novo avatar."
|
| 37 |
+
|
| 38 |
+
#: simple-local-avatars.php:151
|
| 39 |
+
msgid "Delete local avatar"
|
| 40 |
+
msgstr "Deletar avatar"
|
| 41 |
+
|
| 42 |
+
#: simple-local-avatars.php:152
|
| 43 |
+
msgid "Replace the local avatar by uploading a new avatar, or erase the local avatar (falling back to a gravatar) by checking the delete option."
|
| 44 |
+
msgstr "Substituir o avatar enviando um novo, ou apague o avatar atual selecionando a opção de deletar (em seu lugar se utilizará o Gravatar.com)."
|
| 45 |
+
|
| 46 |
+
#: simple-local-avatars.php:158
|
| 47 |
+
msgid "No local avatar is set. Set up your avatar at Gravatar.com."
|
| 48 |
+
msgstr "Não há nenhum avatar configurado. Configure seu avatar em Gravatar.com."
|
| 49 |
+
|
| 50 |
+
#: simple-local-avatars.php:161
|
| 51 |
+
msgid "You do not have media management permissions. To change your local avatar, contact the blog administrator."
|
| 52 |
+
msgstr "Você não tem permissão para mudar seu avatar contate o administrador do blog."
|
| 53 |
+
|
| 54 |
+
#. Plugin Name of the plugin/theme
|
| 55 |
+
msgid "Simple Local Avatars"
|
| 56 |
+
msgstr "Simple Local Avatars"
|
| 57 |
+
|
| 58 |
+
#. Description of the plugin/theme
|
| 59 |
+
msgid "Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar! Simple and lightweight."
|
| 60 |
+
msgstr "Adicione um avatar no campo de upload de perfis de usuário se o usuário atual tem permissões de mídia. Gere tamanhos solicitada como no Gravatar! Simples e leve."
|
| 61 |
+
|
readme.txt
CHANGED
|
@@ -2,12 +2,13 @@
|
|
| 2 |
Contributors: jakemgold, 10up, thinkoomph
|
| 3 |
Donate link: http://get10up.com/plugins/simple-local-avatars-wordpress/
|
| 4 |
Tags: avatar, gravatar, user photos, users, profile
|
| 5 |
-
Requires at least: 3.
|
| 6 |
-
Tested up to: 3.
|
| 7 |
-
Stable tag: 1.3
|
| 8 |
|
| 9 |
Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar!
|
| 10 |
|
|
|
|
| 11 |
== Description ==
|
| 12 |
|
| 13 |
Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar! Simple and lightweight.
|
|
@@ -22,6 +23,7 @@ Unlike other avatar plug-ins, Simple Local Avatars:
|
|
| 22 |
1. Generates the requested avatar size on demand (and stores the new size for efficiency), so it looks great, just like Gravatar!
|
| 23 |
1. Let's you decide whether lower privilege users (subscribers, contributors) can upload their own avatar
|
| 24 |
|
|
|
|
| 25 |
== Installation ==
|
| 26 |
|
| 27 |
1. Install easily with the WordPress plugin control panel or manually download the plugin and upload the extracted folder to the `/wp-content/plugins/` directory
|
|
@@ -29,12 +31,23 @@ Unlike other avatar plug-ins, Simple Local Avatars:
|
|
| 29 |
1. If you only want users with file upload capabilities to upload avatars, check the applicable option under Settings > Discussion
|
| 30 |
1. Start uploading avatars by editing user profiles!
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
== Screenshots ==
|
| 33 |
|
| 34 |
1. Avatar upload field on a user profile page
|
| 35 |
|
|
|
|
| 36 |
== Changelog ==
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
= 1.3 =
|
| 39 |
* Avatar file name saved as "user-display-name_avatar" (or other image extension)
|
| 40 |
* Russian localization added
|
|
@@ -71,4 +84,10 @@ Unlike other avatar plug-ins, Simple Local Avatars:
|
|
| 71 |
|
| 72 |
= 1.1 =
|
| 73 |
* All users (regardless of capabilities) can upload avatars by default. To limit avatar uploading to users with upload files capabilities (Authors and above), check the applicable option under Settings > Discussion. This was the default behavior in 1.0.
|
| 74 |
-
* Localization support; German included
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
Contributors: jakemgold, 10up, thinkoomph
|
| 3 |
Donate link: http://get10up.com/plugins/simple-local-avatars-wordpress/
|
| 4 |
Tags: avatar, gravatar, user photos, users, profile
|
| 5 |
+
Requires at least: 3.2
|
| 6 |
+
Tested up to: 3.3
|
| 7 |
+
Stable tag: 1.3.1
|
| 8 |
|
| 9 |
Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar!
|
| 10 |
|
| 11 |
+
|
| 12 |
== Description ==
|
| 13 |
|
| 14 |
Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar! Simple and lightweight.
|
| 23 |
1. Generates the requested avatar size on demand (and stores the new size for efficiency), so it looks great, just like Gravatar!
|
| 24 |
1. Let's you decide whether lower privilege users (subscribers, contributors) can upload their own avatar
|
| 25 |
|
| 26 |
+
|
| 27 |
== Installation ==
|
| 28 |
|
| 29 |
1. Install easily with the WordPress plugin control panel or manually download the plugin and upload the extracted folder to the `/wp-content/plugins/` directory
|
| 31 |
1. If you only want users with file upload capabilities to upload avatars, check the applicable option under Settings > Discussion
|
| 32 |
1. Start uploading avatars by editing user profiles!
|
| 33 |
|
| 34 |
+
Use avatars in your theme using WordPress' built in `get_avatar()` function: [http://codex.wordpress.org/Function_Reference/get_avatar](http://codex.wordpress.org/Function_Reference/get_avatar "get_avatar function")
|
| 35 |
+
|
| 36 |
+
You can also use `get_simple_local_avatar()` (with the same arguments) to retreive local avatars a bit faster, but this will make your theme dependent on this plug-in.
|
| 37 |
+
|
| 38 |
+
|
| 39 |
== Screenshots ==
|
| 40 |
|
| 41 |
1. Avatar upload field on a user profile page
|
| 42 |
|
| 43 |
+
|
| 44 |
== Changelog ==
|
| 45 |
|
| 46 |
+
= 1.3.1 =
|
| 47 |
+
* Brazilian Portuguese and Belarusian translations
|
| 48 |
+
* Bug fixes (most notably correct naming of image files based on user display name)
|
| 49 |
+
* Optimization for WordPress 3.2 / 3.3 (substitutes deprecated function)
|
| 50 |
+
|
| 51 |
= 1.3 =
|
| 52 |
* Avatar file name saved as "user-display-name_avatar" (or other image extension)
|
| 53 |
* Russian localization added
|
| 84 |
|
| 85 |
= 1.1 =
|
| 86 |
* All users (regardless of capabilities) can upload avatars by default. To limit avatar uploading to users with upload files capabilities (Authors and above), check the applicable option under Settings > Discussion. This was the default behavior in 1.0.
|
| 87 |
+
* Localization support; German included
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
== Upgrade Notice ==
|
| 91 |
+
|
| 92 |
+
= 1.3.1 =
|
| 93 |
+
Like WordPress 3.2, now *REQUIRES* PHP 5.2 or newer.
|
screenshot-1.png
CHANGED
|
Binary file
|
simple-local-avatars.php
CHANGED
|
@@ -3,11 +3,11 @@
|
|
| 3 |
Plugin Name: Simple Local Avatars
|
| 4 |
Plugin URI: http://get10up.com/plugins/simple-local-avatars-wordpress/
|
| 5 |
Description: Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar! Simple and lightweight.
|
| 6 |
-
Version: 1.3
|
| 7 |
Author: Jake Goldman (10up LLC), Oomph Inc
|
| 8 |
Author URI: http://get10up.com
|
| 9 |
|
| 10 |
-
Plugin: Copyright 2011
|
| 11 |
|
| 12 |
This program is free software; you can redistribute it and/or modify
|
| 13 |
it under the terms of the GNU General Public License as published by
|
|
@@ -22,15 +22,21 @@
|
|
| 22 |
You should have received a copy of the GNU General Public License
|
| 23 |
along with this program; if not, write to the Free Software
|
| 24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
*/
|
| 26 |
|
| 27 |
/**
|
| 28 |
* add field to user profiles
|
| 29 |
*/
|
| 30 |
|
| 31 |
-
class
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
add_filter( 'get_avatar', array( $this, 'get_avatar' ), 10, 5 );
|
| 35 |
|
| 36 |
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
|
@@ -44,11 +50,11 @@ class simple_local_avatars
|
|
| 44 |
add_filter( 'avatar_defaults', array( $this, 'avatar_defaults' ) );
|
| 45 |
}
|
| 46 |
|
| 47 |
-
function get_avatar( $avatar = '', $id_or_email, $size =
|
| 48 |
|
| 49 |
if ( is_numeric($id_or_email) )
|
| 50 |
$user_id = (int) $id_or_email;
|
| 51 |
-
elseif ( is_string( $id_or_email ) && ( $user =
|
| 52 |
$user_id = $user->ID;
|
| 53 |
elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) )
|
| 54 |
$user_id = (int) $id_or_email->user_id;
|
|
@@ -70,35 +76,34 @@ class simple_local_avatars
|
|
| 70 |
if ( empty( $local_avatars[$size] ) ) {
|
| 71 |
$upload_path = wp_upload_dir();
|
| 72 |
$avatar_full_path = str_replace( $upload_path['baseurl'], $upload_path['basedir'], $local_avatars['full'] );
|
| 73 |
-
$image_sized = image_resize( $avatar_full_path, $size, $size, true );
|
| 74 |
-
|
| 75 |
// deal with original being >= to original image (or lack of sizing ability)
|
| 76 |
$local_avatars[$size] = is_wp_error($image_sized) ? $local_avatars[$size] = $local_avatars['full'] : str_replace( $upload_path['basedir'], $upload_path['baseurl'], $image_sized );
|
| 77 |
-
|
| 78 |
update_user_meta( $user_id, 'simple_local_avatar', $local_avatars );
|
| 79 |
} elseif ( substr( $local_avatars[$size], 0, 4 ) != 'http' ) {
|
| 80 |
-
$local_avatars[$size] =
|
| 81 |
}
|
| 82 |
|
| 83 |
$author_class = is_author( $user_id ) ? ' current-author' : '' ;
|
| 84 |
-
$avatar = "<img alt='" . esc_attr($alt) . "' src='" . $local_avatars[$size] . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
|
| 85 |
|
| 86 |
return apply_filters( 'simple_local_avatar', $avatar );
|
| 87 |
}
|
| 88 |
|
| 89 |
-
function admin_init() {
|
| 90 |
load_plugin_textdomain( 'simple-local-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/localization/' );
|
| 91 |
|
| 92 |
register_setting( 'discussion', 'simple_local_avatars_caps', array( $this, 'sanitize_options' ) );
|
| 93 |
add_settings_field( 'simple-local-avatars-caps', __('Local Avatar Permissions','simple-local-avatars'), array( $this, 'avatar_settings_field' ), 'discussion', 'avatars' );
|
| 94 |
}
|
| 95 |
|
| 96 |
-
function sanitize_options( $input ) {
|
| 97 |
$new_input['simple_local_avatars_caps'] = empty( $input['simple_local_avatars_caps'] ) ? 0 : 1;
|
| 98 |
return $new_input;
|
| 99 |
}
|
| 100 |
|
| 101 |
-
function avatar_settings_field( $args ) {
|
| 102 |
$options = get_option('simple_local_avatars_caps');
|
| 103 |
|
| 104 |
echo '
|
|
@@ -109,7 +114,7 @@ class simple_local_avatars
|
|
| 109 |
';
|
| 110 |
}
|
| 111 |
|
| 112 |
-
function edit_user_profile( $profileuser ) {
|
| 113 |
?>
|
| 114 |
<h3><?php _e( 'Avatar','simple-local-avatars' ); ?></h3>
|
| 115 |
|
|
@@ -150,7 +155,7 @@ class simple_local_avatars
|
|
| 150 |
<?php
|
| 151 |
}
|
| 152 |
|
| 153 |
-
function edit_user_profile_update( $user_id ) {
|
| 154 |
if ( ! isset( $_POST['_simple_local_avatar_nonce'] ) || ! wp_verify_nonce( $_POST['_simple_local_avatar_nonce'], 'simple_local_avatar_nonce' ) ) //security
|
| 155 |
return;
|
| 156 |
|
|
@@ -169,6 +174,11 @@ class simple_local_avatars
|
|
| 169 |
|
| 170 |
$this->avatar_delete( $user_id ); // delete old images if successful
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
$avatar = wp_handle_upload( $_FILES['simple-local-avatar'], array( 'mimes' => $mimes, 'test_form' => false, 'unique_filename_callback' => array( $this, 'unique_filename_callback' ) ) );
|
| 173 |
|
| 174 |
if ( empty($avatar['file']) ) { // handle failures
|
|
@@ -192,7 +202,7 @@ class simple_local_avatars
|
|
| 192 |
/**
|
| 193 |
* remove the custom get_avatar hook for the default avatar list output on options-discussion.php
|
| 194 |
*/
|
| 195 |
-
function avatar_defaults( $avatar_defaults ) {
|
| 196 |
remove_action( 'get_avatar', array( $this, 'get_avatar' ) );
|
| 197 |
return $avatar_defaults;
|
| 198 |
}
|
|
@@ -200,7 +210,7 @@ class simple_local_avatars
|
|
| 200 |
/**
|
| 201 |
* delete avatars based on user_id
|
| 202 |
*/
|
| 203 |
-
function avatar_delete( $user_id ) {
|
| 204 |
$old_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
|
| 205 |
$upload_path = wp_upload_dir();
|
| 206 |
|
|
@@ -214,14 +224,13 @@ class simple_local_avatars
|
|
| 214 |
delete_user_meta( $user_id, 'simple_local_avatar' );
|
| 215 |
}
|
| 216 |
|
| 217 |
-
function unique_filename_callback( $dir, $name, $ext ) {
|
| 218 |
-
$user =
|
| 219 |
-
$name = sanitize_file_name( $user->display_name . '_avatar' );
|
| 220 |
-
|
| 221 |
$number = 1;
|
| 222 |
|
| 223 |
while ( file_exists( $dir . "/$name$ext" ) ) {
|
| 224 |
-
$name = $
|
| 225 |
$number++;
|
| 226 |
}
|
| 227 |
|
|
@@ -229,7 +238,7 @@ class simple_local_avatars
|
|
| 229 |
}
|
| 230 |
}
|
| 231 |
|
| 232 |
-
$simple_local_avatars = new
|
| 233 |
|
| 234 |
/**
|
| 235 |
* more efficient to call simple local avatar directly in theme and avoid gravatar setup
|
|
@@ -257,7 +266,7 @@ function get_simple_local_avatar( $id_or_email, $size = '96', $default = '', $al
|
|
| 257 |
register_uninstall_hook( __FILE__, 'simple_local_avatars_uninstall' );
|
| 258 |
|
| 259 |
function simple_local_avatars_uninstall() {
|
| 260 |
-
$simple_local_avatars = new
|
| 261 |
$users = get_users_of_blog();
|
| 262 |
|
| 263 |
foreach ( $users as $user )
|
| 3 |
Plugin Name: Simple Local Avatars
|
| 4 |
Plugin URI: http://get10up.com/plugins/simple-local-avatars-wordpress/
|
| 5 |
Description: Adds an avatar upload field to user profiles if the current user has media permissions. Generates requested sizes on demand just like Gravatar! Simple and lightweight.
|
| 6 |
+
Version: 1.3.1
|
| 7 |
Author: Jake Goldman (10up LLC), Oomph Inc
|
| 8 |
Author URI: http://get10up.com
|
| 9 |
|
| 10 |
+
Plugin: Copyright 2011 Jake Goldman (email : jake@get10up.com)
|
| 11 |
|
| 12 |
This program is free software; you can redistribute it and/or modify
|
| 13 |
it under the terms of the GNU General Public License as published by
|
| 22 |
You should have received a copy of the GNU General Public License
|
| 23 |
along with this program; if not, write to the Free Software
|
| 24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
| 25 |
+
|
| 26 |
+
NOTE: Previous versions may have accidentally and incorrectly attributed the
|
| 27 |
+
copyright to employers of Mr. Goldman. While credit is given to all contributors
|
| 28 |
+
to the current version, including Mr. Goldman's employers, the copyright belongs
|
| 29 |
+
- and has always belonged - to Mr. Goldman, personally.
|
| 30 |
*/
|
| 31 |
|
| 32 |
/**
|
| 33 |
* add field to user profiles
|
| 34 |
*/
|
| 35 |
|
| 36 |
+
class Simple_Local_Avatars {
|
| 37 |
+
private $user_id_being_edited;
|
| 38 |
+
|
| 39 |
+
public function __construct() {
|
| 40 |
add_filter( 'get_avatar', array( $this, 'get_avatar' ), 10, 5 );
|
| 41 |
|
| 42 |
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
| 50 |
add_filter( 'avatar_defaults', array( $this, 'avatar_defaults' ) );
|
| 51 |
}
|
| 52 |
|
| 53 |
+
public function get_avatar( $avatar = '', $id_or_email, $size = 96, $default = '', $alt = false ) {
|
| 54 |
|
| 55 |
if ( is_numeric($id_or_email) )
|
| 56 |
$user_id = (int) $id_or_email;
|
| 57 |
+
elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) )
|
| 58 |
$user_id = $user->ID;
|
| 59 |
elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) )
|
| 60 |
$user_id = (int) $id_or_email->user_id;
|
| 76 |
if ( empty( $local_avatars[$size] ) ) {
|
| 77 |
$upload_path = wp_upload_dir();
|
| 78 |
$avatar_full_path = str_replace( $upload_path['baseurl'], $upload_path['basedir'], $local_avatars['full'] );
|
| 79 |
+
$image_sized = image_resize( $avatar_full_path, $size, $size, true );
|
|
|
|
| 80 |
// deal with original being >= to original image (or lack of sizing ability)
|
| 81 |
$local_avatars[$size] = is_wp_error($image_sized) ? $local_avatars[$size] = $local_avatars['full'] : str_replace( $upload_path['basedir'], $upload_path['baseurl'], $image_sized );
|
| 82 |
+
// save updated avatar sizes
|
| 83 |
update_user_meta( $user_id, 'simple_local_avatar', $local_avatars );
|
| 84 |
} elseif ( substr( $local_avatars[$size], 0, 4 ) != 'http' ) {
|
| 85 |
+
$local_avatars[$size] = home_url( $local_avatars[$size] );
|
| 86 |
}
|
| 87 |
|
| 88 |
$author_class = is_author( $user_id ) ? ' current-author' : '' ;
|
| 89 |
+
$avatar = "<img alt='" . esc_attr( $alt ) . "' src='" . $local_avatars[$size] . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
|
| 90 |
|
| 91 |
return apply_filters( 'simple_local_avatar', $avatar );
|
| 92 |
}
|
| 93 |
|
| 94 |
+
public function admin_init() {
|
| 95 |
load_plugin_textdomain( 'simple-local-avatars', false, dirname( plugin_basename( __FILE__ ) ) . '/localization/' );
|
| 96 |
|
| 97 |
register_setting( 'discussion', 'simple_local_avatars_caps', array( $this, 'sanitize_options' ) );
|
| 98 |
add_settings_field( 'simple-local-avatars-caps', __('Local Avatar Permissions','simple-local-avatars'), array( $this, 'avatar_settings_field' ), 'discussion', 'avatars' );
|
| 99 |
}
|
| 100 |
|
| 101 |
+
public function sanitize_options( $input ) {
|
| 102 |
$new_input['simple_local_avatars_caps'] = empty( $input['simple_local_avatars_caps'] ) ? 0 : 1;
|
| 103 |
return $new_input;
|
| 104 |
}
|
| 105 |
|
| 106 |
+
public function avatar_settings_field( $args ) {
|
| 107 |
$options = get_option('simple_local_avatars_caps');
|
| 108 |
|
| 109 |
echo '
|
| 114 |
';
|
| 115 |
}
|
| 116 |
|
| 117 |
+
public function edit_user_profile( $profileuser ) {
|
| 118 |
?>
|
| 119 |
<h3><?php _e( 'Avatar','simple-local-avatars' ); ?></h3>
|
| 120 |
|
| 155 |
<?php
|
| 156 |
}
|
| 157 |
|
| 158 |
+
public function edit_user_profile_update( $user_id ) {
|
| 159 |
if ( ! isset( $_POST['_simple_local_avatar_nonce'] ) || ! wp_verify_nonce( $_POST['_simple_local_avatar_nonce'], 'simple_local_avatar_nonce' ) ) //security
|
| 160 |
return;
|
| 161 |
|
| 174 |
|
| 175 |
$this->avatar_delete( $user_id ); // delete old images if successful
|
| 176 |
|
| 177 |
+
// need to be more secure since low privelege users can upload
|
| 178 |
+
if ( strstr( $_FILES['simple-local-avatar']['name'], '.php' ) )
|
| 179 |
+
wp_die('For security reasons, the extension ".php" cannot be in your file name.');
|
| 180 |
+
|
| 181 |
+
$this->user_id_being_edited = $user_id; // make user_id known to unique_filename_callback function
|
| 182 |
$avatar = wp_handle_upload( $_FILES['simple-local-avatar'], array( 'mimes' => $mimes, 'test_form' => false, 'unique_filename_callback' => array( $this, 'unique_filename_callback' ) ) );
|
| 183 |
|
| 184 |
if ( empty($avatar['file']) ) { // handle failures
|
| 202 |
/**
|
| 203 |
* remove the custom get_avatar hook for the default avatar list output on options-discussion.php
|
| 204 |
*/
|
| 205 |
+
public function avatar_defaults( $avatar_defaults ) {
|
| 206 |
remove_action( 'get_avatar', array( $this, 'get_avatar' ) );
|
| 207 |
return $avatar_defaults;
|
| 208 |
}
|
| 210 |
/**
|
| 211 |
* delete avatars based on user_id
|
| 212 |
*/
|
| 213 |
+
public function avatar_delete( $user_id ) {
|
| 214 |
$old_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
|
| 215 |
$upload_path = wp_upload_dir();
|
| 216 |
|
| 224 |
delete_user_meta( $user_id, 'simple_local_avatar' );
|
| 225 |
}
|
| 226 |
|
| 227 |
+
public function unique_filename_callback( $dir, $name, $ext ) {
|
| 228 |
+
$user = get_user_by( 'id', (int) $this->user_id_being_edited );
|
| 229 |
+
$name = $base_name = sanitize_file_name( $user->display_name . '_avatar' );
|
|
|
|
| 230 |
$number = 1;
|
| 231 |
|
| 232 |
while ( file_exists( $dir . "/$name$ext" ) ) {
|
| 233 |
+
$name = $base_name . '_' . $number;
|
| 234 |
$number++;
|
| 235 |
}
|
| 236 |
|
| 238 |
}
|
| 239 |
}
|
| 240 |
|
| 241 |
+
$simple_local_avatars = new Simple_Local_Avatars;
|
| 242 |
|
| 243 |
/**
|
| 244 |
* more efficient to call simple local avatar directly in theme and avoid gravatar setup
|
| 266 |
register_uninstall_hook( __FILE__, 'simple_local_avatars_uninstall' );
|
| 267 |
|
| 268 |
function simple_local_avatars_uninstall() {
|
| 269 |
+
$simple_local_avatars = new Simple_Local_Avatars;
|
| 270 |
$users = get_users_of_blog();
|
| 271 |
|
| 272 |
foreach ( $users as $user )
|
