Skip to content

Commit

Permalink
Onionize the config
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsoo committed Jan 27, 2025
1 parent cd61b49 commit f650be5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
9 changes: 4 additions & 5 deletions packages/js/src/integrations-page/recommended-integrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,15 @@ const RecommendedIntegrations = [
];

const googleSiteKitProps = {
isInstalled: get( window, "wpseoIntegrationsData.google_site_kit_configuration.installed", false ) === "1",
isActive: get( window, "wpseoIntegrationsData.google_site_kit_configuration.active", false ) === "1",
afterSetup: get( window, "wpseoIntegrationsData.google_site_kit_configuration.setup_completed", false ) === "1",
isConnected: get( window, "wpseoIntegrationsData.google_site_kit_configuration.connected", false ) === "1",
isInstalled: get( window, "wpseoIntegrationsData.google_site_kit_configuration.installed", false ),
isActive: get( window, "wpseoIntegrationsData.google_site_kit_configuration.active", false ),
afterSetup: get( window, "wpseoIntegrationsData.google_site_kit_configuration.setup_completed", false ),
isConnected: get( window, "wpseoIntegrationsData.google_site_kit_configuration.connected", false ),
installUrl: get( window, "wpseoIntegrationsData.google_site_kit_configuration.install_url", "" ),
activateUrl: get( window, "wpseoIntegrationsData.google_site_kit_configuration.activate_url", "" ),
setupUrl: get( window, "wpseoIntegrationsData.google_site_kit_configuration.setup_url", "" ),
};

console.log(get( window, "wpseoIntegrationsData.google_site_kit_configuration.installed", false ));

if ( isGoogleSiteKitFeatureEnabled ) {
RecommendedIntegrations.push( <GoogleSiteKitIntegration key={ integrations.length } { ...googleSiteKitProps } /> );
Expand Down
33 changes: 23 additions & 10 deletions src/dashboard/infrastructure/integrations/site-kit.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Integrations;

use Yoast\WP\SEO\Conditionals\Google_Site_Kit_Feature_Conditional;
use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface;
use Yoast\WP\SEO\Helpers\Options_Helper;

/**
* Describes if the Site kit integration is enabled and configured.
*/
class Site_Kit implements Integration_Data_Provider_Interface {

private const GOOGLE_SITE_KIT_FILE = 'google-site-kit/google-site-kit.php';
Expand All @@ -27,24 +30,32 @@ public function __construct( Options_Helper $options_helper ) {
}

/**
* @inheritDoc
* If the integration is activated.
*
* @return bool If the integration is activated.
*/
public function is_enabled(): bool {
return \is_plugin_active( self::GOOGLE_SITE_KIT_FILE );
}

/**
* @inheritDoc
* Return this object represented by a key value array.
*
* @return array<string,bool> Returns the name and if the feature is enabled.
*/
public function to_array(): array {
$google_site_kit_activate_url = \wp_nonce_url(
\self_admin_url( 'plugins.php?action=activate&plugin=' . self::GOOGLE_SITE_KIT_FILE ),
'activate-plugin_' . self::GOOGLE_SITE_KIT_FILE
$google_site_kit_activate_url = \html_entity_decode(
\wp_nonce_url(
\self_admin_url( 'plugins.php?action=activate&plugin=' . self::GOOGLE_SITE_KIT_FILE ),
'activate-plugin_' . self::GOOGLE_SITE_KIT_FILE
)
);

$google_site_kit_install_url = \wp_nonce_url(
\self_admin_url( 'update.php?action=install-plugin&plugin=google-site-kit' ),
'install-plugin_google-site-kit'
$google_site_kit_install_url = \html_entity_decode(
\wp_nonce_url(
\self_admin_url( 'update.php?action=install-plugin&plugin=google-site-kit' ),
'install-plugin_google-site-kit'
)
);

$google_site_kit_setup_url = \self_admin_url( 'admin.php?page=googlesitekit-splash' );
Expand All @@ -62,7 +73,9 @@ public function to_array(): array {
}

/**
* @inheritDoc
* Return this object represented by a key value array.
*
* @return array<string,bool> Returns the name and if the feature is enabled.
*/
public function to_legacy_array(): array {
return $this->to_array();
Expand Down

0 comments on commit f650be5

Please sign in to comment.