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

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

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

0.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_Admin_Asset_Manager;
10
use WPSEO_Plugin_Availability;
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\Conditionals\WooCommerce_Conditional;
18
use Yoast\WP\SEO\Helpers\Options_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 admin asset manager.
28
         *
29
         * @var WPSEO_Admin_Asset_Manager
30
         */
31
        private $admin_asset_manager;
32

33
        /**
34
         * The options helper.
35
         *
36
         * @var Options_Helper
37
         */
38
        private $options_helper;
39

40
        /**
41
         * {@inheritDoc}
42
         */
43
        public static function get_conditionals() {
×
44
                return [ Admin_Conditional::class ];
×
45
        }
46

47
        /**
48
         * Workouts_Integration constructor.
49
         *
50
         * @param WPSEO_Admin_Asset_Manager $admin_asset_manager The admin asset manager.
51
         * @param Options_Helper            $options_helper      The options helper.
52
         */
53
        public function __construct(
×
54
                WPSEO_Admin_Asset_Manager $admin_asset_manager,
55
                Options_Helper $options_helper
56
        ) {
57
                $this->admin_asset_manager = $admin_asset_manager;
×
58
                $this->options_helper      = $options_helper;
×
59
        }
60

61
        /**
62
         * {@inheritDoc}
63
         */
64
        public function register_hooks() {
×
65
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 10 );
×
66
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ], 11 );
×
67
        }
68

69
        /**
70
         * Adds the integrations submenu page.
71
         *
72
         * @param array $submenu_pages The Yoast SEO submenu pages.
73
         *
74
         * @return array The filtered submenu pages.
75
         */
76
        public function add_submenu_page( $submenu_pages ) {
×
77
                $integrations_page = [
78
                        'wpseo_dashboard',
×
79
                        '',
×
80
                        \__( 'Integrations', 'wordpress-seo' ),
×
81
                        'wpseo_manage_options',
×
82
                        'wpseo_integrations',
×
83
                        [ $this, 'render_target' ],
×
84
                ];
85

86
                \array_splice( $submenu_pages, 1, 0, [ $integrations_page ] );
×
87

88
                return $submenu_pages;
×
89
        }
90

91
        /**
92
         * Enqueue the integrations app.
93
         */
94
        public function enqueue_assets() {
×
95
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
96
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_integrations' ) {
×
97
                        return;
×
98
                }
99

100
                $this->admin_asset_manager->enqueue_style( 'admin-css' );
×
101
                $this->admin_asset_manager->enqueue_style( 'tailwind' );
×
102
                $this->admin_asset_manager->enqueue_style( 'monorepo' );
×
103

104
                $this->admin_asset_manager->enqueue_script( 'integrations-page' );
×
105

106
                $elementor_conditional                 = new Elementor_Activated_Conditional();
×
107
                $jetpack_conditional                   = new Jetpack_Conditional();
×
108
                $woocommerce_conditional               = new WooCommerce_Conditional();
×
109
                $jetpack_boost_active_conditional      = new Jetpack_Boost_Active_Conditional();
×
110
                $jetpack_boost_not_premium_conditional = new Jetpack_Boost_Not_Premium_Conditional();
×
111

112
                $woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php';
×
113
                $acf_seo_file         = 'acf-content-analysis-for-yoast-seo/yoast-acf-analysis.php';
×
114
                $acf_seo_file_github  = 'yoast-acf-analysis/yoast-acf-analysis.php';
×
115
                $algolia_file         = 'wp-search-with-algolia/algolia.php';
×
116
                $old_algolia_file     = 'search-by-algolia-instant-relevant-results/algolia.php';
×
117

118
                $host = \YoastSEO()->helpers->url->get_url_host( \get_site_url() );
×
119

120
                $wpseo_plugin_availability_checker = new WPSEO_Plugin_Availability();
×
121
                $woocommerce_seo_installed         = \file_exists( \WP_PLUGIN_DIR . '/' . $woocommerce_seo_file );
×
122
                $woocommerce_seo_active            = $wpseo_plugin_availability_checker->is_active( $woocommerce_seo_file );
×
123
                $woocommerce_active                = $woocommerce_conditional->is_met();
×
124
                $acf_seo_installed                 = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file );
×
125
                $acf_seo_github_installed          = \file_exists( \WP_PLUGIN_DIR . '/' . $acf_seo_file_github );
×
126
                $acf_seo_active                    = $wpseo_plugin_availability_checker->is_active( $acf_seo_file );
×
127
                $acf_seo_github_active             = $wpseo_plugin_availability_checker->is_active( $acf_seo_file_github );
×
128
                $acf_active                        = \class_exists( 'acf' );
×
129
                $algolia_active                    = $wpseo_plugin_availability_checker->is_active( $algolia_file );
×
130
                $edd_active                        = \class_exists( Easy_Digital_Downloads::class );
×
131
                $jetpack_boost_active              = $jetpack_boost_active_conditional->is_met();
×
132
                $jetpack_boost_premium             = ( ! $jetpack_boost_not_premium_conditional->is_met() );
×
133
                $old_algolia_active                = $wpseo_plugin_availability_checker->is_active( $old_algolia_file );
×
134
                $tec_active                        = \class_exists( Events_Schema::class );
×
135
                $ssp_active                        = \class_exists( PodcastEpisode::class );
×
136
                $wp_recipe_maker_active            = \class_exists( WP_Recipe_Maker::class );
×
137
                $mastodon_active                   = $this->is_mastodon_active();
×
138

139
                $woocommerce_seo_activate_url = \wp_nonce_url(
×
140
                        \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ),
×
141
                        'activate-plugin_' . $woocommerce_seo_file
×
142
                );
143

144
                if ( $acf_seo_installed ) {
×
145
                        $acf_seo_activate_url = \wp_nonce_url(
×
146
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file ),
×
147
                                'activate-plugin_' . $acf_seo_file
×
148
                        );
149
                }
150
                else {
151
                        $acf_seo_activate_url = \wp_nonce_url(
×
152
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . $acf_seo_file_github ),
×
153
                                'activate-plugin_' . $acf_seo_file_github
×
154
                        );
155
                }
156

157
                $acf_seo_install_url = \wp_nonce_url(
×
158
                        \self_admin_url( 'update.php?action=install-plugin&plugin=acf-content-analysis-for-yoast-seo' ),
×
159
                        'install-plugin_acf-content-analysis-for-yoast-seo'
×
160
                );
161

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

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

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

© 2025 Coveralls, Inc