Version Description
- Properly deletes old avatars upon changing avatar
- Fixes "foreach" warning in debug mode when updating avatar image
Download this release
Release Info
Developer | jakemgold |
Plugin | Simple Local Avatars |
Version | 1.1.3 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.1.3
- readme.txt +5 -1
- simple-local-avatars.php +18 -12
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.thinkoomph.com/plugins-modules/wordpress-simple-local-av
|
|
4 |
Tags: avatar, gravatar, user photos, users, profile
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.1
|
7 |
-
Stable tag: 1.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 |
|
@@ -35,6 +35,10 @@ Unlike other avatar plug-ins, Simple Local Avatars:
|
|
35 |
|
36 |
== Changelog ==
|
37 |
|
|
|
|
|
|
|
|
|
38 |
= 1.1.2 =
|
39 |
* Norwegian localization
|
40 |
|
4 |
Tags: avatar, gravatar, user photos, users, profile
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.1
|
7 |
+
Stable tag: 1.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 |
|
35 |
|
36 |
== Changelog ==
|
37 |
|
38 |
+
= 1.1.3 =
|
39 |
+
* Properly deletes old avatars upon changing avatar
|
40 |
+
* Fixes "foreach" warning in debug mode when updating avatar image
|
41 |
+
|
42 |
= 1.1.2 =
|
43 |
* Norwegian localization
|
44 |
|
simple-local-avatars.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Simple Local Avatars
|
4 |
Plugin URI: http://www.thinkoomph.com/plugins-modules/wordpress-simple-local-avatars/
|
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.1.
|
7 |
Author: Jake Goldman (Oomph, Inc)
|
8 |
Author URI: http://www.thinkoomph.com
|
9 |
|
@@ -57,7 +57,7 @@ class simple_local_avatars
|
|
57 |
elseif ( is_object($id_or_email) && !empty($id_or_email->user_id) )
|
58 |
$user_id = (int) $id_or_email->user_id;
|
59 |
|
60 |
-
if (
|
61 |
$local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
|
62 |
|
63 |
if ( !isset($local_avatars) || empty($local_avatars) || !isset($local_avatars['full']) )
|
@@ -78,7 +78,7 @@ class simple_local_avatars
|
|
78 |
$alt = get_the_author_meta( 'display_name', $user_id );
|
79 |
|
80 |
// generate a new size
|
81 |
-
if (
|
82 |
{
|
83 |
$image_sized = image_resize( ABSPATH . $local_avatars['full'], $size, $size, true );
|
84 |
|
@@ -137,14 +137,14 @@ class simple_local_avatars
|
|
137 |
<?php
|
138 |
$options = get_option('simple_local_avatars_caps');
|
139 |
|
140 |
-
if (
|
141 |
{
|
142 |
do_action( 'simple_local_avatar_notices' );
|
143 |
wp_nonce_field( 'simple_local_avatar_nonce', '_simple_local_avatar_nonce', false );
|
144 |
?>
|
145 |
<input type="file" name="simple-local-avatar" id="simple-local-avatar" /><br />
|
146 |
<?php
|
147 |
-
if (
|
148 |
echo '<span class="description">' . __('No local avatar is set. Use the upload field to add a local avatar.','simple-local-avatars') . '</span>';
|
149 |
else
|
150 |
echo '
|
@@ -154,7 +154,7 @@ class simple_local_avatars
|
|
154 |
}
|
155 |
else
|
156 |
{
|
157 |
-
if (
|
158 |
echo '<span class="description">' . __('No local avatar is set. Set up your avatar at Gravatar.com.','simple-local-avatars') . '</span>';
|
159 |
else
|
160 |
echo '
|
@@ -192,7 +192,7 @@ class simple_local_avatars
|
|
192 |
|
193 |
$avatar = wp_handle_upload( $_FILES['simple-local-avatar'], array( 'mimes' => $mimes, 'test_form' => false ) );
|
194 |
|
195 |
-
if (
|
196 |
{
|
197 |
switch ( $avatar['error'] )
|
198 |
{
|
@@ -206,12 +206,18 @@ class simple_local_avatars
|
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
-
|
|
|
210 |
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
// set up new avatar meta array
|
217 |
$avatar_meta = array();
|
3 |
Plugin Name: Simple Local Avatars
|
4 |
Plugin URI: http://www.thinkoomph.com/plugins-modules/wordpress-simple-local-avatars/
|
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.1.3
|
7 |
Author: Jake Goldman (Oomph, Inc)
|
8 |
Author URI: http://www.thinkoomph.com
|
9 |
|
57 |
elseif ( is_object($id_or_email) && !empty($id_or_email->user_id) )
|
58 |
$user_id = (int) $id_or_email->user_id;
|
59 |
|
60 |
+
if ( !empty($user_id) )
|
61 |
$local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
|
62 |
|
63 |
if ( !isset($local_avatars) || empty($local_avatars) || !isset($local_avatars['full']) )
|
78 |
$alt = get_the_author_meta( 'display_name', $user_id );
|
79 |
|
80 |
// generate a new size
|
81 |
+
if ( empty( $local_avatars[$size] ) )
|
82 |
{
|
83 |
$image_sized = image_resize( ABSPATH . $local_avatars['full'], $size, $size, true );
|
84 |
|
137 |
<?php
|
138 |
$options = get_option('simple_local_avatars_caps');
|
139 |
|
140 |
+
if ( empty($options['simple_local_avatars_caps']) || current_user_can('upload_files') )
|
141 |
{
|
142 |
do_action( 'simple_local_avatar_notices' );
|
143 |
wp_nonce_field( 'simple_local_avatar_nonce', '_simple_local_avatar_nonce', false );
|
144 |
?>
|
145 |
<input type="file" name="simple-local-avatar" id="simple-local-avatar" /><br />
|
146 |
<?php
|
147 |
+
if ( empty( $profileuser->simple_local_avatar ) )
|
148 |
echo '<span class="description">' . __('No local avatar is set. Use the upload field to add a local avatar.','simple-local-avatars') . '</span>';
|
149 |
else
|
150 |
echo '
|
154 |
}
|
155 |
else
|
156 |
{
|
157 |
+
if ( empty( $profileuser->simple_local_avatar ) )
|
158 |
echo '<span class="description">' . __('No local avatar is set. Set up your avatar at Gravatar.com.','simple-local-avatars') . '</span>';
|
159 |
else
|
160 |
echo '
|
192 |
|
193 |
$avatar = wp_handle_upload( $_FILES['simple-local-avatar'], array( 'mimes' => $mimes, 'test_form' => false ) );
|
194 |
|
195 |
+
if ( empty($avatar['file']) ) // handle failures
|
196 |
{
|
197 |
switch ( $avatar['error'] )
|
198 |
{
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
+
// delete old images if successful
|
210 |
+
if ( $old_avatars = get_user_meta( $user_id, 'simple_local_avatar', true ) ) :
|
211 |
|
212 |
+
if ( is_array($old_avatars) )
|
213 |
+
{
|
214 |
+
foreach ($old_avatars as $old_avatar )
|
215 |
+
@unlink( ABSPATH . $old_avatar );
|
216 |
+
}
|
217 |
+
|
218 |
+
delete_user_meta( $user_id, 'simple_local_avatar' );
|
219 |
+
|
220 |
+
endif;
|
221 |
|
222 |
// set up new avatar meta array
|
223 |
$avatar_meta = array();
|