Skip to content

Commit

Permalink
Fix Badge Date
Browse files Browse the repository at this point in the history
  • Loading branch information
markparolisi authored and lautarodragan committed Nov 27, 2018
1 parent b9533ae commit 20a832e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion public/class-poet-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ public function poet_badge_handler( $content ) {
$post = get_post();
$quill_image_url = plugin_dir_url( __FILE__ ) . '/images/quill.svg';
$post_publication_date = get_the_modified_time( 'F jS Y, H:i', $post );
$frost_last_updated = date( 'F jS Y, H:i', (int) get_post_meta( $post->ID, 'poet_last_updated', true ) );
$work_id = get_post_meta( $post->ID, 'poet_work_id', true );
$poet_badge = '';

// are we working with a 64 char string.
if ( strlen( $work_id ) === 64 ) {
include_once dirname( __FILE__ ) . '/partials/poet-badge-template.php';
$poet_badge = print_poet_template( $quill_image_url, $work_id, $post_publication_date );
$poet_badge = print_poet_template( $quill_image_url, $work_id, $frost_last_updated );
}

return $content . $poet_badge;
Expand Down Expand Up @@ -145,6 +146,7 @@ public function post_article( $post_id ) {

// Creating or updating poet work id meta to the returned work id.
update_post_meta( $post_id, 'poet_work_id', $decoded_response_body->{'workId'} );
update_post_meta( $post_id, 'poet_last_updated', time() );

}
} catch ( Exception $e ) {
Expand Down
4 changes: 2 additions & 2 deletions public/partials/poet-badge-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @param string $post_publication_date date of the post publication.
* @return string html code plus Po.et badge
*/
function print_poet_template( $quill_image_url, $work_id, $post_publication_date ) {
function print_poet_template( $quill_image_url, $work_id, $display_date ) {
ob_start()
?>
<div class = "poet-container">
Expand All @@ -26,7 +26,7 @@ function print_poet_template( $quill_image_url, $work_id, $post_publication_date
Verified on Po.et</p>
<p class = "poet-date">
<?php
echo esc_html( $post_publication_date );
echo esc_html( $display_date );
?>
</p>
</div>
Expand Down

0 comments on commit 20a832e

Please sign in to comment.