Completed
Push — develop ( 73f182...380088 )
by Zack
18:24
created
future/includes/class-gv-shortcode-gvlogic.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 		$value    = $this->get_value( $atts );
62 62
 
63 63
 		if ( false === $operator && is_null( $value ) ) {
64
-			if ( false !== $atts['if'] ) { // Only-if test
65
-				$match = $authed && ! in_array( strtolower( $atts['if'] ), array( '', '0', 'false', 'no' ) );
64
+			if ( false !== $atts[ 'if' ] ) { // Only-if test
65
+				$match = $authed && ! in_array( strtolower( $atts[ 'if' ] ), array( '', '0', 'false', 'no' ) );
66 66
 			} else {
67 67
 				$match = $authed; // Just login test
68 68
 			}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 				// Need to match all AND
83 83
 				foreach ( $and_values as $and_value ) {
84
-					$match = $authed && \GVCommon::matches_operation( $atts['if'], $and_value, $operator );
84
+					$match = $authed && \GVCommon::matches_operation( $atts[ 'if' ], $and_value, $operator );
85 85
 					if ( ! $match ) {
86 86
 						break;
87 87
 					}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 				// Only need to match a single OR
93 93
 				foreach ( $or_values as $or_value ) {
94 94
 
95
-					$match = \GVCommon::matches_operation( $atts['if'], $or_value, $operator );
95
+					$match = \GVCommon::matches_operation( $atts[ 'if' ], $or_value, $operator );
96 96
 
97 97
 					// Negate the negative operators
98 98
 					if ( ( $authed && $match ) || ( $authed && ( ! $match && in_array( $operator, array( 'isnot', 'not_contains', 'not_in' ) ) ) ) ) {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 				}
102 102
 
103 103
 			} else {
104
-				$match = $authed && \GVCommon::matches_operation( $atts['if'], $value, $operator );
104
+				$match = $authed && \GVCommon::matches_operation( $atts[ 'if' ], $value, $operator );
105 105
 			}
106 106
 
107 107
 			$output = $this->get_output( $match, $atts, $output );
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 * @return string The output.
190 190
 	 */
191 191
 	private function get_output( $match, $atts, $content ) {
192
-		if ( ! $match && ! empty( $atts['else'] ) ) {
193
-			return $atts['else']; // Attributized else is easy :)
192
+		if ( ! $match && ! empty( $atts[ 'else' ] ) ) {
193
+			return $atts[ 'else' ]; // Attributized else is easy :)
194 194
 		}
195 195
 
196 196
 		$if = '';
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 		$atts = array_intersect_key( $supplied_atts, $atts );
318 318
 
319 319
 		// Strip whitespace if it's not default false
320
-		if ( isset( $atts['if'] ) && is_string( $atts['if'] ) ) {
321
-			$atts['if'] = trim( $atts['if'] );
320
+		if ( isset( $atts[ 'if' ] ) && is_string( $atts[ 'if' ] ) ) {
321
+			$atts[ 'if' ] = trim( $atts[ 'if' ] );
322 322
 		} else {
323
-			$atts['if'] = false;
323
+			$atts[ 'if' ] = false;
324 324
 		}
325 325
 
326
-		if ( isset( $atts['logged_in'] ) ) {
326
+		if ( isset( $atts[ 'logged_in' ] ) ) {
327 327
 			// Truthy
328
-			if ( in_array( strtolower( $atts['logged_in'] ), array( '0', 'false', 'no' ) ) ) {
329
-				$atts['logged_in'] = false;
328
+			if ( in_array( strtolower( $atts[ 'logged_in' ] ), array( '0', 'false', 'no' ) ) ) {
329
+				$atts[ 'logged_in' ] = false;
330 330
 			} else {
331
-				$atts['logged_in'] = true;
331
+				$atts[ 'logged_in' ] = true;
332 332
 			}
333 333
 		}
334 334
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,14 +61,16 @@  discard block
 block discarded – undo
61 61
 		$value    = $this->get_value( $atts );
62 62
 
63 63
 		if ( false === $operator && is_null( $value ) ) {
64
-			if ( false !== $atts['if'] ) { // Only-if test
64
+			if ( false !== $atts['if'] ) {
65
+// Only-if test
65 66
 				$match = $authed && ! in_array( strtolower( $atts['if'] ), array( '', '0', 'false', 'no' ) );
66 67
 			} else {
67 68
 				$match = $authed; // Just login test
68 69
 			}
69 70
 
70 71
 			$output = $this->get_output( $match, $atts, $content );
71
-		} else { // Regular test
72
+		} else {
73
+// Regular test
72 74
 
73 75
 			$output = $content;
74 76
 
@@ -199,12 +201,15 @@  discard block
 block discarded – undo
199 201
 		$opens = 0; // inner opens
200 202
 		$found = false; // found split position
201 203
 
202
-		while ( $content ) { // scan
204
+		while ( $content ) {
205
+// scan
203 206
 
204 207
 			if ( ! preg_match( '#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches ) ) {
205
-				if ( ! $found ) { // We're still iffing.
208
+				if ( ! $found ) {
209
+// We're still iffing.
206 210
 					$if .= $content;
207
-				} else { // We are elsing
211
+				} else {
212
+// We are elsing
208 213
 					$else .= $content;
209 214
 				}
210 215
 				break; // No more shortcodes
@@ -212,9 +217,11 @@  discard block
 block discarded – undo
212 217
 
213 218
 			list( $_, $before_shortcode, $shortcode, $_, $after_shortcode ) = $matches;
214 219
 
215
-			if ( ! $found ) { // We're still iffing.
220
+			if ( ! $found ) {
221
+// We're still iffing.
216 222
 				$if .= $before_shortcode;
217
-			} else { // We are elsing
223
+			} else {
224
+// We are elsing
218 225
 				$else .= $before_shortcode;
219 226
 			}
220 227
 
@@ -238,9 +245,11 @@  discard block
 block discarded – undo
238 245
 				}
239 246
 
240 247
 				// Tack on the shortcode
241
-				if ( ! $found ) { // We're still iffing.
248
+				if ( ! $found ) {
249
+// We're still iffing.
242 250
 					$if .= $shortcode;
243
-				} else { // We are elsing
251
+				} else {
252
+// We are elsing
244 253
 					$else .= $shortcode;
245 254
 				}
246 255
 			}
Please login to merge, or discard this patch.