好吧,我尝试了很多(字面上的)代码和方法,但都失败了。因此,正如我在问题中所说,唯一安全的方法似乎是重新注册(取消注册并排队)脚本。
The Scripts:
http://mywebsite.com/wp-includes/js/comment-reply.js
http://mywebsite.com/wp-includes/js/quicktags.js
Should be served from:
http://example.com/wp-includes/js/comment-reply.js
http://example.com/wp-includes/js/quicktags.js
Code in functions.php:
add_action(\'wp_enqueue_scripts\',\'wpse56742_register_script\');
function wpse56742_register_script(){
//Register and enqueue Comment Reply script
wp_deregister_script(\'comment-reply\');
wp_register_script(\'comment-reply\', \'http://example.com/wp-includes/js/comment-reply.js\', false, false);
wp_enqueue_script( \'comment-reply\' );
//Re-register quicktags script
wp_deregister_script(\'quicktags\');
wp_register_script(\'quicktags\', \'http://example.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\') )
));
wp_enqueue_script( \'quicktags\' );
}
至于wp\\u localize\\u脚本中使用的代码,我知道了
straight from trunk (您也可以在您的WP版本中获得它,例如,对于WP 3.4,链接为
http://core.svn.wordpress.org/tags/3.4/wp-includes/media.php
).
<小时>FAQ: Why is quicktags.js loaded in the front-end in the first place? 因为我正在使用插件-Basic Comment Quicktags