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

Yoast / wordpress-seo / 56db0408fe2a0dbffe1c2c6cfad9b5c2f6941e34

14 Apr 2025 12:24PM UTC coverage: 52.454% (-2.1%) from 54.594%
56db0408fe2a0dbffe1c2c6cfad9b5c2f6941e34

Pull #22077

github

enricobattocchi
Adjust carryforward in Coveralls action
Pull Request #22077: Drop compatibility with PHP 7.2 and 7.3

7827 of 13877 branches covered (56.4%)

Branch coverage included in aggregate %.

29025 of 56379 relevant lines covered (51.48%)

42277.18 hits per line

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

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

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

5
use Easy_Digital_Downloads;
6
use SeriouslySimplePodcasting\Integrations\Yoast\Schema\PodcastEpisode;
7
use TEC\Events\Integrations\Plugins\WordPress_SEO\Events_Schema;
8
use WP_Recipe_Maker;
9
use WPSEO_Addon_Manager;
10
use WPSEO_Admin_Asset_Manager;
11
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
12
use Yoast\WP\SEO\Conditionals\Jetpack_Conditional;
13
use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Activated_Conditional;
14
use Yoast\WP\SEO\Dashboard\Infrastructure\Endpoints\Site_Kit_Consent_Management_Endpoint;
15
use Yoast\WP\SEO\Dashboard\Infrastructure\Integrations\Site_Kit;
16
use Yoast\WP\SEO\Helpers\Options_Helper;
17
use Yoast\WP\SEO\Helpers\Woocommerce_Helper;
18
use Yoast\WP\SEO\Integrations\Integration_Interface;
19

20
/**
21
 * Integrations_Page class
22
 */
23
class Integrations_Page implements Integration_Interface {
24

25
        /**
26
         * The Woocommerce helper.
27
         *
28
         * @var Woocommerce_Helper
29
         */
30
        private $woocommerce_helper;
31

32
        /**
33
         * The admin asset manager.
34
         *
35
         * @var WPSEO_Admin_Asset_Manager
36
         */
37
        private $admin_asset_manager;
38

39
        /**
40
         * The options helper.
41
         *
42
         * @var Options_Helper
43
         */
44
        private $options_helper;
45

46
        /**
47
         * The elementor conditional.
48
         *
49
         * @var Elementor_Activated_Conditional
50
         */
51
        private $elementor_conditional;
52

53
        /**
54
         * The jetpack conditional.
55
         *
56
         * @var Jetpack_Conditional
57
         */
58
        private $jetpack_conditional;
59

60
        /**
61
         * The site kit integration configuration data.
62
         *
63
         * @var Site_Kit
64
         */
65
        private $site_kit_integration_data;
66

67
        /**
68
         * The site kit consent management endpoint.
69
         *
70
         * @var Site_Kit_Consent_Management_Endpoint
71
         */
72
        private $site_kit_consent_management_endpoint;
73

74
        /**
75
         * {@inheritDoc}
76
         */
77
        public static function get_conditionals() {
2✔
78
                return [ Admin_Conditional::class ];
2✔
79
        }
80

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

112
        /**
113
         * {@inheritDoc}
114
         */
115
        public function register_hooks() {
2✔
116
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 10 );
2✔
117
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ], 11 );
2✔
118
        }
119

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

137
                \array_splice( $submenu_pages, 1, 0, [ $integrations_page ] );
×
138

139
                return $submenu_pages;
×
140
        }
141

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

153
                $this->admin_asset_manager->enqueue_style( 'admin-css' );
2✔
154
                $this->admin_asset_manager->enqueue_style( 'tailwind' );
2✔
155
                $this->admin_asset_manager->enqueue_style( 'monorepo' );
2✔
156

157
                $this->admin_asset_manager->enqueue_script( 'integrations-page' );
2✔
158

159
                $woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php';
2✔
160
                $acf_seo_file         = 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php';
2✔
161
                $acf_seo_file_github  = 'yoast-acf-analysis/yoast-acf-analysis.php';
2✔
162
                $algolia_file         = 'wp-search-with-algolia/algolia.php';
2✔
163
                $old_algolia_file     = 'search-by-algolia-instant-relevant-results/algolia.php';
2✔
164

165
                $addon_manager             = new WPSEO_Addon_Manager();
2✔
166
                $woocommerce_seo_installed = $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG );
2✔
167

168
                $woocommerce_seo_active   = \is_plugin_active( $woocommerce_seo_file );
2✔
169
                $woocommerce_active       = $this->woocommerce_helper->is_active();
2✔
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
                $edd_active               = \class_exists( Easy_Digital_Downloads::class );
2✔
177
                $old_algolia_active       = \is_plugin_active( $old_algolia_file );
2✔
178
                $tec_active               = \class_exists( Events_Schema::class );
2✔
179
                $ssp_active               = \class_exists( PodcastEpisode::class );
2✔
180
                $wp_recipe_maker_active   = \class_exists( WP_Recipe_Maker::class );
2✔
181
                $mastodon_active          = $this->is_mastodon_active();
2✔
182

183
                $woocommerce_seo_activate_url = \wp_nonce_url(
2✔
184
                        \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ),
2✔
185
                        'activate-plugin_' . $woocommerce_seo_file
2✔
186
                );
2✔
187

188
                if ( $acf_seo_installed ) {
2✔
189
                        $acf_seo_activate_url = \wp_nonce_url(
×
190
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file ),
×
191
                                'activate-plugin_' . $acf_seo_file
×
192
                        );
×
193
                }
194
                else {
195
                        $acf_seo_activate_url = \wp_nonce_url(
2✔
196
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file_github ),
2✔
197
                                'activate-plugin_' . $acf_seo_file_github
2✔
198
                        );
2✔
199
                }
200

201
                $acf_seo_install_url = \wp_nonce_url(
2✔
202
                        \self_admin_url( 'update.php?action=install-plugin&plugin=acf-content-analysis-for-yoast-seo' ),
2✔
203
                        'install-plugin_acf-content-analysis-for-yoast-seo'
2✔
204
                );
2✔
205

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

241
        /**
242
         * Renders the target for the React to mount to.
243
         *
244
         * @return void
245
         */
246
        public function render_target() {
×
247
                ?>
248
                <div class="wrap yoast wpseo-admin-page page-wpseo">
×
249
                        <div class="wp-header-end" style="height: 0; width: 0;"></div>
×
250
                        <div id="wpseo-integrations"></div>
×
251
                </div>
×
252
                <?php
×
253
        }
254

255
        /**
256
         * Checks whether the Mastodon profile field has been filled in.
257
         *
258
         * @return bool
259
         */
260
        private function is_mastodon_active() {
2✔
261
                return \apply_filters( 'wpseo_mastodon_active', false );
2✔
262
        }
263
}
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