The no_texturize_shortcodes WordPress PHP filter allows you to modify the list of shortcodes that shouldn’t be texturized.
Usage
add_filter('no_texturize_shortcodes', 'my_custom_no_texturize_shortcodes'); function my_custom_no_texturize_shortcodes($default_no_texturize_shortcodes) { // your custom code here return $default_no_texturize_shortcodes; }
Parameters
$default_no_texturize_shortcodes
(string[]): An array of shortcode names that should not be texturized.
More information
See WordPress Developer Resources: no_texturize_shortcodes
Examples
Add a new shortcode to the list
Add a new shortcode called ‘my_shortcode’ to the list of shortcodes that shouldn’t be texturized.
add_filter('no_texturize_shortcodes', 'add_my_shortcode_no_texturize'); function add_my_shortcode_no_texturize($default_no_texturize_shortcodes) { $default_no_texturize_shortcodes[] = 'my_shortcode'; return $default_no_texturize_shortcodes; }
Remove a shortcode from the list
Remove the ‘caption’ shortcode from the list of shortcodes that shouldn’t be texturized.
add_filter('no_texturize_shortcodes', 'remove_caption_shortcode_no_texturize'); function remove_caption_shortcode_no_texturize($default_no_texturize_shortcodes) { $key = array_search('caption', $default_no_texturize_shortcodes); if ($key !== false) { unset($default_no_texturize_shortcodes[$key]); } return $default_no_texturize_shortcodes; }
Replace the entire list
Replace the entire list of shortcodes with a new array of shortcodes that shouldn’t be texturized.
add_filter('no_texturize_shortcodes', 'replace_entire_list_no_texturize'); function replace_entire_list_no_texturize($default_no_texturize_shortcodes) { return array('my_shortcode1', 'my_shortcode2', 'my_shortcode3'); }
Clear the list
Clear the entire list of shortcodes that shouldn’t be texturized.
add_filter('no_texturize_shortcodes', 'clear_list_no_texturize'); function clear_list_no_texturize($default_no_texturize_shortcodes) { return array(); }
Modify the list conditionally
Add a new shortcode to the list only if a certain condition is met.
add_filter('no_texturize_shortcodes', 'conditionally_add_shortcode_no_texturize'); function conditionally_add_shortcode_no_texturize($default_no_texturize_shortcodes) { if (current_user_can('edit_posts')) { $default_no_texturize_shortcodes[] = 'my_shortcode'; } return $default_no_texturize_shortcodes; }