WordPress.org

Plugin Directory

Changeset 496626


Ignore:
Timestamp:
01/28/12 21:37:50 (2 years ago)
Author:
Jayjdk
Message:

Version 1.2

  • You can now change the order of the Quicktags. Just drag 'n' drop them on the settings page
  • You can easier remove Quicktags. Each row has a delete link on the right
  • You can now add more than one Quicktag a time
  • The settings page Javascript and CSS has been moved to seperate files
Location:
jayj-quicktag/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • jayj-quicktag/trunk/jayj-quicktag.php

    r472012 r496626  
    66 * Author:      Jesper J 
    77 * Author URI:  http://jayj.dk 
    8  * Version:     1.1 
     8 * Version:     1.2 
    99 * License: GPLv2 or later 
    1010 */ 
     
    116116            <thead> 
    117117                <tr> 
     118                    <th scope="col" class="jayj-order" title="Change order"><!-- order --></th> 
    118119                    <th scope="col">Button Label *</th> 
    119120                    <th scope="col">Title Attribute</th> 
    120121                    <th scope="col">Start Tag(s) *</th> 
    121122                    <th scope="col">End Tag(s)</th> 
     123                    <th scope="col" title="Remove button"><!-- remove --></th> 
    122124                </tr> 
    123125            </thead> 
     
    127129                    if ( isset( $options['buttons'] ) ) : 
    128130 
    129                         // Loop through all the buttons 
     131                    // Loop through all the buttons 
    130132                    for ( $i = 0; $i < count( $options['buttons'] ); $i++ ) : 
    131133 
     
    133135                            break; 
    134136                ?> 
    135                     <tr valign="top"> 
     137                    <tr valign="top" class="jayj-row"> 
     138                        <td class="jayj-order" title="Change order"><?php echo esc_attr( $i + 1 ); ?></td> 
    136139                        <td><input type="text" name="jayj_qt_settings[buttons][<?php echo $i; ?>][text]" value="<?php echo esc_attr( $options['buttons'][$i]['text'] ); ?>" /></td> 
    137140                        <td><input type="text" name="jayj_qt_settings[buttons][<?php echo $i; ?>][title]" value="<?php echo esc_attr( $options['buttons'][$i]['title'] ); ?>" /></td> 
    138141                        <td><textarea class="code" name="jayj_qt_settings[buttons][<?php echo $i; ?>][start]" rows="2" cols="25"><?php echo esc_textarea( $options['buttons'][$i]['start'] ); ?></textarea></td> 
    139142                        <td><textarea class="code" name="jayj_qt_settings[buttons][<?php echo $i; ?>][end]" rows="2" cols="25"><?php echo esc_textarea( $options['buttons'][$i]['end'] ); ?></textarea></td> 
     143                        <td class="jayj-remove"><a class="jayj-remove-button" href="javascript:;" title="Remove button">&times;</a></td> 
    140144                    </tr> 
    141145                <?php endfor; endif; ?> 
    142146 
    143147                    <!-- Empty --> 
    144                     <?php $i = isset( $i ) ? $i : 0; ?> 
    145                     <tr valign="top" class="alternative"> 
     148                    <?php $i = 999; ?> 
     149                    <tr valign="top" class="jayj-clone"> 
     150                        <td class="jayj-order" title="Change order"><?php echo esc_attr( $i ); ?></td> 
    146151                        <td><input type="text" name="jayj_qt_settings[buttons][<?php echo $i; ?>][text]" title="Label of the Quicktag" value="" /></td> 
    147152                        <td><input type="text" name="jayj_qt_settings[buttons][<?php echo $i; ?>][title]" title="Title attribute of the Quicktag" value="" /></td> 
    148153                        <td><textarea class="code" name="jayj_qt_settings[buttons][<?php echo $i; ?>][start]" rows="2" cols="25" title="Start Tag(s)"></textarea></td> 
    149154                        <td><textarea class="code" name="jayj_qt_settings[buttons][<?php echo $i; ?>][end]" rows="2" cols="25" title="End Tag(s)"></textarea></td> 
     155                        <td class="jayj-remove"><a class="jayj-remove-button" href="javascript:;" title="Remove button">&times;</a></td> 
    150156                    </tr> 
    151157            </tbody> 
    152158        </table> 
    153  
    154         <p>To delete a Quicktag, just leave the "Button Label" empty</p> 
    155  
    156         <?php submit_button( __( 'Save Changes' ) ); ?> 
     159         
     160        <div class="jayj-table-footer"> 
     161            <div class="jayj-order-message"></div> 
     162            <?php submit_button( __( 'Save Changes' ) ); ?> 
     163            <a href="javascript:;" id="jayj-add-button" class="button-secondary">+ Add New Button</a> 
     164        </div> 
    157165    </form> 
    158166 
    159167    <!-- Export/Import metaboxes --> 
    160     <style type="text/css"> 
    161         .jayj-quicktags-postbox { font-size: 13px; float: left; width: 48%; margin-right: 3%; } 
    162         .jayj-quicktags-postbox-last { margin-right: 0; } 
    163         .jayj-quicktags-postbox .hndle { cursor: pointer; } 
    164         .jayj-quicktags-postbox textarea, .jayj-quicktags-table input, .jayj-quicktags-table textarea { width: 95%; } 
    165         .jayj-quicktags-postbox li { list-style: disc; margin-left: 40px; } 
    166     </style> 
    167  
    168168    <form action="" method="post" name="jayj-import-quicktags"> 
    169169    <div id="poststuff"><div class="metabox-holder"> 
     
    217217 
    218218    // Don't save empty inputs 
    219     for ( $i = 0; $i < count( $input['buttons'] ); $i++ ) : 
    220         if ( empty( $input['buttons'][$i]['text'] ) ) { 
    221             unset( $input['buttons'][$i] ); 
    222  
    223             $input['buttons'] = array_values( $input['buttons'] ); 
    224  
    225             // In rare circumstances the empty inputs has to be removed again 
    226             if ( empty( $input['buttons'][$i]['text'] ) ) 
    227                 unset( $input['buttons'][$i] ); 
    228  
    229             $input['buttons'] = array_values( $input['buttons'] ); 
    230         } 
    231     endfor; 
     219    foreach( $input['buttons'] as $i => $btn ) : 
     220 
     221        if ( empty( $btn['text'] ) ) 
     222            unset( $input['buttons'][$i], $btn ); 
     223 
     224    endforeach; 
     225 
     226    $input['buttons'] = array_values( $input['buttons'] ); 
    232227 
    233228    return $input; 
     
    235230 
    236231/** 
    237  * Loads the JavaScript files required for managing the meta boxes on the plugin settings 
     232 * Loads the JavaScript and CSS files required for managing the meta boxes on the plugin settings 
    238233 * page, which allows users to toggle the metaboxes 
     234 * and for ordering the Quicktags 
    239235 * 
    240236 * @since 1.1.0 
    241  * @todo Find a way to save the open/close state 
    242237 */ 
    243238function jayj_quicktag_settings_page_enqueue_scripts( $hook_suffix ) { 
    244     if ( $hook_suffix == 'settings_page_jayj-quicktag/jayj-quicktag' ) 
     239    if ( $hook_suffix == 'settings_page_jayj-quicktag/jayj-quicktag' ) { 
    245240        wp_enqueue_script( 'postbox' ); 
     241        wp_enqueue_script( 'jayj-quicktag', plugins_url( 'jayj-quicktag.js', __FILE__ ), array( 'jquery', 'postbox' ), '1.2' ); 
     242        wp_enqueue_style( 'jayj-quicktag', plugins_url( 'jayj-quicktag.css', __FILE__ ), array(), '1.2' ); 
     243    } 
    246244} 
    247245 
     
    249247 
    250248/** 
    251  * Loads the JavaScript required for toggling the meta boxes on the plugin settings page. 
    252  * 
    253  * @since 1.1.0 
    254  */ 
    255 function jayj_quicktag_settings_page_load_scripts() { ?> 
    256     <script type="text/javascript"> 
    257         jQuery(document).ready( function($) { 
    258             $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' ); 
    259             postboxes.add_postbox_toggles( 'settings_page_jayj-quicktag/jayj-quicktag' ); 
    260         }); 
    261     </script><?php 
    262 } 
    263  
    264 add_action( "admin_head-settings_page_jayj-quicktag/jayj-quicktag", 'jayj_quicktag_settings_page_load_scripts' ); 
    265      
    266 /** 
    267249 * Add the quicktags to editor 
    268250 * 
    269251 * @since 1.0.0 
    270  * @uses apply_filters() Calls 'jayj_quicktag_screens' filter on the screens array 
    271252 */ 
    272253function jayj_quicktag_editor() { 
     254 
     255    // Check if the wp_editor() function has been called. If it hasn't, don't include the Quicktags javascript 
     256    if ( ! did_action( 'before_wp_tiny_mce' ) ) 
     257        return; 
    273258 
    274259    // Get the options 
  • jayj-quicktag/trunk/readme.txt

    r488391 r496626  
    44Requires at least: 3.3 
    55Tested up to: 3.3 
    6 Stable tag: 1.1 
     6Stable tag: 1.2 
    77 
    88Allows you easily to add custom Quicktags to the post editor 
     
    3939Yes, you can. Just leave the "Button Label" empty. 
    4040 
     41= Can I delete a Quicktag? = 
     42 
     43Yes, you can. There's two ways. The first one is to click the delete link on the right (you'll see it when you roll over the row) 
     44 
     45The other way is to leave the "Button Label" field empty. 
     46 
     47= Can I change the order of the Quicktags? = 
     48 
     49Yes. Since 1.2 you can change the order of the tags. Just roll over the number on the left and you should to able to drag 'n' drop the rows. 
     50 
    4151= I'm a theme author, can I set up default Quicktags if a user choose to use this plugin? = 
    4252 
    4353Yes, you can. If you put this code in your theme's functions.php, they will automatically be added if a user install this plugin 
    4454 
    45 <code> 
     55``` 
    4656function my_theme_jayj_quicktag_defaults( $defaults ) { 
    4757    $defaults = array( 'buttons' => array( 
     
    6575 
    6676add_filter( 'jayj_quicktag_defaults', 'my_theme_jayj_quicktag_defaults' ); 
    67 </code> 
     77``` 
    6878 
    6979= Can I export/import Quicktags? = 
     
    7989== Screenshots == 
    8090 
    81 1. The Quicktag generator settings page. 
     911. The Quicktag generator settings page. You can drag 'n' drop the rows to change the order. 
    82922. A post editor with the new Quicktags 
    8393 
    8494== Changelog == 
    8595 
     96= 1.2 = 
     97* You can now change the order of the Quicktags. Just drag 'n' drop them on the settings page 
     98* You can easier remove Quicktags. Each row has a delete link on the right 
     99* You can now add more than one Quicktag a time 
     100* The settings page Javascript and CSS has been moved to seperate files 
     101 
     102= 1.1.1 = 
     103* Don't include the Quicktags javascript on pages without an editor 
    86104= 1.1 = 
    87105* You can now export and import Quicktags 
     
    90108* Initial Release 
    91109 
     110 
    92111== Upgrade Notice == 
     112 
     113= 1.2 = 
     114You can change the order of the tags. Easier to add and remove them. 
     115 
     116= 1.1.1 = 
     117The javascript is no longer included on all admin pages 
    93118 
    94119= 1.1 = 
Note: See TracChangeset for help on using the changeset viewer.