The htmledit_pre WordPress PHP Filter is used to modify the text before it is formatted for the HTML editor.
Note: this filter has been deprecated.
Usage
add_filter('htmledit_pre', 'your_custom_function', 10, 1); function your_custom_function($output) { // your custom code here return $output; }
Parameters
$output
(string) – The HTML-formatted text.
More information
See WordPress Developer Resources: htmledit_pre
Examples
Replace ‘WordPress’ with ‘WP’
This example replaces all instances of ‘WordPress’ with ‘WP’ before the text is formatted for the HTML editor.
add_filter('htmledit_pre', 'replace_wordpress_with_wp', 10, 1); function replace_wordpress_with_wp($output) { $output = str_replace('WordPress', 'WP', $output); return $output; }
Remove HTML tags
This example removes all HTML tags from the text before it is formatted for the HTML editor.
add_filter('htmledit_pre', 'remove_html_tags', 10, 1); function remove_html_tags($output) { $output = strip_tags($output); return $output; }
Convert text to uppercase
This example converts all text to uppercase before it is formatted for the HTML editor.
add_filter('htmledit_pre', 'convert_text_to_uppercase', 10, 1); function convert_text_to_uppercase($output) { $output = strtoupper($output); return $output; }
Add a copyright notice
This example adds a copyright notice at the end of the text before it is formatted for the HTML editor.
add_filter('htmledit_pre', 'add_copyright_notice', 10, 1); function add_copyright_notice($output) { $copyright = '© ' . date('Y') . ' YourCompanyName. All rights reserved.'; $output = $output . "\n\n" . $copyright; return $output; }
Remove shortcodes
This example removes all shortcodes from the text before it is formatted for the HTML editor.
add_filter('htmledit_pre', 'remove_shortcodes', 10, 1); function remove_shortcodes($output) { $output = strip_shortcodes($output); return $output; }