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

Yoast / wordpress-seo / 711656c237bc76273e323a92b5c22383c654a26f

14 Feb 2025 12:38PM UTC coverage: 54.636%. First build
711656c237bc76273e323a92b5c22383c654a26f

push

github

web-flow
Merge pull request #22040 from Yoast/450-implement-the-permanently-dismiss-in-the-site-kit-setup-widget

Implement permanent dismiss Site Kit setup widget

7804 of 13861 branches covered (56.3%)

Branch coverage included in aggregate %.

6 of 22 new or added lines in 5 files covered. (27.27%)

30390 of 56045 relevant lines covered (54.22%)

41053.1 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\Dashboard\Infrastructure\Configuration\Permanently_Dismissed_Site_Kit_Configuration_Repository_Interface;
7
use Yoast\WP\SEO\Dashboard\Infrastructure\Configuration\Site_Kit_Consent_Repository_Interface;
8
use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface;
9

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

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

17
        /**
18
         * The Site Kit consent repository.
19
         *
20
         * @var Site_Kit_Consent_Repository_Interface
21
         */
22
        private $site_kit_consent_repository;
23

24
        /**
25
         * The Site Kit consent repository.
26
         *
27
         * @var Permanently_Dismissed_Site_Kit_Configuration_Repository_Interface
28
         */
29
        private $permanently_dismissed_site_kit_configuration_repository;
30

31
        /**
32
         * The constructor.
33
         *
34
         * @param Site_Kit_Consent_Repository_Interface                             $site_kit_consent_repository                             The
35
         *                                                                                                                                   Site
36
         *                                                                                                                                   Kit
37
         *                                                                                                                                   consent
38
         *                                                                                                                                   repository.
39
         * @param Permanently_Dismissed_Site_Kit_Configuration_Repository_Interface $permanently_dismissed_site_kit_configuration_repository The
40
         *                                                                                                                                   Site
41
         *                                                                                                                                   Kit
42
         *                                                                                                                                   permanently
43
         *                                                                                                                                   dismissed
44
         *                                                                                                                                   configuration
45
         *                                                                                                                                   repository.
46
         */
NEW
47
        public function __construct(
×
48
                Site_Kit_Consent_Repository_Interface $site_kit_consent_repository,
49
                Permanently_Dismissed_Site_Kit_Configuration_Repository_Interface $permanently_dismissed_site_kit_configuration_repository
50
        ) {
NEW
51
                $this->site_kit_consent_repository                             = $site_kit_consent_repository;
×
NEW
52
                $this->permanently_dismissed_site_kit_configuration_repository = $permanently_dismissed_site_kit_configuration_repository;
×
53
        }
54

55
        /**
56
         * If the integration is activated.
57
         *
58
         * @return bool If the integration is activated.
59
         */
60
        public function is_enabled(): bool {
×
61
                return \is_plugin_active( self::SITE_KIT_FILE );
×
62
        }
63

64
        /**
65
         * Return this object represented by a key value array.
66
         *
67
         * @return array<string,bool> Returns the name and if the feature is enabled.
68
         */
69
        public function to_array(): array {
×
70
                $site_kit_activate_url = \html_entity_decode(
×
71
                        \wp_nonce_url(
×
72
                                \self_admin_url( 'plugins.php?action=activate&plugin=' . self::SITE_KIT_FILE ),
×
73
                                'activate-plugin_' . self::SITE_KIT_FILE
×
74
                        )
75
                );
76

77
                $site_kit_install_url = \html_entity_decode(
×
78
                        \wp_nonce_url(
×
79
                                \self_admin_url( 'update.php?action=install-plugin&plugin=google-site-kit' ),
×
80
                                'install-plugin_google-site-kit'
×
81
                        )
82
                );
83

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

86
                return [
NEW
87
                        'isInstalled'              => \file_exists( \WP_PLUGIN_DIR . '/' . self::SITE_KIT_FILE ),
×
NEW
88
                        'isActive'                 => \is_plugin_active( self::SITE_KIT_FILE ),
×
NEW
89
                        'isSetupCompleted'         => \get_option( 'googlesitekit_has_connected_admins', false ) === '1',
×
NEW
90
                        'isConnected'              => $this->site_kit_consent_repository->is_consent_granted(),
×
NEW
91
                        'isFeatureEnabled'         => ( new Google_Site_Kit_Feature_Conditional() )->is_met(),
×
NEW
92
                        'installUrl'               => $site_kit_install_url,
×
NEW
93
                        'activateUrl'              => $site_kit_activate_url,
×
NEW
94
                        'setupUrl'                 => $site_kit_setup_url,
×
NEW
95
                        'isConfigurationDismissed' => $this->permanently_dismissed_site_kit_configuration_repository->is_site_kit_configuration_dismissed(),
×
96
                ];
97
        }
98

99
        /**
100
         * Return this object represented by a key value array.
101
         *
102
         * @return array<string,bool> Returns the name and if the feature is enabled.
103
         */
104
        public function to_legacy_array(): array {
×
105
                return $this->to_array();
×
106
        }
107
}
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