wp_sprintf_l [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Localize list items before the rest of the content.
The '%l' must be at the first characters can then contain the rest of the content. The list items will have ', ', ', and', and ' and ' added depending on the amount of list items in the $args parameter.
Source
<?php
function wp_sprintf_l($pattern, $args) {
// Not a match
if ( substr($pattern, 0, 2) != '%l' )
return $pattern;
// Nothing to work with
if ( empty($args) )
return '';
// Translate and filter the delimiter set (avoid ampersands and entities here)
$l = apply_filters('wp_sprintf_l', array(
/* translators: used between list items, there is a space after the comma */
'between' => __(', '),
/* translators: used between list items, there is a space after the and */
'between_last_two' => __(', and '),
/* translators: used between only two list items, there is a space after the and */
'between_only_two' => __(' and '),
));
$args = (array) $args;
$result = array_shift($args);
if ( count($args) == 1 )
$result .= $l['between_only_two'] . array_shift($args);
// Loop when more than two args
$i = count($args);
while ( $i ) {
$arg = array_shift($args);
$i--;
if ( 0 == $i )
$result .= $l['between_last_two'] . $arg;
else
$result .= $l['between'] . $arg;
}
return $result . substr($pattern, 2);
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- wp_sprintf_l() WordPress function reference, arguments and source ...
wp_sprintf_l(). Localize list items before the rest of the content. The '%l' must be at the first characters can then contain the rest of the content. The list items will ...
queryposts.com - WordPress code surprise: wp_sprintf | Andy Skelton
Jan 5, 2011 ... The only 'wp_sprintf' filter now in core is wp_sprintf_l() , which adds a new ... To that end, wp_sprintf_l formats lists with Oxford commas.
andy.wordpress.com - Andy Skelton | Just another WordPress hacker | Page 2
Jan 5, 2011 ... Our filter, wp_sprintf_l() , receives a format fragment and the $args that corresponds with its position or number. It returns the first fragment, '%s: ...
andy.wordpress.com - Vanessa Athens
@return string Localized list items and rest of the content. */ function wp_sprintf_l( $pattern, $args) { // Not a match if ( substr($pattern, 0, 2) != '%l' ) return $pattern ...
www.vanessaathens.com