Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_sprintf_l [ WordPress Function ]

wp_sprintf_l ( $pattern, $args )
Parameters:
  • (string) $pattern Content containing '%l' at the beginning.
  • (array) $args List items to prepend to the content and replace '%l'.
Returns:
  • (string) Localized list items and rest of the content.
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($pattern02) != '%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) == )
        
$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 ( 
== $i )
            
$result .= $l['between_last_two'] . $arg;
        else
            
$result .= $l['between'] . $arg;
    }
    return 
$result substr($pattern2);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics