WordPress.org

Forums

AdRotate
JavaScript error with AdBlock disrupting the rest of the website (1 post)

  1. radgh
    Member
    Posted 1 year ago #

    (NOTE: I solved this myself, I guess this is more of a bug report?)

    If your visitors are running adblock, the adrotate plugin will throw an error that the function "jQuery().gslider" is undefined. Obviously this is because the dependency is being blocked by the adblock plugin, but there is no failsafe in case that script fails to load.

    If they get this error, it seems all other scripts loaded afterwards will not run either.

    There isn't a filter to let me fix this using functions.php, so I had to modify the plugin source code directly. That's why I'm posting here, hopefully this gets added to the next version so I do not have the "hack" the plugin again.

    The fix is below and is very straightforward, it just checks that the "gslider" function is not defined before calling it.

    adrotate-output.php
    line 557

    $array_js[] = "\tif ( typeof jQuery('body').gslider != 'undefined' ) jQuery('.g-".$group->id."').gslider({ groupid: ".$group->id.", speed: ".$group->adspeed." });\n";

    https://wordpress.org/plugins/adrotate/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • AdRotate
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic