Forums Forums Search & Filter Pro Post Meta filter clears itself whenever an option is chosen.

Viewing 10 posts - 11 through 20 (of 21 total)
  • Trevor
    #67739

    Just a heads up. I am taking a look right now.

    Trevor
    #68077
    This reply has been marked as private.
    Anonymous
    #68254
    This reply has been marked as private.
    Anonymous
    #68275

    I’ve it tested it with nothing but MasterPress and Search & Filter Pro installed, on a fresh WordPress installation, with minimal settings changes, and it’s definitely an issue with MasterPress fields.

    Trevor
    #68302
    This reply has been marked as private.
    Anonymous
    #68519
    This reply has been marked as private.
    Anonymous
    #68521

    After some digging, I have found that the issue is partially caused by the field names.

    A field with the name _sfm_details.gender will be converted to _sfm_details_gender when the js makes the GET request. There’s code in place (in Search_Filter_Cache.init_filters) to handle when spaces get converted to underscores, but not when full stops do: $filter_name_get = str_replace(" ", "_", $filter_name);. Which causes the check to fail at this point: if(isset($_GET[$filter_name_get])).

    Adding a line to convert the full stop to an underscore seems to have fixed the filtering portion of this problem; but when it comes to displaying the fields, the selected option is not getting given the “selected” attribute. Looking at the function for determining whether a field is selected or not (in Search_Filter_Generate_Input):
    `
    private function is_option_selected($option, $defaults)
    {

    if(isset($option->selected_value))

    }
    `

    I cannot seem to find where selected_value is set. After doing a grep of all the files in the plugin, it doesn’t seem to be set anywhere obvious.

    Because there is no selected value set, this causes the field to revert back to being empty.

    My apologies if this post is an unorganized mess, but I hope what I have found is useful in some way.

    Ross Moderator
    #68555

    Thanks for the update, I didn’t realise . get converted to _ when part of a url param name :/

    Very strange but thanks for digging – as Trevor mentioned I’m just putting the finishing touches to an update, I’ll take a look at this over the weekend and if a modification needs to be made to S&F I’ll do that.

    After which we can move on to the selected issue, I suspect that it is the same issue, as the Active Query class (which is used for the fields themselves) also uses $_GET to grab the values, so I suspect its the conversion happening again.

    Best

    Anonymous
    #69137

    Hi Ross,

    After doing a bit more digging, what you said is correct.

    Adding the following fixes the issue.

    public/includes/class-search-filter-active-query.php
    after line 177
    $field_name_get = str_replace(".", "_", $field_name_get); // do the same with full stops

    after line 596 (now 697 because of the above)
    $sf_post_meta_key_get = str_replace(".", "_", $sf_post_meta_key_get); // do the same with full stops
    public/includes/class-search-search-filter-cache.php
    after line 150
    $filter_name_get = str_replace(".", "_", $filter_name_get); // do the same with full stops

    Tested and working now.

    Cheers,

    Jayme

    Anonymous
    #69338

    Actually, I completely forgot that str_replace can take an array as the first parameter!

Viewing 10 posts - 11 through 20 (of 21 total)