[wp-trac] [WordPress Trac] #16747: 'feedtype_enclosure' hooks not triggered without custom field
WordPress Trac
wp-trac at lists.automattic.com
Fri Mar 4 13:42:07 UTC 2011
#16747: 'feedtype_enclosure' hooks not triggered without custom field
--------------------------+-----------------------------
Reporter: tcloninger | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Feeds | Version: 3.1
Severity: trivial | Keywords:
--------------------------+-----------------------------
file: '''wp-includes/feed.php''', functions: '''atom_enclosure()''' and
'''rss_enclosure()'''
If a "enclosure" custom field is not provided, the ''atom_enclosure'' and
''rss_enclosure'' filters are never triggered (because they're inside an
if statement).
Wouldn't it make sense to replace this ...
{{{
function atom_enclosure() {
if ( post_password_required() )
return;
foreach ( (array) get_post_custom() as $key => $val ) {
if ($key == 'enclosure') {
foreach ( (array) $val as $enc ) {
$enclosure = split("\n", $enc);
echo apply_filters('atom_enclosure',
'<link href="' . trim(htmlspecialchars($enclosure[0])) . '"
rel="enclosure" length="' . trim($enclosure[1]) . '" type="' .
trim($enclosure[2]) . '" />' . "\n");
}
}
}
}
}}}
... with this ...
{{{
function atom_enclosure() {
if ( post_password_required() )
return;
$output = '';
foreach ( (array) get_post_custom() as $key => $val ) {
if ($key == 'enclosure') {
foreach ( (array) $val as $enc ) {
$enclosure = split("\n", $enc);
$output = '<link href="' .
trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' .
trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . '\n';
}
}
}
echo apply_filters('atom_enclosure',$output);
}
}}}
... so that those functions can be hooked via plugins, even if the custom
field doesn't exist?
''In my particular case, I wanted to use a different--already existing--
custom field name to pull the url from, but I couldn't hook
'''atom_enclosure()''' because '''apply_filters()''' is only triggered if
the "enclosure" custom field name exists.''
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16747>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list