• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 7165018257

11 Dec 2023 08:52AM UTC coverage: 49.48%. First build
7165018257

Pull #20470

github

thijsoo
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into feature/cron-indexation-verification
Pull Request #20470: Introduces indexables verification cron

241 of 371 new or added lines in 25 files covered. (64.96%)

15614 of 31556 relevant lines covered (49.48%)

4.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/src/indexables/application/verification-cron-schedule-handler.php
1
<?php
2

3
namespace Yoast\WP\SEO\Indexables\Application;
4

5
use Yoast\WP\SEO\Helpers\Options_Helper;
6

7
/**
8
 * The Verification_Cron_Schedule_Handler class.
9
 */
10
class Verification_Cron_Schedule_Handler {
11

12
        /**
13
         * The name of the cron job.
14
         */
15
        public const INDEXABLE_VERIFY_POST_INDEXABLES_NAME = 'wpseo_indexable_verify_post_indexables';
16

17
        /**
18
         * The name of the cron job.
19
         */
20
        public const INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME = 'wpseo_indexable_verify_non_timestamped_indexables';
21

22
        /**
23
         * The Cron_Verification_Gate instance.
24
         *
25
         * @var Cron_Verification_Gate
26
         */
27
        private $cron_verification_gate;
28

29
        /**
30
         * The Options_Helper instance.
31
         *
32
         * @var Options_Helper
33
         */
34
        private $options_helper;
35

36
        /**
37
         * The constructor.
38
         *
39
         * @param Cron_Verification_Gate $cron_verification_gate The cron verification gate.
40
         * @param Options_Helper         $options_helper         The options helper.
41
         */
42
        public function __construct( Cron_Verification_Gate $cron_verification_gate, Options_Helper $options_helper ) {
10✔
43
                $this->cron_verification_gate = $cron_verification_gate;
10✔
44
                $this->options_helper         = $options_helper;
10✔
45
        }
5✔
46

47
        /**
48
         * Schedules the indexable verification crons.
49
         *
50
         * @return void
51
         */
52
        public function schedule_indexable_verification(): void {
10✔
53
                if ( $this->options_helper->get( 'activation_redirect_timestamp_free', 0 ) === 0 ) {
10✔
NEW
54
                        return;
×
55
                }
56

57
                if ( $this->cron_verification_gate->should_verify_on_cron() && ! \wp_next_scheduled( self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME ) ) {
10✔
58
                        \wp_schedule_event( ( \time() + \HOUR_IN_SECONDS ), 'fifteen_minutes', self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME );
2✔
59
                }
60

61
                if ( $this->cron_verification_gate->should_verify_on_cron() && ! \wp_next_scheduled( self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME ) ) {
10✔
62
                        \wp_schedule_event( ( \time() + \HOUR_IN_SECONDS ), 'fifteen_minutes', self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME );
4✔
63
                }
64
        }
5✔
65

66
        /**
67
         * Unschedules the indexable post verification cron.
68
         *
69
         * @return void
70
         */
71
        public function unschedule_verify_post_indexables_cron() {
4✔
72
                $scheduled = \wp_next_scheduled( self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME );
4✔
73
                if ( $scheduled ) {
4✔
74
                        \wp_unschedule_event( $scheduled, self::INDEXABLE_VERIFY_POST_INDEXABLES_NAME );
2✔
75
                }
76
        }
2✔
77

78
        /**
79
         * Unschedules the non timestamped cron.
80
         *
81
         * @return void
82
         */
83
        public function unschedule_verify_non_timestamped_indexables_cron() {
4✔
84
                $scheduled = \wp_next_scheduled( self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME );
4✔
85
                if ( $scheduled ) {
4✔
86
                        \wp_unschedule_event( $scheduled, self::INDEXABLE_VERIFY_NON_TIMESTAMPED_INDEXABLES_NAME );
2✔
87
                }
88
        }
2✔
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc