Skip to content

Commit

Permalink
Add First-Party Mode site health and value helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
benbowler committed Dec 2, 2024
1 parent d129dca commit fab5ce0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
9 changes: 8 additions & 1 deletion includes/Core/Site_Health/Debug_Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Google\Site_Kit\Core\Storage\Options;
use Google\Site_Kit\Core\Storage\User_Options;
use Google\Site_Kit\Core\Permissions\Permissions;
use Google\Site_Kit\Core\Tags\First_Party_Mode\First_Party_Mode;
use Google\Site_Kit\Core\Util\Feature_Flags;
use Google\Site_Kit\Core\Util\Scopes;

Expand Down Expand Up @@ -559,7 +560,13 @@ function ( Module_With_Debug_Fields $module ) {
array_values( $modules_with_debug_fields )
);

return array_merge( array(), ...$fields_by_module );
if ( Feature_Flags::enabled( 'firstPartyMode' ) ) {
// First-Party Mode is not a module so it's debug fields must be added here.
$first_party_mode = new First_Party_Mode( $this->context );
$fields_from_first_party_mode = $first_party_mode->get_debug_fields();
}

return array_merge( array(), $fields_from_first_party_mode, ...$fields_by_module );
}

/**
Expand Down
22 changes: 21 additions & 1 deletion includes/Core/Tags/First_Party_Mode/First_Party_Mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Google\Site_Kit\Core\Tags\First_Party_Mode;

use Google\Site_Kit\Context;
use Google\Site_Kit\Core\Modules\Module_With_Debug_Fields;
use Google\Site_Kit\Core\Storage\Options;
use Google\Site_Kit\Core\Util\Method_Proxy_Trait;

Expand All @@ -21,7 +22,7 @@
* @access private
* @ignore
*/
class First_Party_Mode {
class First_Party_Mode implements Module_With_Debug_Fields {
use Method_Proxy_Trait;

/**
Expand Down Expand Up @@ -72,4 +73,23 @@ public function register() {
$this->first_party_mode_settings->register();
$this->rest_controller->register();
}

/**
* Gets an array of debug field definitions.
*
* @since n.e.x.t
*
* @return array
*/
public function get_debug_fields() {
$settings = $this->first_party_mode_settings->get();

return array(
'first_party_mode_is_enabled' => array(
'label' => __( 'First Party Mode: Enabled', 'google-site-kit' ),
'value' => $settings['isEnabled'] ? __( 'Yes', 'google-site-kit' ) : __( 'No', 'google-site-kit' ),
'debug' => $settings['isEnabled'] ? 'yes' : 'no',
),
);
}
}

0 comments on commit fab5ce0

Please sign in to comment.