[wp-trac] [WordPress Trac] #19098: QTags.addButton not working according to the docblocks
WordPress Trac
wp-trac at lists.automattic.com
Tue Nov 1 14:12:23 UTC 2011
#19098: QTags.addButton not working according to the docblocks
--------------------------+------------------------------
Reporter: amereservant | Owner: azaozz
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.3
Severity: minor | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by amereservant):
Tell me what you think of this idea...
There's a couple of ways to do this and one idea is using a global such as
{{{$wp_quicktag_buttons}}} and then you could create two functions,
{{{add_quicktag_button($id, $title, $arg1, $arg2, $access_key,
$priority)}}} and {{{remove_quicktag_button($id)}}} that modify the
{{{$wp_quicktag_buttons}}} global.
In {{{WP_Editor::editor_settings}}}, add the default buttons (like they
have been added in quicktags.js at the bottom) and then add them to the
{{{$qtInit}}} variable before calling the 'quicktags_settings' filter,
which would give developers a chance to filter out buttons they don't want
or add new ones at the last minute, although they should use the two
previously mentioned functions and hook to the quicktags_settings filter
at the latest.
The value of {{{$wp_quicktag_buttons}}} could be a simple array such as:
{{{
$wp_quicktag_buttons = array(
10 => array(
'id' => 'strong',
'title' => 'b',
'arg1' => '<strong>',
'arg2' => '</strong>',
'accesskey' => 'b'
),
20 => array(
'id' => 'em',
'title' => 'i',
'arg1' => '<em>',
'arg2' => '</em>',
'accesskey' => 'i'
),
);
}}}
Finally, once that is converted into a JSON-Encoded object and added to
the ''qtInit'' object, the values can easily be iterated over in the
quicktags.js and added, similar to how they are added at the bottom now.
This would allow you to do away with the ''disabled_buttons'' variable in
the {{{$qtInit}}} array and the ''buttons'' variable could be changed to
the value of {{{$wp_quicktag_buttons}}}, making it an array instead of a
comma-separated string.
I'm not sure what else would need to be changed to accommodate these
changes since I'm not spending too much time on this idea until I get
feedback, but it seems very easy to implement with very little changes to
the current code and would allow greater flexibility in the future.
I'd be glad to write the patches for this if you like the idea, but I
wanted to get feedback first in case there's something I'm overlooking or
if this doesn't sound like a good idea to anyone but me. Thanks!
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19098#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list