Skip Navigation

[Resolved] Filter hook on view shortcode output

This thread is resolved. Here is a description of the problem and solution.

Problem:

I need to wrap am email address with `antispambot()`

Solution:

You can create a custom shortcode [email] for it, for example:

https://toolset.com/forums/topic/filter-hook-on-view-shortcode-output/#post-1362315

Relevant Documentation:

https://codex.wordpress.org/Function_Reference/antispambot

This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by UNC Digital Services 5 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1362081

Tell us what you are trying to do?

I'd like to know which filter hook to use to change the output of a shortcode used in the Views Editor (admin.php?page=views-editor) . I need to wrap am email address with `antispambot()` .

the shortcode used is [types field='email-people'][/types] and I'd like to filter like:

```
apply_filters( 'do_shortcode_tag', function( $output, $tag, $attr ){
if( "types" === $tag && 'email-people' === $attr['field'] ){
$output = antispambot( $output );
}
return $output;
});
```
but the Views editor seems to circumvent typical WordPress methods for filtering shortcodes

Is there any documentation that you are following?
I could not find it in the documentation. can you help point me in the right direction

Is there a similar example that we can see?

What is the link to your site?

#1362315

Hello,

I assume we are talking about the WordPress function antispambot():
https://codex.wordpress.org/Function_Reference/antispambot

In your case, you can create a custom shortcode [email] for it, for example:
1) Add below PHP codes

function wpcodex_hide_email_shortcode( $atts , $content = null ) {
	$content= do_shortcode($content);
	$content = antispambot( $content );
	$email_link = sprintf( 'mailto:%s', $content );
	return sprintf( '<a href="%s">%s</a>', esc_url( $email_link, array( 'mailto' ) ), esc_html( $content ) );
}
add_shortcode( 'email', 'wpcodex_hide_email_shortcode' );

2) Use above shortcode like this:

 [email] [types field='email-people' output='raw'][/types] [/email] 
#1365483

My issue is resolved now. Thank you!