Notifications
Clear all

Date Formatting Update Regarding Caching Problems

13 Posts
4 Users
4 Reactions
753 Views
Posts: 15
Topic starter
(@spielo)
Eminent Member
Joined: 2 years ago

Hi, I changed the recent post widgets and also the secondary format in the forum theme because there are always cacher problems. Is there a way to save the changed RecentPosts.php outside of the plugin so that it is not overwritten during a plugin update? We added the wpforo theme to our wp theme. Maybe your developers could simply renew the entire time format in the plugin, because these days it's no longer possible without additional cacher systems, even if wpforo itself has one.

Thats the code changes in RecentPosts.php file for all are interesting:

 <p class="posttext"><?php echo esc_html( wpforo_text( $post['body'], $instance['excerpt_length'], false ) ); ?></p>
                                <p class="postuser"><?php wpforo_phrase( 'by' ) ?> <?php wpforo_member_link( $member ) ?>
                                    , <span class="uncached" style="white-space: nowrap;">
    <?php
    $current_date = date("Y-m-d");
    $last_post_date = date("Y-m-d", strtotime($post['created']));

    if ($last_post_date === $current_date) {
        echo "heute um " . date("H:i", strtotime($post['created']));
    } elseif ($last_post_date === date("Y-m-d", strtotime("-1 day"))) {
        echo "gestern um " . date("H:i", strtotime($post['created']));
    } else {
        echo "am " . '<div class="full-date">' . date("d/m/Y, H:i", strtotime($post['created'])) . '</div>';
    }
    ?>
</span></p>
12 Replies
dimalifragis
Posts: 2615
(@dimalifragis)
Famed Member
Joined: 4 years ago

What is a "cacher" system?

You mean a Page caching plugin? An Object caching of the server?

Reply
Posts: 15
Topic starter
(@spielo)
Eminent Member
Joined: 2 years ago

Sorry is not my native language, yes we use wp-rocket

Reply
Tutrix
Posts: 1436
(@tutrix)
Noble Member
Joined: 4 years ago

Posted by: @spielo

yes we use wp-rocket

>>> wpForo and Cache Plugins 😉

 

Reply
1 Reply
(@spielo)
Joined: 2 years ago

Eminent Member
Posts: 15

@tutrix Thanks for your tip,

I know all the settings and have implemented them, but cached content is static and no longer dynamic and with a time format in current minutes and seconds, as in the wpforo standard, this is not particularly advantageous. That's why we made this modification to set it to the time of creation and thought we would share it here or maybe encourage the developers to think about the current system displayed, because the one from an hour ago, a month ago, etc. is pretty flat. This can be useful in forums that may require more precise timing. The whole cacher problem also becomes irrelevant.

Reply
Tutrix
Posts: 1436
(@tutrix)
Noble Member
Joined: 4 years ago

@spielo Ah, I understand

For example, I use

<?php esc_html( wpforo_date( $post['created'], 'd/m/Y g:i a' ) ) ?>

To show the full date and time (without today and yesterday)

 

But I will test your code, today and yesterday makes the date even clearer 😉 

 

Reply
Page 1 / 2