関数 wp_sprintf_l()
2014/12/11
関数 wp_sprintf_l()
定義ファイル :/blog/wp-includes/formatting.php 7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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 ''; $l = apply_filters( 'wp_sprintf_l', array( /* translators: used to join items in a list with more than 2 items */ 'between' => sprintf( __('%s, %s'), '', '' ), /* translators: used to join last two items in a list with more than 2 times */ 'between_last_two' => sprintf( __('%s, and %s'), '', '' ), /* translators: used to join items in a list with only 2 items */ 'between_only_two' => sprintf( __('%s and %s'), '', '' ), ) ); $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); } |