Skip Navigation

[Resuelto] Filter hook on view shortcode output

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 5 años, 1 mes. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por UNC Digital Services hace 5 años, 1 mes.

Asistido por: Luo Yang.

Autor
Mensajes
#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!