Skip to content

Instantly share code, notes, and snippets.

@matty0501
Created August 8, 2024 12:54
Show Gist options
  • Save matty0501/94b5bc41f03eb13edeb1ce484aad7c79 to your computer and use it in GitHub Desktop.
Save matty0501/94b5bc41f03eb13edeb1ce484aad7c79 to your computer and use it in GitHub Desktop.
<?php
/**
* Gravity Wiz // Gravity Forms // URL Encode Merge Tag Modifier
* https://gravitywiz.com
*
* Use the :url_encode modifier on merge tags to URL encode the value
*
* this: Advanced Save & Continue
* to: Advanced+Save+%26+Continue
*/
add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value, $format ) {
if ( empty( $modifier ) ) {
return $value;
}
$modifiers = array_map( 'strtolower', explode( ',', $modifier ) );
if ( ! in_array( 'url_encode', $modifiers, true ) ) {
return $value;
}
return urlencode( $value );
}, 10, 6 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment