Custom User Profile Photo - Version 0.2.5

Version Description

  • Tested with WordPress v4.1
  • Fixed a bug where the external URL option would not return the URL with get_cupp_meta().
  • Fixed a bug where the saved image did not correspond to the selected radio button.
  • Replaced depricated update_usermeta with update_user_meta.
  • Improved image selection functionality.
  • Images now show immediately after selecting an uploaded item or entering an external URL.
  • Added Dutch translation - Thanks Olaf Lederer
Download this release

Release Info

Developer 3five
Plugin Icon wp plugin Custom User Profile Photo
Version 0.2.5
Comparing to
See all releases

Code changes from version 0.2.4 to 0.2.5

3five_cupp.php CHANGED
@@ -7,7 +7,7 @@ Author: 3five
7
  Author URI: http://3five.com
8
  Text Domain: custom-user-profile-photo
9
  Domain Path: /languages/
10
- Version: 0.2.4
11
  */
12
 
13
  /**
@@ -98,6 +98,8 @@ function cupp_profile_img_fields( $user ) {
98
  <div class="edit_options single">
99
  <a class="remove_img"><span>Remove</span></a>
100
  </div>
 
 
101
  <?php endif; ?>
102
  </div>
103
 
@@ -111,6 +113,7 @@ function cupp_profile_img_fields( $user ) {
111
 
112
  <!-- Hold the value here if this is a WPMU image -->
113
  <div id="cupp_upload">
 
114
  <input type="hidden" name="cupp_upload_meta" id="cupp_upload_meta" value="<?php echo esc_url_raw( $cupp_upload_url ); ?>" class="hidden" />
115
  <input type="hidden" name="cupp_upload_edit_meta" id="cupp_upload_edit_meta" value="<?php echo esc_url_raw( $cupp_upload_edit_url ); ?>" class="hidden" />
116
  <input type='button' class="cupp_wpmu_button button-primary" value="<?php _e( $btn_text, 'custom-user-profile-photo' ); ?>" id="uploadimage"/><br />
@@ -142,9 +145,9 @@ function cupp_save_img_meta( $user_id ) {
142
  return false;
143
 
144
  // If the current user can edit Users, allow this.
145
- update_usermeta( $user_id, 'cupp_meta', $_POST['cupp_meta'] );
146
- update_usermeta( $user_id, 'cupp_upload_meta', $_POST['cupp_upload_meta'] );
147
- update_usermeta( $user_id, 'cupp_upload_edit_meta', $_POST['cupp_upload_edit_meta'] );
148
  }
149
 
150
  /**
@@ -208,20 +211,26 @@ function get_cupp_meta( $user_id, $size ) {
208
  // get the external image
209
  $attachment_ext_url = esc_url( get_the_author_meta( 'cupp_meta', $user_id ) );
210
  $attachment_url = '';
 
211
  if($attachment_upload_url){
212
  $attachment_url = $attachment_upload_url;
 
 
 
 
 
 
 
 
213
  } elseif($attachment_ext_url) {
214
- $attachment_url = $attachment_ext_url;
215
  }
216
-
217
- // grabs the id from the URL using Frankie Jarretts function
218
- $attachment_id = get_attachment_image_by_url( $attachment_url );
219
-
220
- // retrieve the thumbnail size of our image
221
- $image_thumb = wp_get_attachment_image_src( $attachment_id, $size );
222
-
223
  // return the image thumbnail
224
- return $image_thumb[0];
225
  }
226
 
227
  ?>
7
  Author URI: http://3five.com
8
  Text Domain: custom-user-profile-photo
9
  Domain Path: /languages/
10
+ Version: 0.2.5
11
  */
12
 
13
  /**
98
  <div class="edit_options single">
99
  <a class="remove_img"><span>Remove</span></a>
100
  </div>
101
+ <?php else : ?>
102
+ <img src="<?php echo plugins_url( 'custom-user-profile-photo/img/placeholder.gif' ); ?>" class="cupp-current-img placeholder">
103
  <?php endif; ?>
104
  </div>
105
 
113
 
114
  <!-- Hold the value here if this is a WPMU image -->
115
  <div id="cupp_upload">
116
+ <input type="hidden" name="cupp_placeholder_meta" id="cupp_placeholder_meta" value="<?php echo plugins_url( 'custom-user-profile-photo/img/placeholder.gif' ); ?>" class="hidden" />
117
  <input type="hidden" name="cupp_upload_meta" id="cupp_upload_meta" value="<?php echo esc_url_raw( $cupp_upload_url ); ?>" class="hidden" />
118
  <input type="hidden" name="cupp_upload_edit_meta" id="cupp_upload_edit_meta" value="<?php echo esc_url_raw( $cupp_upload_edit_url ); ?>" class="hidden" />
119
  <input type='button' class="cupp_wpmu_button button-primary" value="<?php _e( $btn_text, 'custom-user-profile-photo' ); ?>" id="uploadimage"/><br />
145
  return false;
146
 
147
  // If the current user can edit Users, allow this.
148
+ update_user_meta( $user_id, 'cupp_meta', $_POST['cupp_meta'] );
149
+ update_user_meta( $user_id, 'cupp_upload_meta', $_POST['cupp_upload_meta'] );
150
+ update_user_meta( $user_id, 'cupp_upload_edit_meta', $_POST['cupp_upload_edit_meta'] );
151
  }
152
 
153
  /**
211
  // get the external image
212
  $attachment_ext_url = esc_url( get_the_author_meta( 'cupp_meta', $user_id ) );
213
  $attachment_url = '';
214
+ $image_url = '';
215
  if($attachment_upload_url){
216
  $attachment_url = $attachment_upload_url;
217
+
218
+ // grabs the id from the URL using Frankie Jarretts function
219
+ $attachment_id = get_attachment_image_by_url( $attachment_url );
220
+
221
+ // retrieve the thumbnail size of our image
222
+ $image_thumb = wp_get_attachment_image_src( $attachment_id, $size );
223
+ $image_url = $image_thumb[0];
224
+
225
  } elseif($attachment_ext_url) {
226
+ $image_url = $attachment_ext_url;
227
  }
228
+
229
+ if ( empty($image_url) )
230
+ return;
231
+
 
 
 
232
  // return the image thumbnail
233
+ return $image_url;
234
  }
235
 
236
  ?>
css/styles.css CHANGED
@@ -35,6 +35,13 @@
35
  border: 1px solid #e5e5e5;
36
  }
37
 
 
 
 
 
 
 
 
38
  .edit_options{
39
  display: block;
40
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
35
  border: 1px solid #e5e5e5;
36
  }
37
 
38
+ .cupp-current-img.placeholder{
39
+ width: 1px;
40
+ height: 1px;
41
+ border: 0;
42
+ background: transparent;
43
+ }
44
+
45
  .edit_options{
46
  display: block;
47
  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
img/placeholder.gif ADDED
Binary file
js/scripts.js CHANGED
@@ -35,7 +35,7 @@ var file_frame;
35
  jQuery('#cupp_meta').val('');
36
  jQuery('#cupp_upload_meta').val(attachment.url);
37
  jQuery('#cupp_upload_edit_meta').val('/wp-admin/post.php?post='+attachment.id+'&action=edit&image-editor');
38
- jQuery('.cupp-current-img').attr('src', attachment.url);
39
  });
40
 
41
  // Finally, open the modal
@@ -55,6 +55,22 @@ var file_frame;
55
  }
56
 
57
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  // Remove Image Function
60
  jQuery('.edit_options').hover(function(){
@@ -64,7 +80,12 @@ var file_frame;
64
  });
65
 
66
  jQuery('.remove_img').on('click', function( event ){
67
- jQuery(this).parent().add('.cupp-current-img').fadeOut('fast', function(){jQuery(this).remove()});
 
 
 
 
 
68
  jQuery('#cupp_upload_meta, #cupp_upload_edit_meta, #cupp_meta').val('');
69
  });
70
 
35
  jQuery('#cupp_meta').val('');
36
  jQuery('#cupp_upload_meta').val(attachment.url);
37
  jQuery('#cupp_upload_edit_meta').val('/wp-admin/post.php?post='+attachment.id+'&action=edit&image-editor');
38
+ jQuery('.cupp-current-img').attr('src', attachment.url).removeClass('placeholder');
39
  });
40
 
41
  // Finally, open the modal
55
  }
56
 
57
  });
58
+
59
+ if ( '' !== jQuery('#cupp_meta').val() ) {
60
+ jQuery('#external_option').attr('checked', 'checked');
61
+ jQuery('#cupp_external').show();
62
+ jQuery('#cupp_upload').hide();
63
+ } else {
64
+ jQuery('#upload_option').attr('checked', 'checked');
65
+ }
66
+
67
+ // Update hidden field meta when external option url is entered
68
+ jQuery('#cupp_meta').blur(function(event) {
69
+ if( '' !== $(this).val() ) {
70
+ jQuery('#cupp_upload_meta').val('');
71
+ jQuery('.cupp-current-img').attr('src', $(this).val()).removeClass('placeholder');
72
+ }
73
+ });
74
 
75
  // Remove Image Function
76
  jQuery('.edit_options').hover(function(){
80
  });
81
 
82
  jQuery('.remove_img').on('click', function( event ){
83
+ var placeholder = jQuery('#cupp_placeholder_meta').val();
84
+
85
+ jQuery(this).parent().fadeOut('fast', function(){
86
+ jQuery(this).remove();
87
+ jQuery('.cupp-current-img').addClass('placeholder').attr('src', placeholder);
88
+ });
89
  jQuery('#cupp_upload_meta, #cupp_upload_edit_meta, #cupp_meta').val('');
90
  });
91
 
languages/custom-user-profile-photo-nl_NL.mo ADDED
Binary file
languages/custom-user-profile-photo-nl_NL.po ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Custom User Profile Photo\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: Thu Jan 22 2015 15:00:48 GMT+0100 (CET)\n"
6
+ "PO-Revision-Date: Thu Jan 22 2015 15:14:05 GMT+0100 (CET)\n"
7
+ "Last-Translator: prcadmin <im@olaflederer.com>\n"
8
+ "Language-Team: \n"
9
+ "Language: Dutch\n"
10
+ "Plural-Forms: nplurals=2; plural=n != 1\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SearchPath-0: ../../plugins/custom-user-profile-photo\n"
17
+ "X-Poedit-KeywordsList: _:1;gettext:1;dgettext:2;ngettext:1,2;dngettext:2,3;"
18
+ "__:1;_e:1;_c:1;_n:1,2;_n_noop:1,2;_nc:1,2;__ngettext:1,2;__ngettext_noop:1,2;"
19
+ "_x:1,2c;_ex:1,2c;_nx:1,2,4c;_nx_noop:1,2,3c;_n_js:1,2;_nx_js:1,2,3c;"
20
+ "esc_attr__:1;esc_html__:1;esc_attr_e:1;esc_html_e:1;esc_attr_x:1,2c;"
21
+ "esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
22
+ "X-Loco-Target-Locale: nl_NL\n"
23
+ "X-Generator: Loco - https://localise.biz/"
24
+
25
+ #: ../3five_cupp.php:80 ../3five_cupp.php:114
26
+ msgid "Upload New Image"
27
+ msgstr "Upload een nieuwe foto"
28
+
29
+ #: ../3five_cupp.php:83
30
+ msgid "Change Current Image"
31
+ msgstr "Wijzig huidig foto"
32
+
33
+ #: ../3five_cupp.php:88
34
+ msgid "Custom User Profile Photo"
35
+ msgstr "Kies/upload je foto."
36
+
37
+ #: ../3five_cupp.php:93
38
+ msgid "Profile Photo"
39
+ msgstr "Profiel foto"
40
+
41
+ #: ../3five_cupp.php:100 ../3five_cupp.php:106
42
+ msgid "Remove"
43
+ msgstr "Verwijderen"
44
+
45
+ #: ../3five_cupp.php:101
46
+ msgid "Edit"
47
+ msgstr "Wijzigen"
48
+
49
+ #: ../3five_cupp.php:116
50
+ msgid "Use External URL"
51
+ msgstr "Gebruik foto link/URL"
52
+
53
+ #: ../3five_cupp.php:130
54
+ msgid ""
55
+ "Upload a custom photo for your user profile or use a URL to a pre-existing "
56
+ "photo."
57
+ msgstr "Upload een nieuw foto of kies er een foto uit de media bibliotheek."
58
+
59
+ #: ../3five_cupp.php:131
60
+ msgid "Update Profile to save your changes."
61
+ msgstr "Klik \"Profiel bijwerken\" om de wijziging te bevestigen."
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: 3five, VincentListrani
3
  Donate link:
4
  Tags: custom profile photo, user profile, profile photo, user profile photo
5
  Requires at least: 3.6.1
6
- Tested up to: 3.9
7
- Stable tag: 0.2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -73,6 +73,15 @@ Currently, only a user with admin privileges can manage this option.
73
 
74
  == Changelog ==
75
 
 
 
 
 
 
 
 
 
 
76
  = 0.2.4 =
77
  * Tested with WordPress v3.8
78
  * Updated description text. Better explanation of how to quickly use this plugin.
@@ -82,5 +91,8 @@ Currently, only a user with admin privileges can manage this option.
82
 
83
  == Upgrade Notice ==
84
 
 
 
 
85
  = 0.2.3 =
86
  Beta Release
3
  Donate link:
4
  Tags: custom profile photo, user profile, profile photo, user profile photo
5
  Requires at least: 3.6.1
6
+ Tested up to: 4.1
7
+ Stable tag: 0.2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
73
 
74
  == Changelog ==
75
 
76
+ = 0.2.5 =
77
+ * Tested with WordPress v4.1
78
+ * Fixed a bug where the external URL option would not return the URL with get_cupp_meta().
79
+ * Fixed a bug where the saved image did not correspond to the selected radio button.
80
+ * Replaced depricated update_usermeta with update_user_meta.
81
+ * Improved image selection functionality.
82
+ * Images now show immediately after selecting an uploaded item or entering an external URL.
83
+ * Added Dutch translation - Thanks Olaf Lederer
84
+
85
  = 0.2.4 =
86
  * Tested with WordPress v3.8
87
  * Updated description text. Better explanation of how to quickly use this plugin.
91
 
92
  == Upgrade Notice ==
93
 
94
+ = 0.2.5 =
95
+ Bug Fixes and minor improvements.
96
+
97
  = 0.2.3 =
98
  Beta Release