make user agent dynamic with changes to plugin's Text Domainand Version

This commit is contained in:
2025-06-01 19:19:36 +01:00
parent f913cb1f6d
commit f0f2814d35

View File

@@ -57,9 +57,15 @@ function dsi_get_status() : bool {
return (bool) $cached; return (bool) $cached;
} }
// Get plugin data for dynamic user agent
$plugin_data = get_file_data( __FILE__, array(
'Version' => 'Version',
'TextDomain' => 'Text Domain'
), 'plugin' );
$response = wp_remote_get( DSI_API_URL, [ $response = wp_remote_get( DSI_API_URL, [
'timeout' => 3, 'timeout' => 3,
'user-agent' => 'DoorStatusIndicator/1.1.1 (+https://wordpress.org/)', 'user-agent' => $plugin_data['TextDomain'] . '/' . $plugin_data['Version'] . ' (+https://wordpress.org/)',
] ); ] );
if ( is_wp_error( $response ) ) { if ( is_wp_error( $response ) ) {