| 1 |
<?php |
| 2 |
|
| 3 |
namespace WP_Defender; |
| 4 |
|
| 5 |
use WP_Defender\Traits\Defender_Bootstrap; |
| 6 |
use WP_Defender\Component\Rate; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class Bootstrap |
| 10 |
* |
| 11 |
* @package WP_Defender |
| 12 |
*/ |
| 13 |
class Bootstrap { |
| 14 |
use Defender_Bootstrap; |
| 15 |
|
| 16 |
/** |
| 17 |
* Activation. |
| 18 |
*/ |
| 19 |
public function activation_hook(): void { |
| 20 |
$this->activation_hook_common(); |
| 21 |
$this->set_free_installation_timestamp(); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Add option with plugin install date. |
| 26 |
* |
| 27 |
* @since 2.4 |
| 28 |
*/ |
| 29 |
protected function set_free_installation_timestamp(): void { |
| 30 |
// Let's equate the plugin installation and postponed notice dates. This will simplify future checks. |
| 31 |
$install_date = (int) get_site_option( Rate::SLUG_FREE_INSTALL_DATE, 0 ); |
| 32 |
if ( 0 === $install_date ) { |
| 33 |
update_site_option( Rate::SLUG_FREE_INSTALL_DATE, time() ); |
| 34 |
update_site_option( Rate::SLUG_POSTPONED_NOTICE_DATE, time() ); |
| 35 |
} else { |
| 36 |
update_site_option( Rate::SLUG_POSTPONED_NOTICE_DATE, $install_date ); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Load all modules. |
| 42 |
*/ |
| 43 |
public function init_modules(): void { |
| 44 |
add_action( 'admin_init', array( $this, 'maybe_redirect_after_activation' ), 1 ); |
| 45 |
$this->init_modules_common(); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Deactivation clears only free version cron hooks. |
| 50 |
*/ |
| 51 |
public function deactivation_hook(): void { |
| 52 |
$this->deactivation_hook_common(); |
| 53 |
wp_clear_scheduled_hook( 'audit_clean_up_logs' ); |
| 54 |
} |
| 55 |
} |
| 56 |
|