Text snippets for WordPress Posts

Home Forums Web Hosting Forum Text snippets for WordPress Posts


This topic contains 2 replies, has 2 voices, and was last updated by  Keith Taylor 3 years, 10 months ago.

  • Author
  • #2701

    Ŧollars: Ŧ 54.40

    Related to my other question HTML for long list of words. I frequently use Definition Lists and tables in my posts and pages. I have a text file that I use to copy and paste my frequently used HTML tags. Is there an easy way to add a buttons to the text editor?

    Also, I never use the del, img, or close tags buttons. Can I get rid of these?

  • #2702

    Keith Taylor
    Ŧollars: Ŧ 1 ,191.76

    I’ll cover removing buttons first. The full list of buttons are:

    I got that list from WordPress Add/Remove quicktags, where some of the following code comes from.

    I based the code for adding buttons on WordPress Quicktags API

    add_filter( 'quicktags_settings', 'kct_remove_quicktags', 10, 1 );
    function kct_remove_quicktags( $qtInit ) {
        $remove_these = array('del', 'img', 'close');
        // Convert string to array
        $buttons = explode(',', $qtInit['buttons']);
        // Loop over items to remove and unset them from the buttons
        for( $i=0; $i < count($remove_these); $i++ ) {
            if( ($key = array_search($remove_these[$i], $buttons)) !== false)
        // Convert new buttons array back into a comma-separated string
        $qtInit['buttons'] = implode(',', $buttons);
        return $qtInit;
    add_action( 'admin_print_footer_scripts', 'kct_add_quicktags' );
    function kct_add_quicktags() {
        if (wp_script_is('quicktags')){
        <script type="text/javascript">
        QTags.addButton( 'kct_dl', 'dl', '<dl>\n<dt></dt><dd></dd>\n</dl>\n','', '', 'dl block tags' );
        QTags.addButton( 'kct_hr', 'hr', '\n<hr />\n', '', 'h', 'Horizontal rule line');
        QTags.addButton( 'kct_smile', ':?:', kct_smilies );
    	function kct_smilies(){ alert(':smile:\n :grin:\n :sad:\n :eek:\n :shock:\n :???:\n :cool:\n :mad:\n :razz:\n :neutral:\n :wink:\n :lol:\n :oops:\n :cry:\n :evil:\n :twisted:\n :roll:\n :!:\n :?:\n :idea:\n :arrow:\n :mrgreen:'); }

    The alert for showing smiley codes is less than perfect. It works for me, but could be improved significantly by incorporating a dropdown list to choose a specific smiley. As it stands, I find it easy enough to triple-click my choice, then copy-paste. 😎

  • #2703

    Keith Taylor
    Ŧollars: Ŧ 1 ,191.76

    So far, this only works in the back-end admin area. It ought to add buttons to the editor in these bbPress forum pages. However, though the delete button function works, the add button function doesn’t. 😮

    For now, I’m happy to restrict it to administrators only. But, if you want me to troubleshoot the front-end operation, please just ask.

    By the way, there is code for dropdown buttons in the editor at http://bililite.com/blog/2012/08/20/custom-buttons-in-the-wordpress-html-editor/

You must be logged in to reply to this topic.