| 1 |
<?php |
| 2 |
namespace WPFunnels\Admin\SetupWizard; |
| 3 |
|
| 4 |
/** |
| 5 |
* Activate Plugins |
| 6 |
* |
| 7 |
* @since 3.3.1 |
| 8 |
*/ |
| 9 |
class ActivatePlugin { |
| 10 |
|
| 11 |
protected $plugins = []; |
| 12 |
|
| 13 |
|
| 14 |
/** |
| 15 |
* Constructor |
| 16 |
* |
| 17 |
* @param array $plugins |
| 18 |
* @since 3.3.1 |
| 19 |
*/ |
| 20 |
public function __construct( $plugins = [] ){ |
| 21 |
$this->plugins = $plugins; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Activate plugins |
| 26 |
* |
| 27 |
* @return array |
| 28 |
* @since 3.3.1 |
| 29 |
*/ |
| 30 |
public function activate_plugins(){ |
| 31 |
|
| 32 |
if( empty($this->plugins) && !is_array($this->plugins) ){ |
| 33 |
return; |
| 34 |
} |
| 35 |
|
| 36 |
$response = [ |
| 37 |
'suceess' => true, |
| 38 |
]; |
| 39 |
foreach( $this->plugins as $key=>$plugin ){ |
| 40 |
|
| 41 |
if( !isset($plugin['name'],$plugin['status'],$plugin['path'],$plugin['type']) && ($plugin['status'] == 'activated' || $plugin['status'] == 'uninstalled') ){ |
| 42 |
continue; |
| 43 |
} |
| 44 |
|
| 45 |
if( 'bricks' === $plugin['name'] ){ |
| 46 |
if (wp_get_theme($plugin['path'])->exists()) { |
| 47 |
switch_theme($plugin['path']); |
| 48 |
} |
| 49 |
}else{ |
| 50 |
\activate_plugin( $plugin['path'] ); |
| 51 |
|
| 52 |
if( isset($plugin['slug']) ){ |
| 53 |
if( 'woocommerce' === $plugin['slug'] ){ |
| 54 |
delete_transient( '_wc_activation_redirect' ); |
| 55 |
} |
| 56 |
|
| 57 |
if( 'elementor' === $plugin['slug'] ){ |
| 58 |
update_option('elementor_onboarded',true); |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
return $response; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
?> |