pop-up options for custom quicktags
pop-up options for custom quicktags
pop-up options for custom quicktags
Figured it out. You’ll need something like this in your custom JS: $(‘#textarea_id’).on(‘click focusin’, function() { wpActiveEditor=”textarea_id”; });
Simple example that will add a Quicktag button that calls a Javascript function when it is clicked… <?PHP function _add_my_quicktags(){ ?> <script type=”text/javascript”> QTags.addButton( ‘alert’, ‘Alert Button’, simple_alert ); function simple_alert() { alert(‘hello, example callback function’); } </script> <?php } add_action(‘admin_print_footer_scripts’, ‘_add_my_quicktags’); ?> UPDATE…. Adding a Callback function that utilizes the passed in variables… // … Read more
I had the same problem. I fixed it by using the ep_enqueue_script aproach shown here: https://codex.wordpress.org/Quicktags_API listed under “A more modern example”. It’s the same thing that Tom mentions. Instead of using ‘admin_print_fotter_scripts’ to write an inline script on the page, the example shows putting the Qtags javascript in a separate JS file, and loading … Read more
it you’re not seeing the buttons, try to call QTags._buttonsInit(); right after you call the quicktags( settings ); function. quicktags(settings); QTags._buttonsInit(); Following also works for me qt_editor = new QTags( { ‘id’: ‘my_editor’, ‘buttons’: ‘strong,em,link’ } ); QTags._buttonsInit(); Also, it seems that adding a button via QTags.addButton() function also makes your toolbar to display qt_editor … Read more
As you noted, setting quicktags to false removes the “visual” and “text” tabs. So, to leave the tabs you need to set quicktags to true and remove the buttons: $settings = array( ‘quicktags’ => array( ‘buttons’ => ‘,’ ) ); wp_editor($input, ‘editor_name’, $settings); To have this in all quicktags instances you can use quicktags_settings filter: … Read more
I have stumbled into this very same issue, and got the quicktags to work. Here’s the code to add to functions.php: <?php add_action(‘admin_print_footer_scripts’,’my_admin_print_footer_scripts’); function my_admin_print_footer_scripts() { ?> <script type=”text/javascript”>/* <![CDATA[ */ var id = “myID”; // this is your metabox’s textarea id settings = { id : id, buttons: ‘strong,em,link’ } quicktags(settings); /* ]]> */</script> … Read more
The concept Adding something to the content during saving and considering all sorts of possible MarkUp isn’t an easy task. I played around a bit with it and decided that the best chance would be to use PHP native \DOMDocument class to parse the content, identify the paragraph and add the HTML comment to it. … Read more
According to the Codex, you can’t do this directly through the API. However, you can do it by using your own quicktags.js file as shown below. function sample_load_admin_scripts() { if ( is_admin() ) { wp_deregister_script(‘quicktags’); wp_register_script(‘quicktags’, (“/path/to/your/quicktags.js”), false, ”, true); } } if (is_admin()) { add_action(‘init’, sample_load_admin_scripts); } Then just add Javascript to do your … Read more
Also an small example for change the url in link-button to use the url from installed blog. Use print JS in footer, not an include from js file via wp_enqueue_script() – ist faster vor development, specially for this small requirement, but not so on standard and fine, how the example from the other answer. <?php … Read more