Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the site_ID to the syn_rss_pull_filter_post filter #72

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions includes/class-syndication-wp-rss-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Expand All @@ -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 );
Expand Down Expand Up @@ -199,8 +202,19 @@ 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 );

/**
* 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;
$posts[] = $post;
Expand Down