Plugin Author
Tim W
(@timwhitlock)
See the latest_tweets_render_date filter hook – example in the Other Notes tab.
Thanks. i was looking at that yesterday and I thought I was doing this correctly, but I cannot seem to get a value for the datetime attribute to render. I basically took your example and added an additional filter:
add_filter('latest_tweets_render_date', function( $created_at ){
$datetime = DateTime::createFromFormat('D M d H:i:s O Y', $created_at );
return $datetimeX->format('Y-M-d H:i:s');
}, 10 , 1 );
add_filter('latest_tweets_render_date', function( $created_at ){
$date = DateTime::createFromFormat('D M d H:i:s O Y', $created_at );
return $date->format('d M h:ia');
}, 10 , 1 );
add_filter('latest_tweets_render_text', function( $text ){
return $text; // <- will use default
}, 10 , 1 );
add_filter('latest_tweets_render_tweet', function( $html, $date, $datetimeX, $link, array $tweet ){
$pic = $tweet['user']['profile_image_url_https'];
return '<article class="tweet"><figure class="tavatar"><img src="'.$pic.'"></figure><p class="my-tweet">'.$html.'</p><footer class="my-date"><time pubdate datetime="'.$datetimeX.'"><a href="'.$link.'">'.$date.'</a></footer></article>';
}, 10, 4 );
add_filter('latest_tweets_render_after', function(){
return '<footer><a href="https://twitter.com/christianready/">More from me</a></footer>';
}, 10, 0 );
[Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
To be on the safe side, I even called the value “datetimeX” in case “datetime” was a reserved word in PHP. The resulting <time> element looks like <time pubdate datetime=””> with no value for the datetime. Any guess as to what I might be doing wrong?
Plugin Author
Tim W
(@timwhitlock)
there are two mistakes in that code:
1. you assign $datetime and then attempt to access $datetimeX, which doesn’t exist.
2. You added $datetimeX as an additional argument to latest_tweets_render_tweet. It takes 4 only.
If you want to write out two separate date values, you’ll have to parse and format them again in latest_tweets_render_tweet function.
Plugin Author
Tim W
(@timwhitlock)
closing after one month with no follow up.