Simple Local Avatars - Version 1.2

Version Description

  • Fix path issues on some IIS servers (resulting in missing avatar images)
  • Fix rare uninstall issues related to deleted avatars
  • Spanish localization
  • Other minor under the hood optimizations
Download this release

Release Info

Developer jakemgold
Plugin Icon 128x128 Simple Local Avatars
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.3 to 1.2

localization/simple-local-avatars-es_ES.mo ADDED
Binary file
localization/simple-local-avatars-es_ES.po ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-01-26 10:57+0100\n"
12
+ "Last-Translator: KLAMM <http://retroriff.com>\n"
13
+ "Language-Team: \n"
14
+ "X-Poedit-Language: Spanish\n"
15
+
16
+ #: simple-local-avatars.php:104
17
+ msgid "Local Avatar Permissions"
18
+ msgstr "Permisos de Local Avatar"
19
+
20
+ #: simple-local-avatars.php:120
21
+ msgid "Only allow users with file upload capabilities to upload local avatars (Authors and above)"
22
+ msgstr "Sólo aceptar usuarios con permisos para subir avatares locales (Autores y superiores)"
23
+
24
+ #: simple-local-avatars.php:128
25
+ msgid "Avatar"
26
+ msgstr "Avatar"
27
+
28
+ #: simple-local-avatars.php:132
29
+ msgid "Upload Avatar"
30
+ msgstr "Subir avatar"
31
+
32
+ #: simple-local-avatars.php:148
33
+ msgid "No local avatar is set. Use the upload field to add a local avatar."
34
+ msgstr "No se ha configurado ningún avatar. Usa el formulario para subir tu propio avatar."
35
+
36
+ #: simple-local-avatars.php:151
37
+ msgid "Delete local avatar"
38
+ msgstr "Eliminar avatar"
39
+
40
+ #: simple-local-avatars.php:152
41
+ 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."
42
+ msgstr "Substituye el avatar subiendo uno nuevo, o borrando el avatar actual seleccionando la opción de eliminar (en su lugar se utilizará Gravatar.com)."
43
+
44
+ #: simple-local-avatars.php:158
45
+ msgid "No local avatar is set. Set up your avatar at Gravatar.com."
46
+ msgstr "No se ha configurado ningún avatar. Configura tu avatar en Gravatar.com."
47
+
48
+ #: simple-local-avatars.php:161
49
+ msgid "You do not have media management permissions. To change your local avatar, contact the blog administrator."
50
+ msgstr "No tienes los permisos necesarios. Para cambiar tu avatar contacta con el administrador del blog."
51
+
52
+ #. Plugin Name of the plugin/theme
53
+ msgid "Simple Local Avatars"
54
+ msgstr "Simple Local Avatars"
55
+
56
+ #. Description of the plugin/theme
57
+ 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."
58
+ msgstr "Añade un campo para subir un avatar a los perfiles de usuario siempre que éstos tengan los permisos adecuados. Redimensiona las imágenes de la misma manera que Gravatar. Simple y ligero."
59
+
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.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,6 +35,12 @@ Unlike other avatar plug-ins, Simple Local Avatars:
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
4
  Tags: avatar, gravatar, user photos, users, profile
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
+ Stable tag: 1.2
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.2 =
39
+ * Fix path issues on some IIS servers (resulting in missing avatar images)
40
+ * Fix rare uninstall issues related to deleted avatars
41
+ * Spanish localization
42
+ * Other minor under the hood optimizations
43
+
44
  = 1.1.3 =
45
  * Properly deletes old avatars upon changing avatar
46
  * Fixes "foreach" warning in debug mode when updating avatar image
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.3
7
  Author: Jake Goldman (Oomph, Inc)
8
  Author URI: http://www.thinkoomph.com
9
 
@@ -80,18 +80,20 @@ class simple_local_avatars
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
 
85
  if ( is_wp_error($image_sized) ) // deal with original being >= to original image (or lack of sizing ability)
86
  $local_avatars[$size] = $local_avatars['full'];
87
  else
88
- $local_avatars[$size] = str_replace( ABSPATH, '', $image_sized );
89
 
90
  update_user_meta( $user_id, 'simple_local_avatar', $local_avatars );
91
  }
92
 
93
  $author_class = is_author( $user_id ) ? ' current-author' : '' ;
94
- $avatar = "<img alt='" . esc_attr($alt) . "' src='" . site_url( $local_avatars[$size] ) . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
95
 
96
  return $avatar;
97
  }
@@ -106,7 +108,7 @@ class simple_local_avatars
106
 
107
  function sanitize_options( $input )
108
  {
109
- $new_input['simple_local_avatars_caps'] = ( isset($input['simple_local_avatars_caps']) && !empty($input['simple_local_avatars_caps']) ) ? 1 : 0;
110
  return $new_input;
111
  }
112
 
@@ -206,50 +208,12 @@ class simple_local_avatars
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();
224
- $avatar_meta['full'] = str_replace( ABSPATH, '', $avatar['file'] );
225
-
226
- // create some common sizes now
227
-
228
- $sizes = array( 32, 50, 96 );
229
-
230
- foreach ( $sizes as $size ) :
231
-
232
- $image_sized = image_resize( $avatar['file'], $size, $size, true );
233
-
234
- if ( is_wp_error($image_sized) ) // deal with original being >= to original image (or lack of sizing ability)
235
- $image_sized = $avatar['file'];
236
-
237
- $avatar_meta[$size] = str_replace( ABSPATH, '', $image_sized );
238
-
239
- endforeach;
240
-
241
- // save user information (overwriting old)
242
- update_user_meta( $user_id, 'simple_local_avatar', $avatar_meta );
243
  }
244
  elseif ( isset($_POST['simple-local-avatar-erase']) && $_POST['simple-local-avatar-erase'] == 1 )
245
- {
246
- // delete old images if successful
247
- $old_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
248
- foreach ($old_avatars as $old_avatar )
249
- unlink( ABSPATH . $old_avatar );
250
-
251
- delete_user_meta( $user_id, 'simple_local_avatar' );
252
- }
253
  }
254
 
255
  /**
@@ -260,6 +224,26 @@ class simple_local_avatars
260
  remove_action( 'get_avatar', array( $this, 'get_avatar' ) );
261
  return $avatar_defaults;
262
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  }
264
 
265
  $simple_local_avatars = new simple_local_avatars;
@@ -292,13 +276,17 @@ register_uninstall_hook( __FILE__, 'simple_local_avatars_uninstall' );
292
  function simple_local_avatars_uninstall()
293
  {
294
  $users = get_users_of_blog();
 
295
 
296
  foreach ( $users as $user )
297
- {
298
  if ( $old_avatars = get_user_meta( $user->$user_id, 'simple_local_avatar', true ) )
299
  {
300
  foreach ($old_avatars as $old_avatar )
301
- unlink( ABSPATH . $old_avatar );
 
 
 
302
 
303
  delete_user_meta( $user->$user_id, 'simple_local_avatar' );
304
  }
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.2
7
  Author: Jake Goldman (Oomph, Inc)
8
  Author URI: http://www.thinkoomph.com
9
 
80
  // generate a new size
81
  if ( empty( $local_avatars[$size] ) )
82
  {
83
+ $upload_path = wp_upload_dir();
84
+ $avatar_full_path = str_replace( $upload_path['baseurl'], $upload_path['basedir'], $local_avatars['full'] );
85
+ $image_sized = image_resize( $avatar_full_path, $size, $size, true );
86
 
87
  if ( is_wp_error($image_sized) ) // deal with original being >= to original image (or lack of sizing ability)
88
  $local_avatars[$size] = $local_avatars['full'];
89
  else
90
+ $local_avatars[$size] = str_replace( $upload_path['basedir'], $upload_path['baseurl'], $image_sized );
91
 
92
  update_user_meta( $user_id, 'simple_local_avatar', $local_avatars );
93
  }
94
 
95
  $author_class = is_author( $user_id ) ? ' current-author' : '' ;
96
+ $avatar = "<img alt='" . esc_attr($alt) . "' src='" . $local_avatars[$size] . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";
97
 
98
  return $avatar;
99
  }
108
 
109
  function sanitize_options( $input )
110
  {
111
+ $new_input['simple_local_avatars_caps'] = empty($input['simple_local_avatars_caps']) ? 0 : 1;
112
  return $new_input;
113
  }
114
 
208
  return;
209
  }
210
 
211
+ $this->avatar_delete( $user_id ); // delete old images if successful
 
212
 
213
+ update_user_meta( $user_id, 'simple_local_avatar', array( 'full' => $avatar['url'] ) ); // save user information (overwriting old)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
  elseif ( isset($_POST['simple-local-avatar-erase']) && $_POST['simple-local-avatar-erase'] == 1 )
216
+ $this->avatar_delete( $user_id );
 
 
 
 
 
 
 
217
  }
218
 
219
  /**
224
  remove_action( 'get_avatar', array( $this, 'get_avatar' ) );
225
  return $avatar_defaults;
226
  }
227
+
228
+ /**
229
+ * delete avatars based on user_id
230
+ */
231
+ function avatar_delete( $user_id )
232
+ {
233
+ $old_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
234
+ $upload_path = wp_upload_dir();
235
+
236
+ if ( is_array($old_avatars) )
237
+ {
238
+ foreach ($old_avatars as $old_avatar )
239
+ {
240
+ $old_avatar_path = str_replace( $upload_path['baseurl'], $upload_path['basedir'], $old_avatar );
241
+ @unlink( $old_avatar_path );
242
+ }
243
+ }
244
+
245
+ delete_user_meta( $user_id, 'simple_local_avatar' );
246
+ }
247
  }
248
 
249
  $simple_local_avatars = new simple_local_avatars;
276
  function simple_local_avatars_uninstall()
277
  {
278
  $users = get_users_of_blog();
279
+ $upload_path = wp_upload_dir();
280
 
281
  foreach ( $users as $user )
282
+ {
283
  if ( $old_avatars = get_user_meta( $user->$user_id, 'simple_local_avatar', true ) )
284
  {
285
  foreach ($old_avatars as $old_avatar )
286
+ {
287
+ $old_avatar_path = str_replace( $upload_path['baseurl'], $upload_path['basedir'], $old_avatar );
288
+ @unlink( $old_avatar_path );
289
+ }
290
 
291
  delete_user_meta( $user->$user_id, 'simple_local_avatar' );
292
  }