fix date rendering in API callback
Some checks failed
continuous-integration/drone/push Build is failing
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:
parent
e607ae270f
commit
fa936d3f54
@ -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' ),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user