| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Events; |
| 4 |
|
| 5 |
use FluentCart\Api\StoreSettings; |
| 6 |
use FluentCart\App\Listeners\FirstTimePluginActivation as FirstTimeEvents; |
| 7 |
|
| 8 |
class FirstTimePluginActivation extends EventDispatcher |
| 9 |
{ |
| 10 |
protected array $listeners = [ |
| 11 |
//FirstTimeEvents\CreatePages::class, |
| 12 |
FirstTimeEvents\ManagePayments::class, |
| 13 |
FirstTimeEvents\SetupStore::class |
| 14 |
]; |
| 15 |
public StoreSettings $storeSettings; |
| 16 |
|
| 17 |
public function __construct() |
| 18 |
{ |
| 19 |
$this->storeSettings = new StoreSettings(); |
| 20 |
} |
| 21 |
|
| 22 |
public function toArray(): array |
| 23 |
{ |
| 24 |
return [ |
| 25 |
'settings' => $this->storeSettings->toArray() |
| 26 |
]; |
| 27 |
} |
| 28 |
|
| 29 |
public function getActivityEventModel() |
| 30 |
{ |
| 31 |
return null; |
| 32 |
} |
| 33 |
|
| 34 |
public function shouldCreateActivity(): bool |
| 35 |
{ |
| 36 |
return false; |
| 37 |
} |
| 38 |
|
| 39 |
public static function handle() |
| 40 |
{ |
| 41 |
if (get_option('fluent_cart_do_activation_redirect', false)) { |
| 42 |
delete_option('fluent_cart_do_activation_redirect'); |
| 43 |
if (get_option('fluent_cart_plugin_once_activated') !== '1') { |
| 44 |
update_option('fluent_cart_plugin_once_activated', true); |
| 45 |
(new static())->dispatch(); |
| 46 |
wp_redirect(admin_url('admin.php?page=fluent-cart#/onboarding')); |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
|