Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Robin

Inline edit date picker starts in the year 1483

Using the WP-Types plugins for a custom date field. I’ve made it editable via Admin Columns Pro however when I go to edit a date the year start on something stupid like 1483. The date I am editing for example is April 15, 2016.

How can I get it to start closer to the time.

5 years, 5 months ago
Stefan
Developer

Hi Robin,

I can reproduce your problem.
The problem is that you set that format in the custom field column to date. This automatically add inline edit support for the column with a date picker. The only problem is that we don’t know which format for the date is used in the database. That’s why we have a plugin for ACF but not (yet) for WP Types. WP Types uses a timestamp format as date and that doesn’t work with our code.

You can get and save the correct date format for types by using the following filters. Just paste them in your function.php and it should work for WP Types dates.


function cac_get_types_date_format( $value, $column ) {
	if( 'date' == $column->get_option( 'field_type') && strpos( $column->get_option( 'field'), 'wpcf') !== false  ){
		$value = date( 'Ymd', $value );
	}
	return $value ;
}
add_filter( 'cac/editable/column_value', 'cac_get_types_date_format', 10, 2 );

function cac_save_types_date_format( $value, $column ) {

	if( 'date' == $column->get_option( 'field_type') && strpos( $column->get_option( 'field'), 'wpcf') !== false  ){
		$value = strtotime( $value );
	}

	return $value;
}
add_filter( 'cac/inline-edit/ajax-column-save/value', 'cac_save_types_date_format', 10, 2 );
5 years, 5 months ago
Robin

Wonderful that works great. Any plans for a Types plugin in the future?

5 years, 5 months ago
Stefan
Developer

You’re welcome
We’ve added it to our feature request list.
Maybe we create a custom addon for Types or just some filters like this to support Types in our product.
Thanks for noticing the date bug anyway :)

5 years, 5 months ago

You must be logged in to reply to this topic.