Skip to content

Commit

Permalink
Activate plugins silently.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Nov 3, 2024
1 parent 81f790f commit c74baae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
19 changes: 4 additions & 15 deletions src/php/Settings/Integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c74baae

Please sign in to comment.