Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Need additional filter to support an extension for prefixes #79

Closed
actual-saurabh opened this issue May 27, 2016 · 4 comments
Closed

Need additional filter to support an extension for prefixes #79

actual-saurabh opened this issue May 27, 2016 · 4 comments

Comments

@actual-saurabh
Copy link

actual-saurabh commented May 27, 2016

Hi @philiparthurmoore,

For a project, I needed to add subtitles and prefixes to titles. Rather than reinventing the wheel, I use this plugin and it's great.

I used the the_subtitle filter in https://github.com/professionalthemes/Subtitles/blob/master/public/class-subtitles.php#L713 to add prefixes to my custom post type titles. It helps me that Subtitles has already taken the decisions that my code needs to take before displaying prefixes.

Only problem is some of my posts have a prefix, but not a subtitle. Because of https://github.com/professionalthemes/Subtitles/blob/master/public/class-subtitles.php#L586-L588, I never reach the filter.

Right now, I have two strategies:

  1. Add a placeholder subtitle when editing the post. This way, I still reach the filter. In my filter, check if it is the placeholder and then not display the title. Not very elegant, but the one that I'm using right now to avoid the second strategy.
  2. Filter the_title and single_post_title on my own and try to replicate almost everything that the the_subtitle method does somehow or duplicate and plug the class Subtitles itself. Not elegant at all.

Would you be open to adding a boolean filter that allows the code to continue at https://github.com/professionalthemes/Subtitles/blob/master/public/class-subtitles.php#L586-L588? It could be set to false when subtitles are empty, but an extension like mine could force set it to true.

If you are, I can send in a PR.

@philiparthurmoore
Copy link
Member

@actual-saurabh Love the idea. Go ahead and whip up a PR for it, and I'll make sure to get it in the next release ASAP. Your use case makes total sense there. Thanks for bringing it to my attention!

actual-saurabh pushed a commit to actual-saurabh/Subtitles that referenced this issue May 27, 2016
@philiparthurmoore
Copy link
Member

Done in 409ef14.

@philiparthurmoore
Copy link
Member

@actual-saurabh
Copy link
Author

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants