The ‘quicktags_settings’ filter allows you to modify the Quicktags settings of a WordPress editor.
Usage
add_filter( 'quicktags_settings', 'my_custom_quicktags_settings', 10, 2 ); function my_custom_quicktags_settings( $qtInit, $editor_id ) { // Your custom code here return $qtInit; }
Parameters
- $qtInit (array): The Quicktags settings array.
- $editor_id (string): Unique editor identifier, e.g. ‘content’.
Examples
Add a custom button to the Quicktags toolbar
add_filter( 'quicktags_settings', 'add_custom_quicktag_button', 10, 2 ); function add_custom_quicktag_button( $qtInit, $editor_id ) { // Add custom button to the toolbar $qtInit['buttons'] .= ',custom_button'; // Return the modified settings return $qtInit; }
This code adds a custom button called “custom_button” to the Quicktags toolbar for the specified editor.
Remove the ‘strong’ button from the Quicktags toolbar
add_filter( 'quicktags_settings', 'remove_strong_button', 10, 2 ); function remove_strong_button( $qtInit, $editor_id ) { // Remove 'strong' button from the toolbar $qtInit['buttons'] = str_replace( ',strong', '', $qtInit['buttons'] ); // Return the modified settings return $qtInit; }
This code removes the ‘strong’ button from the Quicktags toolbar for the specified editor.
Change the order of buttons in the Quicktags toolbar
add_filter( 'quicktags_settings', 'change_quicktag_buttons_order', 10, 2 ); function change_quicktag_buttons_order( $qtInit, $editor_id ) { // Set new order for the buttons $qtInit['buttons'] = 'link,em,strong'; // Return the modified settings return $qtInit; }
This code changes the order of buttons in the Quicktags toolbar for the specified editor.
Disable the Quicktags toolbar for a specific editor
add_filter( 'quicktags_settings', 'disable_quicktags_for_specific_editor', 10, 2 ); function disable_quicktags_for_specific_editor( $qtInit, $editor_id ) { if ( $editor_id === 'my_custom_editor' ) { $qtInit['buttons'] = ''; } // Return the modified settings return $qtInit; }
This code disables the Quicktags toolbar for a specific editor with the ID ‘my_custom_editor’.
Add custom settings to the Quicktags toolbar
add_filter( 'quicktags_settings', 'add_custom_quicktags_settings', 10, 2 ); function add_custom_quicktags_settings( $qtInit, $editor_id ) { // Add custom settings to the toolbar $qtInit['custom_setting'] = 'custom_value'; // Return the modified settings return $qtInit; }
This code adds a custom setting to the Quicktags toolbar for the specified editor.