WP Quicktags – Expand Your WordPress HTML editor

Jun 1, 2013Blog, Web design, WordPress

This simply plugin adds useful buttons to native WordPress HTML editor. Every day we produce for our clients more and more pages in WordPress so we decided to get that job a little more pleasant and managed to create a plugin which adds some additional buttons in native WordPress HTML editor.

WP Quicktags – Expand Your WordPress HTML editor

WP Quicktags - Expand Your WordPress HTML editor

Code:

<?php
/*
Plugin Name: WP Quicktags
Description: This simply plugin adds useful buttons to native WordPress HTML editor. 
Version: 1.0.5
Author: phirebase
Author URI: https://phirebase.com/
License: GPL2
*/

// add more buttons to the html editor
function appthemes_add_quicktags() {
?>
    <script type="text/javascript">
    QTags.addButton( 'eg_strong', 'b', '<strong>', '</strong>', 'b', 'Strong', 1 );
    QTags.addButton( 'eg_h1', 'h1', '<h1>', '</h1>', '', 'Heading 1', 2 );
    QTags.addButton( 'eg_h2', 'h2', '<h2>', '</h2>', '', 'Heading 2', 3 );
    QTags.addButton( 'eg_h3', 'h3', '<h3>', '</h3>', '', 'Heading 3', 4 );
    QTags.addButton( 'eg_h4', 'h4', '<h4>', '</h4>', '', 'Heading 4', 5 );
    QTags.addButton( 'eg_h5', 'h5', '<h5>', '</h5>', '', 'Heading 5', 6 );
    QTags.addButton( 'eg_hr', 'hr', '<hr />', '', '', 'Horizontal rule line', 201 );
    QTags.addButton( 'eg_nbsp', 'nbsp', ' ', '', '', 'Non Breaking Space', 111 );
    </script>
<?php
}
add_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags', 100 );

// Removing buttons from the html editor
function wpa_init( $qtInit ) {
    $qtInit['buttons'] = 'h1,h2,h3,h4,h5,em,link,block,del,img,ul,ol,li,code,more,hr,nbsp,spell,close,fullscreen';
    return $qtInit;
}
add_filter('quicktags_settings', 'wpa_init');

Installation

1. Unzip into your /wp-content/plugins/ directory. If you’re uploading it make sure to upload the top-level folder. Don’t just upload all the php files and put them in /wp-content/plugins/.
2. Activate the plugin through the ‘Plugins’ menu in WordPress

Frequently Asked Questions

Currently No FAQs but feel free to contact us with any questions you do have.

Update 2017

A write up on customizing the WordPress HTML editor by adding custom toolbar buttons via the Quicktags API

Source: Customizing the WordPress HTML Editor with the Quicktags API

Fix Uncaught ReferenceError: QTags is not defined

// add more buttons to the html editor
function appthemes_add_quicktags() {
//check to see if the 'quicktags' script is in use to avoid errors 
 if (wp_script_is('quicktags')){ 
?>
    <script type="text/javascript">
    QTags.addButton( 'eg_strong', 'b', '<strong>', '</strong>', 'b', 'Strong', 1 );
    QTags.addButton( 'eg_h1', 'h1', '<h1>', '</h1>', '', 'Heading 1', 2 );
    QTags.addButton( 'eg_h2', 'h2', '<h2>', '</h2>', '', 'Heading 2', 3 );
    QTags.addButton( 'eg_h3', 'h3', '<h3>', '</h3>', '', 'Heading 3', 4 );
    QTags.addButton( 'eg_h4', 'h4', '<h4>', '</h4>', '', 'Heading 4', 5 );
    QTags.addButton( 'eg_h5', 'h5', '<h5>', '</h5>', '', 'Heading 5', 6 );
    QTags.addButton( 'eg_hr', 'hr', '<hr />', '', '', 'Horizontal rule line', 201 );
    QTags.addButton( 'eg_nbsp', 'nbsp', ' ', '', '', 'Non Breaking Space', 111 );
    QTags.addButton( 'eg_mox', 'mox', '<div class="mox">', '</div>', '', 'Mox', 111 );
    </script>
<?php
}
}
add_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags', 100 );

Sources

Quicktags API « WordPress Codex
Writing a Plugin « WordPress Codex
Add Custom Buttons to the WordPress Editor | AppThemes Docs
WordPress Add/Remove quicktags simple editor buttons in 3.3+ | My Own Home Server
Removing buttons from the html editor – WordPress Answers
How to Add Your Plugin to the WordPress Plugin Directory | Digging into WordPress
How To Publish To The WordPress Plugin Repository | Wptuts+
How To Improve Your WordPress Plugin’s Readme.txt | Smashing WordPress


Download

David

Graphic and website designer, currently maintaining web servers for existing clients and building websites for new clients. In my free time, I learn about Linux, SSH, and WP-CLI and I’m preparing this blog.

Related Posts

25+ Free Fonts for Your Next Design Project

25+ Free Fonts for Your Next Design Project

Looking for some fresh and creative fonts to spice up your design projects in 2023? You’re in luck! In this blog post, we’ve curated a list of 25 free fonts that you can download and use right away. These fonts are suitable for various purposes such as logos,...

Adobe Photoshop Shortcuts – Infographic

Adobe Photoshop Shortcuts – Infographic

Thanks to Amanda from the Consumer Base that she sent us an ultimate Adobe Photoshop shortcuts cheat sheet. If you are a beginner or want to brush up your knowledge on Adobe Photoshop shortcuts then you are at the right place. Have look at it and let us your thoughts...

20 WordPress Tutorial channels on Youtube

20 WordPress Tutorial channels on Youtube

This post will introduce you a useful list of the 20+ best currently active WordPress tutorial related channels on Youtube. These channels are mostly focused on Tutorials and Guides for Developers and Designers that want to learn all about WordPress. Check them out...

12 AI Tools for Graphic and Website Designers

12 AI Tools for Graphic and Website Designers

Artificial intelligence (AI) is transforming the way designers work, from ideation to execution. AI tools can help designers automate tedious tasks, generate new content, and enhance their creativity. In this blog post, I will introduce AI tools that you can use to...

How to Pair Fonts – Tips and Tools for Perfect Font Combinations

How to Pair Fonts – Tips and Tools for Perfect Font Combinations

Font pairing is the art of choosing two or more fonts that work well together and create a harmonious design. Font pairing can make or break your website, logo, poster, or any other project that involves typography. But how do you pair fonts like a pro? In this...

The Ultimate Guide to Color Palettes

The Ultimate Guide to Color Palettes

Color palettes are collections of colors that work well together and create a harmonious visual effect. They are essential for any design and art project, as they help to convey the mood, message, and style of your work. But how do you choose the right color palette...

Show/Hide Comments (0 comments)
L

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social followers

Articles

Visits

Pin It on Pinterest

Shares