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

Yoast / wordpress-seo / 9594812bf110d67afe78816058eb15ec830063d2

15 Jul 2025 10:16AM UTC coverage: 52.595% (-1.0%) from 53.638%
9594812bf110d67afe78816058eb15ec830063d2

Pull #22432

github

web-flow
Merge branch 'trunk' into feature/ai-generator-in-free
Pull Request #22432: Merge feature branch into trunk

8341 of 15027 branches covered (55.51%)

Branch coverage included in aggregate %.

382 of 1769 new or added lines in 122 files covered. (21.59%)

2 existing lines in 2 files now uncovered.

30934 of 59648 relevant lines covered (51.86%)

40029.26 hits per line

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

0.0
/src/conditionals/ai-editor-conditional.php
1
<?php
2

3
namespace Yoast\WP\SEO\Conditionals;
4

5
use Yoast\WP\SEO\Conditionals\Admin\Post_Conditional;
6
use Yoast\WP\SEO\Helpers\Current_Page_Helper;
7
use Yoast\WP\SEO\Helpers\Product_Helper;
8

9
/**
10
 * Conditional that is met when the AI editor integration should be active.
11
 */
12
class AI_Editor_Conditional implements Conditional {
13

14
        /**
15
         * Holds the Post_Conditional.
16
         *
17
         * @var Post_Conditional
18
         */
19
        private $post_conditional;
20

21
        /**
22
         * Holds the Current_Page_Helper.
23
         *
24
         * @var Current_Page_Helper
25
         */
26
        private $current_page_helper;
27

28
        /**
29
         * Holds the Product_Helper.
30
         *
31
         * @var Product_Helper
32
         */
33
        private $product_helper;
34

35
        /**
36
         * Constructs Ai_Editor_Conditional.
37
         *
38
         * @param Post_Conditional    $post_conditional    The Post_Conditional.
39
         * @param Current_Page_Helper $current_page_helper The Current_Page_Helper.
40
         * @param Product_Helper      $product_helper      The Product_Helper.
41
         */
NEW
42
        public function __construct( Post_Conditional $post_conditional, Current_Page_Helper $current_page_helper, Product_Helper $product_helper ) {
×
NEW
43
                $this->post_conditional    = $post_conditional;
×
NEW
44
                $this->current_page_helper = $current_page_helper;
×
NEW
45
                $this->product_helper      = $product_helper;
×
46
        }
47

48
        /**
49
         * Returns `true` when the AI editor integration should be active.
50
         *
51
         * @return bool `true` when the AI editor integration should be active.
52
         */
NEW
53
        public function is_met() {
×
NEW
54
                if ( $this->is_attachment() ) {
×
NEW
55
                        return false;
×
56
                }
57

NEW
58
                if ( $this->is_ai_generator_premium() ) {
×
NEW
59
                        return false;
×
60
                }
61

NEW
62
                return $this->post_conditional->is_met() || $this->is_term() || $this->is_elementor_editor();
×
63
        }
64

65
        /**
66
         * Returns `true` when the page is a term page.
67
         *
68
         * @return bool `true` when the page is a term page.
69
         */
NEW
70
        private function is_term() {
×
NEW
71
                return $this->current_page_helper->get_current_admin_page() === 'term.php';
×
72
        }
73

74
        /**
75
         * Returns `true` when the page is the Elementor editor.
76
         *
77
         * @return bool `true` when the page is the Elementor editor.
78
         */
NEW
79
        private function is_elementor_editor() {
×
NEW
80
                if ( $this->current_page_helper->get_current_admin_page() !== 'post.php' ) {
×
NEW
81
                        return false;
×
82
                }
83

84
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
NEW
85
                if ( isset( $_GET['action'] ) && \is_string( $_GET['action'] ) ) {
×
86
                        // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing.
NEW
87
                        if ( \wp_unslash( $_GET['action'] ) === 'elementor' ) {
×
NEW
88
                                return true;
×
89
                        }
90
                }
91

NEW
92
                return false;
×
93
        }
94

95
        /**
96
         * Is an attchment post type.
97
         *
98
         * @return bool
99
         */
NEW
100
        public function is_attachment() {
×
NEW
101
                return $this->current_page_helper->get_current_post_type() === 'attachment';
×
102
        }
103

104
        /**
105
         * Is premium version containes AI generator. We exclude product post type because it is not supported in premium version before 25.6.
106
         *
107
         * @return bool
108
         */
NEW
109
        public function is_ai_generator_premium() {
×
NEW
110
                if ( ! $this->product_helper->is_premium() ) {
×
NEW
111
                        return false;
×
112
                }
NEW
113
                return \version_compare( $this->product_helper->get_premium_version(), '25.6', '<' ) && $this->current_page_helper->get_current_post_type() !== 'product';
×
114
        }
115
}
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