Reply To: Background image zooms in when ASP in activated

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Background image zooms in when ASP in activated Reply To: Background image zooms in when ASP in activated

#6552

Ernest Marcinko
Keymaster

Hi!

I've just done some testing.

After deactivating the plugin from what I can see there is an error in one of the header scripts, which is most likely causing the whole problem: https://i.imgur.com/aDFlcE4.png

The error states:

Uncaught TypeError: $ is not a function

Which happens if the jQuery object is not mixed into the “$” object. The reason why it worked with the search active is, that the plugin tries to fix this issue. This is definitely not caused by ajax search pro, as a de-activated plugin code has no effect on the site whatsoever – because simply no code is executed from it's directory.

After looking more into the error message, the following code is giving the error in the site header:

jQuery(document).ready(function(){
$(".wpurp-user-menus-by").before( "<div class='sHeadTxtsidebar'>Your saved meal planners</div>" );
$(".user-menus-input-container").before( "<div class='sHeadTxt'>Your planner name:</div>" );
$(".user-menus-input-container").before( "<div class='sHeadsubTxtNote' >(default is date and username, but you can change it)</div>" );
$(".user-menus-selected-recipes").before( "<div class='sHeadTxt'>Recipes in your grocery list and planner:</div>" );
$(".user-menus-buttons-container").before( "<div class='sHeadsubTxt'>don't forget to adjust the number of servings</div>" );
$(".user-menus-ingredients").before( "<div class='sHeadTxtgrocerylist' style='padding-top:40px;'>your grocery list</div>" );
$(".user-menus-buttons-container button").first().text("SAVE YOUR PLANNING");
$(".user-menus-buttons-container button").last().text("PRINT PLANNER");

})

This code is actually adding elements, menu items into the page. And the problem is that while the function waits for the jQuery document ready event, it then uses the “$” variable as jQuery, which of course is not defined. So I would try to change it to something like:

jQuery(document).ready(function(){
jQuery(".wpurp-user-menus-by").before( "<div class='sHeadTxtsidebar'>Your saved meal planners</div>" );
jQuery(".user-menus-input-container").before( "<div class='sHeadTxt'>Your planner name:</div>" );
jQuery(".user-menus-input-container").before( "<div class='sHeadsubTxtNote' >(default is date and username, but you can change it)</div>" );
jQuery(".user-menus-selected-recipes").before( "<div class='sHeadTxt'>Recipes in your grocery list and planner:</div>" );
jQuery(".user-menus-buttons-container").before( "<div class='sHeadsubTxt'>don't forget to adjust the number of servings</div>" );
jQuery(".user-menus-ingredients").before( "<div class='sHeadTxtgrocerylist' style='padding-top:40px;'>your grocery list</div>" );
jQuery(".user-menus-buttons-container button").first().text("SAVE YOUR PLANNING");
jQuery(".user-menus-buttons-container button").last().text("PRINT PLANNER");

})

Or maybe leave it unchanged and rather move it to the footer.php file in your theme, so it won't block the page rendering.

This is the only error as far as I can see, but there might be more after fixing this one. I suggest fixing the page with the plugin deactivated to make sure it's working properly.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)