PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.6
28.6 28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 All 130 releases
wordpress-seo / src / llms-txt / user-interface / cleanup-llms-txt-on-deactivation.php

cleanup-llms-txt-on-deactivation.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/llms-txt/user-interface/cleanup-llms-txt-on-deactivation.php

64 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Integrations\Integration_Interface;
7 use Yoast\WP\SEO\Llms_Txt\Application\File\Commands\Remove_File_Command_Handler;
8 use Yoast\WP\SEO\Llms_Txt\Application\File\Llms_Txt_Cron_Scheduler;
9
10 /**
11 * Trys to clean up the llms.txt file when the plugin is deactivated.
12 */
13 class Cleanup_Llms_Txt_On_Deactivation implements Integration_Interface {
14
15 use No_Conditionals;
16
17 /**
18 * The command handler.
19 *
20 * @var Remove_File_Command_Handler
21 */
22 private $command_handler;
23
24 /**
25 * The cron scheduler.
26 *
27 * @var Llms_Txt_Cron_Scheduler
28 */
29 private $cron_scheduler;
30
31 /**
32 * Constructor.
33 *
34 * @param Remove_File_Command_Handler $command_handler The command handler.
35 * @param Llms_Txt_Cron_Scheduler $cron_scheduler The scheduler.
36 */
37 public function __construct(
38 Remove_File_Command_Handler $command_handler,
39 Llms_Txt_Cron_Scheduler $cron_scheduler
40 ) {
41 $this->command_handler = $command_handler;
42 $this->cron_scheduler = $cron_scheduler;
43 }
44
45 /**
46 * Registers the unscheduling of the cron to the deactivation action.
47 *
48 * @return void
49 */
50 public function register_hooks() {
51 \add_action( 'wpseo_deactivate', [ $this, 'maybe_remove_llms_file' ] );
52 }
53
54 /**
55 * Call the command handler to remove the file.
56 *
57 * @return void
58 */
59 public function maybe_remove_llms_file(): void {
60 $this->command_handler->handle();
61 $this->cron_scheduler->unschedule_llms_txt_population();
62 }
63 }
64