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

Yoast / wordpress-seo / b78c91bd80d89b034df841d284a428c954224385

03 Sep 2024 07:50AM UTC coverage: 54.503% (+0.4%) from 54.072%
b78c91bd80d89b034df841d284a428c954224385

push

github

YoastBot
Bump version to 23.4 on free

7504 of 13559 branches covered (55.34%)

Branch coverage included in aggregate %.

29831 of 54942 relevant lines covered (54.3%)

41571.6 hits per line

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

86.84
/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 WPSEO_Shortlinker;
12
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
13
use Yoast\WP\SEO\Conditionals\Jetpack_Conditional;
14
use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Activated_Conditional;
15
use Yoast\WP\SEO\Conditionals\Third_Party\Jetpack_Boost_Active_Conditional;
16
use Yoast\WP\SEO\Conditionals\Third_Party\Jetpack_Boost_Not_Premium_Conditional;
17
use Yoast\WP\SEO\Helpers\Options_Helper;
18
use Yoast\WP\SEO\Helpers\Woocommerce_Helper;
19
use Yoast\WP\SEO\Integrations\Integration_Interface;
20

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

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

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

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

47
        /**
48
         * {@inheritDoc}
49
         */
50
        public static function get_conditionals() {
2✔
51
                return [ Admin_Conditional::class ];
2✔
52
        }
53

54
        /**
55
         * Workouts_Integration constructor.
56
         *
57
         * @param WPSEO_Admin_Asset_Manager $admin_asset_manager The admin asset manager.
58
         * @param Options_Helper            $options_helper      The options helper.
59
         * @param Woocommerce_Helper        $woocommerce_helper  The WooCommerce helper.
60
         */
61
        public function __construct(
6✔
62
                WPSEO_Admin_Asset_Manager $admin_asset_manager,
63
                Options_Helper $options_helper,
64
                Woocommerce_Helper $woocommerce_helper
65
        ) {
3✔
66
                $this->admin_asset_manager = $admin_asset_manager;
6✔
67
                $this->options_helper      = $options_helper;
6✔
68
                $this->woocommerce_helper  = $woocommerce_helper;
6✔
69
        }
3✔
70

71
        /**
72
         * {@inheritDoc}
73
         */
74
        public function register_hooks() {
2✔
75
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 10 );
2✔
76
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ], 11 );
2✔
77
        }
1✔
78

79
        /**
80
         * Adds the integrations submenu page.
81
         *
82
         * @param array $submenu_pages The Yoast SEO submenu pages.
83
         *
84
         * @return array The filtered submenu pages.
85
         */
86
        public function add_submenu_page( $submenu_pages ) {
×
87
                $integrations_page = [
88
                        'wpseo_dashboard',
×
89
                        '',
×
90
                        \__( 'Integrations', 'wordpress-seo' ),
×
91
                        'wpseo_manage_options',
×
92
                        'wpseo_integrations',
×
93
                        [ $this, 'render_target' ],
×
94
                ];
95

96
                \array_splice( $submenu_pages, 1, 0, [ $integrations_page ] );
×
97

98
                return $submenu_pages;
×
99
        }
100

101
        /**
102
         * Enqueue the integrations app.
103
         *
104
         * @return void
105
         */
106
        public function enqueue_assets() {
2✔
107
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
108
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_integrations' ) {
2✔
109
                        return;
×
110
                }
111

112
                $this->admin_asset_manager->enqueue_style( 'admin-css' );
2✔
113
                $this->admin_asset_manager->enqueue_style( 'tailwind' );
2✔
114
                $this->admin_asset_manager->enqueue_style( 'monorepo' );
2✔
115

116
                $this->admin_asset_manager->enqueue_script( 'integrations-page' );
2✔
117

118
                $elementor_conditional                 = new Elementor_Activated_Conditional();
2✔
119
                $jetpack_conditional                   = new Jetpack_Conditional();
2✔
120
                $jetpack_boost_active_conditional      = new Jetpack_Boost_Active_Conditional();
2✔
121
                $jetpack_boost_not_premium_conditional = new Jetpack_Boost_Not_Premium_Conditional();
2✔
122

123
                $woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php';
2✔
124
                $acf_seo_file         = 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php';
2✔
125
                $acf_seo_file_github  = 'yoast-acf-analysis/yoast-acf-analysis.php';
2✔
126
                $algolia_file         = 'wp-search-with-algolia/algolia.php';
2✔
127
                $old_algolia_file     = 'search-by-algolia-instant-relevant-results/algolia.php';
2✔
128

129
                $host                      = \YoastSEO()->helpers->url->get_url_host( \get_site_url() );
2✔
130
                $addon_manager             = new WPSEO_Addon_Manager();
2✔
131
                $woocommerce_seo_installed = $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG );
2✔
132

133
                $woocommerce_seo_active   = \is_plugin_active( $woocommerce_seo_file );
2✔
134
                $woocommerce_active       = $this->woocommerce_helper->is_active();
2✔
135
                $acf_seo_installed        = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file );
2✔
136
                $acf_seo_github_installed = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file_github );
2✔
137
                $acf_seo_active           = \is_plugin_active( $acf_seo_file );
2✔
138
                $acf_seo_github_active    = \is_plugin_active( $acf_seo_file_github );
2✔
139
                $acf_active               = \class_exists( 'acf' );
2✔
140
                $algolia_active           = \is_plugin_active( $algolia_file );
2✔
141
                $edd_active               = \class_exists( Easy_Digital_Downloads::class );
2✔
142
                $jetpack_boost_active     = $jetpack_boost_active_conditional->is_met();
2✔
143
                $jetpack_boost_premium    = ( ! $jetpack_boost_not_premium_conditional->is_met() );
2✔
144
                $old_algolia_active       = \is_plugin_active( $old_algolia_file );
2✔
145
                $tec_active               = \class_exists( Events_Schema::class );
2✔
146
                $ssp_active               = \class_exists( PodcastEpisode::class );
2✔
147
                $wp_recipe_maker_active   = \class_exists( WP_Recipe_Maker::class );
2✔
148
                $mastodon_active          = $this->is_mastodon_active();
2✔
149

150
                $woocommerce_seo_activate_url = \wp_nonce_url(
2✔
151
                        \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ),
2✔
152
                        'activate-plugin_' . $woocommerce_seo_file
2✔
153
                );
1✔
154

155
                if ( $acf_seo_installed ) {
2✔
156
                        $acf_seo_activate_url = \wp_nonce_url(
×
157
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file ),
×
158
                                'activate-plugin_' . $acf_seo_file
×
159
                        );
160
                }
161
                else {
162
                        $acf_seo_activate_url = \wp_nonce_url(
2✔
163
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file_github ),
2✔
164
                                'activate-plugin_' . $acf_seo_file_github
2✔
165
                        );
1✔
166
                }
167

168
                $acf_seo_install_url = \wp_nonce_url(
2✔
169
                        \self_admin_url( 'update.php?action=install-plugin&plugin=acf-content-analysis-for-yoast-seo' ),
2✔
170
                        'install-plugin_acf-content-analysis-for-yoast-seo'
2✔
171
                );
1✔
172

173
                $this->admin_asset_manager->localize_script(
2✔
174
                        'integrations-page',
2✔
175
                        'wpseoIntegrationsData',
2✔
176
                        [
1✔
177
                                'semrush_integration_active'         => $this->options_helper->get( 'semrush_integration_active', true ),
2✔
178
                                'allow_semrush_integration'          => $this->options_helper->get( 'allow_semrush_integration_active', true ),
2✔
179
                                'algolia_integration_active'         => $this->options_helper->get( 'algolia_integration_active', false ),
2✔
180
                                'allow_algolia_integration'          => $this->options_helper->get( 'allow_algolia_integration_active', true ),
2✔
181
                                'wincher_integration_active'         => $this->options_helper->get( 'wincher_integration_active', true ),
2✔
182
                                'allow_wincher_integration'          => null,
1✔
183
                                'elementor_integration_active'       => $elementor_conditional->is_met(),
2✔
184
                                'jetpack_integration_active'         => $jetpack_conditional->is_met(),
2✔
185
                                'woocommerce_seo_installed'          => $woocommerce_seo_installed,
2✔
186
                                'woocommerce_seo_active'             => $woocommerce_seo_active,
2✔
187
                                'woocommerce_active'                 => $woocommerce_active,
2✔
188
                                'woocommerce_seo_activate_url'       => $woocommerce_seo_activate_url,
2✔
189
                                'acf_seo_installed'                  => $acf_seo_installed || $acf_seo_github_installed,
2✔
190
                                'acf_seo_active'                     => $acf_seo_active || $acf_seo_github_active,
2✔
191
                                'acf_active'                         => $acf_active,
2✔
192
                                'acf_seo_activate_url'               => $acf_seo_activate_url,
2✔
193
                                'acf_seo_install_url'                => $acf_seo_install_url,
2✔
194
                                'algolia_active'                     => $algolia_active || $old_algolia_active,
2✔
195
                                'edd_integration_active'             => $edd_active,
2✔
196
                                'ssp_integration_active'             => $ssp_active,
2✔
197
                                'tec_integration_active'             => $tec_active,
2✔
198
                                'wp-recipe-maker_integration_active' => $wp_recipe_maker_active,
2✔
199
                                'mastodon_active'                    => $mastodon_active,
2✔
200
                                'is_multisite'                       => \is_multisite(),
2✔
201
                                'plugin_url'                         => \plugins_url( '', \WPSEO_FILE ),
2✔
202
                                'jetpack-boost_active'               => $jetpack_boost_active,
2✔
203
                                'jetpack-boost_premium'              => $jetpack_boost_premium,
2✔
204
                                'jetpack-boost_logo_link'            => WPSEO_Shortlinker::get( 'https://yoa.st/integrations-logo-jetpack-boost' ),
2✔
205
                                'jetpack-boost_get_link'             => WPSEO_Shortlinker::get( 'https://yoa.st/integrations-get-jetpack-boost?domain=' . $host ),
2✔
206
                                'jetpack-boost_upgrade_link'         => WPSEO_Shortlinker::get( 'https://yoa.st/integrations-upgrade-jetpack-boost?domain=' . $host ),
2✔
207
                                'jetpack-boost_learn_more_link'      => \admin_url( 'admin.php?page=jetpack-boost' ),
2✔
208
                        ]
1✔
209
                );
1✔
210
        }
1✔
211

212
        /**
213
         * Renders the target for the React to mount to.
214
         *
215
         * @return void
216
         */
217
        public function render_target() {
×
218
                ?>
219
                <div class="wrap yoast wpseo-admin-page page-wpseo">
×
220
                        <div class="wp-header-end" style="height: 0; width: 0;"></div>
221
                        <div id="wpseo-integrations"></div>
222
                </div>
223
                <?php
224
        }
225

226
        /**
227
         * Checks whether the Mastodon profile field has been filled in.
228
         *
229
         * @return bool
230
         */
231
        private function is_mastodon_active() {
2✔
232
                return \apply_filters( 'wpseo_mastodon_active', false );
2✔
233
        }
234
}
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