WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/20/2012 10:46:50 AM (8 years ago)
Author:
westi
Message:

Posting: Improve the invalid date protection code based on feedback from nacin.

  • Introduce a wp_checkdate() function with a single filter to centralise the code that validates dates.
  • Improve the error message
  • Correctly handle the return value of wp_insert_post which is not always a WP_Error on failure

Fixes #17180

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r21865 r21922  
    37043704}
    37053705
     3706/**
     3707 * Test if the supplied date is valid for the Gregorian calendar
     3708 *
     3709 * @since 3.5.0
     3710 *
     3711 * @return bool true|false
     3712 */
     3713function wp_checkdate( $month, $day, $year, $source_date ) {
     3714    return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
     3715}
Note: See TracChangeset for help on using the changeset viewer.