feed-rules is a WordPress plugin for sites that import items from feeds. It holds the keep, drop and mapping rules for any importer in one place, with a test state and a test screen. It is MIT licensed, and v0.1.0 was released on 15 November 2026.
A site that imports from feeds gets everything each feed carries: job listings, horoscopes, sponsored posts, sections it never wanted. Operators usually fix this with a keyword list inside each importer, and that has three failures.
\b boundary treats a vowel sign in Devanagari or Tamil as a word break, so a keyword in those scripts either never matches or matches inside other words.exclude, include, keep, categorise, tag and author, with one to ten conditions per rule.test state, where it is evaluated and logged and changes nothing.fetch_feed() that creates drafts or pending posts only.list, status, test, export, import, run-feeds and reset-errors.An importer wraps its post insert with two calls:
$item = apply_filters('feed_rules_filter_item', [
'url' => $link, 'title' => $title, 'body' => $html, 'source_name' => 'Example Wire',
], 'my-importer');
if ($item === false) {
return; // Dropped by a rule.
}
$postId = wp_insert_post([...]);
do_action('feed_rules_apply_to_post', $postId, $item);
Text is normalised once. Scripts and styles are removed, tags are stripped with block boundaries kept as spaces, entities are decoded up to three times, bad UTF-8 is repaired, NFC is applied and whitespace is collapsed. The body is cut to a window, 2,000 characters by default.
Rules then run in list order with a fixed precedence:
keep rule that matches keeps the item, whatever the other rules say.exclude rule that matches drops it.include rule is in scope, one must match or the item is dropped.test rules are evaluated for every item and recorded as “would drop”, “would keep” or “would map”.Whole words are found with Unicode letter, mark and number classes, never \b. A Hindi keyword does not match inside a longer Hindi word, and a Tamil keyword followed by a vowel sign does not match.
Each decision goes to a recent-items table (newest 100 per importer by default), to per-rule daily counters kept for 14 days, and, for kept posts, to one post meta key listing the live rules that matched. Test runs write none of this and never fire feed_rules_decided. Other hooks include feed_rules_item_text to strip importer boilerplate before matching, feed_rules_decision as a last chance to change a decision, and feed_rules_register_adapters.
test. The global switch can turn the plugin off, and feed_rules_enabled filters it.preg_quote. User regexes are checked for delimiter and flags (only imsx, with u always added) and compiled on save.manage_options by default, filterable) and a nonce, and all output is escaped.preg_replace() failed during normalisation, for example on a very large body, the failure was cast to an empty string and silently emptied the field. It now keeps the input.Test status: this is v0.1.0. The review reports 94 PHPUnit tests, PHPStan level 8 and phpcs clean on a local PHP 8.3, on stubs and mocks. The README gives about 0.7 ms for one item against 50 rules holding 5,000 keywords, from a benchmark script in the repo on synthetic data. CI has not run on GitHub yet, and the plugin has not run against a live importer. It was specified, built and reviewed in separate roles by language-model coding agents under the editor’s direction.
It needs WordPress 6.4 or later and PHP 8.1 or later with mbstring and PCRE. intl is used for NFC normalisation when present.
composer require indianopinion/feed-rules
The package is not on Packagist yet, so add a Composer vcs repository entry for https://github.com/IndianOpinion/feed-rules first.
Without Composer, put the folder in wp-content/plugins/feed-rules and activate it.