From c74baae5f78787163e2f488fa4827aa156a84eab Mon Sep 17 00:00:00 2001 From: kagg-design Date: Sun, 3 Nov 2024 13:30:36 +0200 Subject: [PATCH] Activate plugins silently. --- readme.txt | 1 + src/php/Settings/Integrations.php | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/readme.txt b/readme.txt index eb295409..b4140932 100644 --- a/readme.txt +++ b/readme.txt @@ -583,6 +583,7 @@ Instructions for popular native integrations are below: * Fixed showing hCaptcha in Elementor admin in some cases. * Fixed inability to sort by Source column on Forms and Events admin pages. * Fixed inability to deactivate Divi theme right after activation. +* Fixed error on plugin activation when plugin makes redirect on activation. * Tested with WordPress 6.7. * Tested with WooCommerce 9.3. diff --git a/src/php/Settings/Integrations.php b/src/php/Settings/Integrations.php index 6a82919f..ecdc663d 100644 --- a/src/php/Settings/Integrations.php +++ b/src/php/Settings/Integrations.php @@ -143,16 +143,6 @@ protected function init_hooks(): void { add_action( 'after_switch_theme', [ $this, 'after_switch_theme_action' ], 0 ); } - /** - * Activated plugin action. - * Do not allow redirect during plugin activation. - * - * @return void - */ - public function activated_plugin_action(): void { - remove_action( 'activated_plugin', 'Brizy_Admin_GettingStarted::redirectAfterActivation' ); - } - /** * After switch theme action. * Do not allow redirect during Divi theme activation. @@ -1115,12 +1105,10 @@ protected function activate_plugin( string $plugin ) { return true; } - // Do not allow redirect during plugin activation. - add_action( 'activated_plugin', [ $this, 'activated_plugin_action' ], PHP_INT_MIN ); - ob_start(); - // Null on success, WP_Error on failure. - $result = activate_plugin( $plugin ); + // Activate plugins silently to avoid redirects. + // Result is null on success, WP_Error on failure. + $result = activate_plugin( $plugin, '', false, true ); ob_end_clean(); return $result; @@ -1331,6 +1319,7 @@ static function ( $theme ) { * Get default theme. * * @return string + * @noinspection PhpVoidFunctionResultUsedInspection */ public function get_default_theme(): string { $core_default_theme_obj = WP_Theme::get_core_default_theme();