Version Description
- 2022-06-24 =
- Added: Skip cropping button (props @dkotter, @faisal-alvi, @cadic, @jeffpaul, @dinhtungdu via #130)!
- Added: Updated the button name from "Skip Crop" to "Default Crop" only on the edit profile page (props @faisal-alvi, @peterwilsoncc via #136).
- Added: If an image used for a local avatar has alt text assigned, ensure that alt text is used when rendering the image (props @dkotter, @pixelloop, @faisal-alvi via #127).
- Added: Support for bbPress by loading the JS at FE on the profile edit page (props @foliovision, @faisal-alvi, @iamdharmesh via #134).
- Added: Cypress E2E tests (props @faisal-alvi, @vikrampm1, @Sidsector9 via #115).
- Fixed: Broken avatar URLs for network-configured shared avatars with non-standard thumbnail sizes (props @vladolaru, @faisal-alvi via #125).
-
Fixed:
HTTP_REFERER
is null and causing PHP warning (props @alireza-salehi, @faisal-alvi, @peterwilsoncc via #129).
Download this release
Release Info
Developer | 10up |
Plugin | Simple Local Avatars |
Version | 2.5.0 |
Comparing to | |
See all releases |
Code changes from version 2.4.0 to 2.5.0
- dist/simple-local-avatars.asset.php +1 -1
- dist/simple-local-avatars.js +1 -1
- includes/class-simple-local-avatars.php +100 -12
- readme.txt +17 -8
- simple-local-avatars.php +2 -2
dist/simple-local-avatars.asset.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php return array('dependencies' => array(), 'version' => '
|
1 |
+
<?php return array('dependencies' => array(), 'version' => 'fdc7a56cb4a6a7999938');
|
dist/simple-local-avatars.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
(()=>{let a,e,t,r,i,l,s,o,n,c=!1;function m(a){void 0===e&&(t=document.getElementById("simple-local-avatar-ratings"),e=jQuery(document.getElementById("simple-local-avatar-spinner")),r=document.getElementById("simple-local-avatar-photo"),i=jQuery(t).closest("form").find("input[type=submit]")),"unlock"===a?(c=!1,i.removeAttr("disabled"),e.hide()):(c=!0,i.attr("disabled","disabled"),e.show())}function p(a,e){const t=e.get("control"),r=a.get("width"),i=a.get("height");let l=parseInt(t.params.width,10),s=parseInt(t.params.height,10);const o=l/s;e.set("canSkipCrop",!0);const n=l,c=s;r/i>o?(s=i,l=s*o):(l=r,s=l/o);const m=(r-l)/2,p=(i-s)/2;return{handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:r,imageHeight:i,minWidth:n>l?l:n,minHeight:c>s?s:c,x1:m,y1:p,x2:l+m,y2:s+p,aspectRatio:`${l}:${s}`}}function d(a,e,i,l){const s={};s.url=a,s.thumbnail_url=a,s.timestamp=_.now(),e&&(s.attachment_id=e),i&&(s.width=i),l&&(s.height=l),m("lock"),jQuery.post(i10n_SimpleLocalAvatars.ajaxurl,{action:"assign_simple_local_avatar_media",media_id:e,user_id:i10n_SimpleLocalAvatars.user_id,_wpnonce:i10n_SimpleLocalAvatars.mediaNonce}).done((function(a){""!==a&&(r.innerHTML=a,jQuery("#simple-local-avatar-remove").show(),t.disabled=!1)})).always((function(){m("unlock")}))}jQuery(document).ready((function(e){s=e("#simple-local-avatar"),l=e("#simple-local-avatar-photo img"),n=l.attr("src"),t=e("#simple-local-avatar-ratings"),r=e("#simple-local-avatar-photo"),e("#simple-local-avatar-media").on("click",(function(e){if(e.preventDefault(),c)return;const i={id:"control-id",params:{flex_width:!0,flex_height:!0,width:200,height:200}};a=wp.media({button:{text:i10n_SimpleLocalAvatars.selectCrop,close:!1},states:[new wp.media.controller.Library({title:i10n_SimpleLocalAvatars.selectCrop,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:200,suggestedHeight:200}),new wp.media.controller.CustomizeImageCropper({imgSelectOptions:p,control:i})]}),a.on("cropped",(function(a){const{url:e}=a;d(e,a.id,a.width,a.height)})),a.on("skippedcrop",(function(a){const e=a.get("url"),t=a.get("width"),r=a.get("height");d(e,a.id,t,r)})),a.on("select",(function(){const e=a.state().get("selection").first().toJSON();var l;i.params.width!==e.width||i.params.height!==e.height||i.params.flex_width||i.params.flex_height?a.setState("cropper"):(e.dst_width=e.width,e.dst_height=e.height,l=e,m("lock"),jQuery.post(i10n_SimpleLocalAvatars.ajaxurl,{action:"assign_simple_local_avatar_media",media_id:l.id,user_id:i10n_SimpleLocalAvatars.user_id,_wpnonce:i10n_SimpleLocalAvatars.mediaNonce}).done((function(a){""!==a&&(r.innerHTML=a,jQuery("#simple-local-avatar-remove").show(),t.disabled=!1,m("unlock"))})).always((function(){m("unlock")})),a.close())})),a.open()})),e("#simple-local-avatar-remove").on("click",(function(a){a.preventDefault(),c||(m("lock"),e.get(i10n_SimpleLocalAvatars.ajaxurl,{action:"remove_simple_local_avatar",user_id:i10n_SimpleLocalAvatars.user_id,_wpnonce:i10n_SimpleLocalAvatars.deleteNonce}).done((function(a){""!==a&&(r.innerHTML=a,e("#simple-local-avatar-remove").hide(),t.disabled=!0)})).always((function(){m("unlock")})))})),s.on("change",(function(a){l.attr("srcset",""),l.attr("height","auto"),URL.revokeObjectURL(o),a.target.files.length>0?(o=URL.createObjectURL(a.target.files[0]),l.attr("src",o)):l.attr("src",n)})),e(document.getElementById("simple-local-avatars-migrate-from-wp-user-avatar")).on("click",(function(a){a.preventDefault(),jQuery.post(i10n_SimpleLocalAvatars.ajaxurl,{action:"migrate_from_wp_user_avatar",migrateFromWpUserAvatarNonce:i10n_SimpleLocalAvatars.migrateFromWpUserAvatarNonce}).always((function(){e(".simple-local-avatars-migrate-from-wp-user-avatar-progress").empty(),e(".simple-local-avatars-migrate-from-wp-user-avatar-progress").text(i10n_SimpleLocalAvatars.migrateFromWpUserAvatarProgress)})).done((function(a){e(".simple-local-avatars-migrate-from-wp-user-avatar-progress").empty();const t=e.parseJSON(a).count;0===t&&e(".simple-local-avatars-migrate-from-wp-user-avatar-progress").text(i10n_SimpleLocalAvatars.migrateFromWpUserAvatarFailure),t>0&&e(".simple-local-avatars-migrate-from-wp-user-avatar-progress").text(i10n_SimpleLocalAvatars.migrateFromWpUserAvatarSuccess+": "+t),setTimeout((function(){e(".simple-local-avatars-migrate-from-wp-user-avatar-progress").empty()}),5e3)}))}));const i=e("#clear_cache_btn"),u=e("#clear_cache_message"),v=e("#simple-local-avatar-default"),g=e("#simple-local-avatar-file-url"),h=e("#simple-local-avatar-file-id");function _(){i.find("span").remove(),i.removeClass("disabled")}function f(a,t){t.step=a,e.ajax({url:i10n_SimpleLocalAvatars.ajaxurl,dataType:"json",data:t,method:"POST",success:function(a){if(a.success)return"done"===a.data.step?(u.text(a.data.message),_()):(u.text(a.data.message),f(parseInt(a.data.step,10),t)),!1;u.text(i10n_SimpleLocalAvatars.clearCacheError),_()},error:function(){u.text(i10n_SimpleLocalAvatars.clearCacheError),_()}})}if(i.on("click",(function(a){a.preventDefault(),i.addClass("disabled"),i.append('<span class="spinner is-active" style="margin-left:5px;margin-right:0;"></span>'),f(1,{action:"sla_clear_user_cache",nonce:i10n_SimpleLocalAvatars.cacheNonce})})),v.click((function(a){a.preventDefault();var t=e(this),r=wp.media({title:i10n_SimpleLocalAvatars.insertMediaTitle,multiple:!1,library:{type:"image"}}).open().on("select",(function(a){var e=r.state().get("selection").first(),i=(e=e.toJSON())?.sizes?.thumbnail?.url;void 0===i&&(i=e.url);var l=t.parent().find("img.avatar");l.show(),l.attr("src",i),l.attr("srcset",i),g.val(i),h.val(e.id)}))})),g.length&&""!==g.val()){var w=g.parent().find("img.avatar");w.attr("src",g.val()),w.attr("srcset",g.val())}""===h.val()&&h.parent().find("img.avatar").hide()}))})();
|
includes/class-simple-local-avatars.php
CHANGED
@@ -80,7 +80,7 @@ class Simple_Local_Avatars {
|
|
80 |
&& (
|
81 |
( // And either an ajax request not in the network admin.
|
82 |
defined( 'DOING_AJAX' ) && DOING_AJAX
|
83 |
-
&& ! preg_match( '#^' . network_admin_url() . '#i', $_SERVER['HTTP_REFERER'] )
|
84 |
)
|
85 |
||
|
86 |
( // Or normal request not in the network admin.
|
@@ -99,6 +99,7 @@ class Simple_Local_Avatars {
|
|
99 |
* Register actions and filters.
|
100 |
*/
|
101 |
public function add_hooks() {
|
|
|
102 |
|
103 |
add_filter( 'plugin_action_links_' . SLA_PLUGIN_BASENAME, array( $this, 'plugin_filter_action_links' ) );
|
104 |
|
@@ -107,7 +108,10 @@ class Simple_Local_Avatars {
|
|
107 |
|
108 |
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
109 |
|
110 |
-
|
|
|
|
|
|
|
111 |
add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) );
|
112 |
add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) );
|
113 |
|
@@ -130,6 +134,14 @@ class Simple_Local_Avatars {
|
|
130 |
|
131 |
add_filter( 'avatar_defaults', array( $this, 'add_avatar_default_field' ) );
|
132 |
add_action( 'wpmu_new_blog', array( $this, 'set_defaults' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
@@ -262,21 +274,28 @@ class Simple_Local_Avatars {
|
|
262 |
|
263 |
if ( ! empty( $args['url'] ) ) {
|
264 |
$args['found_avatar'] = true;
|
|
|
|
|
|
|
|
|
|
|
265 |
}
|
266 |
|
267 |
return $args;
|
268 |
}
|
269 |
|
270 |
/**
|
271 |
-
* Get
|
272 |
*
|
273 |
-
* @since 2.
|
274 |
*
|
275 |
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
|
276 |
* user email, WP_User object, WP_Post object, or WP_Comment object.
|
277 |
-
* @
|
278 |
*/
|
279 |
-
public function
|
|
|
|
|
280 |
if ( is_numeric( $id_or_email ) ) {
|
281 |
$user_id = (int) $id_or_email;
|
282 |
} elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
|
@@ -288,6 +307,21 @@ class Simple_Local_Avatars {
|
|
288 |
$user_id = $user ? $user->ID : '';
|
289 |
}
|
290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
if ( empty( $user_id ) ) {
|
292 |
return '';
|
293 |
}
|
@@ -354,7 +388,15 @@ class Simple_Local_Avatars {
|
|
354 |
$dest_file = $editor->generate_filename();
|
355 |
$saved = $editor->save( $dest_file );
|
356 |
if ( ! is_wp_error( $saved ) ) {
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
}
|
360 |
}
|
@@ -372,6 +414,31 @@ class Simple_Local_Avatars {
|
|
372 |
return esc_url( $local_avatars[ $size ] );
|
373 |
}
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
/**
|
376 |
* Get default avatar url
|
377 |
*
|
@@ -620,7 +687,7 @@ class Simple_Local_Avatars {
|
|
620 |
*
|
621 |
* @param string $hook_suffix Page hook
|
622 |
*/
|
623 |
-
public function
|
624 |
|
625 |
/**
|
626 |
* Filter the admin screens where we enqueue our scripts.
|
@@ -631,6 +698,11 @@ class Simple_Local_Avatars {
|
|
631 |
*/
|
632 |
$screens = apply_filters( 'simple_local_avatars_admin_enqueue_scripts', array( 'profile.php', 'user-edit.php', 'options-discussion.php' ), $hook_suffix );
|
633 |
|
|
|
|
|
|
|
|
|
|
|
634 |
if ( ! in_array( $hook_suffix, $screens, true ) ) {
|
635 |
return;
|
636 |
}
|
@@ -649,6 +721,7 @@ class Simple_Local_Avatars {
|
|
649 |
'simple-local-avatars',
|
650 |
'i10n_SimpleLocalAvatars',
|
651 |
array(
|
|
|
652 |
'user_id' => $user_id,
|
653 |
'insertIntoPost' => __( 'Set as avatar', 'simple-local-avatars' ),
|
654 |
'selectCrop' => __( 'Select avatar and Crop', 'simple-local-avatars' ),
|
@@ -779,7 +852,8 @@ class Simple_Local_Avatars {
|
|
779 |
<?php
|
780 |
// if user is author and above hide the choose file option
|
781 |
// force them to use the WP Media Selector
|
782 |
-
|
|
|
783 |
?>
|
784 |
<p style="display: inline-block; width: 26em;">
|
785 |
<span class="description"><?php esc_html_e( 'Choose an image from your computer:' ); ?></span><br />
|
@@ -889,6 +963,14 @@ class Simple_Local_Avatars {
|
|
889 |
include_once ABSPATH . 'wp-admin/includes/media.php';
|
890 |
}
|
891 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
892 |
// allow developers to override file size upload limit for avatars
|
893 |
add_filter( 'upload_size_limit', array( $this, 'upload_size_limit' ) );
|
894 |
|
@@ -1248,7 +1330,13 @@ class Simple_Local_Avatars {
|
|
1248 |
*/
|
1249 |
private function clear_user_avatar_cache( $local_avatars, $user_id, $media_id ) {
|
1250 |
if ( ! empty( $media_id ) ) {
|
1251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1252 |
$file_dir_name = $file_name_data['dirname'];
|
1253 |
$file_name = $file_name_data['filename'];
|
1254 |
$file_ext = $file_name_data['extension'];
|
@@ -1306,10 +1394,10 @@ class Simple_Local_Avatars {
|
|
1306 |
update_option( 'simple_local_avatar_default', $file_id );
|
1307 |
}
|
1308 |
}
|
1309 |
-
|
1310 |
/**
|
1311 |
* Migrate the user's avatar data from WP User Avatar/ProfilePress
|
1312 |
-
*
|
1313 |
* This function creates a new option in the wp_options table to store the processed user IDs
|
1314 |
* so that we can run this command multiple times without processing the same user over and over again.
|
1315 |
*
|
80 |
&& (
|
81 |
( // And either an ajax request not in the network admin.
|
82 |
defined( 'DOING_AJAX' ) && DOING_AJAX
|
83 |
+
&& isset( $_SERVER['HTTP_REFERER'] ) && ! preg_match( '#^' . network_admin_url() . '#i', $_SERVER['HTTP_REFERER'] )
|
84 |
)
|
85 |
||
|
86 |
( // Or normal request not in the network admin.
|
99 |
* Register actions and filters.
|
100 |
*/
|
101 |
public function add_hooks() {
|
102 |
+
global $pagenow;
|
103 |
|
104 |
add_filter( 'plugin_action_links_' . SLA_PLUGIN_BASENAME, array( $this, 'plugin_filter_action_links' ) );
|
105 |
|
108 |
|
109 |
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
110 |
|
111 |
+
// Load the JS on BE & FE both, in order to support third party plugins like bbPress.
|
112 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
113 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
114 |
+
|
115 |
add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) );
|
116 |
add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) );
|
117 |
|
134 |
|
135 |
add_filter( 'avatar_defaults', array( $this, 'add_avatar_default_field' ) );
|
136 |
add_action( 'wpmu_new_blog', array( $this, 'set_defaults' ) );
|
137 |
+
|
138 |
+
if ( 'profile.php' === $pagenow ) {
|
139 |
+
add_filter( 'media_view_strings', function ( $strings ) {
|
140 |
+
$strings['skipCropping'] = esc_html__( 'Default Crop', 'simple-local-avatars' );
|
141 |
+
|
142 |
+
return $strings;
|
143 |
+
}, 10, 1 );
|
144 |
+
}
|
145 |
}
|
146 |
|
147 |
/**
|
274 |
|
275 |
if ( ! empty( $args['url'] ) ) {
|
276 |
$args['found_avatar'] = true;
|
277 |
+
|
278 |
+
// If custom alt text isn't passed, pull alt text from the local image.
|
279 |
+
if ( empty( $args['alt'] ) ) {
|
280 |
+
$args['alt'] = $this->get_simple_local_avatar_alt( $id_or_email );
|
281 |
+
}
|
282 |
}
|
283 |
|
284 |
return $args;
|
285 |
}
|
286 |
|
287 |
/**
|
288 |
+
* Get a user ID from certain possible values.
|
289 |
*
|
290 |
+
* @since 2.5.0
|
291 |
*
|
292 |
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
|
293 |
* user email, WP_User object, WP_Post object, or WP_Comment object.
|
294 |
+
* @return int|false
|
295 |
*/
|
296 |
+
public function get_user_id( $id_or_email ) {
|
297 |
+
$user_id = false;
|
298 |
+
|
299 |
if ( is_numeric( $id_or_email ) ) {
|
300 |
$user_id = (int) $id_or_email;
|
301 |
} elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
|
307 |
$user_id = $user ? $user->ID : '';
|
308 |
}
|
309 |
|
310 |
+
return $user_id;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Get local avatar url.
|
315 |
+
*
|
316 |
+
* @since 2.2.0
|
317 |
+
*
|
318 |
+
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
|
319 |
+
* user email, WP_User object, WP_Post object, or WP_Comment object.
|
320 |
+
* @param int $size Requested avatar size.
|
321 |
+
*/
|
322 |
+
public function get_simple_local_avatar_url( $id_or_email, $size ) {
|
323 |
+
$user_id = $this->get_user_id( $id_or_email );
|
324 |
+
|
325 |
if ( empty( $user_id ) ) {
|
326 |
return '';
|
327 |
}
|
388 |
$dest_file = $editor->generate_filename();
|
389 |
$saved = $editor->save( $dest_file );
|
390 |
if ( ! is_wp_error( $saved ) ) {
|
391 |
+
// Transform the destination file path into URL.
|
392 |
+
$dest_file_url = '';
|
393 |
+
if ( false !== strpos( $dest_file, $upload_path['basedir'] ) ) {
|
394 |
+
$dest_file_url = str_replace( $upload_path['basedir'], $upload_path['baseurl'], $dest_file );
|
395 |
+
} else if ( is_multisite() && false !== strpos( $dest_file, ABSPATH . 'wp-content/uploads' ) ) {
|
396 |
+
$dest_file_url = str_replace( ABSPATH . 'wp-content/uploads', network_site_url( '/wp-content/uploads' ), $dest_file );
|
397 |
+
}
|
398 |
+
|
399 |
+
$local_avatars[ $size ] = $dest_file_url;
|
400 |
}
|
401 |
}
|
402 |
}
|
414 |
return esc_url( $local_avatars[ $size ] );
|
415 |
}
|
416 |
|
417 |
+
/**
|
418 |
+
* Get local avatar alt text.
|
419 |
+
*
|
420 |
+
* @since 2.5.0
|
421 |
+
*
|
422 |
+
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
|
423 |
+
* user email, WP_User object, WP_Post object, or WP_Comment object.
|
424 |
+
* @return string
|
425 |
+
*/
|
426 |
+
public function get_simple_local_avatar_alt( $id_or_email ) {
|
427 |
+
$user_id = $this->get_user_id( $id_or_email );
|
428 |
+
|
429 |
+
if ( empty( $user_id ) ) {
|
430 |
+
return '';
|
431 |
+
}
|
432 |
+
|
433 |
+
// Fetch local avatar from meta and make sure we have a media ID.
|
434 |
+
$local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
|
435 |
+
if ( empty( $local_avatars['media_id'] ) ) {
|
436 |
+
return '';
|
437 |
+
}
|
438 |
+
|
439 |
+
return esc_attr( get_post_meta( $local_avatars['media_id'], '_wp_attachment_image_alt', true ) );
|
440 |
+
}
|
441 |
+
|
442 |
/**
|
443 |
* Get default avatar url
|
444 |
*
|
687 |
*
|
688 |
* @param string $hook_suffix Page hook
|
689 |
*/
|
690 |
+
public function enqueue_scripts( $hook_suffix ) {
|
691 |
|
692 |
/**
|
693 |
* Filter the admin screens where we enqueue our scripts.
|
698 |
*/
|
699 |
$screens = apply_filters( 'simple_local_avatars_admin_enqueue_scripts', array( 'profile.php', 'user-edit.php', 'options-discussion.php' ), $hook_suffix );
|
700 |
|
701 |
+
// Allow SLA actions on a bbPress profile edit page at FE.
|
702 |
+
if ( function_exists( 'bbp_is_user_home_edit' ) && bbp_is_user_home_edit() ) {
|
703 |
+
$hook_suffix = 'profile.php';
|
704 |
+
}
|
705 |
+
|
706 |
if ( ! in_array( $hook_suffix, $screens, true ) ) {
|
707 |
return;
|
708 |
}
|
721 |
'simple-local-avatars',
|
722 |
'i10n_SimpleLocalAvatars',
|
723 |
array(
|
724 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
725 |
'user_id' => $user_id,
|
726 |
'insertIntoPost' => __( 'Set as avatar', 'simple-local-avatars' ),
|
727 |
'selectCrop' => __( 'Select avatar and Crop', 'simple-local-avatars' ),
|
852 |
<?php
|
853 |
// if user is author and above hide the choose file option
|
854 |
// force them to use the WP Media Selector
|
855 |
+
// At FE, show the file input field regardless of the caps.
|
856 |
+
if ( ! is_admin() || ! current_user_can( 'upload_files' ) ) {
|
857 |
?>
|
858 |
<p style="display: inline-block; width: 26em;">
|
859 |
<span class="description"><?php esc_html_e( 'Choose an image from your computer:' ); ?></span><br />
|
963 |
include_once ABSPATH . 'wp-admin/includes/media.php';
|
964 |
}
|
965 |
|
966 |
+
// front end (plugin bbPress etc) support
|
967 |
+
if ( ! function_exists( 'wp_handle_upload' ) ) {
|
968 |
+
include_once ABSPATH . 'wp-admin/includes/file.php';
|
969 |
+
}
|
970 |
+
if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) {
|
971 |
+
include_once ABSPATH . 'wp-admin/includes/image.php';
|
972 |
+
}
|
973 |
+
|
974 |
// allow developers to override file size upload limit for avatars
|
975 |
add_filter( 'upload_size_limit', array( $this, 'upload_size_limit' ) );
|
976 |
|
1330 |
*/
|
1331 |
private function clear_user_avatar_cache( $local_avatars, $user_id, $media_id ) {
|
1332 |
if ( ! empty( $media_id ) ) {
|
1333 |
+
// In order to support WP 4.9.
|
1334 |
+
if ( function_exists( 'wp_get_original_image_path' ) ) {
|
1335 |
+
$file_name_data = pathinfo( wp_get_original_image_path( $media_id ) );
|
1336 |
+
} else {
|
1337 |
+
$file_name_data = pathinfo( get_attached_file( $media_id ) );
|
1338 |
+
}
|
1339 |
+
|
1340 |
$file_dir_name = $file_name_data['dirname'];
|
1341 |
$file_name = $file_name_data['filename'];
|
1342 |
$file_ext = $file_name_data['extension'];
|
1394 |
update_option( 'simple_local_avatar_default', $file_id );
|
1395 |
}
|
1396 |
}
|
1397 |
+
|
1398 |
/**
|
1399 |
* Migrate the user's avatar data from WP User Avatar/ProfilePress
|
1400 |
+
*
|
1401 |
* This function creates a new option in the wp_options table to store the processed user IDs
|
1402 |
* so that we can run this command multiple times without processing the same user over and over again.
|
1403 |
*
|
readme.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
=== Simple Local Avatars ===
|
2 |
-
Contributors:
|
3 |
-
Donate link:
|
4 |
-
Tags:
|
5 |
Requires at least: 4.6
|
6 |
-
Tested up to:
|
7 |
-
Requires PHP:
|
8 |
-
Stable tag:
|
9 |
-
License:
|
10 |
-
License URI:
|
11 |
|
12 |
Adds an avatar upload field to user profiles. Generates requested sizes on demand just like Gravatar!
|
13 |
|
@@ -41,6 +41,15 @@ You can also use `get_simple_local_avatar()` (with the same arguments) to retrei
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
= 2.4.0 - 2022-05-10 =
|
45 |
* **Added:** Ability to set a default avatar. (props [@mehulkaklotar](https://github.com/mehulkaklotar), [@jeffpaul](https://github.com/jeffpaul), [@dinhtungdu](https://github.com/dinhtungdu), [@faisal-alvi](https://github.com/faisal-alvi) via [#96](https://github.com/10up/simple-local-avatars/pull/96)).
|
46 |
* **Fixed:** Correct plugin name in changelog. (props [@grappler](https://github.com/grappler), [@jeffpaul](https://github.com/jeffpaul) via [#117](https://github.com/10up/simple-local-avatars/pull/117)).
|
1 |
=== Simple Local Avatars ===
|
2 |
+
Contributors: jakemgold, 10up, thinkoomph, jeffpaul, faisal03
|
3 |
+
Donate link: https://10up.com/plugins/simple-local-avatars-wordpress/
|
4 |
+
Tags: avatar, gravatar, user photos, users, profile
|
5 |
Requires at least: 4.6
|
6 |
+
Tested up to: 6.0
|
7 |
+
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.5.0
|
9 |
+
License: GPLv2 or later
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
Adds an avatar upload field to user profiles. Generates requested sizes on demand just like Gravatar!
|
13 |
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 2.5.0 - 2022-06-24 =
|
45 |
+
* **Added:** Skip cropping button (props [@dkotter](https://github.com/dkotter), [@faisal-alvi](https://github.com/faisal-alvi), [@cadic](https://github.com/cadic), [@jeffpaul](https://github.com/jeffpaul), [@dinhtungdu](https://github.com/dinhtungdu) via [#130](https://github.com/10up/simple-local-avatars/pull/130))!
|
46 |
+
* **Added:** Updated the button name from "Skip Crop" to "Default Crop" only on the edit profile page (props [@faisal-alvi](https://github.com/faisal-alvi), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#136](https://github.com/10up/simple-local-avatars/pull/136)).
|
47 |
+
* **Added:** If an image used for a local avatar has alt text assigned, ensure that alt text is used when rendering the image (props [@dkotter](https://github.com/dkotter), [@pixelloop](https://github.com/pixelloop), [@faisal-alvi](https://github.com/faisal-alvi) via [#127](https://github.com/10up/simple-local-avatars/pull/127)).
|
48 |
+
* **Added:** Support for bbPress by loading the JS at FE on the profile edit page (props [@foliovision](https://github.com/foliovision), [@faisal-alvi](https://github.com/faisal-alvi), [@iamdharmesh](https://github.com/iamdharmesh) via [#134](https://github.com/10up/simple-local-avatars/pull/134)).
|
49 |
+
* **Added:** Cypress E2E tests (props [@faisal-alvi](https://github.com/faisal-alvi), [@vikrampm1](https://github.com/vikrampm1), [@Sidsector9](https://github.com/Sidsector9) via [#115](https://github.com/10up/simple-local-avatars/pull/115)).
|
50 |
+
* **Fixed:** Broken avatar URLs for network-configured shared avatars with non-standard thumbnail sizes (props [@vladolaru](https://github.com/vladolaru), [@faisal-alvi](https://github.com/faisal-alvi) via [#125](https://github.com/10up/simple-local-avatars/pull/125)).
|
51 |
+
* **Fixed:** `HTTP_REFERER` is null and causing PHP warning (props [@alireza-salehi](https://github.com/alireza-salehi), [@faisal-alvi](https://github.com/faisal-alvi), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#129](https://github.com/10up/simple-local-avatars/pull/129)).
|
52 |
+
|
53 |
= 2.4.0 - 2022-05-10 =
|
54 |
* **Added:** Ability to set a default avatar. (props [@mehulkaklotar](https://github.com/mehulkaklotar), [@jeffpaul](https://github.com/jeffpaul), [@dinhtungdu](https://github.com/dinhtungdu), [@faisal-alvi](https://github.com/faisal-alvi) via [#96](https://github.com/10up/simple-local-avatars/pull/96)).
|
55 |
* **Fixed:** Correct plugin name in changelog. (props [@grappler](https://github.com/grappler), [@jeffpaul](https://github.com/jeffpaul) via [#117](https://github.com/10up/simple-local-avatars/pull/117)).
|
simple-local-avatars.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Simple Local Avatars
|
4 |
* Plugin URI: https://10up.com/plugins/simple-local-avatars-wordpress/
|
5 |
* Description: Adds an avatar upload field to user profiles. Generates requested sizes on demand, just like Gravatar! Simple and lightweight.
|
6 |
-
* Version: 2.
|
7 |
* Requires at least: 4.6
|
8 |
* Requires PHP: 5.6
|
9 |
* Author: Jake Goldman, 10up
|
@@ -20,7 +20,7 @@ define( 'SLA_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
|
20 |
require_once dirname( __FILE__ ) . '/includes/class-simple-local-avatars.php';
|
21 |
|
22 |
// Global constants.
|
23 |
-
define( 'SLA_VERSION', '2.
|
24 |
define( 'SLA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
25 |
|
26 |
if ( ! defined( 'SLA_IS_NETWORK' ) ) {
|
3 |
* Plugin Name: Simple Local Avatars
|
4 |
* Plugin URI: https://10up.com/plugins/simple-local-avatars-wordpress/
|
5 |
* Description: Adds an avatar upload field to user profiles. Generates requested sizes on demand, just like Gravatar! Simple and lightweight.
|
6 |
+
* Version: 2.5.0
|
7 |
* Requires at least: 4.6
|
8 |
* Requires PHP: 5.6
|
9 |
* Author: Jake Goldman, 10up
|
20 |
require_once dirname( __FILE__ ) . '/includes/class-simple-local-avatars.php';
|
21 |
|
22 |
// Global constants.
|
23 |
+
define( 'SLA_VERSION', '2.5.0' );
|
24 |
define( 'SLA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
25 |
|
26 |
if ( ! defined( 'SLA_IS_NETWORK' ) ) {
|