[wp-hackers] Bug when post title contains > and "

Elliotte Harold elharo at metalab.unc.edu
Sat Mar 17 20:30:38 GMT 2007


Matt wrote:

> But, what is really need is a function that will strip out HTML for output
> to title or alt tags.

What I would ideally want is a little more general: a function that 
converts any HTML fragment to plain text+numeric character references by 
stripping out all tags and converting entity references to numeric 
character references.

There may well already be such a function in either PHP or WordPress 
since this seems to be exactly what the_title_rss and the_excerpt_rss 
already do. Hmm, looks like they're filters of some kind:

$ grep the_excerpt_rss wp-includes/*.php
wp-includes/default-filters.php:add_filter('the_excerpt_rss', 
'convert_chars');
wp-includes/default-filters.php:add_filter('the_excerpt_rss', 'ent2ncr', 8);
wp-includes/feed-functions.php:function the_excerpt_rss() {
wp-includes/feed-functions.php: echo apply_filters('the_excerpt_rss', 
$output);
$ grep the_title_rss wp-includes/*.php
wp-includes/default-filters.php:add_filter('the_title_rss', 'strip_tags');
wp-includes/default-filters.php:add_filter('the_title_rss', 'ent2ncr', 8);
wp-includes/default-filters.php:add_filter('the_title_rss', 
'wp_specialchars');

I haven't explored this part of WP before so I'm not quite sure what's 
going on.

I suspect what we really need are two families of functions:

the_title_with_markup (same as the current the_title)
the_title_without_markup (same as the current the_title_rss)

So we may not really need any API we don't have already. However the 
names of the functions are misleading theme developers (including the 
default theme). They are using the_title in some places where they 
should be using the_title_rss.

Same story for the_excerpt and perhaps some other functions I haven't 
noticed yet.

-- 
Elliotte Rusty Harold  elharo at metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/


More information about the wp-hackers mailing list