updated plugin Simple Local Avatars version 2.7.1

This commit is contained in:
2022-12-19 23:08:22 +00:00
committed by Gitium
parent 7b2202370c
commit db68484a59
3 changed files with 44 additions and 13 deletions

View File

@ -100,6 +100,7 @@ class Simple_Local_Avatars {
*/
public function add_hooks() {
global $pagenow;
global $wp_version;
add_filter( 'plugin_action_links_' . SLA_PLUGIN_BASENAME, array( $this, 'plugin_filter_action_links' ) );
@ -133,7 +134,11 @@ class Simple_Local_Avatars {
add_action( 'wp_ajax_sla_clear_user_cache', array( $this, 'sla_clear_user_cache' ) );
add_filter( 'avatar_defaults', array( $this, 'add_avatar_default_field' ) );
add_action( 'wpmu_new_blog', array( $this, 'set_defaults' ) );
if ( version_compare( $wp_version, '5.1', '<' ) ) {
add_action( 'wpmu_new_blog', array( $this, 'set_defaults' ) );
} else {
add_action( 'wp_initialize_site', array( $this, 'set_defaults' ) );
}
if ( 'profile.php' === $pagenow ) {
add_filter( 'media_view_strings', function ( $strings ) {
@ -142,6 +147,13 @@ class Simple_Local_Avatars {
return $strings;
}, 10, 1 );
}
// Fix: An error occurred cropping the image (https://github.com/10up/simple-local-avatars/issues/141).
if ( isset( $_POST['action'] ) && 'crop-image' === $_POST['action'] && is_admin() && wp_doing_ajax() ) {
add_action( 'plugins_loaded', function () {
remove_all_actions( 'setup_theme' );
} );
}
}
/**
@ -1233,13 +1245,17 @@ class Simple_Local_Avatars {
/**
* Set plugin defaults for a new site
*
* @param int $blog_id Blog ID.
* @param int|WP_Site $blog_id Blog ID or object.
*/
public function set_defaults( $blog_id ) {
if ( 'enforce' === $this->get_network_mode() ) {
return;
}
if ( $blog_id instanceof WP_Site ) {
$blog_id = (int) $blog_id->blog_id;
}
switch_to_blog( $blog_id );
update_option( 'simple_local_avatars', $this->sanitize_options( $this->options ) );
restore_current_blog();