From e88962d8f83ef7408dc5563544ac70df39bd5f92 Mon Sep 17 00:00:00 2001 From: Mohammad Jangda <batmoo@gmail.com> Date: Wed, 3 Apr 2013 19:14:25 -0400 Subject: [PATCH] Send a custom user agent with our request so that sites with "mobile" in the name don't get redirected to the mobile theme. --- includes/class-wp-push-syndication-server.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/class-wp-push-syndication-server.php b/includes/class-wp-push-syndication-server.php index b97229e..2d541d8 100644 --- a/includes/class-wp-push-syndication-server.php +++ b/includes/class-wp-push-syndication-server.php @@ -4,6 +4,8 @@ require_once( dirname( __FILE__ ) . '/class-syndication-client-factory.php' ); class WP_Push_Syndication_Server { + const CUSTOM_USER_AGENT = 'WordPress/Syndication Plugin'; + public $push_syndicate_settings; public $push_syndicate_default_settings; public $push_syndicate_transports; @@ -1224,6 +1226,8 @@ class WP_Push_Syndication_Server { } public function pull_content( $sites ) { + add_filter( 'http_headers_useragent', array( $this, 'syndication_user_agent' ) ); + if ( empty( $sites ) ) $sites = $this->pull_get_selected_sites(); @@ -1294,6 +1298,12 @@ class WP_Push_Syndication_Server { update_post_meta( $site_id, 'syn_last_pull_time', current_time( 'timestamp', 1 ) ); } + + remove_filter( 'http_headers_useragent', array( $this, 'syndication_user_agent' ) ); + } + + public function syndication_user_agent( $user_agent ) { + return apply_filters( 'syn_pull_user_agent', self::CUSTOM_USER_AGENT ); } function find_post_by_guid( $guid, $post, $site ) { -- GitLab