Completed
Pull Request — develop (#1800)
by Zack
18:55
created
future/includes/class-gv-settings-plugin.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @var array
32 32
 	 */
33
-	private $_plugin_settings = [];
33
+	private $_plugin_settings = [ ];
34 34
 
35 35
 	public function __construct() {
36 36
 		// GravityKitFoundation may not yet be available when this class is instantiated, so let's temporarily use the Settings framework from Foundation that's included with GravityView and then possibly replace it with the latest version.
37 37
 		$this->_foundation_settings = SettingsFramework::get_instance();
38 38
 
39
-		add_action( 'gk/foundation/initialized', function () {
39
+		add_action( 'gk/foundation/initialized', function() {
40 40
 			$this->_foundation_settings = GravityKitFoundation::settings();
41 41
 		} );
42 42
 
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 
134 134
 		if ( empty( $legacy_settings ) ) {
135
-			return [];
135
+			return [ ];
136 136
 		}
137 137
 
138 138
 		// Migrate legacy GravityView settings that are still part of GravityView.
139 139
 		$plugin_settings = [
140
-			'rest_api' => (int) Arr::get( $legacy_settings, 'rest_api' ),
140
+			'rest_api' => (int)Arr::get( $legacy_settings, 'rest_api' ),
141 141
 		];
142 142
 
143 143
 		$this->_foundation_settings->save_plugin_settings( self::SETTINGS_PLUGIN_ID, $plugin_settings );
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 			$gk_settings = [
154 154
 				'support_email'    => Arr::get( $legacy_settings, 'support-email' ),
155 155
 				'support_port'     => Arr::get( $legacy_settings, 'support_port' ),
156
-				'powered_by'       => (int) Arr::get( $legacy_settings, 'powered_by' ),
156
+				'powered_by'       => (int)Arr::get( $legacy_settings, 'powered_by' ),
157 157
 				'affiliate_id'     => Arr::get( $legacy_settings, 'affiliate_id' ),
158
-				'beta'             => (int) Arr::get( $legacy_settings, 'beta' ),
158
+				'beta'             => (int)Arr::get( $legacy_settings, 'beta' ),
159 159
 				'support_email'    => Arr::get( $legacy_settings, 'support-email' ),
160
-				'support_port'     => (int) Arr::get( $legacy_settings, 'support_port' ),
161
-				'no_conflict_mode' => (int) Arr::get( $legacy_settings, 'no-conflict-mode' ),
160
+				'support_port'     => (int)Arr::get( $legacy_settings, 'support_port' ),
161
+				'no_conflict_mode' => (int)Arr::get( $legacy_settings, 'no-conflict-mode' ),
162 162
 			];
163 163
 
164 164
 			$this->_foundation_settings->save_plugin_settings( $gk_settings_id, $gk_settings );
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 							'type'        => 'checkbox',
240 240
 							'title'       => esc_html__( 'REST API', 'gk-gravityview' ),
241 241
 							'description' => esc_html__( 'Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gk-gravityview' ) . ' ' . esc_html__( 'If you are unsure, disable this setting.', 'gk-gravityview' ),
242
-							'value'       => $this->get( 'rest_api', $default_settings['rest_api'] ),
242
+							'value'       => $this->get( 'rest_api', $default_settings[ 'rest_api' ] ),
243 243
 						],
244 244
 					],
245 245
 				],
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 							'type'        => 'checkbox',
252 252
 							'title'       => esc_html__( 'Public Entry Moderation Merge Tags', 'gk-gravityview' ),
253 253
 							'description' => esc_html__( 'Allow entry moderation to be performed by anyone with the link, even if they are not logged in.', 'gk-gravityview' ) . ' ' . esc_html__( 'If you are unsure, disable this setting.', 'gk-gravityview' ),
254
-							'value'       => $this->get( 'public_entry_moderation', $default_settings['rest_api'] ),
254
+							'value'       => $this->get( 'public_entry_moderation', $default_settings[ 'rest_api' ] ),
255 255
 						],
256 256
 					],
257 257
 				],
258 258
 			],
259 259
 		];
260 260
 
261
-		return array_merge( (array) $plugins_data, [ self::SETTINGS_PLUGIN_ID => $settings ] );
261
+		return array_merge( (array)$plugins_data, [ self::SETTINGS_PLUGIN_ID => $settings ] );
262 262
 	}
263 263
 
264 264
 	/**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	public function maybe_save_app_settings() {
321 321
 		if ( $this->is_save_postback() ) {
322 322
 			if ( ! \GVCommon::has_cap( 'gravityview_edit_settings' ) ) {
323
-				$_POST = []; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
323
+				$_POST = [ ]; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
324 324
 				\GFCommon::add_error_message( __( 'You don\'t have the ability to edit plugin settings.', 'gk-gravityview' ) );
325 325
 
326 326
 				return;
Please login to merge, or discard this patch.
includes/class-gravityview-entry-approval-merge-tags.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$global_default = gravityview()->plugin->settings->get( 'public_entry_moderation', '0' );
84 84
 
85
-		$fields['restrictions']['fields'][] = array(
85
+		$fields[ 'restrictions' ][ 'fields' ][ ] = array(
86 86
 			'name'          => self::FORM_SETTINGS_KEY,
87 87
 			'type'          => 'radio',
88 88
 			'horizontal'    => true,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 					'value' => '0',
100 100
 				),
101 101
 			),
102
-			'default_value' => (string) $global_default,
102
+			'default_value' => (string)$global_default,
103 103
 		);
104 104
 
105 105
 		return $fields;
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 
187 187
 		foreach ( $matches as $match ) {
188 188
 
189
-			$full_tag         = $match[0];
190
-			$action           = $match[1];
191
-			$expiration_value = ! empty( $match[2] ) ? (int) $match[2] : self::DEFAULT_EXPIRATION_VALUE;
192
-			$expiration_unit  = ! empty( $match[3] ) ? $match[3] : self::DEFAULT_EXPIRATION_UNIT;
193
-			$privacy          = isset( $match[4] ) ? $match[4] : self::DEFAULT_PRIVACY;
189
+			$full_tag         = $match[ 0 ];
190
+			$action           = $match[ 1 ];
191
+			$expiration_value = ! empty( $match[ 2 ] ) ? (int)$match[ 2 ] : self::DEFAULT_EXPIRATION_VALUE;
192
+			$expiration_unit  = ! empty( $match[ 3 ] ) ? $match[ 3 ] : self::DEFAULT_EXPIRATION_UNIT;
193
+			$privacy          = isset( $match[ 4 ] ) ? $match[ 4 ] : self::DEFAULT_PRIVACY;
194 194
 
195 195
 			switch ( $expiration_unit ) {
196 196
 				case 'd':
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 					break;
209 209
 			}
210 210
 
211
-			if ( false === (bool) \GV\Utils::get( $form, self::FORM_SETTINGS_KEY, false ) ) {
211
+			if ( false === (bool)\GV\Utils::get( $form, self::FORM_SETTINGS_KEY, false ) ) {
212 212
 				$privacy = self::DEFAULT_PRIVACY;
213 213
 			}
214 214
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	protected function get_token( $action = false, $expiration_timestamp = 0, $privacy = 'private', $entry = array() ) {
249 249
 
250
-		if ( ! $action || ! $entry['id'] ) {
250
+		if ( ! $action || ! $entry[ 'id' ] ) {
251 251
 			return false;
252 252
 		}
253 253
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		$expiration_seconds = time() - $expiration_timestamp;
270 270
 
271 271
 		$scopes = array(
272
-			'entry_id'           => $entry['id'],
272
+			'entry_id'           => $entry[ 'id' ],
273 273
 			'approval_status'    => $approval_status,
274 274
 			'expiration_seconds' => $expiration_seconds,
275 275
 			'privacy'            => $privacy,
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 			$query_args[ self::TOKEN_URL_ARG ] = $token;
343 343
 		}
344 344
 
345
-		if ( DAY_IN_SECONDS >= (int) $expiration_seconds ) {
346
-			$query_args['nonce'] = wp_create_nonce( self::TOKEN_URL_ARG );
345
+		if ( DAY_IN_SECONDS >= (int)$expiration_seconds ) {
346
+			$query_args[ 'nonce' ] = wp_create_nonce( self::TOKEN_URL_ARG );
347 347
 		}
348 348
 
349 349
 		return add_query_arg( $query_args, $base_url );
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 			wp_die( sprintf( __( 'Entry moderation failed: %s', 'gravityview' ), $is_request_valid->get_error_message() ) );
400 400
 		}
401 401
 
402
-		$scopes = $token['scopes'];
402
+		$scopes = $token[ 'scopes' ];
403 403
 
404
-		$entry_id        = $scopes['entry_id'];
405
-		$approval_status = $scopes['approval_status'];
404
+		$entry_id        = $scopes[ 'entry_id' ];
405
+		$approval_status = $scopes[ 'approval_status' ];
406 406
 
407 407
 		$entry = GFAPI::get_entry( $entry_id );
408 408
 
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 			wp_die( $entry->get_error_message() );
413 413
 		}
414 414
 
415
-		$form_id = $entry['form_id'];
415
+		$form_id = $entry[ 'form_id' ];
416 416
 
417
-		if ( self::DEFAULT_PRIVACY === $scopes['privacy'] ) {
417
+		if ( self::DEFAULT_PRIVACY === $scopes[ 'privacy' ] ) {
418 418
 			$return_url = admin_url( '/admin.php?page=gf_entries&s=' . $entry_id . '&field_id=entry_id&operator=is&id=' . $form_id );
419 419
 		} else {
420 420
 			$return_url = home_url( '/' );
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 			exit;
440 440
 		}
441 441
 
442
-		if ( self::DEFAULT_PRIVACY === $scopes['privacy'] && ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) {
442
+		if ( self::DEFAULT_PRIVACY === $scopes[ 'privacy' ] && ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) {
443 443
 
444 444
 			gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' );
445 445
 
@@ -462,20 +462,20 @@  discard block
 block discarded – undo
462 462
 	 */
463 463
 	protected function is_request_valid( $token ) {
464 464
 
465
-		if ( self::DEFAULT_PRIVACY === $token['scopes']['privacy'] && ! is_user_logged_in() ) {
465
+		if ( self::DEFAULT_PRIVACY === $token[ 'scopes' ][ 'privacy' ] && ! is_user_logged_in() ) {
466 466
 			return new WP_Error( 'user_not_logged_in', __( 'You are not allowed to perform this operation.', 'gravityview' ) );
467 467
 		}
468 468
 
469
-		if ( $token['exp'] < time() ) {
469
+		if ( $token[ 'exp' ] < time() ) {
470 470
 			gravityview()->log->error( 'The entry moderation link expired.', array( 'data' => $is_valid_token ) );
471 471
 
472 472
 			return new WP_Error( 'link_expired', esc_html__( 'The link has expired.', 'gk-gravityview' ) );
473 473
 		}
474 474
 
475 475
 		// Since nonces are only valid for 24 hours, we only check the nonce if the token is valid for less than 24 hours.
476
-		if ( DAY_IN_SECONDS >= $token['scopes']['expiration_seconds'] ) {
476
+		if ( DAY_IN_SECONDS >= $token[ 'scopes' ][ 'expiration_seconds' ] ) {
477 477
 
478
-			if ( ! isset( $_REQUEST['nonce'] ) ) {
478
+			if ( ! isset( $_REQUEST[ 'nonce' ] ) ) {
479 479
 				gravityview()->log->error( 'Entry moderation failed: No nonce was set for entry approval.' );
480 480
 
481 481
 				return new WP_Error( 'missing_nonce', esc_html__( 'The link is invalid.', 'gk-gravityview' ) );
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 			return;
517 517
 		}
518 518
 
519
-		$approval_label = GravityView_Entry_Approval_Status::get_label( (int) $approval_status );
519
+		$approval_label = GravityView_Entry_Approval_Status::get_label( (int)$approval_status );
520 520
 		$approval_label = mb_strtolower( $approval_label );
521 521
 
522 522
 		if ( 'success' === $result ) {
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 		);
637 637
 
638 638
 		foreach ( $required_scopes as $required_scope ) {
639
-			if ( ! isset( $token['scopes'][ $required_scope ] ) ) {
639
+			if ( ! isset( $token[ 'scopes' ][ $required_scope ] ) ) {
640 640
 				return new WP_Error( 'approve_link_no_' . $required_scope . '_scope', esc_html__( 'The link is invalid.', 'gk-gravityview' ) );
641 641
 			}
642 642
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-entry-approval-status.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 		$new_value = $old_value;
115 115
 
116 116
 		// Meta value does not exist yet
117
-		if( false === $old_value ) {
117
+		if ( false === $old_value ) {
118 118
 			return self::UNAPPROVED;
119 119
 		}
120 120
 
121 121
 		// Meta value does not exist yet
122
-		if( true === $old_value ) {
122
+		if ( true === $old_value ) {
123 123
 			return self::APPROVED;
124 124
 		}
125 125
 
126
-		switch ( (string) $old_value ) {
126
+		switch ( (string)$old_value ) {
127 127
 
128 128
 			// Approved values
129 129
 			case 'Approved':
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 		foreach ( $choices as $key => $choice ) {
250 250
 
251 251
 			// Is the passed status value the same as the choice value or key?
252
-			if ( $status === $choice['value'] || $status === $key ) {
253
-				if( 'key' === $attr_key ) {
252
+			if ( $status === $choice[ 'value' ] || $status === $key ) {
253
+				if ( 'key' === $attr_key ) {
254 254
 					return $key;
255 255
 				} else {
256 256
 					return \GV\Utils::get( $choice, $attr_key, false );
Please login to merge, or discard this patch.