WordPress.org

Ready to get started?Download WordPress

Forums

wp enqueue script help! (5 posts)

  1. heriz
    Member
    Posted 4 years ago #

    Hi,

    I'm trying to use the wp enqueue script function to get around plugin js conflicts, but I'm afraid javascript doesn't really agree with me. Can anyone help me with this please? I'm trying to convert this code from the Inline MP3 plugin:

    function setplayerscripts() {
    ?>
    <link rel="stylesheet" href="/wp-content/plugins/mp3inline/css/player.css" type="text/css" media="screen" />
    <script type="text/javascript" src="/wp-content/plugins/mp3inline/javascripts/prototype.js"></script>
    <script type="text/javascript" src="/wp-content/plugins/mp3inline/javascripts/domready.js"></script>
    <script type="text/javascript" src="/wp-content/plugins/mp3inline/javascripts/sprintf.js"></script>
    <script type="text/javascript" src="/wp-content/plugins/mp3inline/javascripts/Sound.js"></script>
    <script type="text/javascript" src="/wp-content/plugins/mp3inline/javascripts/Player.js"></script>
    <script type="text/javascript" src="/wp-content/plugins/mp3inline/javascripts/scriptaculous.js"></script>
    <?php
    }
    
    add_action('wp_head', 'setplayerscripts');
    
    ?>

    In this format:

    wp_enqueue_script('prototype', '/wp-content/plugins/mp3inline/javascripts/prototype.js');
    
    wp_enqueue_script('domready', '/wp-content/plugins/mp3inline/javascripts/domready.js');

    etc.

    I have no idea if this is even the correct way of doing it, I'm just in dire need of making Inline MP3 & NextGen work together, and it looks like this is the only way...

    As always, any help much appreciated!

  2. Avram
    Member
    Posted 4 years ago #

    I'm having same problem. It just won't work. Here's the code I'm using:

    wp_enqueue_script('pagepeel', '/wp-content/plugins/page-peel/pagepeel-js.php', array(), false, true);

    Tried to hook it in wp_head and wp_footer (I'm trying to add footer script), but it won't work for some reason.

  3. serhanbuy
    Member
    Posted 4 years ago #

    Hi,
    I guess, the path of the script must be given in URL format. http://www.........
    Try it this way.

  4. tengutech
    Member
    Posted 4 years ago #

    But rather than putting in a static URL you might like to use something like:

    wp_enqueue_script('devlounge_plugin_series', get_bloginfo('wpurl') . '/wp-content/plugins/devlounge-plugin-series/js/devlounge-plugin-series.js', array('prototype'), '0.1');

    Notice the 'get_bloginfo('wpurl') .' section.

    Code borrowed from Using JavaScript and CSS with your WordPress Plugin

    --

    Though from other stuff I have read 'wp_enqueue_script' doesn't work if you call it in 'wp_head'.

  5. satansatansatan
    Member
    Posted 3 years ago #

    so part of the solution is:

    change

    add_action('wp_head', 'setplayerscripts');

    to

    add_action('init', 'setplayerscripts');

Topic Closed

This topic has been closed to new replies.

About this Topic