[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 17:35:32 UTC 2012
#19906: Quicktags docs recommend code causing JS error: Uncaught ReferenceError:
QTags is not defined
------------------------------------------------+--------------------------
Reporter: jeremyclarke | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone: Awaiting
Component: Inline Docs | Review
Severity: trivial | Version: 3.3.1
Keywords: has-patch needs-codex dev-feedback | Resolution:
------------------------------------------------+--------------------------
Comment (by TobiasBg):
> clarification in the inline docs because right now it encourages
something that throws a javascript error which causes all kinds of havoc.
You could interpret it this way, but if you do, this basically is valid
for all documentation in WP. You would actually have to add a similar
warning to the docs of many other JS objects or even PHP functions that
are in core. IMHO, that's "over-documenting".
(And as you mentioned the wiki: This would probably be the more
appropriate place for this hint/warning.)
So, to correct way simply is to load your JS only on pages where you know
that the prerequisites (here for quicktags) are fulfilled: For core, this
would be post.php and post-new.php (for post types that have support for
the editor), and on your own plugin's screens, this would be all screens
where you actually load a wp_editor() yourself.
Now, as your intention seems to be to add a button to *all* wp_editors()
that there are (which I'm not sure is good thing to do), a typeof
undefined check would indeed be in order, and I fully support and
encourage it. I just doubt that it has to be recommended in the docs, as
most plugins won't need it, if they load their scripts in the proper way,
and only for certain wp_editor() instances.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19906#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list