Skip to content

Commit 13fc00c

Browse files
committed
minor code tweaks from self review
1 parent e8396c5 commit 13fc00c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

classes/WpMatomo/Admin/TrackingSettings.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ public static function is_track_script_used_in_wp_config( $abspath_override = nu
8282
return null;
8383
}
8484

85+
// phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
8586
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
86-
$wp_config_contents = file_get_contents( $wp_config_path );
87+
$wp_config_contents = @file_get_contents( $wp_config_path );
8788

8889
// some systems may disable reading of files outside of wp-content
8990
if ( ! is_string( $wp_config_contents ) ) {

classes/WpMatomo/TrackingCode/TrackingCodeGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ function ( $host ) {
328328

329329
// set cookie via javascript cookie for known AI bots so we can skip tracking server side
330330
// for them.
331+
// NOTE: this must be done ONLY for known AI bots to be compliant with privacy regulations.
331332
$user_agent_substrings = wp_json_encode( AjaxTracker::AI_BOT_USER_AGENT_SUBSTRINGS );
332333
array_unshift(
333334
$options,

misc/track_ai_bot.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ function matomo_track_if_ai_bot() {
2525
if (
2626
( ! defined( 'WP_CACHE' ) || ! WP_CACHE )
2727
&& empty( $_GET['mtm_esi'] )
28-
) {
29-
return; // advanced-cache.php not in use
28+
) { // advanced-cache.php not in use and we are not tracking via esi:include
29+
return;
3030
}
3131

32-
if ( isset( $_GET['mtm_esi'] ) ) {
33-
$GLOBALS['MATOMO_IN_AI_ESI'] = true; // executing via esi:include directive
32+
if ( isset( $_GET['mtm_esi'] ) ) { // executing via esi:include directive
33+
$GLOBALS['MATOMO_IN_AI_ESI'] = true;
3434
}
3535

3636
require_once __DIR__ . '/../app/vendor/matomo/matomo-php-tracker/MatomoTracker.php';
3737

38-
// check user agent is AI bot first thing, so if it is a normal request, we do
38+
// check user agent is AI bot first thing, so if it is a normal request we do
3939
// as little extra work as possible
4040
$user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
4141
if ( ! MatomoTracker::isUserAgentAIBot( $user_agent ) ) {

0 commit comments

Comments
 (0)