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 83 forks source link

Add "wpp_post_title" filter for updating post_title manually #226

Closed blackWhitePanda closed 4 years ago

blackWhitePanda commented 4 years ago

For rendering post output, I wish the plugin would add a filter, so that custom style / prefix / suffix can be added on output of each post.

I have added and used the hook in my project. It helps me add border with different colour (based on the taxonomies value of post). Also, suffix of book author is added, with grey colour.

I believe adding the hook could make the plugin more custom-able.

I understand "wpp_post" filter is existing. It would make entire update of post output. However, I believe it is not the most convenient and compatible for user. It is because when user makes minor changes, it is no need to clone the existing "render_post" function and make minor changes (unnecessary overhead of run similar code twice). Also, if the "render_post" function is changed in upcoming release, the user customized code for "wpp_post" filter may cause error.

Wish you may add the hook so that help programmer develop with wordpress-popular-posts. Thanks

cabrerahector commented 4 years ago

Hi @blackWhitePanda,

There's already a filter hook available inside the get_title() method that can be used to modify the post title (see here) so adding a new one doesn't make much sense to me. I would consider renaming it to wpp_post_title though, if you're up for it please make this change (and remove the line you added) and I'll merge your PR.

cabrerahector commented 4 years ago

Implemented with commit 747fadb. The filter name is slightly different though: wpp_the_title.