fix date rendering in API callback
Some checks failed
continuous-integration/drone/push Build is failing

THe callback function gets a prepared data array as input while
get_the_modified_date expects an ID or WP_Post object. We now use
DateTime::parse directly instead of taking another round loading the
post data.
This commit is contained in:
Stefan Kalscheuer 2022-01-22 19:53:16 +01:00
parent e607ae270f
commit fa936d3f54

View File

@ -14,6 +14,8 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
use DateTime;
/** /**
* Liveticker. * Liveticker.
* *
@ -32,7 +34,7 @@ class Api {
'modified_rendered', 'modified_rendered',
array( array(
'get_callback' => function ( $post ) { 'get_callback' => function ( $post ) {
return get_the_modified_date( 'd.m.Y H:i', $post ); return ( new DateTime( $post['modified'] ) )->format( 'd.m.Y H:i' );
}, },
'schema' => array( 'schema' => array(
'description' => __( 'Rendered modification date and time.', 'stklcode-liveticker' ), 'description' => __( 'Rendered modification date and time.', 'stklcode-liveticker' ),