classicpress_user_agent( bool $include_site_id = false )

Returns the ClassicPress User-Agent header for outgoing requests.


Description

In WordPress, this header looks like "WordPress/X.Y.Z; https://siteurl.com". To ensure compatibility with third-party services that expect requests to come from WordPress, ClassicPress uses the same pattern, but uses the URL to indicate that requests come from a ClassicPress site.


Parameters

$include_site_id

(bool) (Optional) Whether to include a site identifier (used when communicating with the ClassicPress API). This is not personally identifiable information.

Default value: false


Return

(string) The User-Agent header value.


Source

File: wp-includes/http.php

function classicpress_user_agent( $include_site_id = false ) {
	$url = 'https://www.classicpress.net/?wp_compatible=true'
		. '&ver=' . classicpress_version_short();

	if ( $include_site_id ) {
		$url .= '&site=' . sha1( preg_replace(
			'#^https?:#',
			'',
			strtolower( untrailingslashit( home_url( '/' ) ) )
		) );
	}

	$user_agent = 'WordPress/' . get_bloginfo( 'version' ) . '; ' . $url;

	/**
	 * Filters the user agent value sent with an HTTP request.
	 *
	 * @since WP-2.7.0
	 * @since 1.0.0 This filter is applied to all HTTP requests.
	 *
	 * @param string $user_agent ClassicPress user agent string.
	 */
	return apply_filters( 'http_headers_useragent', $user_agent );
}


Changelog

Changelog
Version Description
1.0.0 Introduced.