[wp-trac] [WordPress Trac] #19906: Quicktags docs recommend code causing JS error: Uncaught ReferenceError: QTags is not defined

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 27 10:36:13 UTC 2012


#19906: Quicktags docs recommend code causing JS error: Uncaught ReferenceError:
QTags is not defined
------------------------------------------------+--------------------------
 Reporter:  jeremyclarke                        |       Owner:
     Type:  enhancement                         |      Status:  closed
 Priority:  normal                              |   Milestone:  Awaiting
Component:  Inline Docs                         |  Review
 Severity:  trivial                             |     Version:  3.3.1
 Keywords:  has-patch needs-codex dev-feedback  |  Resolution:  invalid
------------------------------------------------+--------------------------
Changes (by TobiasBg):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Hi Jeremy,

 the solution is much easier: You'll just need to enqueue the "quicktags"
 script before you add your footer print action. There's no need to enqueue
 a script that *depends*, you just enqueue "quicktags" directly.
 {{{
 wp_enqueue_script( 'quicktags' );
 }}}
 This works because "output_my_js" is hooked with a priority of 100, so
 this will be done after all the footer scripts (including "quicktags"
 then) will have been included.

 And about this:

 > The issue is avoided if you use the other option, enqueuing a script
 dependent on 'quicktags', but that is a lot more work and forces all pages
 in the admin to load the quicktags script unnecessarily.

 The script would only be loaded on all pages if you don't use the correct
 hooks. Script enqueuing should only be done when you know that you are on
 your plugin's admin screen, e.g. in "load-{$plugin_hook}".

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19906#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list