WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Bug in relevanssi_default_post_ok (5 posts)

  1. Alexander Gieg
    Member
    Posted 1 year ago #

    There's a bug in the relevanssi_default_post_ok function. The problem is that, although it receives a $post_ok value from earlier filter function(s), it disregards this received value and overwrites it with true or false depending on its own tests.

    The easiest solution is to add a, let's say, $my_post_ok = true; declaration at the beginning of the function, then use this variable in the 6 instances where $post_ok was originally used, and finally end the function with a return ( $my_post_ok && $post_ok );. This way an originally false $post_ok value won't suddenly become true and make posts that should be hidden reappear in the search.

    What do you think?

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

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Well, yeah, it's not designed to care about the previous value =) It's just if nothing catches in the default post ok function, the previous value will pass through.

    If you want to make sure your filter overrides the default value, you can set it to run after the default filter by adjusting the priorities.

    I suppose your suggestion does make sense.

  3. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    I decided not to change this. If you want to make sure your function is not overridden by the default function, use a later priority or disable the default function.

  4. Alexander Gieg
    Member
    Posted 1 year ago #

    Disabling the default function had't occurred to me. Yes, it makes sense in many ways. This is to show how I'm still a long way from being really proficient at customizing things in code. :-)

    Another suggestion then: since the default function is quite fundamental, wouldn't it make more sense to run it at priority 9 or lower?

  5. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Yeah, that would make sense.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags