• Resolved Mobster

    (@mobster)


    I have been having issues a with mootools plugin and WordPress.

    Everything seems to function properly on a static page but secondary pages show errors and fail to function.

    Is there be a “preferred” way to import JavaScript in WordPress that loads as the static content would?

    I have already tried this:

    wp_enqueue_script('mootools', get_bloginfo('template_directory') .'/js/mootools.js', false, '1.1.1');

    I have also tried adding linked JavaScript directly to the page in question. That doesn’t seem to work properly either.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Mobster

    (@mobster)

    No ideas?

    Thread Starter Mobster

    (@mobster)

    Ok,

    For those of you having issues with mootools plugins. I found this little plugin which isn’t all that complicated to use or hack.

    Plugin Name: Mootools Framework
    Plugin URI: https://nilswindisch.de

    I just added all my mootools plugins to be included as an action.

    add_action("wp_head","domready");
    
    function domready() {
    	echo "\n\n<script type='text/javascript' src='".get_bloginfo('wpurl')."/wp-content/plugins/mootools-framework/domready.js'></script>\n\n";
    }

    Now all my plugins work on all pages.

    Problem solved.

    Sounds perfect for what I need.

    Please could you demonstrate exactly what you did and where you put the coding in as I cannot get it to work and have just started doing it?

    The initial code you posted did not work for me, could be doing it all wrong though?

    Any info would be greatly appreciated.

    Thanks in advanced,

    Gabi.

    Hi,

    I finally got it working without additional plugins or anything like that.

    The syntax I used is the following;

    <script type="text/javascript" src="<?php echo bloginfo('template_directory'); ?>/mootools.js"></script>

    Instead of this;

    <SCRIPT language=JavaScript src="<?php bloginfo('stylesheet_directory'); ?>/mootools.js" type=text/javascript></SCRIPT>

    Thanks,

    G.

    Just to clarify for others, add the .js files to your template directory

    Well, actually you can add your JS files anywhere inside your theme, i recomend to do this:

    /my_theme/js/scripts.js

    You should always use the WordPress native “wp_enqueue_script” function instead of hardcode, actually in the examples above, we see how <?php bloginfo(‘stylesheet_directory’); ?> is beeing used, wich is wrong since you could be using a “child-theme”.

    David.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mootools’ is closed to new replies.