admin管理员组文章数量:1130349
I'm having a little problem figuring out how to execute shortcodes stored in a mail content option of a plugin.
The thing is, I have a field in my options page named '_message' that works with WYSIWYG Editor, and I want to save shortcodes there and then execute them before send the email.
There is some way of detect shortcodes in strings?. Ex:
$message = 'blablabla [sale_products] blablaba';
do_shortcode($message);
If you have another suggestion of how can this be done, that would be great!
I'm having a little problem figuring out how to execute shortcodes stored in a mail content option of a plugin.
The thing is, I have a field in my options page named '_message' that works with WYSIWYG Editor, and I want to save shortcodes there and then execute them before send the email.
There is some way of detect shortcodes in strings?. Ex:
$message = 'blablabla [sale_products] blablaba';
do_shortcode($message);
If you have another suggestion of how can this be done, that would be great!
Share Improve this question edited Nov 3, 2018 at 17:52 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Nov 3, 2018 at 17:31 Renan A. DiazRenan A. Diaz 11 bronze badge2 Answers
Reset to default 0Have you tried
$message = apply_filters('the_content', $your_data);
I think this filter could handle the shortcode. (not tested)
While this is not very obvious, do_shortcode is usually applied as a filter on a function that generates a certain text. It is, for instance, defined as a standard filter on the_content like this:
add_filter ('the_content','do_shortcode');
So, the trick is to define it as a filter on get_option in your plugin. If you look at the source code of get_option you'll see that on the last line there is a filter applied, the name of which depends on the name of the option. Suppose the name of the option that stores the message is my_message You would have something like this:
add_filter ('option_my_message','do_shortcode');
That should mean that if you have $message = get_option('my_message') in your plugin, you would get it with shortcodes evaluated.
I'm having a little problem figuring out how to execute shortcodes stored in a mail content option of a plugin.
The thing is, I have a field in my options page named '_message' that works with WYSIWYG Editor, and I want to save shortcodes there and then execute them before send the email.
There is some way of detect shortcodes in strings?. Ex:
$message = 'blablabla [sale_products] blablaba';
do_shortcode($message);
If you have another suggestion of how can this be done, that would be great!
I'm having a little problem figuring out how to execute shortcodes stored in a mail content option of a plugin.
The thing is, I have a field in my options page named '_message' that works with WYSIWYG Editor, and I want to save shortcodes there and then execute them before send the email.
There is some way of detect shortcodes in strings?. Ex:
$message = 'blablabla [sale_products] blablaba';
do_shortcode($message);
If you have another suggestion of how can this be done, that would be great!
Share Improve this question edited Nov 3, 2018 at 17:52 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Nov 3, 2018 at 17:31 Renan A. DiazRenan A. Diaz 11 bronze badge2 Answers
Reset to default 0Have you tried
$message = apply_filters('the_content', $your_data);
I think this filter could handle the shortcode. (not tested)
While this is not very obvious, do_shortcode is usually applied as a filter on a function that generates a certain text. It is, for instance, defined as a standard filter on the_content like this:
add_filter ('the_content','do_shortcode');
So, the trick is to define it as a filter on get_option in your plugin. If you look at the source code of get_option you'll see that on the last line there is a filter applied, the name of which depends on the name of the option. Suppose the name of the option that stores the message is my_message You would have something like this:
add_filter ('option_my_message','do_shortcode');
That should mean that if you have $message = get_option('my_message') in your plugin, you would get it with shortcodes evaluated.
本文标签: pluginsDoshortcode before send email content
版权声明:本文标题:plugins - Do_shortcode before send email content 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749208361a2332947.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论