cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
280 stars 82 forks source link

Long date-format for widget #297

Closed exetico closed 2 years ago

exetico commented 2 years ago

Hi,

I really like the l, j. F Y date-format, which will render the date as saturday, 7. august 2021. The "by/posted" string are removed, too.

Therefore, I hope you'd like to implement the change.

Alternative Use get_option('date_format'); if the owner selects Use the default Wordpress-format, however, I'd like to skip the call to get_option.

Fell free to pull part of the requests, if you're building the source on your own.

And oh; Thank you for a awesome plugin. I really like the Use custom HTML Markup option. I'm moving away from Jetpack, and needed a new popular-post plugin. But the date-format is a deal-breaker for me.

Own thoughts about the changes The inline if-statement could be rewritten to something much more readable. But I simply did this as short as possible. Also, I'm not sure if the sprintf() was necessary to use here, but I ended up using the same solution, and trimmed it down to %s.

exetico commented 2 years ago

O... m.... g.... I just spotted the detail about the usage of {date}, and the date-format too, while using the shortcode...

So, maybe this is not that relevant anymore.

However.. I'm currently facing issues with a conflict (LiteSpeed Cache with Page Optimizations turned on): https://golitespeed.slack.com/archives/C3RJHNBTQ/p1628368830048800

exetico commented 2 years ago

Update: It's only a problem with the experimental features.

If you like, I can provide you more information. I disabled the experimental version, and added a [wpp] shortcode instead. Everything work. If I enable the experimental functions, it starts to complain about wp.i18n issues and so. It's 100% a conflict with the page optimization, but... That's needed in our setup :-)

It must be something related to: ['wp-blocks', 'wp-i18n', 'wp-element', 'wp-block-editor', 'wp-server-side-render']

cabrerahector commented 2 years ago

Hi Tobias,

I'm currently facing issues with a conflict (LiteSpeed Cache with Page Optimizations turned on): https://golitespeed.slack.com/archives/C3RJHNBTQ/p1628368830048800

I tried accessing that link but it asks me to log in to your (?) Slack domain :P Please consider posting your screenshot(s) somewhere that doesn't require user registration / login instead (like Dropbox or GDrive).

O... m.... g.... I just spotted the detail about the usage of {date}, and the date-format too, while using the shortcode...

So, maybe this is not that relevant anymore.

Alright, so I take it that there's no need for me to review this PR then? :P

Also, you could still use the WPP block and then create your own custom date tag (eg. {long_date}) via the wpp_parse_custom_content_tags filter hook so your dates are displayed in whichever format you need, removing the need of having the plugin ship with specific date formats (and yours is very specific to your use case).

Here's a real-life example on registering and using custom content tags: Display Tags and Author image.

... or you could just forget about all that and either just keep using the [wpp] shortcode as you mentioned before or you could also install the Classic Widgets plugin which will allow you to use the "classic" WordPress Popular Posts widget instead.

If you like, I can provide you more information.

If I enable the experimental functions, it starts to complain about wp.i18n issues and so. It's 100% a conflict with the page optimization, but... That's needed in our setup :-)

If it's throwing errors because of wp.i18n though chances are this is not something I can fix because that's a core WordPress library. Nonetheless it would still be helpful if you shared more details about the issue so I could take a look at least.

And oh; Thank you for a awesome plugin.

Thank you, I'm glad you like it!

exetico commented 2 years ago

Hi Héctor

Thank you, for a great reply!

First of all, I must say the PR and comments was created while working on the things - so I didn't think about the Slack link. LiteSpeed Cache's "Page Optimization" are known to be a bit aggressive, but all our other plugins works just fine (Well, know that many.. But still).

Maybe I should find time to give it a fresh test, with a clean install, with only WPP on the site - just to see if stuff are still breaking.

I'll close this one, for sure.

I ended up with the wpp short-code to properly format the date. But after a day or so, I actually swapped it out with a category-metadata.