How to add shortcode in text tab of editor?


username

Take a look at the image below to understand exactly what I mean.

Label text

I know how to add snapshot codes to tinymce, but I don't know how to add shortcodes to text tabs. I want to add my shortcode next to the "full screen" button. What is the solution?

Brasofilo

Interesting question, couldn't find any reference here or on WordPress Developers and found the solution on the Japanese page .

In the code, we only trigger the filter hook on the page /wp-admin/post-new.php, and /wp-admin/post.phponly for and pagepost types.

<?php
/**
 * Plugin Name: (SO) Add buttons to Text mode editor
 * Plugin URI:  http://stackoverflow.com/a/22425171/1287812
 * Description: Based on http://fog-town.net/note/web/addquicktag-unplugged/
 * Author:      brasofilo
 * License:     GPLv3
 */

// Hook only in this admin pages
foreach( array( 'post', 'post-new' ) as $hook )
    add_action( "load-$hook.php", 'setup_so_22396339' );

// Hook only for the 'page'  post type
function setup_so_22396339()
{
    global $typenow;
    if( 'page' !== $typenow )
        return;
    add_filter( 'quicktags_settings', 'quicktags_so_22396339', 10, 2 );
    add_action( 'admin_print_footer_scripts', 'my_quicktags_so_22396339' );
}

// Default buttons (remove buttons from the comma-separated string)
function quicktags_so_22396339( $qtInit, $editor_id ) 
{
    // There's another editor for the Comments box (editor_id == 'replycontent')
    if( 'content' === $editor_id )
        $qtInit['buttons'] = 'link,block,img,ul,ol,li,code,more,spell,close,fullscreen';
    return $qtInit;
}

// Add new buttons
function my_quicktags_so_22396339() 
{ 
    // Don't know how to target only the main content editor. Changes are applied to both editors (content and comments).
    ?>
    <script type="text/javascript">
        //QTags.addButton('ID', 'label', 'start_tag', 'end_tag', 'access_key', 'title', 'priority', 'instance');
        QTags.addButton( 'shortcode_1', 'shortcode 1', '[shortcode1]', '[/shortcode1]', '', 'Tooltip about the shortcode 1', '1', '' );
        QTags.addButton( 'shortcode_2', 'shortcode 2', '[shortcode2 category="ADD-THE-CATEGORY-ID"]', '', '', 'Tooltip about the shortcode 2', '1', '' );
        QTags.addButton( 'pre_tag', 'my-pre', '<pre>', '</pre>', '', '<pre></pre>', '1', '' );
        QTags.addButton( 'div_tag', 'my-div', '<div>', '</div>', '', '<div></div>', '101', '' );
        QTags.addButton( 'span_tag', 'my-span', '<span>', '</span>', '', '<span></span>', '150', '' );
    </script>
    <?php
}

Unable to place custom button behind full screen, please check the priority in the following QTags.addButton:

enter image description here

Related


How to add shortcode in text tab of editor?

username Take a look at the image below to understand exactly what I mean. I know how to add snapshot codes to tinymce, but I don't know how to add shortcodes to text tabs. I want to add my shortcode next to the "full screen" button. What is the solution? Bras

How to Add Custom Shortcode Buttons in TinyMCE Editor WordPress

Harun R Rayhan Hi, I am using the latest version of WordPress. I want to add my shortcode in TinyMCE editor like this image : http://prntscr.com/72ycrs My shortcode is: [my_tabs] [my_tab title = "Tab One Title"]Tab One Content Goes Here[/my_tab] [my_tab title

How to Add Custom Shortcode Buttons in TinyMCE Editor WordPress

Harun R Rayhan Hi, I am using the latest version of WordPress. I want to add my shortcode in TinyMCE editor like this image : http://prntscr.com/72ycrs My shortcode is: [my_tabs] [my_tab title = "Tab One Title"]Tab One Content Goes Here[/my_tab] [my_tab title

How to Add Custom Shortcode Buttons in TinyMCE Editor WordPress

Harun R Rayhan Hi, I am using the latest version of WordPress. I want to add my shortcode in TinyMCE editor with an image like this : http://prntscr.com/72ycrs My shortcode is: [my_tabs] [my_tab title = "Tab One Title"]Tab One Content Goes Here[/my_tab] [my_ta

How to Add Custom Shortcode Buttons in TinyMCE Editor WordPress

Harun R Rayhan Hi, I am using the latest version of WordPress. I want to add my shortcode in TinyMCE editor with an image like this : http://prntscr.com/72ycrs My shortcode is: [my_tabs] [my_tab title = "Tab One Title"]Tab One Content Goes Here[/my_tab] [my_ta

Shortcode not working in wordpress text editor

Yaser Nadeem I want to add shortcode from text editor of wordpress post. I added the following shortcode to my wordpress post: <img alt="" src="[template_url]/images/ic_sol_1a.png" /> This [template_url]is the shortcode I'm going to use that doesn't work. When

Shortcode not working in wordpress text editor

Yaser Nadeem I want to add shortcode from text editor of wordpress post. I added the following shortcode to my wordpress post: <img alt="" src="[template_url]/images/ic_sol_1a.png" /> This [template_url]is the shortcode I'm going to use that doesn't work. When

Shortcode not working in wordpress text editor

Yaser Nadeem I want to add shortcode from text editor of wordpress post. I added the following shortcode to my wordpress post: <img alt="" src="[template_url]/images/ic_sol_1a.png" /> This [template_url]is the shortcode I'm going to use that doesn't work. When

Wordpress Shortcode not working in WP page text editor

slightest I'm using the wordpress profilebuilder plugin... When I place the shortcode in the wordpress content area "[wppb-register]" it doesn't contain the code. It only shows shortcode text. Can anyone help me with the problem..i really appreciate it. Sadly

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Wordpress Shortcode not working in WP page text editor

slightest I'm using the wordpress profilebuilder plugin... When I place the shortcode in the wordpress content area "[wppb-register]" it doesn't contain the code. It only shows shortcode text. Can anyone help me with the problem..i really appreciate it. Sadly

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Shortcode Dropdown WordPress - Text Editor Only

Matthew Tilley I'm trying to add a shortcode dropdown in the plain text editor next to the add media button in the WordPress page editor. I've seen a lot of questions related to dropdowns, but they're all specific to the tinyMce editor and not the plain text e

Shortcode Ultimate Wordpress to add image to tab

Nick Borisenko I'm trying to put a unique icon onto a custom label created with shortcode Ultimate, but nothing seems to work. It's probably obvious what I'm missing. I made three custom CSS classes which are attached to each tab. In CSS, each class has a uniq

Shortcode Ultimate Wordpress to add image to tab

Nick Borisenko I'm trying to put a unique icon onto a custom label created with shortcode Ultimate, but nothing seems to work. It's probably obvious what I'm missing. I made three custom CSS classes which are attached to each tab. In CSS, each class has a uniq

Shortcode Ultimate Wordpress to add image to tab

Nick Borisenko I'm trying to put a unique icon onto a custom label created with shortcode Ultimate, but nothing seems to work. It's probably obvious what I'm missing. I made three custom CSS classes which are attached to each tab. In CSS, each class has a uniq

Shortcode Ultimate Wordpress to add image to tab

Nick Borisenko I'm trying to put a unique icon onto a custom label created with shortcode Ultimate, but nothing seems to work. It's probably obvious what I'm missing. I made three custom CSS classes which are attached to each tab. In CSS, each class has a uniq

How to add line numbers in this text editor

Nikhil Nicksell Here is my text editor code, import sys from collections import Counter from PyQt5.QtCore import pyqtRemoveInputHook from PyQt5.QtWidgets import QMainWindow, QApplication, QAction from PyQt5 import uic Ui_MainWindow, QtBaseClass = uic.loadUiTyp

How to add placeholder text when editor is empty

Kevin Laslow How to add placeholder text when editor is empty? After typing starts, it should disappear. a user You can add a listener for the inputevent and add a div with text if needed like this: var editor = ace.edit("editor", { theme: "ace/theme/chaos"

How to add text editor in Angular JS?

chipmunk In my project I want to provide a text editor. I cite some sites. But still I don't have the right idea. I try to use textangular editor.i include <script src="core/angular.min.js"></script> <script src="core/angular-route.min.js"></script> <script sr

How to add placeholder text when editor is empty

Kevin Laslow How to add placeholder text when editor is empty? After typing starts, it should disappear. a user You can add a listener for the inputevent and add a div with text if needed like this: var editor = ace.edit("editor", { theme: "ace/theme/chaos"

How to add placeholder text when editor is empty

Kevin Laslow How to add placeholder text when editor is empty? After typing starts, it should disappear. a user You can add a listener for the inputevent and add a div with text if needed like this: var editor = ace.edit("editor", { theme: "ace/theme/chaos"