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

Yoast / wordpress-seo / d6fd498912430cf12e405e4df66ee8b29264fd73

03 Feb 2025 03:07PM UTC coverage: 54.505% (-3.1%) from 57.608%
d6fd498912430cf12e405e4df66ee8b29264fd73

Pull #21978

github

web-flow
Merge d7065dd6d into 3e955d7f5
Pull Request #21978: 402 implement site kit setup flow

7761 of 13798 branches covered (56.25%)

Branch coverage included in aggregate %.

29 of 48 new or added lines in 6 files covered. (60.42%)

1 existing line in 1 file now uncovered.

30194 of 55838 relevant lines covered (54.07%)

41205.31 hits per line

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

0.0
/src/dashboard/infrastructure/integrations/site-kit.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Integrations;
4

5
use Yoast\WP\SEO\Conditionals\Google_Site_Kit_Feature_Conditional;
6
use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface;
7
use Yoast\WP\SEO\Helpers\Options_Helper;
8

9
/**
10
 * Describes if the Site kit integration is enabled and configured.
11
 */
12
class Site_Kit implements Integration_Data_Provider_Interface {
13

14
        private const SITE_KIT_FILE = 'google-site-kit/google-site-kit.php';
15

16
        /**
17
         * The options helper.
18
         *
19
         * @var Options_Helper
20
         */
21
        private $options_helper;
22

23
        /**
24
         * The constructor.
25
         *
26
         * @param Options_Helper $options_helper The options helper.
27
         */
28
        public function __construct( Options_Helper $options_helper ) {
×
29
                $this->options_helper = $options_helper;
×
30
        }
31

32
        /**
33
         * If the integration is activated.
34
         *
35
         * @return bool If the integration is activated.
36
         */
37
        public function is_enabled(): bool {
×
38
                return \is_plugin_active( self::SITE_KIT_FILE );
×
39
        }
40

41
        /**
42
         * Return this object represented by a key value array.
43
         *
44
         * @return array<string,bool> Returns the name and if the feature is enabled.
45
         */
46
        public function to_array(): array {
×
47
                $site_kit_activate_url = \html_entity_decode(
×
48
                        \wp_nonce_url(
×
49
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . self::SITE_KIT_FILE ),
×
50
                                'activate-plugin_' . self::SITE_KIT_FILE
×
51
                        )
52
                );
53

54
                $site_kit_install_url = \html_entity_decode(
×
55
                        \wp_nonce_url(
×
56
                                \self_admin_url( 'update.php?action=install-plugin&plugin=google-site-kit' ),
×
57
                                'install-plugin_google-site-kit'
×
58
                        )
59
                );
60

61
                $site_kit_setup_url = \self_admin_url( 'admin.php?page=googlesitekit-splash' );
×
62

63
                return [
NEW
64
                        'isInstalled'      => \file_exists( \WP_PLUGIN_DIR . '/' . self::SITE_KIT_FILE ),
×
NEW
65
                        'isActive'         => \is_plugin_active( self::SITE_KIT_FILE ),
×
NEW
66
                        'isSetupCompleted' => \get_option( 'googlesitekit_has_connected_admins', false ) === '1',
×
NEW
67
                        'isConnected'      => $this->options_helper->get( 'google_site_kit_connected', false ),
×
NEW
68
                        'isFeatureEnabled' => ( new Google_Site_Kit_Feature_Conditional() )->is_met(),
×
NEW
69
                        'installUrl'       => $site_kit_install_url,
×
NEW
70
                        'activateUrl'      => $site_kit_activate_url,
×
NEW
71
                        'setupUrl'         => $site_kit_setup_url,
×
72
                ];
73
        }
74

75
        /**
76
         * Return this object represented by a key value array.
77
         *
78
         * @return array<string,bool> Returns the name and if the feature is enabled.
79
         */
80
        public function to_legacy_array(): array {
×
81
                return $this->to_array();
×
82
        }
83
}
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