mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 14:14:36 +00:00
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:
@@ -2637,9 +2637,12 @@ function wp_insert_post($postarr, $wp_error = false) {
|
||||
$mm = substr( $post_date, 5, 2 );
|
||||
$jj = substr( $post_date, 8, 2 );
|
||||
$aa = substr( $post_date, 0, 4 );
|
||||
$valid_date = apply_filters( 'wp_insert_post_validate_date', checkdate( $mm, $jj, $aa ), $post_date );
|
||||
$valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
|
||||
if ( !$valid_date ) {
|
||||
return new WP_Error( 'invalid_date', __( 'Woops, the provided date is invalid.' ) );
|
||||
if ( $wp_error )
|
||||
return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
|
||||
|
||||
Reference in New Issue
Block a user