Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$.ageCheck is not a function #1

Open
dxdc opened this issue Nov 17, 2020 · 0 comments
Open

$.ageCheck is not a function #1

dxdc opened this issue Nov 17, 2020 · 0 comments

Comments

@dxdc
Copy link

dxdc commented Nov 17, 2020

Similar problem to the one reported by another user TypeError: $.ageCheck is not a function:

Was able to trace the problem to these lines:

wp_enqueue_script( 'age-verification-cookie', plugin_dir_url( __FILE__ ) . 'js/js.cookie.js', array( 'jquery' ), $this->version, false );
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/dispensary-age-verification-public.js', array( 'jquery' ), $this->version, false );

The side effect is that these scripts are not loaded at all. If this JS code is pasted into the console, then the $.ageCheck script works just fine. Also, these scripts are not present in the HTML code at all, meaning they never got loaded.

Trying to debug this, I found that plugin_dir_url( __FILE__ ) . 'js/dispensary-age-verification-public.js' does produce the correct path, so I'm not sure if there is a filter removing these somewhere else? The site I'm debugging for this problem is extremely complex so not sure what other features may be involved.

Was able to temporarily get around this using the following hack solution in another function:

    ?>
    <script type="text/javascript">
	  <?php echo file_get_contents(__DIR__. '/js/js.cookie.js'); ?>
    </script>
    <script type="text/javascript">
	  <?php echo file_get_contents(__DIR__. '/js/dispensary-age-verification-public.js'); ?>
    </script>
    <?php

Any idea why this could be failing or how to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant