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

Yoast / wordpress-seo / 5254cddff39e2d3358f6ba8d54603a64b0d70891

18 Feb 2025 09:10AM UTC coverage: 54.48% (-0.1%) from 54.606%
5254cddff39e2d3358f6ba8d54603a64b0d70891

push

github

YoastBot
Bump version to 24.5 on free

7738 of 13771 branches covered (56.19%)

Branch coverage included in aggregate %.

30157 of 55787 relevant lines covered (54.06%)

41242.87 hits per line

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

85.71
/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\Integrations\Site_Kit;
15
use Yoast\WP\SEO\Helpers\Options_Helper;
16
use Yoast\WP\SEO\Helpers\Woocommerce_Helper;
17
use Yoast\WP\SEO\Integrations\Integration_Interface;
18

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

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

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

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

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

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

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

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

73
        /**
74
         * Workouts_Integration constructor.
75
         *
76
         * @param WPSEO_Admin_Asset_Manager       $admin_asset_manager       The admin asset manager.
77
         * @param Options_Helper                  $options_helper            The options helper.
78
         * @param Woocommerce_Helper              $woocommerce_helper        The WooCommerce helper.
79
         * @param Elementor_Activated_Conditional $elementor_conditional     The elementor conditional.
80
         * @param Jetpack_Conditional             $jetpack_conditional       The Jetpack conditional.
81
         * @param Site_Kit                        $site_kit_integration_data The site kit integration configuration data.
82
         */
83
        public function __construct(
6✔
84
                WPSEO_Admin_Asset_Manager $admin_asset_manager,
85
                Options_Helper $options_helper,
86
                Woocommerce_Helper $woocommerce_helper,
87
                Elementor_Activated_Conditional $elementor_conditional,
88
                Jetpack_Conditional $jetpack_conditional,
89
                Site_Kit $site_kit_integration_data
90
        ) {
3✔
91
                $this->admin_asset_manager       = $admin_asset_manager;
6✔
92
                $this->options_helper            = $options_helper;
6✔
93
                $this->woocommerce_helper        = $woocommerce_helper;
6✔
94
                $this->elementor_conditional     = $elementor_conditional;
6✔
95
                $this->jetpack_conditional       = $jetpack_conditional;
6✔
96
                $this->site_kit_integration_data = $site_kit_integration_data;
6✔
97
        }
3✔
98

99
        /**
100
         * {@inheritDoc}
101
         */
102
        public function register_hooks() {
2✔
103
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 10 );
2✔
104
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ], 11 );
2✔
105
        }
1✔
106

107
        /**
108
         * Adds the integrations submenu page.
109
         *
110
         * @param array $submenu_pages The Yoast SEO submenu pages.
111
         *
112
         * @return array The filtered submenu pages.
113
         */
114
        public function add_submenu_page( $submenu_pages ) {
×
115
                $integrations_page = [
116
                        'wpseo_dashboard',
×
117
                        '',
×
118
                        \__( 'Integrations', 'wordpress-seo' ),
×
119
                        'wpseo_manage_options',
×
120
                        'wpseo_integrations',
×
121
                        [ $this, 'render_target' ],
×
122
                ];
123

124
                \array_splice( $submenu_pages, 1, 0, [ $integrations_page ] );
×
125

126
                return $submenu_pages;
×
127
        }
128

129
        /**
130
         * Enqueue the integrations app.
131
         *
132
         * @return void
133
         */
134
        public function enqueue_assets() {
2✔
135
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
136
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_integrations' ) {
2✔
137
                        return;
×
138
                }
139

140
                $this->admin_asset_manager->enqueue_style( 'admin-css' );
2✔
141
                $this->admin_asset_manager->enqueue_style( 'tailwind' );
2✔
142
                $this->admin_asset_manager->enqueue_style( 'monorepo' );
2✔
143

144
                $this->admin_asset_manager->enqueue_script( 'integrations-page' );
2✔
145

146
                $woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php';
2✔
147
                $acf_seo_file         = 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php';
2✔
148
                $acf_seo_file_github  = 'yoast-acf-analysis/yoast-acf-analysis.php';
2✔
149
                $algolia_file         = 'wp-search-with-algolia/algolia.php';
2✔
150
                $old_algolia_file     = 'search-by-algolia-instant-relevant-results/algolia.php';
2✔
151

152
                $addon_manager             = new WPSEO_Addon_Manager();
2✔
153
                $woocommerce_seo_installed = $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG );
2✔
154

155
                $woocommerce_seo_active   = \is_plugin_active( $woocommerce_seo_file );
2✔
156
                $woocommerce_active       = $this->woocommerce_helper->is_active();
2✔
157
                $acf_seo_installed        = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file );
2✔
158
                $acf_seo_github_installed = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file_github );
2✔
159
                $acf_seo_active           = \is_plugin_active( $acf_seo_file );
2✔
160
                $acf_seo_github_active    = \is_plugin_active( $acf_seo_file_github );
2✔
161
                $acf_active               = \class_exists( 'acf' );
2✔
162
                $algolia_active           = \is_plugin_active( $algolia_file );
2✔
163
                $edd_active               = \class_exists( Easy_Digital_Downloads::class );
2✔
164
                $old_algolia_active       = \is_plugin_active( $old_algolia_file );
2✔
165
                $tec_active               = \class_exists( Events_Schema::class );
2✔
166
                $ssp_active               = \class_exists( PodcastEpisode::class );
2✔
167
                $wp_recipe_maker_active   = \class_exists( WP_Recipe_Maker::class );
2✔
168
                $mastodon_active          = $this->is_mastodon_active();
2✔
169

170
                $woocommerce_seo_activate_url = \wp_nonce_url(
2✔
171
                        \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ),
2✔
172
                        'activate-plugin_' . $woocommerce_seo_file
2✔
173
                );
1✔
174

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

188
                $acf_seo_install_url = \wp_nonce_url(
2✔
189
                        \self_admin_url( 'update.php?action=install-plugin&plugin=acf-content-analysis-for-yoast-seo' ),
2✔
190
                        'install-plugin_acf-content-analysis-for-yoast-seo'
2✔
191
                );
1✔
192

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

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

241
        /**
242
         * Checks whether the Mastodon profile field has been filled in.
243
         *
244
         * @return bool
245
         */
246
        private function is_mastodon_active() {
2✔
247
                return \apply_filters( 'wpseo_mastodon_active', false );
2✔
248
        }
249
}
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