Completed
Pull Request — develop (#1347)
by Gennady
37:05 queued 21:19
created
includes/class-gvlogic-shortcode.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public static function get_instance() {
96 96
 
97
-		if( empty( self::$instance ) ) {
97
+		if ( empty( self::$instance ) ) {
98 98
 			self::$instance = new self;
99 99
 		}
100 100
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
 		$operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS );
130 130
 
131
-		if( $with_values ) {
131
+		if ( $with_values ) {
132 132
 			$operators_with_values = array();
133
-			foreach( $operators as $key ) {
133
+			foreach ( $operators as $key ) {
134 134
 				$operators_with_values[ $key ] = '';
135 135
 			}
136 136
 			return $operators_with_values;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 		$operators = $this->get_operators( false );
151 151
 
152
-		if( !in_array( $operation, $operators ) ) {
152
+		if ( ! in_array( $operation, $operators ) ) {
153 153
 			gravityview()->log->debug( ' Attempted to add invalid operation type. {operation}', array( 'operation' => $operation ) );
154 154
 			return false;
155 155
 		}
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			return null;
202 202
 		}
203 203
 
204
-		if( empty( $atts ) ) {
204
+		if ( empty( $atts ) ) {
205 205
 			gravityview()->log->error( '$atts are empty.', array( 'data' => $atts ) );
206 206
 			return null;
207 207
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			$setup = $this->setup_operation_and_comparison();
226 226
 
227 227
 			// We need an operation and comparison value
228
-			if( ! $setup ) {
228
+			if ( ! $setup ) {
229 229
 				gravityview()->log->error( 'No valid operators were passed.', array( 'data' => $this->atts ) );
230 230
 				return null;
231 231
 			}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		$logged_in_match = ! $this->logged_in ^ is_user_logged_in(); // XNOR
278 278
 
279 279
 		// Only logged-in match
280
-		if( 1 === sizeof( $this->passed_atts ) ) {
280
+		if ( 1 === sizeof( $this->passed_atts ) ) {
281 281
 			$this->is_match = $logged_in_match;
282 282
 		} else {
283 283
 			$this->is_match = $logged_in_match && $comparison_match;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	private function get_output() {
293 293
 
294
-		if( $this->is_match ) {
294
+		if ( $this->is_match ) {
295 295
 			$output = $this->content;
296 296
 		} else {
297 297
 			$output = $this->else_content;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		 * @param string $output HTML/text output
310 310
 		 * @param GVLogic_Shortcode $this This class
311 311
 		 */
312
-		$output = apply_filters('gravityview/gvlogic/output', $output, $this );
312
+		$output = apply_filters( 'gravityview/gvlogic/output', $output, $this );
313 313
 
314 314
 		gravityview()->log->debug( 'Output: ', array( 'data' => $output ) );
315 315
 
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		list( $before_else, $after_else ) = array_pad( explode( '[else]', $passed_content, 2 ), 2, NULL );
330 330
 		list( $before_else_if, $after_else_if ) = array_pad( explode( '[else', $passed_content, 2 ), 2, NULL );
331 331
 
332
-		$else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL;
332
+		$else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL;
333 333
 		$else_content = isset( $after_else ) ? $after_else : $else_attr;
334 334
 
335 335
 		// The content is everything OTHER than the [else]
336 336
 		$this->content = $before_else_if;
337 337
 
338 338
 		if ( ! $this->is_match ) {
339
-			if( $elseif_content = $this->process_elseif( $before_else ) ) {
339
+			if ( $elseif_content = $this->process_elseif( $before_else ) ) {
340 340
 				$this->else_content = $elseif_content;
341 341
 			} else {
342 342
 				$this->else_content = $else_content;
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 		foreach ( $else_if_matches as $key => $else_if_match ) {
365 365
 
366 366
 			// If $else_if_match[5] exists and has content, check for more shortcodes
367
-			preg_match_all( '/' . $regex . '/', $else_if_match[5] . '[/else]', $recursive_matches, PREG_SET_ORDER );
367
+			preg_match_all( '/' . $regex . '/', $else_if_match[ 5 ] . '[/else]', $recursive_matches, PREG_SET_ORDER );
368 368
 
369 369
 			// If the logic passes, this is the value that should be used for $this->else_content
370
-			$else_if_value = $else_if_match[5];
371
-			$check_elseif_match = $else_if_match[0];
370
+			$else_if_value = $else_if_match[ 5 ];
371
+			$check_elseif_match = $else_if_match[ 0 ];
372 372
 
373 373
 			// Retrieve the value of the match that is currently being checked, without any other [else] tags
374
-			if( ! empty( $recursive_matches[0][0] ) ) {
375
-				$else_if_value = str_replace( $recursive_matches[0][0], '', $else_if_value );
376
-				$check_elseif_match = str_replace( $recursive_matches[0][0], '', $check_elseif_match );
374
+			if ( ! empty( $recursive_matches[ 0 ][ 0 ] ) ) {
375
+				$else_if_value = str_replace( $recursive_matches[ 0 ][ 0 ], '', $else_if_value );
376
+				$check_elseif_match = str_replace( $recursive_matches[ 0 ][ 0 ], '', $check_elseif_match );
377 377
 			}
378 378
 
379 379
 			$check_elseif_match = str_replace( '[else', '[gvlogicelse', $check_elseif_match );
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 			}
391 391
 
392 392
 			// Process any remaining [else] tags
393
-			return $this->process_elseif( $else_if_match[5] );
393
+			return $this->process_elseif( $else_if_match[ 5 ] );
394 394
 		}
395 395
 
396 396
 		return false;
@@ -417,11 +417,11 @@  discard block
 block discarded – undo
417 417
 		$this->atts = array_intersect_key( $this->passed_atts, $this->atts );
418 418
 
419 419
 		// Strip whitespace if it's not default false
420
-		$this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false;
420
+		$this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false;
421 421
 
422
-		if ( isset( $this->atts['logged_in'] ) ) {
422
+		if ( isset( $this->atts[ 'logged_in' ] ) ) {
423 423
 			// Truthy
424
-			if ( in_array( strtolower( $this->atts['logged_in'] ), array( '0', 'false', 'no' ) ) ) {
424
+			if ( in_array( strtolower( $this->atts[ 'logged_in' ] ), array( '0', 'false', 'no' ) ) ) {
425 425
 				$this->logged_in = false;
426 426
 			} else {
427 427
 				$this->logged_in = true;
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		do_action( 'gravityview/gvlogic/parse_atts/after', $this );
438 438
 
439 439
 		// Make sure the "if" isn't processed in self::setup_operation_and_comparison()
440
-		unset( $this->atts['if'] );
440
+		unset( $this->atts[ 'if' ] );
441 441
 	}
442 442
 }
443 443
 
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-unsubscribe.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	 *
49 49
 	 * @param array $field_options The options.
50 50
 	 * @param string $template_id The template ID.
51
-	 * @param int|string|float $field The field ID.
51
+	 * @param int|string|float $field_id The field ID.
52 52
 	 * @param string $context The configuration context (edit, single, etc.)
53 53
 	 * @param string $input_type The input type.
54 54
 	 * @param int $form_id The form ID.
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 	public function __construct() {
20 20
 		$this->label = esc_html__( 'Unsubscribe', 'gravityview' );
21
-		$this->description =  esc_attr__( 'Unsubscribe from a Payment-based entry.', 'gravityview' );
21
+		$this->description = esc_attr__( 'Unsubscribe from a Payment-based entry.', 'gravityview' );
22 22
 		
23 23
 		$this->add_hooks();
24 24
 		
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
59 59
 
60
-		unset( $field_options['only_loggedin'] );
60
+		unset( $field_options[ 'only_loggedin' ] );
61 61
 
62
-		unset( $field_options['new_window'] );
62
+		unset( $field_options[ 'new_window' ] );
63 63
 
64
-		unset( $field_options['show_as_link'] );
64
+		unset( $field_options[ 'show_as_link' ] );
65 65
 
66
-		$add_options['unsub_all'] = array(
66
+		$add_options[ 'unsub_all' ] = array(
67 67
 			'type'       => 'checkbox',
68 68
 			'label'      => __( 'Allow admins to unsubscribe', 'gravityview' ),
69 69
 			'desc'       => __( 'Allow users with `gravityforms_edit_entries` to cancel subscriptions', 'gravityview' ),
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 
122 122
 		foreach ( $feeds as $feed ) {
123
-			if ( isset( $subscription_addons[ $feed['addon_slug'] ] ) && \GV\Utils::get( $feed, 'meta/transactionType' ) == 'subscription' ) {
124
-				if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) {
125
-					$entry_default_fields["{$this->name}"] = array(
123
+			if ( isset( $subscription_addons[ $feed[ 'addon_slug' ] ] ) && \GV\Utils::get( $feed, 'meta/transactionType' ) == 'subscription' ) {
124
+				if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) {
125
+					$entry_default_fields[ "{$this->name}" ] = array(
126 126
 						'label' => $this->label,
127 127
 						'desc'  => $this->description,
128 128
 						'type'  => $this->name,
@@ -153,32 +153,32 @@  discard block
 block discarded – undo
153 153
 			return $output;
154 154
 		}
155 155
 
156
-		$can_current_user_edit = is_numeric( $entry['created_by'] ) && ( wp_get_current_user()->ID === intval( $entry['created_by'] ) );
156
+		$can_current_user_edit = is_numeric( $entry[ 'created_by' ] ) && ( wp_get_current_user()->ID === intval( $entry[ 'created_by' ] ) );
157 157
 
158 158
 		if ( ! $can_current_user_edit ) {
159
-			if ( empty( $field_settings['unsub_all'] ) || ! \GVCommon::has_cap( 'gravityforms_edit_entries', $entry['id'] ) ) {
159
+			if ( empty( $field_settings[ 'unsub_all' ] ) || ! \GVCommon::has_cap( 'gravityforms_edit_entries', $entry[ 'id' ] ) ) {
160 160
 				return $output;
161 161
 			}
162 162
 		}
163 163
 
164
-		$status = $entry['payment_status'];
164
+		$status = $entry[ 'payment_status' ];
165 165
 		// @todo Move to init, or AJAXify, but make sure that the entry is in the View before allowing
166 166
 		if ( $entry = $this->maybe_unsubscribe( $entry ) ) {
167
-			if ( $entry['payment_status'] !== $status ) {
167
+			if ( $entry[ 'payment_status' ] !== $status ) {
168 168
 				// @todo Probably __( 'Unsubscribed', 'gravityview' );
169
-				return $entry['payment_status'];
169
+				return $entry[ 'payment_status' ];
170 170
 			}
171 171
 		}
172 172
 
173
-		if ( strtolower( $entry['payment_status'] ) !== 'active' ) {
173
+		if ( strtolower( $entry[ 'payment_status' ] ) !== 'active' ) {
174 174
 			return $output;
175 175
 		}
176 176
 
177 177
 		global $wp;
178 178
 		$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
179 179
 
180
-		$link = add_query_arg( 'unsubscribe', wp_create_nonce( 'unsubscribe_' . $entry['id'] ), $current_url );
181
-		$link = add_query_arg( 'uid', urlencode( $entry['id'] ), $link );
180
+		$link = add_query_arg( 'unsubscribe', wp_create_nonce( 'unsubscribe_' . $entry[ 'id' ] ), $current_url );
181
+		$link = add_query_arg( 'uid', urlencode( $entry[ 'id' ] ), $link );
182 182
 
183 183
 		return sprintf( '<a href="%s">%s</a>', $link, __( 'Unsubscribe', 'gravityview' ) );
184 184
 	}
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 	 * @return void
197 197
 	 */
198 198
 	private function maybe_unsubscribe( $entry ) {
199
-		if ( ! wp_verify_nonce( \GV\Utils::_REQUEST( 'unsubscribe' ), 'unsubscribe_' . $entry['id'] ) ) {
199
+		if ( ! wp_verify_nonce( \GV\Utils::_REQUEST( 'unsubscribe' ), 'unsubscribe_' . $entry[ 'id' ] ) ) {
200 200
 			return;
201 201
 		}
202 202
 
203
-		if ( ( ! $uid = \GV\Utils::_REQUEST( 'uid' ) ) || ! is_numeric( $uid ) || ( intval( $uid ) !== intval( $entry['id'] ) ) ) {
203
+		if ( ( ! $uid = \GV\Utils::_REQUEST( 'uid' ) ) || ! is_numeric( $uid ) || ( intval( $uid ) !== intval( $entry[ 'id' ] ) ) ) {
204 204
 			return;
205 205
 		}
206 206
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 				if ( ( $feed = $subscription_addons[ $slug ]->get_feed( $feed_id ) ) && \GV\Utils::get( $feed, 'meta/transactionType' ) === 'subscription' ) {
229 229
 					if ( $subscription_addons[ $slug ]->cancel( $entry, $feed ) ) {
230 230
 						$subscription_addons[ $slug ]->cancel_subscription( $entry, $feed );
231
-						return \GFAPI::get_entry( $entry['id'] );
231
+						return \GFAPI::get_entry( $entry[ 'id' ] );
232 232
 					}
233 233
 				}
234 234
 			}
Please login to merge, or discard this patch.