wordpress/wp-content/plugins/admin-menu-editor/includes/ame-utils.php
/**
	 * Capitalize the first character of every word. Supports UTF-8.
	 *
	 * @param string $input
	 * @return string
	 */
Capitalize the first character of every word. Supports UTF-8.
@param string $input
@return string
Capitalize the first character of every word . Supports UTF - 8 . @param string $input @return string
public static function ucWords($input) {
		static $hasUnicodeSupport = null, $charset = 'UTF-8';
		if ( $hasUnicodeSupport === null ) {
			$hasUnicodeSupport = function_exists('mb_list_encodings')
				&& (@preg_match('/\pL/u', 'a') === 1)
				&& function_exists('get_bloginfo');
			if ( $hasUnicodeSupport ) {
				$charset = get_bloginfo('charset');
				$hasUnicodeSupport = in_array($charset, mb_list_encodings()) && ($charset === 'UTF-8');
			}
		}
		if ( $hasUnicodeSupport ) {
			$totalLength = mb_strlen($input);
			$words = preg_split('/([\s\-_]++)/u', $input, null, PREG_SPLIT_DELIM_CAPTURE);
			$output = array();
			foreach ($words as $word) {
				$firstCharacter = mb_substr($word, 0, 1, $charset);
				$remainder = mb_substr($word, 1, $totalLength, $charset);
				$output[] = mb_strtoupper($firstCharacter, $charset) . $remainder;
			}
			return implode('', $output);
		}
		return ucwords($input);
	}
public static function ucWords ( $ input ) { static $ hasUnicodeSupport = null , $ charset = 'UTF-8' ; if ( $ hasUnicodeSupport === null ) { $ hasUnicodeSupport = function_exists ( 'mb_list_encodings' ) && ( @ preg_match ( '/\pL/u' , 'a' ) === 1 ) && function_exists ( 'get_bloginfo' ) ; if ( $ hasUnicodeSupport ) { $ charset = get_bloginfo ( 'charset' ) ; $ hasUnicodeSupport = in_array ( $ charset , mb_list_encodings ( ) ) && ( $ charset === 'UTF-8' ) ; } } if ( $ hasUnicodeSupport ) { $ totalLength = mb_strlen ( $ input ) ; $ words = preg_split ( '/([\s\-_]++)/u' , $ input , null , PREG_SPLIT_DELIM_CAPTURE ) ; $ output = array ( ) ; foreach ( $ words as $ word ) { $ firstCharacter = mb_substr ( $ word , 0 , 1 , $ charset ) ; $ remainder = mb_substr ( $ word , 1 , $ totalLength , $ charset ) ; $ output [ ] = mb_strtoupper ( $ firstCharacter , $ charset ) . $ remainder ; } return implode ( '' , $ output ) ; } return ucwords ( $ input ) ; }
Capitalize the first character of every word.
Capitalize the first character of every word .
//We need the mbstring extension and PCRE UTF-8 support. //Technically, the encoding can change if something switches WP to a different site //in the middle of a request, but we'll ignore that possibility. //In old PHP versions, you must specify a non-null length to get the rest of the string.