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


git-svn-id: https://develop.svn.wordpress.org/trunk@21922 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood
2012-09-20 10:46:50 +00:00
parent 59dd4b7d2b
commit d86f9f140f
3 changed files with 19 additions and 6 deletions

View File

@@ -3703,3 +3703,13 @@ function _device_can_upload() {
return true;
}
/**
* Test if the supplied date is valid for the Gregorian calendar
*
* @since 3.5.0
*
* @return bool true|false
*/
function wp_checkdate( $month, $day, $year, $source_date ) {
return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
}