Error with meta_type_date() function
-
When adding custom date meta, there seems to be a bug. If you use a custom range of dates, the
$interval
variable in the functionmeta_type_date
inwp-meta.php
looks like this:array('name'=>'', 'min'=>'valid date', 'max'=>'valid date');
However, the function goes on to use
array_shift
to get the$min
and$max
values. Soname
ends up in$min
andmin
ends up in$max
. When not using a pre-defined range, this results in an error (Start date must be anterior to end date
) and if you did define a range, it’ll try to format the string name of the range as a date, which won’t error, but also won’t output what you asked for.Proposed resolution:
Replace line 326 in
wp-meta.php
.Currently:
$min = new \Carbon\Carbon( array_shift( $interval ) );
Proposed:$min = new \Carbon\Carbon( $interval['min'] );
And replace line 335 similarly. I’d be happy to contribute that myself if need be.
- The topic ‘Error with meta_type_date() function’ is closed to new replies.