WordPress.org

Make WordPress Core

Ticket #22267: 22267.b.patch

File 22267.b.patch, 1.4 KB (added by knutsp, 18 months ago)

Patch B: Introduces optional arg, removes / and \, but adds / to win file paths as a standard

  • formatting.php

     
    13601360 * @uses untrailingslashit() Unslashes string if it was slashed already. 
    13611361 * 
    13621362 * @param string $string What to add the trailing slash to. 
     1363 * @param bool $is_path Optional. Is $string to be considered to be a file path? When true will first remove both / and \ on Windows, but / is always added. Default is false. 
    13631364 * @return string String with trailing slash added. 
    13641365 */ 
    1365 function trailingslashit($string) { 
    1366         return untrailingslashit($string) . '/'; 
     1366function trailingslashit( $string, $is_path = false ) { 
     1367    if ( $is_path ) 
     1368        return untrailingslashit( $string, $is_path ) . '/'; 
     1369    else 
     1370        return untrailingslashit( $string ) . '/'; 
    13671371} 
    13681372 
    13691373/** 
     
    13751379 * @since 2.2.0 
    13761380 * 
    13771381 * @param string $string What to remove the trailing slash from. 
     1382 * @param bool $is_path Optional. Is $string to be considered to be a file path? When true, will remove both slashes and backslashes on Windows. Default is false. 
    13781383 * @return string String without the trailing slash. 
    13791384 */ 
    1380 function untrailingslashit($string) { 
    1381         return rtrim($string, '/'); 
     1385function untrailingslashit( $string, $is_path = false ) { 
     1386    if ( $is_path ) 
     1387        return rtrim( $string, DIRECTORY_SEPARATOR . '/' ); 
     1388    else 
     1389        return rtrim( $string, '/'); 
    13821390} 
    13831391 
    13841392/**