PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.4
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 19.0 All 129 releases
wordpress-seo / src / alerts / user-interface / default-seo-data / default-seo-data-cron-scheduler.php

default-seo-data-cron-scheduler.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.4, at src/alerts/user-interface/default-seo-data/default-seo-data-cron-scheduler.php

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Alerts\User_Interface\Default_Seo_Data;
5
6 use Yoast\WP\SEO\Conditionals\No_Conditionals;
7 use Yoast\WP\SEO\Integrations\Integration_Interface;
8
9 /**
10 * Responsible for scheduling and unscheduling the cron.
11 */
12 class Default_SEO_Data_Cron_Scheduler implements Integration_Interface {
13
14 use No_Conditionals;
15
16 /**
17 * The name of the cron job.
18 */
19 public const CRON_HOOK = 'wpseo_detect_default_seo_data';
20
21 /**
22 * Register hooks.
23 *
24 * @return void
25 */
26 public function register_hooks() {
27 \add_action( 'admin_init', [ $this, 'schedule_default_seo_data_detection' ] );
28 \add_action( 'wpseo_deactivate', [ $this, 'unschedule_default_seo_data_detection' ] );
29 }
30
31 /**
32 * Schedules the default SEO data detection cron.
33 *
34 * @return void
35 */
36 public function schedule_default_seo_data_detection(): void {
37 if ( ! \wp_next_scheduled( self::CRON_HOOK ) ) {
38 \wp_schedule_event( ( \time() + \DAY_IN_SECONDS ), 'daily', self::CRON_HOOK );
39 }
40 }
41
42 /**
43 * Unschedules the default SEO data detection cron.
44 *
45 * @return void
46 */
47 public function unschedule_default_seo_data_detection() {
48 $scheduled = \wp_next_scheduled( self::CRON_HOOK );
49 if ( $scheduled ) {
50 \wp_unschedule_event( $scheduled, self::CRON_HOOK );
51 }
52 }
53 }
54