| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Llms_Txt\User_Interface; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\No_Conditionals; |
| 6 |
use Yoast\WP\SEO\Helpers\Options_Helper; |
| 7 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 8 |
use Yoast\WP\SEO\Llms_Txt\Application\File\Llms_Txt_Cron_Scheduler; |
| 9 |
|
| 10 |
/** |
| 11 |
* Handles the cron when the plugin is activated. |
| 12 |
*/ |
| 13 |
class Schedule_Population_On_Activation_Integration implements Integration_Interface { |
| 14 |
|
| 15 |
use No_Conditionals; |
| 16 |
|
| 17 |
/** |
| 18 |
* The options helper. |
| 19 |
* |
| 20 |
* @var Options_Helper $options_helper |
| 21 |
*/ |
| 22 |
private $options_helper; |
| 23 |
|
| 24 |
/** |
| 25 |
* The scheduler. |
| 26 |
* |
| 27 |
* @var Llms_Txt_Cron_Scheduler $scheduler |
| 28 |
*/ |
| 29 |
private $scheduler; |
| 30 |
|
| 31 |
/** |
| 32 |
* The constructor. |
| 33 |
* |
| 34 |
* @param Llms_Txt_Cron_Scheduler $scheduler The cron scheduler. |
| 35 |
* @param Options_Helper $options_helper The options helper. |
| 36 |
*/ |
| 37 |
public function __construct( |
| 38 |
Llms_Txt_Cron_Scheduler $scheduler, |
| 39 |
Options_Helper $options_helper |
| 40 |
) { |
| 41 |
$this->scheduler = $scheduler; |
| 42 |
$this->options_helper = $options_helper; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Registers the scheduling of the cron to the activation action. |
| 47 |
* |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
public function register_hooks() { |
| 51 |
\add_action( 'wpseo_activate', [ $this, 'schedule_llms_txt_population' ] ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Schedules the cron if the option is turned on. |
| 56 |
* |
| 57 |
* @return void |
| 58 |
*/ |
| 59 |
public function schedule_llms_txt_population() { |
| 60 |
if ( $this->options_helper->get( 'enable_llms_txt', false ) === true ) { |
| 61 |
$this->scheduler->schedule_quick_llms_txt_population(); |
| 62 |
} |
| 63 |
} |
| 64 |
} |
| 65 |
|