Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.8/wp-includes/formatting.php

    r11635 r12073  
    601601function sanitize_file_name( $filename ) {
    602602    $filename_raw = $filename;
    603     $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}");
     603    $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
    604604    $special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
    605605    $filename = str_replace($special_chars, '', $filename);
     
    14531453 *
    14541454 * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the
    1455  * value of the 'gmt_offset' option.
     1455 * value of the 'gmt_offset' option. Return format can be overridden using the
     1456 * $format parameter
    14561457 *
    14571458 * @since 1.2.0
     
    14591460 * @uses get_option() to retrieve the the value of 'gmt_offset'.
    14601461 * @param string $string The date to be converted.
     1462 * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
    14611463 * @return string GMT version of the date provided.
    14621464 */
    1463 function get_gmt_from_date($string) {
     1465function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
    14641466    preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
    14651467    $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
    1466     $string_gmt = gmdate('Y-m-d H:i:s', $string_time - get_option('gmt_offset') * 3600);
     1468    $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);
    14671469    return $string_gmt;
    14681470}
     
    14721474 *
    14731475 * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of
    1474  * gmt_offset.
     1476 * gmt_offset.Return format can be overridden using the $format parameter
    14751477 *
    14761478 * @since 1.2.0
    14771479 *
    14781480 * @param string $string The date to be converted.
     1481 * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
    14791482 * @return string Formatted date relative to the GMT offset.
    14801483 */
    1481 function get_date_from_gmt($string) {
     1484function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {
    14821485    preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
    14831486    $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
    1484     $string_localtime = gmdate('Y-m-d H:i:s', $string_time + get_option('gmt_offset')*3600);
     1487    $string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600);
    14851488    return $string_localtime;
    14861489}
Note: See TracChangeset for help on using the changeset viewer.