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.

While you can view the full file here, here's the function that enqueues the JavaScript file(s) needed by the plugin:

function ippy_bcq_add_scripts() {

$options = get_option('ippy_bcq_options');
$valuebb = $options['bbpress'];
$valueco = $options['comments'];
$ippy_bcq_bbp_fancy = get_option( '_bbp_use_wp_editor' );

  if ( function_exists('is_bbpress') ) {
          if ( is_bbpress()  && ( $valuebb != '0') && !is_null($valuebb) && ($ippy_bcq_bbp_fancy == '0') ) {
            wp_enqueue_script("bcq_quicktags", plugin_dir_url(__FILE__) . "quicktags.js", array("quicktags","jquery"), "1.8", 1);
            wp_enqueue_style("bcq_quicktags", plugin_dir_url(__FILE__) . "quicktags.css", false, "1.8");
            wp_print_styles('editor-buttons');
        }
  }
  if ( comments_open() && is_singular() && ( $valueco != '0') && !is_null($valueco) ) {
                    wp_enqueue_script("bcq_quicktags", plugin_dir_url(__FILE__) . "quicktags.js", array("quicktags","jquery"), "1.8", 1);
                    wp_enqueue_style("bcq_quicktags", plugin_dir_url(__FILE__) . "quicktags.css", false, "1.8");
                    wp_print_styles('editor-buttons');
  }
}

if( !is_admin() ) {
    add_action('wp_print_styles', 'ippy_bcq_add_scripts');
}

Now, as you can see, quicktags ($handle) is one of the dependencies (alongside jQuery) required the JavaScript enqueued by the plugin.

quicktags represents this file: http://example.com/wp-includes/js/quicktags.js, and I need to have the file served from a different domain, like this for instance — http://static-domain.com/wp-includes/js/quicktags.js. How do I do it?

I tried these two in my theme's functions.php, but they seem to break the JavaScript output by the plugin for some reason:

  • TRY - 1:

    add_action('wp_enqueue_scripts','aahan_register_script');
    function aahan_register_script(){
    
        wp_deregister_script('quicktags');
        wp_register_script('quicktags', 'http://static-domain.com/wp-includes/js/quicktags.js', false, false, true);
        wp_enqueue_script( 'quicktags' );
    
    }
    
  • TRY - 2:

    add_action('wp_print_styles','aahan_register_script');
    function aahan_register_script(){
    
        wp_deregister_script('quicktags');
        wp_register_script('quicktags', 'http://static-domain.com/wp-includes/js/quicktags.js', false, false, true);
        wp_enqueue_script( 'quicktags' );
    
    }
    

I also did try a few other variants, but none worked. What am I doing wrong?


More Info

By default the plugin outputs code like this in the footer:

<script type='text/javascript'>
/* <![CDATA[ */
var quicktagsL10n = {"wordLookup":"Enter a word to look up:","dictionaryLookup":"Dictionary lookup","lookup":"lookup","closeAllOpenTags":"Close all open tags","closeTags":"close tags","enterURL":"Enter the URL","enterImageURL":"Enter the URL of the image","enterImageDescription":"Enter a description of the image","fullscreen":"fullscreen","toggleFullscreen":"Toggle fullscreen mode","textdirection":"text direction","toggleTextdirection":"Toggle Editor Text Direction"};
/* ]]> */
</script>
<script type='text/javascript' src='http://example.com/wp-includes/js/quicktags.js?ver=3.4.1'></script>
<script type='text/javascript' src='http://static-domain.com/wp-content/plugins/basic-comment-quicktags/quicktags.js?ver=1.8'></script>

But when I try the aforementioned functions, the output code is this (essentially broken):

<script type='text/javascript' src='http://whatthenerd.com/wp-includes/js/quicktags.js?ver=3.4.1'></script>
<script type='text/javascript' src='http://wtn-static.whatthenerd.net/wp-content/plugins/basic-comment-quicktags/quicktags.js?ver=1.8'></script>
share|improve this question

migrated from stackoverflow.com Jun 29 '12 at 18:53

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted

Finally, got it to work. Add this in functions.php:

add_action('wp_enqueue_scripts','aahank_register_script');
function aahank_register_script(){

//Re-register quicktags script
wp_deregister_script('quicktags');
wp_register_script('quicktags', 'http://static-content.com/wp-includes/js/quicktags.js', false, false, true);
wp_localize_script( 'quicktags', 'quicktagsL10n', array(
    'wordLookup' => __('Enter a word to look up:'),
    'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
    'lookup' => esc_attr(__('lookup')),
    'closeAllOpenTags' => esc_attr(__('Close all open tags')),
    'closeTags' => esc_attr(__('close tags')),
    'enterURL' => __('Enter the URL'),
    'enterImageURL' => __('Enter the URL of the image'),
    'enterImageDescription' => __('Enter a description of the image'),
    'fullscreen' => __('fullscreen'),
    'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
    'textdirection' => esc_attr( __('text direction') ),
    'toggleTextdirection' => esc_attr( __('Toggle Editor Text Direction') )
));

}

As for the code used in wp_localize_script, I got it straight from source: http://core.svn.wordpress.org/trunk/wp-includes/media.php

share|improve this answer
    
Cross-posted from: wordpress.org/support/topic/844266 –  its_me Jun 29 '12 at 18:36

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.