Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function get_reference_entity_from_url( $url ) {
*
* @since 1.0.0
*
* @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`.
* @param int|\WP_Post $post Optional. Post ID or post object. Default is the global `$post`.
*
* @return string|false The reference permalink URL or false if post does not exist.
*/
Expand Down
2 changes: 1 addition & 1 deletion includes/Core/Admin_Bar/Admin_Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private function get_rest_routes() {
$this->admin_bar_enabled->set( ! empty( $data['enabled'] ) );
}

return $settings_callback( $request );
return $settings_callback();
},
'permission_callback' => $can_authenticate,
'args' => array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class Insufficient_Scopes_Exception extends Exception implements WP_Errorable {
*
* @since 1.9.0
*
* @param string $message Optional. Exception message.
* @param int $code Optional. Exception code.
* @param Throwable $previous Optional. Previous exception used for chaining.
* @param array $scopes Optional. Scopes that are missing.
* @param string $message Optional. Exception message.
* @param int $code Optional. Exception code.
* @param \Throwable $previous Optional. Previous exception used for chaining.
* @param array $scopes Optional. Scopes that are missing.
*/
public function __construct( $message = '', $code = 0, $previous = null, $scopes = array() ) {
parent::__construct( $message, $code, $previous );
Expand Down
2 changes: 1 addition & 1 deletion includes/Core/Consent_Mode/Consent_Mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function install_activate_wp_consent_api() {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // For Plugin_Upgrader and Plugin_Installer_Skin.
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // For plugins_api.

$api = plugins_api(
$api = (object) plugins_api(
'plugin_information',
array(
'slug' => $slug,
Expand Down
4 changes: 3 additions & 1 deletion includes/Core/Modules/Datapoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Google\Site_Kit\Core\Modules;

use Google\Site_Kit_Dependencies\Google\Service as Google_Service;

/**
* Class representing a datapoint definition.
*
Expand Down Expand Up @@ -97,7 +99,7 @@ public function is_shareable() {
*
* @since 1.77.0
*
* @return string
* @return string|Google_Service
*/
protected function get_service() {
$service = $this->service;
Expand Down
13 changes: 7 additions & 6 deletions includes/Core/Modules/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,13 @@ private function get_oauth_client_for_datapoint( Datapoint $datapoint ) {
*
* @since 1.0.0
*
* @param string $identifier Identifier for the service.
* @return Google_Service Google service instance.
* @template T of Google_Service
* @param class-string<T> $class_name Identifier for the service.
* @return T Google service instance.
*
* @throws Exception Thrown when the module did not correctly set up the services or when the identifier is invalid.
*/
final protected function get_service( $identifier ) {
final protected function get_service( $class_name ) {
if ( null === $this->google_services ) {
$services = $this->setup_services( $this->get_client() );
if ( ! is_array( $services ) ) {
Expand All @@ -549,12 +550,12 @@ final protected function get_service( $identifier ) {
$this->google_services = $services;
}

if ( ! isset( $this->google_services[ $identifier ] ) ) {
if ( ! isset( $this->google_services[ $class_name ] ) ) {
/* translators: %s: service identifier */
throw new Exception( sprintf( __( 'Google service identified by %s does not exist.', 'google-site-kit' ), $identifier ) );
throw new Exception( sprintf( __( 'Google service identified by %s does not exist.', 'google-site-kit' ), $class_name ) );
}

return $this->google_services[ $identifier ];
return $this->google_services[ $class_name ];
}

/**
Expand Down
7 changes: 4 additions & 3 deletions includes/Core/Modules/Module_With_Settings_Trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Trait for a module that includes a screen.
*
* @since 1.2.0
* @template T of Module_Settings
* @access private
* @ignore
*/
Expand All @@ -24,7 +25,7 @@ trait Module_With_Settings_Trait {
*
* @since 1.2.0
*
* @var Module_Settings
* @var T
*/
protected $settings;

Expand All @@ -33,7 +34,7 @@ trait Module_With_Settings_Trait {
*
* @since 1.2.0
*
* @return Module_Settings
* @return T
*/
abstract protected function setup_settings();

Expand All @@ -42,7 +43,7 @@ abstract protected function setup_settings();
*
* @since 1.2.0
*
* @return Module_Settings Module_Settings instance.
* @return T Module_Settings instance.
*/
public function get_settings() {
if ( ! $this->settings instanceof Module_Settings ) {
Expand Down
10 changes: 10 additions & 0 deletions includes/Core/Modules/Module_With_Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ public function register_tag();
* @return Module_Tag_Matchers Module_Tag_Matchers instance.
*/
public function get_tag_matchers();

/**
* Checks if the module tag is found in the provided content.
*
* @since n.e.x.t
*
* @param string $content Content to search for the tags.
* @return bool TRUE if tag is found, FALSE if not.
*/
public function has_placed_tag_in_content( $content );
}
6 changes: 3 additions & 3 deletions includes/Core/Modules/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function ( $value, $module_slug ) use ( $old_values ) {

if ( ! $module instanceof Module_With_Service_Entity ) {
// If the option was just added, set the ownerID directly and bail.
if ( empty( $old_values ) ) {
if ( empty( $old_values ) && $module instanceof Module_With_Settings ) {
$module->get_settings()->merge(
array(
'ownerID' => get_current_user_id(),
Expand Down Expand Up @@ -357,7 +357,7 @@ function ( $setting, $setting_key ) use ( $old_values, $module_slug, &$changed_s
);
}

if ( $changed_settings ) {
if ( $changed_settings && $module instanceof Module_With_Settings ) {
$module->get_settings()->merge(
array(
'ownerID' => get_current_user_id(),
Expand Down Expand Up @@ -432,7 +432,7 @@ public function get_module_sharing_settings() {
* @since 1.0.0
* @since 1.85.0 Filter out modules which are missing any of the dependencies specified in `depends_on`.
*
* @return array Available modules as $slug => $module pairs.
* @return Module[] Available modules as $slug => $module pairs.
*/
public function get_available_modules() {
if ( empty( $this->modules ) ) {
Expand Down
17 changes: 10 additions & 7 deletions includes/Core/Modules/REST_Modules_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,17 @@ private function get_rest_routes() {
continue;
}

// Update the module's ownerID to the ID of the user making the request.
$module_setting_updates = array(
'ownerID' => get_current_user_id(),
);
$recovered_module = $module->get_settings()->merge( $module_setting_updates );
if ( $module instanceof Module_With_Settings ) {
// Update the module's ownerID to the ID of the user making the request.
$module_setting_updates = array(
'ownerID' => get_current_user_id(),
);

if ( $recovered_module ) {
$response['success'][ $slug ] = true;
$recovered_module = $module->get_settings()->merge( $module_setting_updates );

if ( $recovered_module ) {
$response['success'][ $slug ] = true;
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions includes/Core/Site_Health/Tag_Placement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

namespace Google\Site_Kit\Core\Site_Health;

use Google\Site_Kit\Core\Modules\Module;
use Google\Site_Kit\Core\Modules\Modules;
use Google\Site_Kit\Core\Modules\Module_With_Tag;
use Google\Site_Kit\Core\Modules\Tags\Module_Tag_Matchers;
use Google\Site_Kit\Core\REST_API\REST_Routes;
use Google\Site_Kit\Core\Tags\Guards\Tag_Environment_Type_Guard;
use Google\Site_Kit\Core\Util\Method_Proxy_Trait;
use Google\Site_Kit\Modules\Analytics_4;

/**
* Class for integrating status tab information with Site Health.
Expand Down Expand Up @@ -212,9 +212,9 @@ function ( $module ) {
*
* @since 1.119.0
*
* @param Module_With_Tag $module Module instance.
* @param string $content Content to search for the tags.
* @param string $module_label Content URL page name appended to the module name to identify multiple tags for a module.
* @param Module_With_Tag|Module $module Module instance.
* @param string $content Content to search for the tags.
* @param string $module_label Content URL page name appended to the module name to identify multiple tags for a module.
*
* @return bool TRUE if tag is found, FALSE if not.
*/
Expand Down
2 changes: 1 addition & 1 deletion includes/Core/Tags/Guards/Tag_Verify_Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct( Input $input ) {
*
* @since 1.24.0
*
* @return bool|WP_Error TRUE if guarded tag can be activated, otherwise FALSE or an error.
* @return bool|\WP_Error TRUE if guarded tag can be activated, otherwise FALSE or an error.
*/
public function can_activate() {
return ! $this->input->filter( INPUT_GET, 'tagverify', FILTER_VALIDATE_BOOLEAN );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private function get_rest_routes( $routes ) {

$this->consent->set( $enabled );

return $tracking_callback( $request );
return $tracking_callback();
},
'permission_callback' => $can_access_tracking,
'args' => array(
Expand Down
6 changes: 3 additions & 3 deletions includes/Core/User_Input/User_Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function register() {
* @return array The user input questions.
*/
public static function get_questions() {
return static::$questions;
return self::$questions;
}

/**
Expand All @@ -142,7 +142,7 @@ public static function get_questions() {
* @return array|WP_Error User input answers.
*/
public function get_answers() {
$questions = static::$questions;
$questions = self::$questions;
$site_answers = $this->site_specific_answers->get();
$user_answers = $this->user_specific_answers->get();

Expand Down Expand Up @@ -238,7 +238,7 @@ public function set_answers( $settings ) {
foreach ( $settings as $setting_key => $answers ) {
$setting_data = array();
$setting_data['values'] = $answers;
$setting_data['scope'] = static::$questions[ $setting_key ]['scope'];
$setting_data['scope'] = self::$questions[ $setting_key ]['scope'];

if ( 'site' === $setting_data['scope'] ) {
$existing_answers = $this->get_answers();
Expand Down
2 changes: 1 addition & 1 deletion includes/Core/Util/Auto_Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Auto_Updates {
* Auto updated not forced.
*
* @since 1.93.0
* @var false
* @var null
*/
const AUTO_UPDATE_NOT_FORCED = null;

Expand Down
2 changes: 1 addition & 1 deletion includes/Core/Util/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Date {
*
* @param string $range Date range string. Either 'last-7-days', 'last-14-days', 'last-90-days', or
* 'last-28-days' (default).
* @param string $multiplier Optional. How many times the date range to get. This value can be specified if the
* @param int $multiplier Optional. How many times the date range to get. This value can be specified if the
* range should be request multiple times back. Default 1.
* @param int $offset Days the range should be offset by. Default 1. Used by Search Console where
* data is delayed by two days.
Expand Down
10 changes: 5 additions & 5 deletions includes/Core/Util/Feature_Flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Feature_Flags {
* @return bool
*/
public static function enabled( $feature ) {
if ( ! $feature || ! is_string( $feature ) || empty( static::$features ) ) {
if ( ! $feature || ! is_string( $feature ) || empty( self::$features ) ) {
return false;
}

Expand Down Expand Up @@ -66,8 +66,8 @@ public static function enabled( $feature ) {
public static function get_enabled_features() {
$enabled_features = array();

foreach ( static::$features as $feature_name ) {
if ( static::enabled( $feature_name ) ) {
foreach ( self::$features as $feature_name ) {
if ( self::enabled( $feature_name ) ) {
$enabled_features[] = $feature_name;
}
}
Expand All @@ -84,7 +84,7 @@ public static function get_enabled_features() {
*/
public static function set_features( $features ) {
if ( is_array( $features ) || $features instanceof ArrayAccess ) {
static::$features = $features;
self::$features = $features;
}
}

Expand All @@ -96,6 +96,6 @@ public static function set_features( $features ) {
* @return array An array of all available features.
*/
public static function get_available_features() {
return static::$features;
return self::$features;
}
}
1 change: 1 addition & 0 deletions includes/Core/Util/Health_Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Exception;
use Google\Site_Kit\Core\Authentication\Authentication;
use Google\Site_Kit\Core\Authentication\Google_Proxy;
use Google\Site_Kit\Core\Permissions\Permissions;
use Google\Site_Kit\Core\REST_API\REST_Route;
use Google\Site_Kit_Dependencies\Google\Service\SearchConsole as Google_Service_SearchConsole;
Expand Down
Loading