This commit is contained in:
Javier Casares 2026-08-20 14:31:43 +00:00
commit e4518812c3

View file

@ -33,22 +33,22 @@ if ( ! class_exists( 'Robotstxt_Telemetry_Network' ) ) {
/**
* Plugin settings and their defaults.
*
* @var array
* @var array<string,mixed>
*/
const SETTINGS = array(
'robotstxt_telemetry_useragent_url' => 'hash',
'robotstxt_telemetry_wp_version' => 'actual',
'robotstxt_telemetry_mask_locale' => false,
'robotstxt_telemetry_replace_news_feed' => true,
'robotstxt_telemetry_replace_events_api' => true,
'robotstxt_telemetry_disable_browse_happy' => true,
'robotstxt_telemetry_wp_core_check' => 'safe',
'robotstxt_telemetry_wp_themes_check' => 'safe',
'robotstxt_telemetry_wp_plugins_check' => 'safe',
'robotstxt_telemetry_hidden_plugins' => array(),
'robotstxt_telemetry_plugin_modes' => array(),
'robotstxt_telemetry_retention_period' => '12hours',
'robotstxt_telemetry_delete_on_uninstall' => false,
'robotstxt_telemetry_useragent_url' => 'hash',
'robotstxt_telemetry_wp_version' => 'actual',
'robotstxt_telemetry_mask_locale' => false,
'robotstxt_telemetry_replace_news_feed' => true,
'robotstxt_telemetry_replace_events_api' => true,
'robotstxt_telemetry_disable_browse_happy' => true,
'robotstxt_telemetry_wp_core_check' => 'safe',
'robotstxt_telemetry_wp_themes_check' => 'safe',
'robotstxt_telemetry_wp_plugins_check' => 'safe',
'robotstxt_telemetry_hidden_plugins' => array(),
'robotstxt_telemetry_plugin_modes' => array(),
'robotstxt_telemetry_retention_period' => '12hours',
'robotstxt_telemetry_delete_on_uninstall' => false,
);
/**
@ -134,6 +134,9 @@ if ( ! class_exists( 'Robotstxt_Telemetry_Network' ) ) {
/**
* The main site ID of the current network.
*
* On WordPress 4.8 and older the current network object exposes the
* main site ID through its magic "blog_id" property.
*
* @return int
*/
public static function main_site_id() {
@ -143,7 +146,9 @@ if ( ! class_exists( 'Robotstxt_Telemetry_Network' ) ) {
$current_site = get_current_site();
return max( 1, (int) $current_site->blog_id );
$blog_id = isset( $current_site->blog_id ) ? (int) $current_site->blog_id : 0;
return max( 1, $blog_id );
}
/**
@ -194,10 +199,15 @@ if ( ! class_exists( 'Robotstxt_Telemetry_Network' ) ) {
* @return string[]
*/
public static function get_hidden_plugins() {
$hidden = self::get_setting( 'robotstxt_telemetry_hidden_plugins', array() );
$stored = self::get_setting( 'robotstxt_telemetry_hidden_plugins', array() );
$hidden = array();
if ( ! is_array( $hidden ) ) {
$hidden = array();
if ( is_array( $stored ) ) {
foreach ( $stored as $basename ) {
if ( is_string( $basename ) ) {
$hidden[] = $basename;
}
}
}
$hidden[] = 'robotstxt-telemetry/robotstxt-telemetry.php';
@ -208,12 +218,24 @@ if ( ! class_exists( 'Robotstxt_Telemetry_Network' ) ) {
/**
* Get the per-plugin safe-mode map (slug => safe|original).
*
* @return array
* @return array<string,string>
*/
public static function get_plugin_modes() {
$modes = self::get_setting( 'robotstxt_telemetry_plugin_modes', array() );
$stored = self::get_setting( 'robotstxt_telemetry_plugin_modes', array() );
return is_array( $modes ) ? $modes : array();
if ( ! is_array( $stored ) ) {
return array();
}
$modes = array();
foreach ( $stored as $slug => $mode ) {
if ( is_string( $slug ) && is_string( $mode ) ) {
$modes[ $slug ] = $mode;
}
}
return $modes;
}
/**