Completed
Push — develop ( c35b1f...3060da )
by Zack
08:36
created
includes/class-gravityview-merge-tags.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@
 block discarded – undo
216 216
 	 * @param bool $url_encode Whether to URL-encode output
217 217
 	 * @param bool $esc_html Whether to apply `esc_html()` to output
218 218
 	 *
219
-	 * @return mixed
219
+	 * @return string
220 220
 	 */
221 221
 	public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
222 222
 
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	public static function process_modifiers( $value, $merge_tag, $modifier, $field, $raw_value ) {
46 46
 
47 47
 		// No modifier was set or the raw value was empty
48
-		if( 'all_fields' === $merge_tag || '' === $modifier || ! is_string( $raw_value ) || '' === $raw_value ) {
48
+		if ( 'all_fields' === $merge_tag || '' === $modifier || ! is_string( $raw_value ) || '' === $raw_value ) {
49 49
 			return $value;
50 50
 		}
51 51
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 		foreach ( $gv_modifiers as $gv_modifier => $method ) {
62 62
 
63 63
 			// Only match the regex if it's the first modifer; this allows us to enforce our own modifier structure
64
-			preg_match( '/^' . $gv_modifier .'/ism', $modifier, $matches );
64
+			preg_match( '/^' . $gv_modifier . '/ism', $modifier, $matches );
65 65
 
66
-			if( ! empty( $matches ) ) {
66
+			if ( ! empty( $matches ) ) {
67 67
 				// The called method is passed the raw value and the full matches array
68 68
 				$return = self::$method( $raw_value, $matches );
69 69
 				break;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	private static function modifier_timestamp( $raw_value, $matches ) {
89 89
 
90
-		if( empty( $matches[0] ) ) {
90
+		if ( empty( $matches[ 0 ] ) ) {
91 91
 			return $raw_value;
92 92
 		}
93 93
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	private static function modifier_wpautop( $raw_value, $matches ) {
113 113
 
114
-		if( empty( $matches[0] ) || ! function_exists( 'wpautop' ) ) {
114
+		if ( empty( $matches[ 0 ] ) || ! function_exists( 'wpautop' ) ) {
115 115
 			return $raw_value;
116 116
 		}
117 117
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	private static function modifier_maxwords( $raw_value, $matches ) {
137 137
 
138
-		if( ! is_string( $raw_value ) || empty( $matches[1] ) || ! function_exists( 'wp_trim_words' ) ) {
138
+		if ( ! is_string( $raw_value ) || empty( $matches[ 1 ] ) || ! function_exists( 'wp_trim_words' ) ) {
139 139
 			return $raw_value;
140 140
 		}
141 141
 
142
-		$max = intval( $matches[1] );
142
+		$max = intval( $matches[ 1 ] );
143 143
 
144 144
 		$more_placeholder = '[GVMORE]';
145 145
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @param  bool             $esc_html     Pass return value through `esc_html()`
172 172
 	 * @return string           Text with variables maybe replaced
173 173
 	 */
174
-	public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) {
174
+	public static function replace_variables( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) {
175 175
 
176 176
 		/**
177 177
 		 * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 		 * @internal Fixed $form['title'] in Gravity Forms
197 197
 		 * @see      https://github.com/gravityforms/gravityforms/pull/27/files
198 198
 		 */
199
-		$form['title']  = isset( $form['title'] ) ? $form['title'] : '';
200
-		$form['id']     = isset( $form['id'] ) ? $form['id'] : '';
201
-		$form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array();
199
+		$form[ 'title' ]  = isset( $form[ 'title' ] ) ? $form[ 'title' ] : '';
200
+		$form[ 'id' ]     = isset( $form[ 'id' ] ) ? $form[ 'id' ] : '';
201
+		$form[ 'fields' ] = isset( $form[ 'fields' ] ) ? $form[ 'fields' ] : array();
202 202
 
203 203
 		return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html );
204 204
 	}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
222 222
 
223
-		if( '' === $text ) {
223
+		if ( '' === $text ) {
224 224
 			return $text;
225 225
 		}
226 226
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		 * @see GFCommon::replace_variables_prepopulate()
231 231
 		 * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14
232 232
 		 */
233
-		if( false === $form ) {
233
+		if ( false === $form ) {
234 234
 			return $text;
235 235
 		}
236 236
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 			'diff' => in_array( 'diff', $exploded ), // {date_created:diff}
265 265
 			'raw' => in_array( 'raw', $exploded ), // {date_created:raw}
266 266
 			'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp}
267
-			'time' => in_array( 'time', $exploded ),  // {date_created:time}
267
+			'time' => in_array( 'time', $exploded ), // {date_created:time}
268 268
 		);
269 269
 
270 270
 		$formatted_date = GVCommon::format_date( $date_created, $atts );
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 			return $original_text;
342 342
 		}
343 343
 
344
-		foreach ( (array) $matches as $match ) {
345
-			$full_tag = $match[0];
344
+		foreach ( (array)$matches as $match ) {
345
+			$full_tag = $match[ 0 ];
346 346
 			$modifier = rgar( $match, 2, 'permalink' );
347 347
 
348 348
 			$replacement = false;
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 					$replacement = esc_html( $replacement );
361 361
 				}
362 362
 
363
-				if( $url_encode ) {
363
+				if ( $url_encode ) {
364 364
 					$replacement = urlencode( $replacement );
365 365
 				}
366 366
 
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 		preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER );
401 401
 
402 402
 		// If there are no matches OR the Entry `created_by` isn't set or is 0 (no user)
403
-		if( empty( $matches ) ) {
403
+		if ( empty( $matches ) ) {
404 404
 			return $text;
405 405
 		}
406 406
 
407 407
 		foreach ( $matches as $match ) {
408 408
 
409
-			$full_tag = $match[0];
410
-			$property = $match[1];
409
+			$full_tag = $match[ 0 ];
410
+			$property = $match[ 1 ];
411 411
 
412 412
 			$value = stripslashes_deep( rgget( $property ) );
413 413
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			 * @since 1.15
432 432
 			 * @param bool $esc_html Whether to esc_html() the value. Default: `true`
433 433
 			 */
434
-			$esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true );
434
+			$esc_html = apply_filters( 'gravityview/merge_tags/get/esc_html/' . $property, true );
435 435
 
436 436
 			$value = $esc_html ? esc_html( $value ) : $value;
437 437
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 			 * @param[in] array $form Gravity Forms form array
443 443
 			 * @param[in] array $entry Entry array
444 444
 			 */
445
-			$value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry );
445
+			$value = apply_filters( 'gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry );
446 446
 
447 447
 			$text = str_replace( $full_tag, $value, $text );
448 448
 		}
Please login to merge, or discard this patch.