From 230f4ad161046cab2eecd18af58b39247f79b139 Mon Sep 17 00:00:00 2001 From: Simon Wheatley Date: Tue, 14 Apr 2015 10:36:06 +0100 Subject: [PATCH 1/3] Save the site ID in the constructor, so we can use it later --- includes/class-syndication-wp-rss-client.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/class-syndication-wp-rss-client.php b/includes/class-syndication-wp-rss-client.php index bbff597..64305f2 100644 --- a/includes/class-syndication-wp-rss-client.php +++ b/includes/class-syndication-wp-rss-client.php @@ -10,6 +10,7 @@ class Syndication_WP_RSS_Client extends SimplePie implements Syndication_Client private $default_comment_status; private $default_ping_status; private $default_cat_status; + protected $site_id; function __construct( $site_ID ) { @@ -27,6 +28,8 @@ function __construct( $site_ID ) { parent::__construct(); + $this->site_id = $site_ID; + $this->set_feed_url( get_post_meta( $site_ID, 'syn_feed_url', true ) ); $this->default_post_type = get_post_meta( $site_ID, 'syn_default_post_type', true ); From 9fd481e6f6478fb0bcb2f0072de26382e478f252 Mon Sep 17 00:00:00 2001 From: Simon Wheatley Date: Tue, 14 Apr 2015 10:36:36 +0100 Subject: [PATCH 2/3] Pass the site ID into the `syn_rss_pull_filter_post` filter --- includes/class-syndication-wp-rss-client.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/class-syndication-wp-rss-client.php b/includes/class-syndication-wp-rss-client.php index 64305f2..a5441cb 100644 --- a/includes/class-syndication-wp-rss-client.php +++ b/includes/class-syndication-wp-rss-client.php @@ -202,8 +202,7 @@ public function get_posts( $args = array() ) { 'post_category' => $taxonomy['cats'], 'tags_input' => $taxonomy['tags'] ); - // This filter can be used to exclude or alter posts during a pull import - $post = apply_filters( 'syn_rss_pull_filter_post', $post, $args, $item ); + $post = apply_filters( 'syn_rss_pull_filter_post', $post, $args, $item, $this->site_id ); if ( false === $post ) continue; $posts[] = $post; From 58062d5802f914a62391b84820195a15e1a004bf Mon Sep 17 00:00:00 2001 From: Simon Wheatley Date: Tue, 14 Apr 2015 10:37:00 +0100 Subject: [PATCH 3/3] Add documentation for the `syn_rss_pull_filter_post` filter --- includes/class-syndication-wp-rss-client.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/class-syndication-wp-rss-client.php b/includes/class-syndication-wp-rss-client.php index a5441cb..6be4b3f 100644 --- a/includes/class-syndication-wp-rss-client.php +++ b/includes/class-syndication-wp-rss-client.php @@ -202,6 +202,18 @@ public function get_posts( $args = array() ) { 'post_category' => $taxonomy['cats'], 'tags_input' => $taxonomy['tags'] ); + + /** + * Exclude or alter posts during an RSS syndication pull + * + * Return an array of post data to save this post. Return false to exclude + * this post. + * + * @param array $post The post data, as would be passed to wp_insert_post + * @param array $args + * @param SimplePie_Item $item A Simplepie item object + * @param int $this->site_id The ID of the post holding the data describing this feed + */ $post = apply_filters( 'syn_rss_pull_filter_post', $post, $args, $item, $this->site_id ); if ( false === $post ) continue;