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

Yoast / wordpress-seo / b297a102e39b2007cbf436fb16441d0beb8d529d

17 Dec 2025 01:13PM UTC coverage: 41.433% (-11.1%) from 52.525%
b297a102e39b2007cbf436fb16441d0beb8d529d

Pull #22772

github

web-flow
Merge 7e4648015 into cdc37a449
Pull Request #22772: Add schema feature toggle and settings page

2611 of 9726 branches covered (26.85%)

Branch coverage included in aggregate %.

19 of 181 new or added lines in 17 files covered. (10.5%)

82 existing lines in 17 files now uncovered.

22742 of 51465 relevant lines covered (44.19%)

4.71 hits per line

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

79.44
/src/integrations/admin/integrations-page.php
1
<?php
2

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

5
use WPSEO_Admin_Asset_Manager;
6
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
7
use Yoast\WP\SEO\Conditionals\Jetpack_Conditional;
8
use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Activated_Conditional;
9
use Yoast\WP\SEO\Dashboard\Infrastructure\Endpoints\Site_Kit_Consent_Management_Endpoint;
10
use Yoast\WP\SEO\Dashboard\Infrastructure\Integrations\Site_Kit;
11
use Yoast\WP\SEO\Helpers\Options_Helper;
12
use Yoast\WP\SEO\Integrations\Integration_Interface;
13
use Yoast\WP\SEO\Schema\Application\Configuration\Schema_Configuration;
14

15
/**
16
 * Integrations_Page class
17
 */
18
class Integrations_Page implements Integration_Interface {
19

20
        /**
21
         * The admin asset manager.
22
         *
23
         * @var WPSEO_Admin_Asset_Manager
24
         */
25
        private $admin_asset_manager;
26

27
        /**
28
         * The options helper.
29
         *
30
         * @var Options_Helper
31
         */
32
        private $options_helper;
33

34
        /**
35
         * The elementor conditional.
36
         *
37
         * @var Elementor_Activated_Conditional
38
         */
39
        private $elementor_conditional;
40

41
        /**
42
         * The jetpack conditional.
43
         *
44
         * @var Jetpack_Conditional
45
         */
46
        private $jetpack_conditional;
47

48
        /**
49
         * The site kit integration configuration data.
50
         *
51
         * @var Site_Kit
52
         */
53
        private $site_kit_integration_data;
54

55
        /**
56
         * The site kit consent management endpoint.
57
         *
58
         * @var Site_Kit_Consent_Management_Endpoint
59
         */
60
        private $site_kit_consent_management_endpoint;
61

62
        /**
63
         * The schema configuration.
64
         *
65
         * @var Schema_Configuration
66
         */
67
        private $schema_configuration;
68

69
        /**
70
         * {@inheritDoc}
71
         */
72
        public static function get_conditionals() {
2✔
73
                return [ Admin_Conditional::class ];
2✔
74
        }
75

76
        /**
77
         * Workouts_Integration constructor.
78
         *
79
         * @param WPSEO_Admin_Asset_Manager            $admin_asset_manager                  The admin asset manager.
80
         * @param Options_Helper                       $options_helper                       The options helper.
81
         * @param Elementor_Activated_Conditional      $elementor_conditional                The elementor conditional.
82
         * @param Jetpack_Conditional                  $jetpack_conditional                  The Jetpack conditional.
83
         * @param Site_Kit                             $site_kit_integration_data            The site kit integration
84
         *                                                                                   configuration data.
85
         * @param Site_Kit_Consent_Management_Endpoint $site_kit_consent_management_endpoint The site kit consent
86
         *                                                                                   management endpoint.
87
         * @param Schema_Configuration                 $schema_configuration                 The schema configuration.
88
         */
89
        public function __construct(
6✔
90
                WPSEO_Admin_Asset_Manager $admin_asset_manager,
91
                Options_Helper $options_helper,
92
                Elementor_Activated_Conditional $elementor_conditional,
93
                Jetpack_Conditional $jetpack_conditional,
94
                Site_Kit $site_kit_integration_data,
95
                Site_Kit_Consent_Management_Endpoint $site_kit_consent_management_endpoint,
96
                Schema_Configuration $schema_configuration
97
        ) {
98
                $this->admin_asset_manager                  = $admin_asset_manager;
6✔
99
                $this->options_helper                       = $options_helper;
6✔
100
                $this->elementor_conditional                = $elementor_conditional;
6✔
101
                $this->jetpack_conditional                  = $jetpack_conditional;
6✔
102
                $this->site_kit_integration_data            = $site_kit_integration_data;
6✔
103
                $this->site_kit_consent_management_endpoint = $site_kit_consent_management_endpoint;
6✔
104
                $this->schema_configuration                 = $schema_configuration;
6✔
105
        }
106

107
        /**
108
         * {@inheritDoc}
109
         */
110
        public function register_hooks() {
2✔
111
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 10 );
2✔
112
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ], 11 );
2✔
113
        }
114

115
        /**
116
         * Adds the integrations submenu page.
117
         *
118
         * @param array $submenu_pages The Yoast SEO submenu pages.
119
         *
120
         * @return array The filtered submenu pages.
121
         */
122
        public function add_submenu_page( $submenu_pages ) {
×
123
                $integrations_page = [
×
124
                        'wpseo_dashboard',
×
125
                        '',
×
126
                        \__( 'Integrations', 'wordpress-seo' ),
×
127
                        'wpseo_manage_options',
×
128
                        'wpseo_integrations',
×
129
                        [ $this, 'render_target' ],
×
130
                ];
×
131

132
                \array_splice( $submenu_pages, 1, 0, [ $integrations_page ] );
×
133

134
                return $submenu_pages;
×
135
        }
136

137
        /**
138
         * Enqueue the integrations app.
139
         *
140
         * @return void
141
         */
142
        public function enqueue_assets() {
2✔
143
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
144
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_integrations' ) {
2✔
145
                        return;
×
146
                }
147

148
                $this->admin_asset_manager->enqueue_style( 'admin-css' );
2✔
149
                $this->admin_asset_manager->enqueue_style( 'tailwind' );
2✔
150
                $this->admin_asset_manager->enqueue_style( 'monorepo' );
2✔
151

152
                $this->admin_asset_manager->enqueue_script( 'integrations-page' );
2✔
153

154
                $acf_seo_file        = 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php';
2✔
155
                $acf_seo_file_github = 'yoast-acf-analysis/yoast-acf-analysis.php';
2✔
156
                $algolia_file        = 'wp-search-with-algolia/algolia.php';
2✔
157
                $old_algolia_file    = 'search-by-algolia-instant-relevant-results/algolia.php';
2✔
158

159
                $schema_api_integrations = $this->schema_configuration->get_schema_api_integrations();
2✔
160

161
                $woocommerce_seo_installed    = $schema_api_integrations['woocommerce']['isInstalled'];
2✔
162
                $woocommerce_seo_active       = $schema_api_integrations['woocommerce']['isActive'];
2✔
163
                $woocommerce_active           = $schema_api_integrations['woocommerce']['isPrerequisiteActive'];
2✔
164
                $woocommerce_seo_activate_url = $schema_api_integrations['woocommerce']['activationLink'];
2✔
165
                $edd_active                   = $schema_api_integrations['edd']['isActive'];
2✔
166
                $tec_active                   = $schema_api_integrations['tec']['isActive'];
2✔
167
                $ssp_active                   = $schema_api_integrations['ssp']['isActive'];
2✔
168
                $wp_recipe_maker_active       = $schema_api_integrations['wp-recipe-maker']['isActive'];
2✔
169

170
                $acf_seo_installed        = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file );
2✔
171
                $acf_seo_github_installed = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file_github );
2✔
172
                $acf_seo_active           = \is_plugin_active( $acf_seo_file );
2✔
173
                $acf_seo_github_active    = \is_plugin_active( $acf_seo_file_github );
2✔
174
                $acf_active               = \class_exists( 'acf' );
2✔
175
                $algolia_active           = \is_plugin_active( $algolia_file );
2✔
176
                $old_algolia_active       = \is_plugin_active( $old_algolia_file );
2✔
177
                $mastodon_active          = $this->is_mastodon_active();
2✔
178

179
                if ( $acf_seo_installed ) {
2✔
UNCOV
180
                        $acf_seo_activate_url = \wp_nonce_url(
×
181
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file ),
×
182
                                'activate-plugin_' . $acf_seo_file
×
183
                        );
×
184
                }
185
                else {
186
                        $acf_seo_activate_url = \wp_nonce_url(
2✔
187
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file_github ),
2✔
188
                                'activate-plugin_' . $acf_seo_file_github
2✔
189
                        );
2✔
190
                }
191

192
                $acf_seo_install_url = \wp_nonce_url(
2✔
193
                        \self_admin_url( 'update.php?action=install-plugin&plugin=acf-content-analysis-for-yoast-seo' ),
2✔
194
                        'install-plugin_acf-content-analysis-for-yoast-seo'
2✔
195
                );
2✔
196

197
                $this->admin_asset_manager->localize_script(
2✔
198
                        'integrations-page',
2✔
199
                        'wpseoIntegrationsData',
2✔
200
                        [
2✔
201
                                'semrush_integration_active'         => $this->options_helper->get( 'semrush_integration_active', true ),
2✔
202
                                'allow_semrush_integration'          => $this->options_helper->get( 'allow_semrush_integration_active', true ),
2✔
203
                                'algolia_integration_active'         => $this->options_helper->get( 'algolia_integration_active', false ),
2✔
204
                                'allow_algolia_integration'          => $this->options_helper->get( 'allow_algolia_integration_active', true ),
2✔
205
                                'wincher_integration_active'         => $this->options_helper->get( 'wincher_integration_active', true ),
2✔
206
                                'allow_wincher_integration'          => null,
2✔
207
                                'elementor_integration_active'       => $this->elementor_conditional->is_met(),
2✔
208
                                'jetpack_integration_active'         => $this->jetpack_conditional->is_met(),
2✔
209
                                'woocommerce_seo_installed'          => $woocommerce_seo_installed,
2✔
210
                                'woocommerce_seo_active'             => $woocommerce_seo_active,
2✔
211
                                'woocommerce_active'                 => $woocommerce_active,
2✔
212
                                'woocommerce_seo_activate_url'       => $woocommerce_seo_activate_url,
2✔
213
                                'acf_seo_installed'                  => $acf_seo_installed || $acf_seo_github_installed,
2✔
214
                                'acf_seo_active'                     => $acf_seo_active || $acf_seo_github_active,
2✔
215
                                'acf_active'                         => $acf_active,
2✔
216
                                'acf_seo_activate_url'               => $acf_seo_activate_url,
2✔
217
                                'acf_seo_install_url'                => $acf_seo_install_url,
2✔
218
                                'algolia_active'                     => $algolia_active || $old_algolia_active,
2✔
219
                                'edd_integration_active'             => $edd_active,
2✔
220
                                'ssp_integration_active'             => $ssp_active,
2✔
221
                                'tec_integration_active'             => $tec_active,
2✔
222
                                'wp-recipe-maker_integration_active' => $wp_recipe_maker_active,
2✔
223
                                'mastodon_active'                    => $mastodon_active,
2✔
224
                                'is_multisite'                       => \is_multisite(),
2✔
225
                                'plugin_url'                         => \plugins_url( '', \WPSEO_FILE ),
2✔
226
                                'site_kit_configuration'             => $this->site_kit_integration_data->to_array(),
2✔
227
                                'site_kit_consent_management_url'    => $this->site_kit_consent_management_endpoint->get_url(),
2✔
228
                                'schema_framework_enabled'           => $this->options_helper->get( 'enable_schema', true ) === true && ! $this->schema_configuration->is_schema_disabled_programmatically(),
2✔
229
                        ]
2✔
230
                );
2✔
231
        }
232

233
        /**
234
         * Renders the target for the React to mount to.
235
         *
236
         * @return void
237
         */
238
        public function render_target() {
×
239
                ?>
240
                <div class="wrap yoast wpseo-admin-page page-wpseo">
×
241
                        <div class="wp-header-end" style="height: 0; width: 0;"></div>
×
242
                        <div id="wpseo-integrations"></div>
×
243
                </div>
×
244
                <?php
×
245
        }
246

247
        /**
248
         * Checks whether the Mastodon profile field has been filled in.
249
         *
250
         * @return bool
251
         */
252
        private function is_mastodon_active() {
2✔
253
                return \apply_filters( 'wpseo_mastodon_active', false );
2✔
254
        }
255
}
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