Completed
Push — develop ( 2cf35b...b1abed )
by Zack
14:52
created
includes/class-gvlogic-shortcode.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public static function get_instance() {
87 87
 
88
-		if( empty( self::$instance ) ) {
88
+		if ( empty( self::$instance ) ) {
89 89
 			self::$instance = new self;
90 90
 		}
91 91
 
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
 		$operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS );
121 121
 
122
-		if( $with_values ) {
122
+		if ( $with_values ) {
123 123
 			$operators_with_values = array();
124
-			foreach( $operators as $key ) {
124
+			foreach ( $operators as $key ) {
125 125
 				$operators_with_values[ $key ] = '';
126 126
 			}
127 127
 			return $operators_with_values;
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	private function set_operation( $operation = '' ) {
140 140
 
141
-		if( empty( $operation ) ) {
141
+		if ( empty( $operation ) ) {
142 142
 			return false;
143 143
 		}
144 144
 
145 145
 		$operators = $this->get_operators( false );
146 146
 
147
-		if( !in_array( $operation, $operators ) ) {
148
-			do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation );
147
+		if ( ! in_array( $operation, $operators ) ) {
148
+			do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation );
149 149
 			return false;
150 150
 		}
151 151
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	private function setup_operation_and_comparison() {
167 167
 
168
-		foreach( $this->atts as $key => $value ) {
168
+		foreach ( $this->atts as $key => $value ) {
169 169
 
170 170
 			$valid = $this->set_operation( $key );
171 171
 
172
-			if( $valid ) {
172
+			if ( $valid ) {
173 173
 				$this->comparison = $value;
174 174
 				return true;
175 175
 			}
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 			return null;
196 196
 		}
197 197
 
198
-		if( empty( $atts ) ) {
199
-			do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts );
198
+		if ( empty( $atts ) ) {
199
+			do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts );
200 200
 			return null;
201 201
 		}
202 202
 
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
 		$this->parse_atts();
211 211
 
212 212
 		// We need an "if"
213
-		if( false === $this->if ) {
214
-			do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts );
213
+		if ( false === $this->if ) {
214
+			do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts );
215 215
 			return null;
216 216
 		}
217 217
 
218 218
 		$setup = $this->setup_operation_and_comparison();
219 219
 
220 220
 		// We need an operation and comparison value
221
-		if( ! $setup ) {
222
-			do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts );
221
+		if ( ! $setup ) {
222
+			do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts );
223 223
 			return null;
224 224
 		}
225 225
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	private function get_output() {
254 254
 
255
-		if( $this->is_match ) {
255
+		if ( $this->is_match ) {
256 256
 			$output = $this->content;
257 257
 		} else {
258 258
 			$output = $this->else_content;
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 		 * @param string $output HTML/text output
267 267
 		 * @param GVLogic_Shortcode $this This class
268 268
 		 */
269
-		$output = apply_filters('gravityview/gvlogic/output', $output, $this );
269
+		$output = apply_filters( 'gravityview/gvlogic/output', $output, $this );
270 270
 
271
-		do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output );
271
+		do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output );
272 272
 
273 273
 		return $output;
274 274
 	}
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
 		list( $before_else, $after_else ) = array_pad( explode( '[else]', $passed_content ), 2, NULL );
287 287
 		list( $before_else_if, $after_else_if ) = array_pad( explode( '[else', $passed_content ), 2, NULL );
288 288
 
289
-		$else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL;
289
+		$else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL;
290 290
 		$else_content = isset( $after_else ) ? $after_else : $else_attr;
291 291
 
292 292
 		// The content is everything OTHER than the [else]
293 293
 		$this->content = $before_else_if;
294 294
 
295 295
 		if ( ! $this->is_match ) {
296
-			if( $elseif_content = $this->process_elseif( $before_else ) ) {
296
+			if ( $elseif_content = $this->process_elseif( $before_else ) ) {
297 297
 				$this->else_content = $elseif_content;
298 298
 			} else {
299 299
 				$this->else_content = $else_content;
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 		foreach ( $else_if_matches as $key => $else_if_match ) {
322 322
 
323 323
 			// If $else_if_match[5] exists and has content, check for more shortcodes
324
-			preg_match_all( '/' . $regex . '/', $else_if_match[5] . '[/else]', $recursive_matches, PREG_SET_ORDER );
324
+			preg_match_all( '/' . $regex . '/', $else_if_match[ 5 ] . '[/else]', $recursive_matches, PREG_SET_ORDER );
325 325
 
326 326
 			// If the logic passes, this is the value that should be used for $this->else_content
327
-			$else_if_value = $else_if_match[5];
328
-			$check_elseif_match = $else_if_match[0];
327
+			$else_if_value = $else_if_match[ 5 ];
328
+			$check_elseif_match = $else_if_match[ 0 ];
329 329
 
330 330
 			// Retrieve the value of the match that is currently being checked, without any other [else] tags
331
-			if( ! empty( $recursive_matches[0][0] ) ) {
332
-				$else_if_value = str_replace( $recursive_matches[0][0], '', $else_if_value );
333
-				$check_elseif_match = str_replace( $recursive_matches[0][0], '', $check_elseif_match );
331
+			if ( ! empty( $recursive_matches[ 0 ][ 0 ] ) ) {
332
+				$else_if_value = str_replace( $recursive_matches[ 0 ][ 0 ], '', $else_if_value );
333
+				$check_elseif_match = str_replace( $recursive_matches[ 0 ][ 0 ], '', $check_elseif_match );
334 334
 			}
335 335
 
336 336
 			$check_elseif_match = str_replace( '[else', '[gvlogicelse', $check_elseif_match );
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			}
348 348
 
349 349
 			// Process any remaining [else] tags
350
-			return $this->process_elseif( $else_if_match[5] );
350
+			return $this->process_elseif( $else_if_match[ 5 ] );
351 351
 		}
352 352
 
353 353
 		return false;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 		$this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts;
374 374
 
375 375
 		// Strip whitespace if it's not default false
376
-		$this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false;
376
+		$this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false;
377 377
 
378 378
 		/**
379 379
 		 * @action `gravityview/gvlogic/parse_atts/after` Modify shortcode attributes after it's been parsed
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		do_action( 'gravityview/gvlogic/parse_atts/after', $this );
385 385
 
386 386
 		// Make sure the "if" isn't processed in self::setup_operation_and_comparison()
387
-		unset( $this->atts['if'] );
387
+		unset( $this->atts[ 'if' ] );
388 388
 	}
389 389
 }
390 390
 
Please login to merge, or discard this patch.