Make WordPress Core

Ticket #17180: 17180.improvements.diff

File 17180.improvements.diff, 2.3 KB (added by westi, 12 years ago)

Improvements based on nacin's feedback

  • wp-includes/post.php

     
    26372637                $mm = substr( $post_date, 5, 2 );
    26382638                $jj = substr( $post_date, 8, 2 );
    26392639                $aa = substr( $post_date, 0, 4 );
    2640                 $valid_date = apply_filters( 'wp_insert_post_validate_date', checkdate( $mm, $jj, $aa ), $post_date );
     2640                $valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
    26412641                if ( !$valid_date ) {
    2642                         return new WP_Error( 'invalid_date', __( 'Woops, the provided date is invalid.' ) );
     2642                        if ( $wp_error )
     2643                                return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
     2644                        else
     2645                                return 0;
    26432646                }
    26442647
    26452648        if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
  • wp-includes/functions.php

     
    37033703        return true;
    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}
     3716 No newline at end of file
  • wp-admin/includes/post.php

     
    122122                $hh = ($hh > 23 ) ? $hh -24 : $hh;
    123123                $mn = ($mn > 59 ) ? $mn -60 : $mn;
    124124                $ss = ($ss > 59 ) ? $ss -60 : $ss;
    125                 $valid_date = apply_filters( '_wp_translate_postdata_valid_date', checkdate( $mm, $jj, $aa ), $post_data );
     125                $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
     126                $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] );
    126127                if ( !$valid_date ) {
    127                         return new WP_Error( 'invalid_date', __( 'Woops, the provided date is invalid.' ) );
     128                        return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
    128129                }
    129                 $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
    130130                $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
    131131        }
    132132