Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using a quicktags plugin, which was not loading on the home page, now it does, but it does it on the wrong place. How can I solve this?

I want the quicktags.min.js file to load first, rather than the basic-comment quicktags...

I am using this script:

add_action( 'wp_enqueue_scripts', 'ron_scripts' );
function ron_scripts(){
   if(is_home()){
     wp_register_script( 'quicktags', '/wp-includes/js/quicktags.min.js?ver=3.5.1');
     wp_enqueue_script( 'quicktags' );
     wp_register_script( 'basic-comment-quicktags', '/wp-content/plugins/basic-comment-quicktags/quicktags.js' );
     wp_enqueue_script( 'basic-comment-quicktags' );
     } else {

    }
}

What should I do to get it work like I want it to be?

Edit: so now I am using:

function quicktags_script() {
    wp_register_script( 'quicktags-min', '/wp-includes/js/quicktags.min.js?ver=3.5.1');
    wp_enqueue_script( 'quicktags-min' );
wp_register_script( 'basic-comment-quicktags', '/wp-content/plugins/basic-comment-quicktags/quicktags.js' );
     wp_enqueue_script( 'basic-comment-quicktags' );
}

add_action( 'wp_enqueue_scripts', 'quicktags_script' );

....

Can I get the basic-comment-quicktags beneath all scripts?

Edit 2:

If I change quicktags-min to quicktags, it does not give me the l10n error and it shows it to me in my page source. This time I get this error: Permission denied to access property 'toString'

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

In your functions.php: edit: First register the quicktags script under a different name than already registered in wp "quicktags" , see Codex

function quicktags_script() {
    wp_register_script( 'quicktags-min', '/wp-includes/js/quicktags.min.js?ver=3.5.1','','',true);
    wp_enqueue_script( 'quicktags-min' );
}

add_action( 'wp_enqueue_scripts', 'quicktags_script' );

This will load the script for all the pages on your front-end. To load it only on front-page :

function quicktags_script() {
    if(is_front_page()){
        wp_register_script( 'quicktags-min', '/wp-includes/js/quicktags.min.js?ver=3.5.1','','',true);
        wp_enqueue_script( 'quicktags-min' );
    }
}

add_action( 'wp_enqueue_scripts', 'quicktags_script' );

Just add the last parameter $in_footer for the wp_register_script to true (see the edited answer) . Or add 'quicktags-min' as the third parameter for the basicktags register function

wp_register_script( 'basic-comment-quicktags', '/wp-content/plugins/basic-comment-quicktags/quicktags.js','quicktags-min' );

This will first load quicktags-min and then the basictags.

share|improve this answer
    
Thanks man, but now, the problem is the order of the plugins... See my edited post... The question has changed a bit now –  Johan Jul 25 '13 at 13:58
    
It should work the way you wrote. What is the problem exactly ? Where do you need it to load and why are you loading them both ? –  Tolea Bivol Jul 25 '13 at 14:04
    
@Johan I think I got it : edited the answer –  Tolea Bivol Jul 25 '13 at 14:19
    
Thanks man, now it is in the correct order indeed. The problem is that it still won't fetch the quicktags.... In single.php the plugin script is beneath the whole page source... Quicktags is where it is now... Maybe that's the problem. You have any idea how I can get the enqueued script beneath all scripts? So whole way down? –  Johan Jul 25 '13 at 14:28
    
See my edit on the post btw –  Johan Jul 25 '13 at 14:29
show 3 more comments

The third parameter of wp_register_script is $deps-- dependencies. wp_enqueue_script also accepts a $deps parameter, by the way.

wp_register_script( $handle, $src, $deps, $ver, $in_footer );

$deps is an array of scripts upon which the script being registered depends. Dependencies load before the scripts upon which they depend. WordPress will juggle things around for you if you register things correctly.

function quicktags_script() {
    wp_register_script( 
       'quicktags-min', 
       '/wp-includes/js/quicktags.min.js?ver=3.5.1'
    );

    wp_register_script( 
       'basic-comment-quicktags', 
       '/wp-content/plugins/basic-comment-quicktags/quicktags.js',
       array('quicktags-min')
    );

    wp_enqueue_script( 'basic-comment-quicktags' );
    wp_enqueue_script( 'quicktags-min' );
}

add_action( 'wp_enqueue_scripts', 'quicktags_script' );

That is what your original question sounded like you wanted. Now, you have rewritten asking how to get "basic-comment-quicktags beneath all scripts". To do that, you probably want to enqueue the script very late with a priority on the wp_enqueue_scripts hook. You can register the script as normal and enqueue it like this:

function enqueue_bcquicktags() {
    wp_enqueue_script( 'basic-comment-quicktags' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_bcquicktags', 1000 );

You may also want to look into the fifth parameter, $in_footer, as that will load your script in the footer of the page. Without that, it should load last in the <head> of the page.

share|improve this answer
    
+1, no need to re-register a script, just add a dependency. –  David Gard Jul 25 '13 at 14:46
    
Did I re-register something? –  s_ha_dum Jul 25 '13 at 14:49
    
This still doesn't do a thing. It does load the js files, yes, but I can't see the tags/buttons anyway.... It says quicktagsL10n is not defined –  Johan Jul 25 '13 at 16:55
    
quicktagsL10n is nowhere in your question. However, if the scripts load as you say they do, and I assume you mean in the correct order, then the problem is elsewhere-- perhaps with the scripts themselves. Do the scripts depend on the $ alias by any chance? –  s_ha_dum Jul 25 '13 at 17:00
    
@s_ha_dum if I use my own script (see first post, first code), then I can see in the page source this quicktagsL10n, so it has to do with their codes.... If I use their codes, I can't see it anymore. The first code (so my code) gives only this error quicktags is not defined –  Johan Jul 25 '13 at 17:02
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.