Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active November 8, 2019 19:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/428d2bc4c643873d0f476b03fb52f526 to your computer and use it in GitHub Desktop.
Save westonruter/428d2bc4c643873d0f476b03fb52f526 to your computer and use it in GitHub Desktop.
Re: Warning: date() expects parameter 2 to be integer, string given in /www/wp-content/plugins/amp/includes/amp-helper-functions.php on line 659 https://wordpress.org/support/topic/line-error-shown-with-wp_debug/#post-10799506
<?php
function et_last_modified_date_blog( $the_date, $format ) {
if ( 'post' === get_post_type() && 'U' !== $format ) { // Make sure the Unix timestamp is not being requested.
$the_time = get_post_time( 'His' );
$the_modified = get_post_modified_time( 'His' );
$last_modified = sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
$published = sprintf( __( 'Published on %s', 'Divi' ), esc_html( get_post_time( 'M j, Y' ) ) );
$the_date = $the_modified !== $the_time ? $last_modified . ' | ' . $published : $published;
}
return $the_date; // A filter must always return a value.
}
add_filter( 'get_the_date', 'et_last_modified_date_blog', 10, 2 );
add_filter( 'get_the_time', 'et_last_modified_date_blog', 10, 2 );
@JulesWebb
Copy link

Hi Weston

I'm trying to add span tags around the dates so I can target each in a Google Tag Manager DOM variable I'm setting up for Structured Data purposes.

The HTML tags are being escaped and showing on the front end.

$last_modified =  sprintf( __( 'Last updated <span class="mod"> %s </span>', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
$published =  sprintf( __( 'Published on <span class="pub"> %s </span>', 'Divi' ), esc_html( get_post_time( 'M j, Y' ) ) );

Is this something that you can help with?

Thank you for your time,
jules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment