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

Yoast / wordpress-seo / 4c5f9780cef7c22b7f9bfbace943d71badc638ed

08 Oct 2024 09:39AM UTC coverage: 54.494% (-0.04%) from 54.538%
4c5f9780cef7c22b7f9bfbace943d71badc638ed

push

github

YoastBot
Bump version to 23.6 on free

7502 of 13498 branches covered (55.58%)

Branch coverage included in aggregate %.

29530 of 54458 relevant lines covered (54.23%)

41951.32 hits per line

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

85.44
/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

15

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
         * {@inheritDoc}
48
         */
49
        public static function get_conditionals() {
2✔
50
                return [ Admin_Conditional::class ];
2✔
51
        }
52

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

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

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

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

97
                return $submenu_pages;
×
98
        }
99

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

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

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

117
                $elementor_conditional = new Elementor_Activated_Conditional();
2✔
118
                $jetpack_conditional   = new Jetpack_Conditional();
2✔
119

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

126
                $addon_manager             = new WPSEO_Addon_Manager();
2✔
127
                $woocommerce_seo_installed = $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG );
2✔
128

129
                $woocommerce_seo_active   = \is_plugin_active( $woocommerce_seo_file );
2✔
130
                $woocommerce_active       = $this->woocommerce_helper->is_active();
2✔
131
                $acf_seo_installed        = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file );
2✔
132
                $acf_seo_github_installed = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file_github );
2✔
133
                $acf_seo_active           = \is_plugin_active( $acf_seo_file );
2✔
134
                $acf_seo_github_active    = \is_plugin_active( $acf_seo_file_github );
2✔
135
                $acf_active               = \class_exists( 'acf' );
2✔
136
                $algolia_active           = \is_plugin_active( $algolia_file );
2✔
137
                $edd_active               = \class_exists( Easy_Digital_Downloads::class );
2✔
138
                $old_algolia_active       = \is_plugin_active( $old_algolia_file );
2✔
139
                $tec_active               = \class_exists( Events_Schema::class );
2✔
140
                $ssp_active               = \class_exists( PodcastEpisode::class );
2✔
141
                $wp_recipe_maker_active   = \class_exists( WP_Recipe_Maker::class );
2✔
142
                $mastodon_active          = $this->is_mastodon_active();
2✔
143

144
                $woocommerce_seo_activate_url = \wp_nonce_url(
2✔
145
                        \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ),
2✔
146
                        'activate-plugin_' . $woocommerce_seo_file
2✔
147
                );
1✔
148

149
                if ( $acf_seo_installed ) {
2✔
150
                        $acf_seo_activate_url = \wp_nonce_url(
×
151
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file ),
×
152
                                'activate-plugin_' . $acf_seo_file
×
153
                        );
154
                }
155
                else {
156
                        $acf_seo_activate_url = \wp_nonce_url(
2✔
157
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file_github ),
2✔
158
                                'activate-plugin_' . $acf_seo_file_github
2✔
159
                        );
1✔
160
                }
161

162
                $acf_seo_install_url = \wp_nonce_url(
2✔
163
                        \self_admin_url( 'update.php?action=install-plugin&plugin=acf-content-analysis-for-yoast-seo' ),
2✔
164
                        'install-plugin_acf-content-analysis-for-yoast-seo'
2✔
165
                );
1✔
166

167
                $this->admin_asset_manager->localize_script(
2✔
168
                        'integrations-page',
2✔
169
                        'wpseoIntegrationsData',
2✔
170
                        [
1✔
171
                                'semrush_integration_active'         => $this->options_helper->get( 'semrush_integration_active', true ),
2✔
172
                                'allow_semrush_integration'          => $this->options_helper->get( 'allow_semrush_integration_active', true ),
2✔
173
                                'algolia_integration_active'         => $this->options_helper->get( 'algolia_integration_active', false ),
2✔
174
                                'allow_algolia_integration'          => $this->options_helper->get( 'allow_algolia_integration_active', true ),
2✔
175
                                'wincher_integration_active'         => $this->options_helper->get( 'wincher_integration_active', true ),
2✔
176
                                'allow_wincher_integration'          => null,
1✔
177
                                'elementor_integration_active'       => $elementor_conditional->is_met(),
2✔
178
                                'jetpack_integration_active'         => $jetpack_conditional->is_met(),
2✔
179
                                'woocommerce_seo_installed'          => $woocommerce_seo_installed,
2✔
180
                                'woocommerce_seo_active'             => $woocommerce_seo_active,
2✔
181
                                'woocommerce_active'                 => $woocommerce_active,
2✔
182
                                'woocommerce_seo_activate_url'       => $woocommerce_seo_activate_url,
2✔
183
                                'acf_seo_installed'                  => $acf_seo_installed || $acf_seo_github_installed,
2✔
184
                                'acf_seo_active'                     => $acf_seo_active || $acf_seo_github_active,
2✔
185
                                'acf_active'                         => $acf_active,
2✔
186
                                'acf_seo_activate_url'               => $acf_seo_activate_url,
2✔
187
                                'acf_seo_install_url'                => $acf_seo_install_url,
2✔
188
                                'algolia_active'                     => $algolia_active || $old_algolia_active,
2✔
189
                                'edd_integration_active'             => $edd_active,
2✔
190
                                'ssp_integration_active'             => $ssp_active,
2✔
191
                                'tec_integration_active'             => $tec_active,
2✔
192
                                'wp-recipe-maker_integration_active' => $wp_recipe_maker_active,
2✔
193
                                'mastodon_active'                    => $mastodon_active,
2✔
194
                                'is_multisite'                       => \is_multisite(),
2✔
195
                                'plugin_url'                         => \plugins_url( '', \WPSEO_FILE ),
2✔
196
                        ]
1✔
197
                );
1✔
198
        }
1✔
199

200
        /**
201
         * Renders the target for the React to mount to.
202
         *
203
         * @return void
204
         */
205
        public function render_target() {
×
206
                ?>
207
                <div class="wrap yoast wpseo-admin-page page-wpseo">
×
208
                        <div class="wp-header-end" style="height: 0; width: 0;"></div>
209
                        <div id="wpseo-integrations"></div>
210
                </div>
211
                <?php
212
        }
213

214
        /**
215
         * Checks whether the Mastodon profile field has been filled in.
216
         *
217
         * @return bool
218
         */
219
        private function is_mastodon_active() {
2✔
220
                return \apply_filters( 'wpseo_mastodon_active', false );
2✔
221
        }
222
}
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