Support » Plugin: Relevanssi - A Better Search » Suggestion: relevanssi_post_ok filter change

  • I’d like to suggest an improvement to the relevanssi_post_ok. Right now, only the result of the last filter in the chain is returned, so previous filters (including Relevanssi’s own relevanssi_default_post_ok) aren’t taken into account. So, it’d be good if the result of a previous function were passed along to the next one, and each one AND’ed it with whatever specific calculation it did internally, returning the result. This way, each individual functions can be smaller, not needing to deal with whether the post status is published or not, since Relevanssi’s relevanssi_default_post_ok already does that, with only posts that pass all the different tests being shown. Additionally, if someone do want to fully control them all, he can easily set a filter with priority 99 or similar and just ignore the previous passed values.

    Below is the list of changes needed for this to work. Sorry if the number lines aren’t quite correct. I did lots of minor edits so they might have slightly changed places:

    a) Line 55, from:

    add_filter('relevanssi_post_ok', 'relevanssi_default_post_ok');


    add_filter('relevanssi_post_ok', 'relevanssi_default_post_ok',10,2);

    b) Line 1341, from:

    $post_ok = apply_filters('relevanssi_post_ok', $doc);


    $post_ok = apply_filters('relevanssi_post_ok', $post_ok, $doc);

    c) Line 1368, from:

    function relevanssi_default_post_ok($doc) {


    function relevanssi_default_post_ok($previous_status, $doc) {

    d) Line 1401, from:

    return $post_ok;


    return ($post_ok && $previous_status);

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Suggestion: relevanssi_post_ok filter change’ is closed to new replies.