From e041cfbc334810523853dcd24beaf8edb41238b5 Mon Sep 17 00:00:00 2001 From: JK Date: Thu, 22 Sep 2022 16:16:44 +0600 Subject: [PATCH 1/2] Fix: Non admin can not crop avatar --- includes/class-simple-local-avatars.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/includes/class-simple-local-avatars.php b/includes/class-simple-local-avatars.php index e5c4c5fa..b4119a85 100644 --- a/includes/class-simple-local-avatars.php +++ b/includes/class-simple-local-avatars.php @@ -142,6 +142,13 @@ public function add_hooks() { 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' ); + }); + } } /** From d4660980eb2e1de7338c9e66564e034eaf6b02e4 Mon Sep 17 00:00:00 2001 From: Faisal Alvi Date: Fri, 23 Sep 2022 22:01:05 +0530 Subject: [PATCH 2/2] minor `phpcs` warning/error fixes --- includes/class-simple-local-avatars.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/class-simple-local-avatars.php b/includes/class-simple-local-avatars.php index b4119a85..38ddd82d 100644 --- a/includes/class-simple-local-avatars.php +++ b/includes/class-simple-local-avatars.php @@ -143,11 +143,11 @@ public function add_hooks() { }, 10, 1 ); } - // Fix: An error occurred cropping the image (https://github.com/10up/simple-local-avatars/issues/141) + // 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() { + add_action( 'plugins_loaded', function () { remove_all_actions( 'setup_theme' ); - }); + } ); } }