updated plugin Simple Local Avatars version 2.6.0

This commit is contained in:
KawaiiPunk 2022-10-05 15:57:36 +00:00 committed by Gitium
parent 9314f5c0b8
commit 15c71c7c0f
3 changed files with 62 additions and 12 deletions

View File

@ -426,17 +426,36 @@ class Simple_Local_Avatars {
public function get_simple_local_avatar_alt( $id_or_email ) { public function get_simple_local_avatar_alt( $id_or_email ) {
$user_id = $this->get_user_id( $id_or_email ); $user_id = $this->get_user_id( $id_or_email );
/**
* Filter the default avatar alt text.
*
* @param string $alt Default alt text.
* @return string
*/
$default_alt = apply_filters( 'simple_local_avatars_default_alt', __( 'Avatar photo', 'simple-local-avatars' ) );
if ( empty( $user_id ) ) { if ( empty( $user_id ) ) {
return ''; return $default_alt;
} }
// Fetch local avatar from meta and make sure we have a media ID. // Fetch local avatar from meta and make sure we have a media ID.
$local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true ); $local_avatars = get_user_meta( $user_id, 'simple_local_avatar', true );
if ( empty( $local_avatars['media_id'] ) ) { if ( empty( $local_avatars['media_id'] ) ) {
return ''; $alt = '';
// If no avatar is set, check if we are using a default avatar with alt text.
if ( 'simple_local_avatar' === get_option( 'avatar_default' ) ) {
$default_avatar_id = get_option( 'simple_local_avatar_default', '' );
if ( ! empty( $default_avatar_id ) ) {
$alt = get_post_meta( $default_avatar_id, '_wp_attachment_image_alt', true );
}
}
return $alt ? $alt : $default_alt;
} }
return esc_attr( get_post_meta( $local_avatars['media_id'], '_wp_attachment_image_alt', true ) ); $alt = get_post_meta( $local_avatars['media_id'], '_wp_attachment_image_alt', true );
return $alt ? $alt : $default_alt;
} }
/** /**
@ -934,6 +953,15 @@ class Simple_Local_Avatars {
$meta_value['blog_id'] = get_current_blog_id(); $meta_value['blog_id'] = get_current_blog_id();
update_user_meta( $user_id, $this->user_key, $meta_value ); // save user information (overwriting old). update_user_meta( $user_id, $this->user_key, $meta_value ); // save user information (overwriting old).
/**
* Enable themes and other plugins to react to changes to a user's avatar.
*
* @since 2.6.0
*
* @param int $user_id Id of the user who's avatar was updated
*/
do_action( 'simple_local_avatar_updated' , $user_id );
} }
/** /**
@ -1036,6 +1064,15 @@ class Simple_Local_Avatars {
$this->avatar_delete( $user_id ); // delete old images if successful $this->avatar_delete( $user_id ); // delete old images if successful
/**
* Enable themes and other plugins to react to avatar deletions.
*
* @since 2.6.0
*
* @param int $user_id Id of the user who's avatar was deleted.
*/
do_action( 'simple_local_avatar_deleted', $user_id );
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
echo wp_kses_post( get_simple_local_avatar( $user_id ) ); echo wp_kses_post( get_simple_local_avatar( $user_id ) );
} }

View File

@ -2,10 +2,10 @@
Contributors: jakemgold, 10up, thinkoomph, jeffpaul, faisal03 Contributors: jakemgold, 10up, thinkoomph, jeffpaul, faisal03
Donate link: https://10up.com/plugins/simple-local-avatars-wordpress/ Donate link: https://10up.com/plugins/simple-local-avatars-wordpress/
Tags: avatar, gravatar, user photos, users, profile Tags: avatar, gravatar, user photos, users, profile
Requires at least: 4.6 Requires at least: 5.7
Tested up to: 6.0 Tested up to: 6.0
Requires PHP: 5.6 Requires PHP: 7.4
Stable tag: 2.5.0 Stable tag: 2.6.0
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -21,7 +21,7 @@ Just edit a user profile, and scroll down to the new "Avatar" field. The plug-in
1. Has a simple, native interface 1. Has a simple, native interface
1. Fully supports Gravatar and default avatars if no local avatar is set for the user - but also allows you turn off Gravatar 1. Fully supports Gravatar and default avatars if no local avatar is set for the user - but also allows you turn off Gravatar
1. Generates the requested avatar size on demand (and stores the new size for efficiency), so it looks great, just like Gravatar! 1. Generates the requested avatar size on demand (and stores the new size for efficiency), so it looks great, just like Gravatar!
1. Let's you decide whether lower privilege users (subscribers, contributors) can upload their own avatar 1. Lets you decide whether lower privilege users (subscribers, contributors) can upload their own avatar
1. Enables rating of local avatars, just like Gravatar 1. Enables rating of local avatars, just like Gravatar
== Installation == == Installation ==
@ -41,6 +41,16 @@ You can also use `get_simple_local_avatar()` (with the same arguments) to retrei
== Changelog == == Changelog ==
= 2.6.0 - 2022-09-13 =
**Note that this release bumps the minimum required version of WordPress from 4.6 to 5.7 and PHP from 5.6 to 7.4.**
* **Added:** If a default avatar image is used, ensure that outputs alt text. This will either be default text (Avatar photo) or the alt text from the uploaded default image (props [@dkotter](https://github.com/dkotter), [@faisal-alvi](https://github.com/faisal-alvi) via [#147](https://github.com/10up/simple-local-avatars/pull/147))
* **Added:** Two hooks, `simple_local_avatar_updated` and `simple_local_avatar_deleted`, (props [@t-lock](https://github.com/t-lock), [@faisal-alvi](https://github.com/faisal-alvi), [@dkotter](https://github.com/dkotter) via [#149](https://github.com/10up/simple-local-avatars/pull/149))
* **Changed:** Bump minimum required version of WordPress from 4.6 to 5.7 (props [@vikrampm1](https://github.com/vikrampm1), [@faisal-alvi](https://github.com/faisal-alvi), [@cadic](https://github.com/cadic) via [#143](https://github.com/10up/simple-local-avatars/pull/143)).
* **Changed:** Bump minimum required version of PHP from 5.6 to 7.4 (props [@vikrampm1](https://github.com/vikrampm1), [@faisal-alvi](https://github.com/faisal-alvi), [@cadic](https://github.com/cadic) via [#143](https://github.com/10up/simple-local-avatars/pull/143)).
* **Changed:**The plugin is now available via Composer without any additional steps required (props [@faisal-alvi](https://github.com/faisal-alvi), [@kovshenin](https://github.com/kovshenin), [@jeffpaul](https://github.com/jeffpaul) via [#145](https://github.com/10up/simple-local-avatars/pull/145))
* **Security:** Bump `terser` from 5.14.1 to 5.14.2 (props [@dependabot](https://github.com/dependabot), [@faisal-alvi](https://github.com/faisal-alvi) via [#142](https://github.com/10up/simple-local-avatars/pull/142))
= 2.5.0 - 2022-06-24 = = 2.5.0 - 2022-06-24 =
* **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))! * **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))!
* **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)). * **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)).
@ -163,6 +173,9 @@ You can also use `get_simple_local_avatar()` (with the same arguments) to retrei
== Upgrade Notice == == Upgrade Notice ==
= 2.6.0 =
**Note that this release bumps the minimum required version of WordPress from 4.6 to 5.7 and PHP from 5.6 to 7.4.**
= 2.1 = = 2.1 =
*Important note:* All avatar uploads now go into the media library. Don't worry - users without the ability to upload files cannot otherwise see the contents of your media library. This allows local avatars to respect other functionality your site may have around uploaded images, such as external hosting. *Important note:* All avatar uploads now go into the media library. Don't worry - users without the ability to upload files cannot otherwise see the contents of your media library. This allows local avatars to respect other functionality your site may have around uploaded images, such as external hosting.

View File

@ -3,9 +3,9 @@
* Plugin Name: Simple Local Avatars * Plugin Name: Simple Local Avatars
* Plugin URI: https://10up.com/plugins/simple-local-avatars-wordpress/ * Plugin URI: https://10up.com/plugins/simple-local-avatars-wordpress/
* Description: Adds an avatar upload field to user profiles. Generates requested sizes on demand, just like Gravatar! Simple and lightweight. * Description: Adds an avatar upload field to user profiles. Generates requested sizes on demand, just like Gravatar! Simple and lightweight.
* Version: 2.5.0 * Version: 2.6.0
* Requires at least: 4.6 * Requires at least: 5.7
* Requires PHP: 5.6 * Requires PHP: 7.4
* Author: Jake Goldman, 10up * Author: Jake Goldman, 10up
* Author URI: https://10up.com * Author URI: https://10up.com
* License: GPLv2 or later * License: GPLv2 or later
@ -20,7 +20,7 @@ define( 'SLA_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
require_once dirname( __FILE__ ) . '/includes/class-simple-local-avatars.php'; require_once dirname( __FILE__ ) . '/includes/class-simple-local-avatars.php';
// Global constants. // Global constants.
define( 'SLA_VERSION', '2.5.0' ); define( 'SLA_VERSION', '2.6.0' );
define( 'SLA_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SLA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
if ( ! defined( 'SLA_IS_NETWORK' ) ) { if ( ! defined( 'SLA_IS_NETWORK' ) ) {