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

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

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

0.0
/src/conditionals/admin/estimated-reading-time-conditional.php
1
<?php
2

3
namespace Yoast\WP\SEO\Conditionals\Admin;
4

5
use Yoast\WP\SEO\Conditionals\Conditional;
6

7
/**
8
 * Conditional that is only when we want the Estimated Reading Time.
9
 */
10
class Estimated_Reading_Time_Conditional implements Conditional {
11

12
        /**
13
         * The Post Conditional.
14
         *
15
         * @var Post_Conditional
16
         */
17
        protected $post_conditional;
18

19
        /**
20
         * Constructs the Estimated Reading Time Conditional.
21
         *
22
         * @param Post_Conditional $post_conditional The post conditional.
23
         */
24
        public function __construct( Post_Conditional $post_conditional ) {
25
                $this->post_conditional = $post_conditional;
×
26
        }
27

28
        /**
29
         * Returns whether this conditional is met.
30
         *
31
         * @return bool Whether the conditional is met.
32
         */
33
        public function is_met() {
34
                // phpcs:disable WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing -- Reason: Nonce verification should not be done in a conditional but rather in the classes using the conditional.
35
                // Check if we are in our Elementor ajax request (for saving).
36
                if ( \wp_doing_ajax() && isset( $_POST['action'] ) && \is_string( $_POST['action'] ) ) {
×
37
                        // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only strictly comparing the variable.
38
                        $post_action = \wp_unslash( $_POST['action'] );
×
39
                        if ( $post_action === 'wpseo_elementor_save' ) {
×
40
                                return true;
×
41
                        }
42
                }
43

44
                if ( ! $this->post_conditional->is_met() ) {
×
45
                        return false;
×
46
                }
47

48
                // We don't support Estimated Reading Time on the attachment post type.
49
                if ( isset( $_GET['post'] ) && \is_string( $_GET['post'] ) ) {
×
50
                        // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are casting to an integer.
51
                        $post_id = (int) \wp_unslash( $_GET['post'] );
×
52
                        if ( $post_id !== 0 && \get_post_type( $post_id ) === 'attachment' ) {
×
53
                                return false;
×
54
                        }
55
                }
56

57
                return true;
×
58
                // phpcs:enable WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing
59
        }
60
}
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