@@ -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; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function add_form_settings( $fields = array(), $form = array() ) { |
97 | 97 | |
98 | - $fields['restrictions']['fields'][] = array( |
|
98 | + $fields[ 'restrictions' ][ 'fields' ][ ] = array( |
|
99 | 99 | 'name' => 'publicApprovalLink', |
100 | 100 | 'type' => 'radio', |
101 | 101 | 'horizontal' => true, |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'value' => '0', |
112 | 112 | ), |
113 | 113 | ), |
114 | - 'default_value' => (string) gravityview()->plugin->settings->get( 'public_entry_moderation', '0' ), |
|
114 | + 'default_value' => (string)gravityview()->plugin->settings->get( 'public_entry_moderation', '0' ), |
|
115 | 115 | ); |
116 | 116 | |
117 | 117 | return $fields; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
184 | 184 | */ |
185 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
185 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
186 | 186 | |
187 | 187 | $matches = array(); |
188 | 188 | preg_match_all( '/{gv_((?:dis|un)?approve)_entry:?(?:(\d+)([d|h|m|s]))?:?(public)?}/', $text, $matches, PREG_SET_ORDER ); |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | return $text; |
193 | 193 | } |
194 | 194 | |
195 | - if ( ! isset( $form['publicApprovalLink'] ) ) { |
|
196 | - $form['publicApprovalLink'] = gravityview()->plugin->settings->get( 'public_entry_moderation' ); |
|
195 | + if ( ! isset( $form[ 'publicApprovalLink' ] ) ) { |
|
196 | + $form[ 'publicApprovalLink' ] = gravityview()->plugin->settings->get( 'public_entry_moderation' ); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | return $this->replace_merge_tag( $matches, $text, $form, $entry, $url_encode, $esc_html ); |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | */ |
216 | 216 | protected function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
217 | 217 | |
218 | - foreach( $matches as $match ) { |
|
218 | + foreach ( $matches as $match ) { |
|
219 | 219 | |
220 | - $full_tag = $match[0]; |
|
221 | - $action = $match[1]; |
|
222 | - $expiration_value = ! empty( $match[2] ) ? (int) $match[2] : self::EXPIRATION_HOURS; |
|
223 | - $expiration_unit = ! empty( $match[3] ) ? $match[3] : self::EXPIRATION_UNIT; |
|
224 | - $privacy = isset( $match[4] ) ? $match[4] : self::DEFAULT_PRIVACY; |
|
220 | + $full_tag = $match[ 0 ]; |
|
221 | + $action = $match[ 1 ]; |
|
222 | + $expiration_value = ! empty( $match[ 2 ] ) ? (int)$match[ 2 ] : self::EXPIRATION_HOURS; |
|
223 | + $expiration_unit = ! empty( $match[ 3 ] ) ? $match[ 3 ] : self::EXPIRATION_UNIT; |
|
224 | + $privacy = isset( $match[ 4 ] ) ? $match[ 4 ] : self::DEFAULT_PRIVACY; |
|
225 | 225 | |
226 | 226 | switch ( $expiration_unit ) { |
227 | 227 | case 'd': |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | break; |
240 | 240 | } |
241 | 241 | |
242 | - if ( false === (bool) $form['publicApprovalLink'] ) { |
|
242 | + if ( false === (bool)$form[ 'publicApprovalLink' ] ) { |
|
243 | 243 | $privacy = self::DEFAULT_PRIVACY; |
244 | 244 | } |
245 | 245 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $link_url = $this->get_link_url( $token, $privacy ); |
253 | 253 | |
254 | 254 | |
255 | - if ( self::EXPIRATION_HOURS > (int) $expiration_hours ) { |
|
255 | + if ( self::EXPIRATION_HOURS > (int)$expiration_hours ) { |
|
256 | 256 | $link_url = add_query_arg( array( 'nonce' => wp_create_nonce( self::TOKEN_URL_ARG ) ), $link_url ); |
257 | 257 | } |
258 | 258 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | protected function get_token( $action = false, $expiration_value = 24, $expiration_unit = 'hours', $privacy = 'private', $entry = array() ) { |
287 | 287 | |
288 | - if ( ! $action || ! $entry['id'] ) { |
|
288 | + if ( ! $action || ! $entry[ 'id' ] ) { |
|
289 | 289 | return false; |
290 | 290 | } |
291 | 291 | |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | $scopes = array( |
307 | - 'entry_id' => $entry['id'], |
|
307 | + 'entry_id' => $entry[ 'id' ], |
|
308 | 308 | 'approval_status' => $approval_status, |
309 | 309 | 'expiration_hours' => $expiration_value, |
310 | 310 | 'privacy' => $privacy, |
311 | 311 | ); |
312 | 312 | |
313 | 313 | $jti = uniqid(); |
314 | - $expiration_timestamp = strtotime( '+' . (int) $expiration_value . ' ' . $expiration_unit ); |
|
314 | + $expiration_timestamp = strtotime( '+' . (int)$expiration_value . ' ' . $expiration_unit ); |
|
315 | 315 | |
316 | 316 | $token_array = array( |
317 | 317 | 'iat' => time(), |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | wp_die( sprintf( __( 'Entry moderation failed: %s', 'gravityview' ), $token->get_error_message() ) ); |
414 | 414 | } |
415 | 415 | |
416 | - if ( self::EXPIRATION_HOURS > $token['scopes']['expiration_hours'] ) { |
|
416 | + if ( self::EXPIRATION_HOURS > $token[ 'scopes' ][ 'expiration_hours' ] ) { |
|
417 | 417 | |
418 | - if ( ! isset( $_REQUEST['nonce'] ) ) { |
|
418 | + if ( ! isset( $_REQUEST[ 'nonce' ] ) ) { |
|
419 | 419 | gravityview()->log->error( 'Entry moderation failed: No nonce was set for entry approval.' ); |
420 | 420 | |
421 | 421 | wp_die( sprintf( __( 'Entry moderation failed: %s', 'gravityview' ), esc_html__( 'The link is invalid.', 'gk-gravityview' ) ) ); |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | - $scopes = $token['scopes']; |
|
433 | + $scopes = $token[ 'scopes' ]; |
|
434 | 434 | |
435 | - if ( self::DEFAULT_PRIVACY === $scopes['privacy'] && ! is_user_logged_in() ) { |
|
435 | + if ( self::DEFAULT_PRIVACY === $scopes[ 'privacy' ] && ! is_user_logged_in() ) { |
|
436 | 436 | wp_die( __( 'You are not allowed to perform this operation.', 'gravityview' ) ); |
437 | 437 | } |
438 | 438 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | return; |
487 | 487 | } |
488 | 488 | |
489 | - $approval_label = GravityView_Entry_Approval_Status::get_label( (int) \GV\Utils::_GET( 'approval_status' ) ); |
|
489 | + $approval_label = GravityView_Entry_Approval_Status::get_label( (int)\GV\Utils::_GET( 'approval_status' ) ); |
|
490 | 490 | $approval_label = mb_strtolower( $approval_label ); |
491 | 491 | |
492 | 492 | $result = GV\Utils::_GET( self::URL_ARG ); |
@@ -588,35 +588,35 @@ discard block |
||
588 | 588 | */ |
589 | 589 | protected function validate_token( array $token ) { |
590 | 590 | |
591 | - if ( ! isset( $token['jti'] ) ) { |
|
591 | + if ( ! isset( $token[ 'jti' ] ) ) { |
|
592 | 592 | return new WP_Error( 'approve_link_no_jti', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
593 | 593 | } |
594 | 594 | |
595 | - if ( ! isset( $token['exp'] ) || $token['exp'] < time() ) { |
|
595 | + if ( ! isset( $token[ 'exp' ] ) || $token[ 'exp' ] < time() ) { |
|
596 | 596 | return new WP_Error( 'approve_link_expired', esc_html__( 'The link has expired.', 'gk-gravityview' ) ); |
597 | 597 | } |
598 | 598 | |
599 | - if ( ! isset( $token['scopes'] ) ) { |
|
599 | + if ( ! isset( $token[ 'scopes' ] ) ) { |
|
600 | 600 | return new WP_Error( 'approve_link_no_scopes', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
601 | 601 | } |
602 | 602 | |
603 | - if ( ! isset( $token['scopes']['expiration_hours'] ) ) { |
|
603 | + if ( ! isset( $token[ 'scopes' ][ 'expiration_hours' ] ) ) { |
|
604 | 604 | return new WP_Error( 'approve_link_no_expiration', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
605 | 605 | } |
606 | 606 | |
607 | - if ( ! isset( $token['scopes']['privacy'] ) ) { |
|
607 | + if ( ! isset( $token[ 'scopes' ][ 'privacy' ] ) ) { |
|
608 | 608 | return new WP_Error( 'approve_link_no_privacy', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
609 | 609 | } |
610 | 610 | |
611 | - if ( empty( $token['scopes']['entry_id'] ) ) { |
|
611 | + if ( empty( $token[ 'scopes' ][ 'entry_id' ] ) ) { |
|
612 | 612 | return new WP_Error( 'approve_link_no_entry_id', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
613 | 613 | } |
614 | 614 | |
615 | - if( empty( $token['scopes']['approval_status'] ) ) { |
|
615 | + if ( empty( $token[ 'scopes' ][ 'approval_status' ] ) ) { |
|
616 | 616 | return new WP_Error( 'approve_link_no_approval_status', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
617 | 617 | } |
618 | 618 | |
619 | - if( empty( $token['scopes']['expiration_hours'] ) ) { |
|
619 | + if ( empty( $token[ 'scopes' ][ 'expiration_hours' ] ) ) { |
|
620 | 620 | return new WP_Error( 'approve_link_no_approval_status', esc_html__( 'The link is invalid.', 'gk-gravityview' ) ); |
621 | 621 | } |
622 | 622 | |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | return; |
640 | 640 | } |
641 | 641 | |
642 | - $entry_id = $scopes['entry_id']; |
|
643 | - $approval_status = $scopes['approval_status']; |
|
642 | + $entry_id = $scopes[ 'entry_id' ]; |
|
643 | + $approval_status = $scopes[ 'approval_status' ]; |
|
644 | 644 | |
645 | - $entry = GFAPI::get_entry( $entry_id ); |
|
645 | + $entry = GFAPI::get_entry( $entry_id ); |
|
646 | 646 | |
647 | 647 | if ( is_wp_error( $entry ) ) { |
648 | 648 | wp_die( $entry->get_error_message() ); |
649 | 649 | } |
650 | 650 | |
651 | - $form_id = $entry['form_id']; |
|
651 | + $form_id = $entry[ 'form_id' ]; |
|
652 | 652 | |
653 | - if( self::DEFAULT_PRIVACY === $scopes['privacy'] ) { |
|
653 | + if ( self::DEFAULT_PRIVACY === $scopes[ 'privacy' ] ) { |
|
654 | 654 | $return_url = admin_url( '/admin.php?page=gf_entries&s=' . $entry_id . '&field_id=entry_id&operator=is&id=' . $form_id ); |
655 | 655 | } else { |
656 | 656 | $return_url = home_url( '/' ); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | } |
678 | 678 | |
679 | 679 | // Has capability |
680 | - elseif ( self::DEFAULT_PRIVACY === $scopes['privacy'] && ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) { |
|
680 | + elseif ( self::DEFAULT_PRIVACY === $scopes[ 'privacy' ] && ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry_id ) ) { |
|
681 | 681 | |
682 | 682 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
683 | 683 |