@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | */ |
20 | 20 | private function add_hooks() { |
21 | 21 | |
22 | - add_filter( 'gform_custom_merge_tags', array( $this, '_gform_custom_merge_tags' ), 10, 4 ); |
|
22 | + add_filter('gform_custom_merge_tags', array($this, '_gform_custom_merge_tags'), 10, 4); |
|
23 | 23 | |
24 | 24 | /** @see GFCommon::replace_variables_prepopulate **/ |
25 | - add_filter( 'gform_replace_merge_tags', array( 'GravityView_Merge_Tags', 'replace_gv_merge_tags' ), 10, 7 ); |
|
25 | + add_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10, 7); |
|
26 | 26 | |
27 | 27 | } |
28 | 28 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param bool $esc_html Pass return value through `esc_html()` |
44 | 44 | * @return string Text with variables maybe replaced |
45 | 45 | */ |
46 | - public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
46 | + public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param[in] array $form GF Form array |
56 | 56 | * @param[in] array $entry GF Entry array |
57 | 57 | */ |
58 | - $do_replace_variables = apply_filters( 'gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry ); |
|
58 | + $do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry); |
|
59 | 59 | |
60 | - if ( strpos( $text, '{' ) === false || ! $do_replace_variables ) { |
|
60 | + if (strpos($text, '{') === false || !$do_replace_variables) { |
|
61 | 61 | return $text; |
62 | 62 | } |
63 | 63 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @internal Reported to GF Support on 12/3 |
68 | 68 | */ |
69 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
70 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
69 | + $form['title'] = isset($form['title']) ? $form['title'] : ''; |
|
70 | + $form['id'] = isset($form['id']) ? $form['id'] : ''; |
|
71 | 71 | |
72 | - return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html ); |
|
72 | + return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array Modified merge tags |
86 | 86 | */ |
87 | - public function _gform_custom_merge_tags( $existing_merge_tags = array(), $form_id, $fields = array(), $element_id = '' ) { |
|
87 | + public function _gform_custom_merge_tags($existing_merge_tags = array(), $form_id, $fields = array(), $element_id = '') { |
|
88 | 88 | |
89 | 89 | $created_by_merge_tags = array( |
90 | 90 | array( |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | ); |
111 | 111 | |
112 | 112 | //return the form object from the php hook |
113 | - return array_merge( $existing_merge_tags, $created_by_merge_tags ); |
|
113 | + return array_merge($existing_merge_tags, $created_by_merge_tags); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -128,21 +128,21 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return mixed |
130 | 130 | */ |
131 | - public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
131 | + public static function replace_gv_merge_tags($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) { |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
135 | 135 | * @see GFCommon::replace_variables() |
136 | 136 | * @see GFCommon::replace_variables_prepopulate() |
137 | 137 | */ |
138 | - if( false === $form ) { |
|
138 | + if (false === $form) { |
|
139 | 139 | return $text; |
140 | 140 | } |
141 | 141 | |
142 | - $text = self::replace_get_variables( $text, $form, $entry, $url_encode ); |
|
142 | + $text = self::replace_get_variables($text, $form, $entry, $url_encode); |
|
143 | 143 | |
144 | 144 | // Process the merge vars here |
145 | - $text = self::replace_user_variables_created_by( $text, $form, $entry, $url_encode, $esc_html ); |
|
145 | + $text = self::replace_user_variables_created_by($text, $form, $entry, $url_encode, $esc_html); |
|
146 | 146 | |
147 | 147 | return $text; |
148 | 148 | } |
@@ -168,22 +168,22 @@ discard block |
||
168 | 168 | * @param array $entry Entry array |
169 | 169 | * @param bool $url_encode Whether to URL-encode output |
170 | 170 | */ |
171 | - public static function replace_get_variables( $text, $form = array(), $entry = array(), $url_encode = false ) { |
|
171 | + public static function replace_get_variables($text, $form = array(), $entry = array(), $url_encode = false) { |
|
172 | 172 | |
173 | 173 | // Is there is {get:[xyz]} merge tag? |
174 | - preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
|
174 | + preg_match_all("/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER); |
|
175 | 175 | |
176 | 176 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
177 | - if( empty( $matches ) ) { |
|
177 | + if (empty($matches)) { |
|
178 | 178 | return $text; |
179 | 179 | } |
180 | 180 | |
181 | - foreach ( $matches as $match ) { |
|
181 | + foreach ($matches as $match) { |
|
182 | 182 | |
183 | 183 | $full_tag = $match[0]; |
184 | 184 | $property = $match[1]; |
185 | 185 | |
186 | - $value = stripslashes_deep( rgget( $property ) ); |
|
186 | + $value = stripslashes_deep(rgget($property)); |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * @filter `gravityview/merge_tags/get/glue/` Modify the glue used to convert an array of `{get}` values from an array to string |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | * @param[in,out] string $glue String used to `implode()` $_GET values Default: ', ' |
192 | 192 | * @param[in] string $property The current name of the $_GET parameter being combined |
193 | 193 | */ |
194 | - $glue = apply_filters( 'gravityview/merge_tags/get/glue/', ', ', $property ); |
|
194 | + $glue = apply_filters('gravityview/merge_tags/get/glue/', ', ', $property); |
|
195 | 195 | |
196 | - $value = is_array( $value ) ? implode( $glue, $value ) : $value; |
|
196 | + $value = is_array($value) ? implode($glue, $value) : $value; |
|
197 | 197 | |
198 | - $value = $url_encode ? urlencode( $value ) : $value; |
|
198 | + $value = $url_encode ? urlencode($value) : $value; |
|
199 | 199 | |
200 | 200 | /** |
201 | 201 | * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Disable esc_html() from running on `{get}` merge tag |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * @since 1.15 |
206 | 206 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
207 | 207 | */ |
208 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
208 | + $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/'.$property, true); |
|
209 | 209 | |
210 | - $value = $esc_html ? esc_html( $value ) : $value; |
|
210 | + $value = $esc_html ? esc_html($value) : $value; |
|
211 | 211 | |
212 | 212 | /** |
213 | 213 | * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Modify the value of the `{get}` replacement before being used |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * @param[in] array $form Gravity Forms form array |
217 | 217 | * @param[in] array $entry Entry array |
218 | 218 | */ |
219 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
219 | + $value = apply_filters('gravityview/merge_tags/get/value/'.$property, $value, $text, $form, $entry); |
|
220 | 220 | |
221 | - $text = str_replace( $full_tag, $value, $text ); |
|
221 | + $text = str_replace($full_tag, $value, $text); |
|
222 | 222 | } |
223 | 223 | |
224 | - unset( $value, $glue, $matches ); |
|
224 | + unset($value, $glue, $matches); |
|
225 | 225 | |
226 | 226 | return $text; |
227 | 227 | } |
@@ -242,41 +242,41 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return string Text, with user variables replaced, if they existed |
244 | 244 | */ |
245 | - private static function replace_user_variables_created_by( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
245 | + private static function replace_user_variables_created_by($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) { |
|
246 | 246 | |
247 | 247 | // Is there is {created_by:[xyz]} merge tag? |
248 | - preg_match_all( "/\{created_by:(.*?)\}/", $text, $matches, PREG_SET_ORDER ); |
|
248 | + preg_match_all("/\{created_by:(.*?)\}/", $text, $matches, PREG_SET_ORDER); |
|
249 | 249 | |
250 | 250 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
251 | - if( empty( $matches ) || empty( $entry['created_by'] ) ) { |
|
251 | + if (empty($matches) || empty($entry['created_by'])) { |
|
252 | 252 | return $text; |
253 | 253 | } |
254 | 254 | |
255 | 255 | // Get the creator of the entry |
256 | - $entry_creator = new WP_User( $entry['created_by'] ); |
|
256 | + $entry_creator = new WP_User($entry['created_by']); |
|
257 | 257 | |
258 | - foreach ( $matches as $match ) { |
|
258 | + foreach ($matches as $match) { |
|
259 | 259 | |
260 | 260 | $full_tag = $match[0]; |
261 | 261 | $property = $match[1]; |
262 | 262 | |
263 | - switch( $property ) { |
|
263 | + switch ($property) { |
|
264 | 264 | /** @since 1.13.2 */ |
265 | 265 | case 'roles': |
266 | - $value = implode( ', ', $entry_creator->roles ); |
|
266 | + $value = implode(', ', $entry_creator->roles); |
|
267 | 267 | break; |
268 | 268 | default: |
269 | - $value = $entry_creator->get( $property ); |
|
269 | + $value = $entry_creator->get($property); |
|
270 | 270 | } |
271 | 271 | |
272 | - $value = $url_encode ? urlencode( $value ) : $value; |
|
272 | + $value = $url_encode ? urlencode($value) : $value; |
|
273 | 273 | |
274 | - $value = $esc_html ? esc_html( $value ) : $value; |
|
274 | + $value = $esc_html ? esc_html($value) : $value; |
|
275 | 275 | |
276 | - $text = str_replace( $full_tag, $value, $text ); |
|
276 | + $text = str_replace($full_tag, $value, $text); |
|
277 | 277 | } |
278 | 278 | |
279 | - unset( $entry_creator ); |
|
279 | + unset($entry_creator); |
|
280 | 280 | |
281 | 281 | return $text; |
282 | 282 | } |