Hy. So would anybody know how to write a function that would sanitize all links in a specific class that are entered through WYSISW开发者_StackOverflowYG editor? I know about the wordpress in-built sanitize_title function, but I don't know how I could refer to those links(links in a specific class). Any help much appreciated.
Why don't you use a filter function to filter the_content()
?
In your functions.php file, include the filter hook:
add_filter ( 'the_content', 'your_sanitizer_function');
Then also in functions.php write the sanitizing function that will filter the normal output of the_content()
:
function your_sanitizer_function($content){
/* use some php here to change your content as you see fit...
for example, $content = str_replace('foo', 'bar', $content);
*/
return $content;
}
精彩评论