Skip to content

Commit 89a706c

Browse files
authored
gppa-replace-new-lines.php: Added new snippet.
1 parent 42774c5 commit 89a706c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Populate Anything // Handle New Lines
4+
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
5+
*
6+
* Replace the `\n` new line terminator with an actual new line in template values. This is particularly
7+
* useful in custom templates for Paragraph fields where you are outputting multiple object values.
8+
*
9+
* Example:
10+
*
11+
* ID: {post:ID}\nAuthor: {post:post_author}\nDate: {post:post_date}
12+
*/
13+
add_filter( 'gppa_process_template_value', function( $value, $field ) {
14+
if ( ! is_array( $value ) ) {
15+
$value = str_replace( '\n', "\n", $value );
16+
}
17+
return $value;
18+
}, 10, 2 );

0 commit comments

Comments
 (0)