Does WordPress have an Browser Agent?

The WordPress user agent is set in the class WP_Http as

'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )

You can set it to a (secret) fixed value per filter:

add_filter( 'http_headers_useragent', 'wpse_59788_user_agent' );
function wpse_59788_user_agent()
{
    // to remove this filter immediately uncomment the following line
    // remove_filter( current_filter(), __FUNCTION__ );
    return 'alfgjlkgjlkgjsldkjhrkjh';
}

To change the user agent for a plugin upgrade only try something like this (not tested):

add_filter( 'upgrader_pre_install', 'wpse_59788_register' );
function wpse_59788_register( $dummy )
{
    add_filter( 'http_headers_useragent', 'wpse_59788_user_agent' );
    return $dummy;
}

And uncomment the self deactivation line in the first function.

Leave a Comment