How to reload S&F properly after ajax page refreshes v.2.0.1

Forums › Forums › Search & Filter Pro › How to reload S&F properly after ajax page refreshes v.2.0.1

Tagged: ,

Viewing 6 posts – 1 through 6 (of 6 total)
  • Anonymous
    #25714

    Hi,

    I loaded the new version yesterday but have had to revert to 1.4.3 because some of my custom functions are not working correctly with 2.0.1

    I am currently using this code in 1.4.3 to recall the form ID after my ajax page refresh…

    if (class_exists('Search_Filter')){
    	global $sf_form_data;
    	wp_localize_script('djax_init', 'SF_LDATA', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'home_url' => (home_url('/')), 'sfid' => $sf_form_data->get_active_form_id() ));
    	}

    BUT in 2.0.1 it does not work and I can’t figure out what I need to change apart from the global var ($searchandfilter). I get an error regarding the get_active_form_id() so obviously something has changed in the new version.

    Also the code which names the search page is incorrect too….

    /***SEARCH & FILTER PRO FUNCTIONS***/
    if (class_exists('Search_Filter')){
    	
    //wp_enqueue_script( 'search-filter-plugin-build' );
    //wp_enqueue_script( 'search-filter-chosen-script' );
    
    // Search Page Title - Yoast SEO friendly :-)
    function search_meta_title($data){
    global $sf_form_data;
    if ( $sf_form_data->is_valid_form() )
    {
    return 'Search Results';
    }
    else
    {
    return $data;
    }
    }
    add_filter('wpseo_title','search_meta_title');
    add_filter('wp_title','search_meta_title');

    Can anyone help me update my functions?

    Ross Moderator
    #25724

    Good catch

    I think renaming the global is enough most of your code above, however I’ve mistakenly and stupidly removed get_active_form_id() when refactoring – I’ll add it back in this afternoon or some equivalent and let you know.

    Thanks

    Anonymous
    #25725

    Thanks very much Ross. I’ll keep an eye out for your post/e-mail

    Ross Moderator
    #25798

    Hi Sarah

    Sending over a mail now…

    Looks like I’ve messed with these two functions a bit, I think I just didn’t think about this use case properly.

    So now in the latest version you should be able to use this function instead:

    $searchandfilter->active_sfid();

    So, active SFID returns the ID of the active search form. You can use this function in both uses cases above because an ID of 0 means its not active.

    So in your first code snippet instead of

    $sf_form_data->get_active_form_id()

    use:

    $searchandfilter->active_sfid();

    And in your second code snippet, instead of:

    if ( $sf_form_data->is_valid_form() )
    {
    return 'Search Results';
    }
    else
    {
    return $data;
    }

    It should be changed to:

    if ( $searchandfilter->active_sfid() )
    {
    return 'Search Results';
    }
    else
    {
    return $data;
    }

    Thanks!

    Anonymous
    #25894
    This reply has been marked as private.
    Anonymous
    #26058

    Hi Ross,

    I know you are incredibly busy with this release but I wasn’t sure if you had missed my preious post regarding the update you sent me last week.

    Sarah

Viewing 6 posts – 1 through 6 (of 6 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.