Permalink
Browse files

feed_settings: add syndicated_post_terms_match, syndicated_post_terms…

…_match_{taxonomy}, syndicated_post_terms_unfamiliar, syndicated_post_terms_mapping filters. Allow finer-grained control over term taxonomy inputs.
  • Loading branch information...
radgeek committed Mar 31, 2016
1 parent 1db57bd commit f7d98d6e230dacfa77f50b52667d6a13baf72ec4
Showing with 33 additions and 11 deletions.
  1. +3 −3 feedwordpress.php
  2. +1 −1 readme.txt
  3. +29 −7 syndicatedpost.class.php
View
@@ -3,15 +3,15 @@
Plugin Name: FeedWordPress
Plugin URI: http://feedwordpress.radgeek.com/
Description: simple and flexible Atom/RSS syndication for WordPress
Version: 2015.0822
Version: 2016.0330
Author: Charles Johnson
Author URI: http://radgeek.com/
License: GPL
*/
/**
* @package FeedWordPress
* @version 2015.0822
* @version 2016.0330
*/
# This uses code derived from:
@@ -32,7 +32,7 @@
# -- Don't change these unless you know what you're doing...
define ('FEEDWORDPRESS_VERSION', '2015.0822');
define ('FEEDWORDPRESS_VERSION', '2016.0330');
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
if (!defined('FEEDWORDPRESS_BLEG')) :
View
@@ -3,7 +3,7 @@ Contributors: Charles Johnson
Donate link: http://feedwordpress.radgeek.com/
Tags: syndication, aggregation, feed, atom, rss
Requires at least: 3.0
Tested up to: 4.2.2
Tested up to: 4.4.2
Stable tag: 2015.0514
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
View
@@ -322,6 +322,9 @@ function SyndicatedPost ($item, &$source) {
$tags = $this->inline_tags();
$this->feed_terms['post_tag'] = apply_filters('syndicated_item_tags', $tags, $this);
// Allow plugins to do weirder things with taxonomies than the stock behavior
$this->feed_terms = apply_filters('syndicated_item_feed_terms', $this->feed_terms, $this);
$taxonomies = $this->link->taxonomies();
$feedTerms = $this->link->setting('terms', NULL, array());
$globalTerms = get_option('feedwordpress_syndication_terms', array());
@@ -1568,23 +1571,42 @@ function store () {
// We have to check again in case post has been filtered during
// the author_id lookup
if ($this->has_fresh_content()) :
$consider = array(
'category' => array('abbr' => 'cats', 'domain' => array('category', 'post_tag')),
'post_tag' => array('abbr' => 'tags', 'domain' => array('post_tag')),
);
$mapping = apply_filters('syndicated_post_terms_mapping', array(
'category' => array('abbr' => 'cats', 'unfamiliar' => 'category', 'domain' => array('category', 'post_tag')),
'post_tag' => array('abbr' => 'tags', 'unfamiliar' => 'post_tag', 'domain' => array('post_tag')),
), $this);
$termSet = array(); $valid = null;
foreach ($consider as $what => $taxes) :
foreach ($this->feed_terms as $what => $anTerms) :
// Default to using the inclusive procedures (for cats) rather than exclusive (for inline tags)
$taxes = (isset($mapping[$what]) ? $mapping[$what] : $mapping['category']);
$unfamiliar = $taxes['unfamiliar'];
if (!is_null($this->post)) : // Not filtered out yet
# -- Look up, or create, numeric ID for categories
$taxonomies = $this->link->setting("match/".$taxes['abbr'], 'match_'.$taxes['abbr'], $taxes['domain']);
// Eliminate dummy variables
$taxonomies = array_filter($taxonomies, 'remove_dummy_zero');
// Allow FWP add-on filters to control the taxonomies we use to search for a term
$taxonomies = apply_filters("syndicated_post_terms_match", $taxonomies, $what, $this);
$taxonomies = apply_filters("syndicated_post_terms_match_${what}", $taxonomies, $this);
// Allow FWP add-on filters to control with greater precision what happens on unmatched
$unmatched = apply_filters("syndicated_post_terms_unfamiliar",
$this->link->setting(
"unfamiliar {$unfamiliar}",
"unfamiliar_{$unfamiliar}",
'create:'.$unfamiliar
),
$what,
$this
);
$terms = $this->category_ids (
$this->feed_terms[$what],
$this->link->setting("unfamiliar {$what}", "unfamiliar_{$what}", 'create:'.$what),
$anTerms,
$unmatched,
/*taxonomies=*/ $taxonomies,
array(
'singleton' => false, // I don't like surprises

0 comments on commit f7d98d6

Please sign in to comment.