• 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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avram

    (@avram)

    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.

    serhanbuy

    (@serhanbuy)

    Hi,
    I guess, the path of the script must be given in URL format. https://www……&#8230;
    Try it this way.

    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’.

    so part of the solution is:

    change

    add_action(‘wp_head’, ‘setplayerscripts’);

    to

    add_action(‘init’, ‘setplayerscripts’);

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp enqueue script help!’ is closed to new replies.