• We have an issue with the plugin throwing “client denied by server configuration:” warnings due to search engines attempting to crawl the plugin directory. In our use-case, we’re running a private site, only accessible via login.

    The warning is thrown because the scripts and styles are enqueued even on the login page.

    And while there are different ways to circumvent this, the most logical is to delay the loading of those scripts, or detect if the login page is the current page and skip the enqueing if so.

    This is our solution.

    Open the plugin main file:

    /plugins/easy-responsive-tabs/easy_res_tab.php

    Find:

    add_action('admin_enqueue_scripts', array($this, 'ert_admin_scripts'));
    add_action('wp_enqueue_scripts', array($this, 'ert_enqueue_scripts'),-10);
    add_action('wp_enqueue_scripts', array($this, 'ert_dynamic_scripts'),100);

    And wrap it in a condition like so:

    if (strpos($_SERVER['REQUEST_URI'], 'login') === false) {
       add_action('admin_enqueue_scripts', array($this, 'ert_admin_scripts'));
       add_action('wp_enqueue_scripts', array($this, 'ert_enqueue_scripts'),-10);
       add_action('wp_enqueue_scripts', array($this, 'ert_dynamic_scripts'),100);
    }

    The above should be flexible enough to detect either the wp-login.php or pretty URL /login/ in the URL.

    We would’ve used the native WordPress function is_page_template() or is_user_logged_in(), but these don’t seem to be in-scope at the time the plugin enqueues it’s scripts/styles.

    Hope this helps someone (and maybe plugin author would consider making this a config option – conditionally loading scripts/styles on login page where they probably aren’t needed).

    Cheers!

    https://www.ads-software.com/plugins/easy-responsive-tabs/

  • The topic ‘Prevent plugin scripts from loading on login page’ is closed to new replies.