2

I would like to add a button to this toolbar, right of "fullscreen":

enter image description here

The button should add this: „“

If text is selected, it should get around the text, like this: „selected text“

How can I add such a button to the ed_toolbar (class: quicktags-toolbar)?

2 Answers 2

1

Try adding the following code in your function.php

add_action( 'admin_footer-post-new.php', 'wpse_64665_add_quick_tag' );
add_action( 'admin_footer-post.php',     'wpse_64665_add_quick_tag' );
function wpse_64665_add_quick_tag() { ?>
    <script type="text/javascript">
        edButtons[edButtons.length] = new edButton( '„“', '„“', '„', '“', '' );
    </script><?php
}
3
0

The new, recommended way to add buttons to the toolbar is via the Quicktags API. Furthermore the site GenerateWP provides a handy code generator, which for this example creates the following:

// Add Quicktags
function custom_quicktags() {
    if ( wp_script_is( 'quicktags' ) ) {
    ?>
    <script type="text/javascript">
    QTags.addButton( 'fancy_quote_button', '„“', '„', '“', '\"', 'Fancy quotes', 9 );
    </script>
    <?php
    }
}
add_action( 'admin_print_footer_scripts', 'custom_quicktags' );

Note also that QTags also allows you to call JavaScript from buttons; the simplest example given is:

QTags.addButton( 'my_id', 'my button', my_callback );
function my_callback() { alert('yeah!'); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.