WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Suggestion: relevanssi_post_ok filter change (2 posts)

  1. Alexander Gieg
    Member
    Posted 2 years ago #

    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');

    to:

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

    b) Line 1341, from:

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

    to:

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

    c) Line 1368, from:

    function relevanssi_default_post_ok($doc) {

    to:

    function relevanssi_default_post_ok($previous_status, $doc) {

    d) Line 1401, from:

    return $post_ok;

    to:

    return ($post_ok && $previous_status);

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags