PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
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 / conditionals / admin / estimated-reading-time-conditional.php

estimated-reading-time-conditional.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.2, at src/conditionals/admin/estimated-reading-time-conditional.php

61 lines 1.9 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\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 }
61