Forums

[resolved] Mootools (7 posts)

  1. Mobster
    Member
    Posted 3 years ago #

    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.

  2. Mobster
    Member
    Posted 3 years ago #

    No ideas?

  3. Mobster
    Member
    Posted 3 years ago #

    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: http://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.

  4. gabi_cavaller
    Member
    Posted 2 years ago #

    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.

  5. gabi_cavaller
    Member
    Posted 2 years ago #

    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.

  6. w77
    Member
    Posted 2 years ago #

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

  7. davoscript
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic