| 1 |
<?php |
| 2 |
|
| 3 |
namespace Booktics\Onboard; |
| 4 |
|
| 5 |
use Booktics\Contracts\Hookable_Service_Contract; |
| 6 |
|
| 7 |
/** |
| 8 |
* Handles initialization of onboarding process for first-time plugin installation |
| 9 |
* |
| 10 |
* @package Booktics/Onboard |
| 11 |
*/ |
| 12 |
class Init_Onboard implements Hookable_Service_Contract { |
| 13 |
|
| 14 |
/** |
| 15 |
* Register admin init action |
| 16 |
* |
| 17 |
* @return void |
| 18 |
*/ |
| 19 |
public function register() { |
| 20 |
add_action( 'admin_init', array( $this, 'init' ) ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Initializes onboarding process by checking if plugin is installed |
| 25 |
* If not installed, sets installation flag and redirects to onboarding page |
| 26 |
* |
| 27 |
* @return void |
| 28 |
*/ |
| 29 |
public function init() { |
| 30 |
$is_installed = get_option( 'booktics_is_installed', false ); |
| 31 |
if ( ! $is_installed ) { |
| 32 |
update_option( 'booktics_is_installed', true ); |
| 33 |
wp_redirect( admin_url( 'admin.php?page=booktics#/onboard' ) ); |
| 34 |
exit(); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
|