Devomo
Forum Replies Created
-
@designextreme The only real benefit here is a better developer experience, I think that’s clear, so I do not feel the need to continue the discussion off the forums.
I understand that this is just a small improvement, which does not have your top priority. I came up with the suggestion because I felt it could be accomplished with minor effort on your part.
But it was just a suggestion after all 🙂
@designextreme It’s not bad, it does the job. But in my opinion, such a long shortcode is not very elegant, nor is it very readable. It’s not about the functionality, just about the developer experience.
I’d rather have the arguments as an array, one per line, and pass them to a function or action. I think that would be less error-prone, too.
If it’s not clear to you, I’d be happy to get in touch.
- This reply was modified 5 years, 8 months ago by Devomo.
@designextreme thanks for the quick response.
Are you able to achieve the same outcome using do_shortcode() to a variable?
I’m not entirely sure what you mean by this, but at least it made me realize that it is not as simple as I thought. After all, a shortcode returns content, and I now assume the
do_action()call will echo it. So maybe you will need a function after all, or create a dedicated method which echoes the shortcode content and add that as an action.The reason I suggested an action instead of a function is the fact that as a theme developer, I will always have to check whether a plugin-provided function exists. If I use an action, I will not have to do that, it will simply do nothing if no listeners are attached.
Same problem here. We don’t use WPML either.