This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook allows shortcodes in field values to be processed rather than shown on the page.
Added security protections prevents shortcodes inside a field from being processed in user-submitted data. If you would like to opt-out of this protection, you can use this filter.
Usage
add_filter( 'frm_sanitize_shortcodes', 'maybe_allow_user_shortcodes', 10, 2 );
Parameters
- $sanitize (boolean) - return true if shortcodes should be secure
- $atts (array)
- $atts['entry'] (object)
- $atts['value'] (string) - the user-submitted value
Examples
Process all shortcodes in all fields
add_filter( 'frm_sanitize_shortcodes', '__return_false' );
Allow the [gallery] shortcode
Only return true is a specific shortcode is included in the field value.
add_filter( 'frm_sanitize_shortcodes', 'maybe_allow_user_shortcodes', 10, 2 );
function maybe_allow_user_shortcodes( $sanitize, $atts ) {
if ( strpos( $atts['value'], '[gallery' ) !== false ) {
$sanitize = false;
}
return $sanitize;
}