@@ -30,13 +30,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -114,16 +114,16 @@ discard block |
||
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 |
||
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 ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $global_default = gravityview()->plugin->settings->get( 'public_entry_moderation', '0' ); |
79 | 79 | |
80 | - $fields['restrictions']['fields'][] = array( |
|
80 | + $fields[ 'restrictions' ][ 'fields' ][ ] = array( |
|
81 | 81 | 'name' => self::FORM_SETTINGS_KEY, |
82 | 82 | 'type' => 'radio', |
83 | 83 | 'horizontal' => true, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | 'value' => '0', |
95 | 95 | ), |
96 | 96 | ), |
97 | - 'default_value' => (string) $global_default, |
|
97 | + 'default_value' => (string)$global_default, |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | return $fields; |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | |
182 | 182 | foreach ( $matches as $match ) { |
183 | 183 | |
184 | - $full_tag = $match[0]; |
|
185 | - $action = $match[1]; |
|
186 | - $expiration_value = ! empty( $match[2] ) ? (int) $match[2] : self::DEFAULT_EXPIRATION_VALUE; |
|
187 | - $expiration_unit = ! empty( $match[3] ) ? $match[3] : self::DEFAULT_EXPIRATION_UNIT; |
|
188 | - $privacy = isset( $match[4] ) ? $match[4] : 'private'; |
|
184 | + $full_tag = $match[ 0 ]; |
|
185 | + $action = $match[ 1 ]; |
|
186 | + $expiration_value = ! empty( $match[ 2 ] ) ? (int)$match[ 2 ] : self::DEFAULT_EXPIRATION_VALUE; |
|
187 | + $expiration_unit = ! empty( $match[ 3 ] ) ? $match[ 3 ] : self::DEFAULT_EXPIRATION_UNIT; |
|
188 | + $privacy = isset( $match[ 4 ] ) ? $match[ 4 ] : 'private'; |
|
189 | 189 | |
190 | 190 | switch ( $expiration_unit ) { |
191 | 191 | case 'd': |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | break; |
204 | 204 | } |
205 | 205 | |
206 | - if ( false === (bool) \GV\Utils::get( $form, self::FORM_SETTINGS_KEY, false ) ) { |
|
206 | + if ( false === (bool)\GV\Utils::get( $form, self::FORM_SETTINGS_KEY, false ) ) { |
|
207 | 207 | $privacy = 'private'; |
208 | 208 | } |
209 | 209 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | protected function get_token( $action = false, $expiration_timestamp = 0, $privacy = 'private', $entry = array() ) { |
244 | 244 | |
245 | - if ( ! $action || ! $entry['id'] ) { |
|
245 | + if ( ! $action || ! $entry[ 'id' ] ) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $expiration_seconds = $expiration_timestamp - time(); |
265 | 265 | |
266 | 266 | $scopes = array( |
267 | - 'entry_id' => $entry['id'], |
|
267 | + 'entry_id' => $entry[ 'id' ], |
|
268 | 268 | 'approval_status' => $approval_status, |
269 | 269 | 'expiration_seconds' => $expiration_seconds, |
270 | 270 | 'privacy' => $privacy, |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | $query_args[ self::TOKEN_URL_ARG ] = $token; |
338 | 338 | } |
339 | 339 | |
340 | - if ( 'private' === $privacy && DAY_IN_SECONDS >= (int) $expiration_seconds ) { |
|
341 | - $query_args['nonce'] = wp_create_nonce( self::TOKEN_URL_ARG ); |
|
340 | + if ( 'private' === $privacy && DAY_IN_SECONDS >= (int)$expiration_seconds ) { |
|
341 | + $query_args[ 'nonce' ] = wp_create_nonce( self::TOKEN_URL_ARG ); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return add_query_arg( $query_args, $base_url ); |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | wp_die( sprintf( __( 'Entry moderation failed: %s', 'gravityview' ), $is_request_valid->get_error_message() ) ); |
395 | 395 | } |
396 | 396 | |
397 | - $scopes = $token['scopes']; |
|
397 | + $scopes = $token[ 'scopes' ]; |
|
398 | 398 | |
399 | - $entry_id = $scopes['entry_id']; |
|
400 | - $approval_status = $scopes['approval_status']; |
|
399 | + $entry_id = $scopes[ 'entry_id' ]; |
|
400 | + $approval_status = $scopes[ 'approval_status' ]; |
|
401 | 401 | |
402 | 402 | $entry = GFAPI::get_entry( $entry_id ); |
403 | 403 | |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | wp_die( $entry->get_error_message() ); |
408 | 408 | } |
409 | 409 | |
410 | - $form_id = $entry['form_id']; |
|
410 | + $form_id = $entry[ 'form_id' ]; |
|
411 | 411 | |
412 | - if ( 'private' === $scopes['privacy'] ) { |
|
412 | + if ( 'private' === $scopes[ 'privacy' ] ) { |
|
413 | 413 | $return_url = admin_url( '/admin.php?page=gf_entries&s=' . $entry_id . '&field_id=entry_id&operator=is&id=' . $form_id ); |
414 | 414 | } else { |
415 | 415 | $return_url = home_url( '/' ); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | exit; |
435 | 435 | } |
436 | 436 | |
437 | - if ( 'private' === $scopes['privacy'] && ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) { |
|
437 | + if ( 'private' === $scopes[ 'privacy' ] && ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) { |
|
438 | 438 | |
439 | 439 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
440 | 440 | |
@@ -457,20 +457,20 @@ discard block |
||
457 | 457 | */ |
458 | 458 | protected function is_request_valid( $token ) { |
459 | 459 | |
460 | - if ( 'private' === $token['scopes']['privacy'] && ! is_user_logged_in() ) { |
|
460 | + if ( 'private' === $token[ 'scopes' ][ 'privacy' ] && ! is_user_logged_in() ) { |
|
461 | 461 | return new WP_Error( 'user_not_logged_in', __( 'You are not allowed to perform this operation.', 'gravityview' ) ); |
462 | 462 | } |
463 | 463 | |
464 | - if ( $token['exp'] < time() ) { |
|
464 | + if ( $token[ 'exp' ] < time() ) { |
|
465 | 465 | gravityview()->log->error( 'The entry moderation link expired.', array( 'data' => $is_valid_token ) ); |
466 | 466 | |
467 | 467 | return new WP_Error( 'link_expired', esc_html__( 'The link has expired.', 'gk-gravityview' ) ); |
468 | 468 | } |
469 | 469 | |
470 | 470 | // Since nonces are only valid for 24 hours, we only check the nonce if the token is valid for less than 24 hours. |
471 | - if ( 'private' === $token['scopes']['privacy'] && DAY_IN_SECONDS >= $token['scopes']['expiration_seconds'] ) { |
|
471 | + if ( 'private' === $token[ 'scopes' ][ 'privacy' ] && DAY_IN_SECONDS >= $token[ 'scopes' ][ 'expiration_seconds' ] ) { |
|
472 | 472 | |
473 | - if ( ! isset( $_REQUEST['nonce'] ) ) { |
|
473 | + if ( ! isset( $_REQUEST[ 'nonce' ] ) ) { |
|
474 | 474 | gravityview()->log->error( 'Entry moderation failed: No nonce was set for entry approval.' ); |
475 | 475 | |
476 | 476 | return new WP_Error( 'missing_nonce', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - $approval_label = GravityView_Entry_Approval_Status::get_label( (int) $approval_status ); |
|
514 | + $approval_label = GravityView_Entry_Approval_Status::get_label( (int)$approval_status ); |
|
515 | 515 | $approval_label = mb_strtolower( $approval_label ); |
516 | 516 | |
517 | 517 | if ( 'success' === $result ) { |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | ); |
632 | 632 | |
633 | 633 | foreach ( $required_scopes as $required_scope ) { |
634 | - if ( ! isset( $token['scopes'][ $required_scope ] ) ) { |
|
634 | + if ( ! isset( $token[ 'scopes' ][ $required_scope ] ) ) { |
|
635 | 635 | return new WP_Error( 'approve_link_no_' . $required_scope . '_scope', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
636 | 636 | } |
637 | 637 | } |