PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.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 18.2, at src/conditionals/admin/estimated-reading-time-conditional.php

65 lines 1.6 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 use Yoast\WP\SEO\Helpers\Input_Helper;
7
8 /**
9 * Conditional that is only when we want the Estimated Reading Time.
10 */
11 class Estimated_Reading_Time_Conditional implements Conditional {
12
13 /**
14 * The Post Conditional.
15 *
16 * @var Post_Conditional
17 */
18 protected $post_conditional;
19
20 /**
21 * The Input Helper.
22 *
23 * @var Input_Helper
24 */
25 protected $input_helper;
26
27 /**
28 * Constructs the Estimated Reading Time Conditional.
29 *
30 * @param Post_Conditional $post_conditional The post conditional.
31 * @param Input_Helper $input_helper The input helper.
32 */
33 public function __construct( Post_Conditional $post_conditional, Input_Helper $input_helper ) {
34 $this->post_conditional = $post_conditional;
35 $this->input_helper = $input_helper;
36 }
37
38 /**
39 * Returns whether or not this conditional is met.
40 *
41 * @return bool Whether or not the conditional is met.
42 */
43 public function is_met() {
44 // Check if we are in our Elementor ajax request (for saving).
45 if ( \wp_doing_ajax() ) {
46 $post_action = $this->input_helper->filter( \INPUT_POST, 'action', \FILTER_SANITIZE_STRING );
47 if ( $post_action === 'wpseo_elementor_save' ) {
48 return true;
49 }
50 }
51
52 if ( ! $this->post_conditional->is_met() ) {
53 return false;
54 }
55
56 // We don't support Estimated Reading Time on the attachment post type.
57 $post_id = (int) $this->input_helper->filter( \INPUT_GET, 'post', \FILTER_SANITIZE_NUMBER_INT );
58 if ( \get_post_type( $post_id ) === 'attachment' ) {
59 return false;
60 }
61
62 return true;
63 }
64 }
65