Skip to content

Instantly share code, notes, and snippets.

@seezee
Last active May 6, 2021 06:33
Show Gist options
  • Select an option

  • Save seezee/d3370afada533310d78ac673964b244a to your computer and use it in GitHub Desktop.

Select an option

Save seezee/d3370afada533310d78ac673964b244a to your computer and use it in GitHub Desktop.

Revisions

  1. seezee revised this gist May 5, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion date-modified.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    */

    /**
    * Returns the last modified date for the post with the datetime tag and the
    * Returns the last modified date for the post with the <time> tag and the
    * time zone.
    *
    * @parameter array $arr Allowed tags.
  2. seezee revised this gist May 5, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion date-modified.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    */

    /**
    * Displays the last modified date for the post with the datetime tag and the
    * Returns the last modified date for the post with the datetime tag and the
    * time zone.
    *
    * @parameter array $arr Allowed tags.
  3. seezee revised this gist May 5, 2021. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions date-modified.php
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,10 @@
    * @parameter array $arr Allowed tags.
    * @parameter string $tz The post modified time.
    * @parameter string $ltz The local timezone offset.
    * @parameter string $modified_time The sanitized output.
    * @parameter string $modified_time The unsanitized output.
    * @parameter string $output The sanitized output.
    *
    * @return string The sanitized output.
    */
    function my_post_modified_date() {
    $arr = array(
    @@ -24,15 +27,18 @@ function my_post_modified_date() {
    );

    $tz = get_the_modified_time( 'T' );
    if ( 'CST' == $tz ) { // Standard Time. Change to match your timezone.
    if ( 'CST' === $tz ) { // Standard Time. Change to match your timezone.
    $ltz = '-6:00'; // Change the offset to match your timezone.
    } elseif ( 'CDT' == $tz ) { // Daylight Saving Time. Change to match your timezone.
    } elseif ( 'CDT' === $tz ) { // Daylight Saving Time. Change to match your timezone.
    $ltz = '-5:00'; // Change the offset to match your timezone.
    } else {
    $ltz = '';
    }

    $modified_time = '<small><i>' . esc_html_e( 'Latest revision:', 'text-domain' ) . '</i> <time datetime="' . get_the_modified_time( 'Y-m-d\TG:i:s', true, null, true ) . $ltz . '">' . get_the_modified_date() . '</time></small>';

    echo wp_kses( $modified_time, $arr );
    $output = wp_kses( $modified_time, $arr );
    return $output;
    // Use a standard WordPress hook to output the string to your post.
    // See https://developer.wordpress.org/plugins/hooks/.
    }
  4. seezee created this gist May 5, 2021.
    38 changes: 38 additions & 0 deletions date-modified.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    <?php
    /**
    * Displays the post modified date.
    *
    * @package There is no package.
    */

    /**
    * Displays the last modified date for the post with the datetime tag and the
    * time zone.
    *
    * @parameter array $arr Allowed tags.
    * @parameter string $tz The post modified time.
    * @parameter string $ltz The local timezone offset.
    * @parameter string $modified_time The sanitized output.
    */
    function my_post_modified_date() {
    $arr = array(
    'time' => array(
    'datetime' => array(),
    ),
    'small' => array(),
    'i' => array(),
    );

    $tz = get_the_modified_time( 'T' );
    if ( 'CST' == $tz ) { // Standard Time. Change to match your timezone.
    $ltz = '-6:00'; // Change the offset to match your timezone.
    } elseif ( 'CDT' == $tz ) { // Daylight Saving Time. Change to match your timezone.
    $ltz = '-5:00'; // Change the offset to match your timezone.
    } else {
    $ltz = '';
    }

    $modified_time = '<small><i>' . esc_html_e( 'Latest revision:', 'text-domain' ) . '</i> <time datetime="' . get_the_modified_time( 'Y-m-d\TG:i:s', true, null, true ) . $ltz . '">' . get_the_modified_date() . '</time></small>';

    echo wp_kses( $modified_time, $arr );
    }