@@ -89,7 +89,7 @@ |
||
89 | 89 | return $response_json; |
90 | 90 | } |
91 | 91 | |
92 | - if ( empty( $response_json['success'] ) ) { |
|
92 | + if ( empty( $response_json[ 'success' ] ) ) { |
|
93 | 93 | return new WP_Error( 'sync_error', __( 'Could not sync to TrustedLogin server', 'gravityview' ) ); |
94 | 94 | } |
95 | 95 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | try { |
146 | - $hash_bin = sodium_crypto_generichash( $string, '', (int) $length ); |
|
146 | + $hash_bin = sodium_crypto_generichash( $string, '', (int)$length ); |
|
147 | 147 | $hash = sodium_bin2hex( $hash_bin ); |
148 | 148 | } catch ( \TypeError $e ) { |
149 | 149 | return new WP_Error( |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | |
252 | 252 | if ( is_wp_error( $response_json ) ) { |
253 | 253 | |
254 | - if ( 'not_found' == $response_json->get_error_code() ){ |
|
254 | + if ( 'not_found' == $response_json->get_error_code() ) { |
|
255 | 255 | return new WP_Error( 'not_found', __( 'Encryption key could not be fetched, Vendor site returned 404.', 'gravityview' ) ); |
256 | 256 | } |
257 | 257 | |
258 | 258 | return $response_json; |
259 | 259 | } |
260 | 260 | |
261 | - return $response_json['publicKey']; |
|
261 | + return $response_json[ 'publicKey' ]; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -366,6 +366,6 @@ discard block |
||
366 | 366 | 'privateKey' => sodium_crypto_box_secretkey( $aliceKeypair ) |
367 | 367 | ); |
368 | 368 | |
369 | - return (object) $alice_keys; |
|
369 | + return (object)$alice_keys; |
|
370 | 370 | } |
371 | 371 | } |
@@ -251,7 +251,7 @@ |
||
251 | 251 | |
252 | 252 | if ( is_wp_error( $response_json ) ) { |
253 | 253 | |
254 | - if ( 'not_found' == $response_json->get_error_code() ){ |
|
254 | + if ( 'not_found' == $response_json->get_error_code() ) { |
|
255 | 255 | return new WP_Error( 'not_found', __( 'Encryption key could not be fetched, Vendor site returned 404.', 'gravityview' ) ); |
256 | 256 | } |
257 | 257 |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | |
84 | 84 | $user_identifier = $passed_user_identifier; |
85 | 85 | |
86 | - if ( $this->in_lockdown() ){ |
|
86 | + if ( $this->in_lockdown() ) { |
|
87 | 87 | |
88 | 88 | $this->logging->log( 'Site is in lockdown mode, aborting login.', __METHOD__, 'error' ); |
89 | 89 | |
90 | - return new WP_Error( 'in-lockdown', __( 'TrustedLogin temporarily disabled.' , 'gravityview') ); |
|
90 | + return new WP_Error( 'in-lockdown', __( 'TrustedLogin temporarily disabled.', 'gravityview' ) ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // When passed in the endpoint URL, the unique ID will be the raw value, not the hash. |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $approved = $this->check_approved_identifier( $secret_id ); |
112 | 112 | |
113 | 113 | // Don't lock-down the site, since there could have been errors related to remote validation |
114 | - if ( is_wp_error( $approved ) ){ |
|
114 | + if ( is_wp_error( $approved ) ) { |
|
115 | 115 | |
116 | 116 | $this->logging->log( |
117 | 117 | sprintf( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'notice' |
153 | 153 | ); |
154 | 154 | |
155 | - return new WP_Error( 'brute-force-detected', 'Login aborted due to potential brute force detection.'); |
|
155 | + return new WP_Error( 'brute-force-detected', 'Login aborted due to potential brute force detection.' ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return true; |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | */ |
166 | 166 | private function maybe_add_used_accesskey( $user_identifier = '' ) { |
167 | 167 | |
168 | - $used_accesskeys = (array) get_site_transient( $this->used_accesskey_transient ); |
|
168 | + $used_accesskeys = (array)get_site_transient( $this->used_accesskey_transient ); |
|
169 | 169 | |
170 | 170 | // This is a new access key |
171 | 171 | if ( ! in_array( $user_identifier, $used_accesskeys, true ) ) { |
172 | 172 | |
173 | - $used_accesskeys[] = $user_identifier; |
|
173 | + $used_accesskeys[ ] = $user_identifier; |
|
174 | 174 | |
175 | 175 | $transient_set = set_site_transient( $this->used_accesskey_transient, $used_accesskeys, self::ACCESSKEY_LIMIT_EXPIRY ); |
176 | 176 | |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | */ |
191 | 191 | private function get_ip() { |
192 | 192 | |
193 | - if ( ! isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
193 | + if ( ! isset( $_SERVER[ 'REMOTE_ADDR' ] ) ) { |
|
194 | 194 | return null; |
195 | 195 | } |
196 | 196 | |
197 | - $ip = wp_unslash( $_SERVER['REMOTE_ADDR'] ); |
|
197 | + $ip = wp_unslash( $_SERVER[ 'REMOTE_ADDR' ] ); |
|
198 | 198 | |
199 | 199 | $ip = trim( $ip ); |
200 | 200 | |
201 | - if ( ! defined('TL_DOING_TESTS') ) { |
|
201 | + if ( ! defined( 'TL_DOING_TESTS' ) ) { |
|
202 | 202 | $ip = filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE ); |
203 | 203 | } |
204 | 204 | |
205 | - return (string) $ip; |
|
205 | + return (string)$ip; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | $body = array( |
228 | 228 | 'timestamp' => time(), |
229 | - 'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 255 ) : '', |
|
229 | + 'user_agent' => isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? substr( $_SERVER[ 'HTTP_USER_AGENT' ], 0, 255 ) : '', |
|
230 | 230 | 'user_ip' => $this->get_ip(), |
231 | 231 | 'site_url' => get_site_url(), |
232 | 232 | ); |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | */ |
266 | 266 | $body = array( |
267 | 267 | 'timestamp' => time(), |
268 | - 'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 255 ) : '', |
|
268 | + 'user_agent' => isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? substr( $_SERVER[ 'HTTP_USER_AGENT' ], 0, 255 ) : '', |
|
269 | 269 | 'user_ip' => $this->get_ip(), |
270 | 270 | 'site_url' => get_site_url(), |
271 | 271 | ); |
272 | 272 | |
273 | 273 | $remote = new Remote( $this->config, $this->logging ); |
274 | - $api_response = $remote->send( self::BRUTE_FORCE_ENDPOINT , $body, 'POST' ); |
|
274 | + $api_response = $remote->send( self::BRUTE_FORCE_ENDPOINT, $body, 'POST' ); |
|
275 | 275 | |
276 | 276 | if ( is_wp_error( $api_response ) ) { |
277 | 277 | return $api_response; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | $notified = $this->report_lockdown(); |
304 | 304 | |
305 | - if ( is_wp_error( $notified ) ){ |
|
305 | + if ( is_wp_error( $notified ) ) { |
|
306 | 306 | $this->logging->log( sprintf( 'Could not notify TrustedLogin (%s)', $notified->get_error_message() ), __METHOD__, 'error' ); |
307 | 307 | } |
308 | 308 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int|false Int: in lockdown. The value returned is the timestamp when lockdown ends. False: not in lockdown, or overridden by a constant. |
357 | 357 | */ |
358 | - public function in_lockdown(){ |
|
358 | + public function in_lockdown() { |
|
359 | 359 | |
360 | 360 | if ( $this->in_local_development() ) { |
361 | 361 | return false; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $registered = array(); |
126 | 126 | |
127 | - $registered['trustedlogin-js'] = wp_register_script( |
|
127 | + $registered[ 'trustedlogin-js' ] = wp_register_script( |
|
128 | 128 | 'trustedlogin-' . $this->config->ns(), |
129 | 129 | $this->config->get_setting( 'paths/js' ), |
130 | 130 | array( 'jquery', 'wp-a11y' ), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | true |
133 | 133 | ); |
134 | 134 | |
135 | - $registered['trustedlogin-css'] = wp_register_style( |
|
135 | + $registered[ 'trustedlogin-css' ] = wp_register_style( |
|
136 | 136 | 'trustedlogin-' . $this->config->ns(), |
137 | 137 | $this->config->get_setting( 'paths/css' ), |
138 | 138 | array(), |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @return bool |
226 | 226 | */ |
227 | 227 | private function is_login_screen() { |
228 | - return did_action( 'login_init' ) && isset( $_GET['ns'] ) && $_GET['ns'] === $this->config->ns(); |
|
228 | + return did_action( 'login_init' ) && isset( $_GET[ 'ns' ] ) && $_GET[ 'ns' ] === $this->config->ns(); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | // Once logged-in, take user back to auth request screen. |
243 | 243 | if ( ! is_user_logged_in() ) { |
244 | - $_REQUEST['redirect_to'] = site_url( add_query_arg( array() ) ); |
|
244 | + $_REQUEST[ 'redirect_to' ] = site_url( add_query_arg( array() ) ); |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
@@ -259,19 +259,19 @@ discard block |
||
259 | 259 | $interim_login = true; |
260 | 260 | |
261 | 261 | // The login_headertitle filter was deprecated in WP 5.2.0 for login_headertext |
262 | - if( version_compare( $wp_version, '5.2.0', '<' ) ) { |
|
262 | + if ( version_compare( $wp_version, '5.2.0', '<' ) ) { |
|
263 | 263 | add_filter( 'login_headertitle', '__return_empty_string' ); |
264 | 264 | } else { |
265 | 265 | add_filter( 'login_headertext', '__return_empty_string' ); |
266 | 266 | } |
267 | 267 | |
268 | - add_filter( 'login_headerurl', function () { |
|
268 | + add_filter( 'login_headerurl', function() { |
|
269 | 269 | return $this->config->get_setting( 'vendor/website' ); |
270 | 270 | }); |
271 | 271 | |
272 | 272 | login_header(); |
273 | 273 | |
274 | - wp_enqueue_style( 'common'); |
|
274 | + wp_enqueue_style( 'common' ); |
|
275 | 275 | |
276 | 276 | wp_add_inline_style( 'common', $this->get_login_inline_css() ); |
277 | 277 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | margin-top: 36px; |
302 | 302 | } |
303 | 303 | .login h1 a { |
304 | - background-image: url("' . $this->config->get_setting( 'vendor/logo_url' ). '")!important; |
|
304 | + background-image: url("' . $this->config->get_setting( 'vendor/logo_url' ) . '")!important; |
|
305 | 305 | background-size: contain!important; |
306 | 306 | } |
307 | 307 | '; |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | return ''; |
326 | 326 | } |
327 | 327 | |
328 | - $support_user = $support_users[0]; |
|
328 | + $support_user = $support_users[ 0 ]; |
|
329 | 329 | |
330 | 330 | $_user_creator_id = get_user_option( $this->support_user->created_by_meta_key, $support_user->ID ); |
331 | 331 | $_user_creator = $_user_creator_id ? get_user_by( 'id', $_user_creator_id ) : false; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | return ''; |
451 | 451 | } |
452 | 452 | |
453 | - $template = '<div class="tl-{{ns}}-auth__ref"><p><span class="tl-{{ns}}-auth_ref__id">{{reference_text}}</span></p></div>'; |
|
453 | + $template = '<div class="tl-{{ns}}-auth__ref"><p><span class="tl-{{ns}}-auth_ref__id">{{reference_text}}</span></p></div>'; |
|
454 | 454 | |
455 | 455 | $content = array( |
456 | 456 | 'reference_text' => sprintf( esc_html__( 'Reference #%s', 'gravityview' ), $reference_id ), |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | if ( $has_access ) { |
469 | 469 | foreach ( $has_access as $access ) { |
470 | 470 | // translators: %1$s is replaced with the name of the software developer (e.g. "Acme Widgets"). %2$s is the amount of time remaining for access ("1 week") |
471 | - $intro = sprintf( esc_html__( '%1$s has site access that expires in %2$s.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting('vendor/website') ) . '" target="_blank" rel="noopener noreferrer">' . $this->config->get_setting( 'vendor/title' ) . '</a>', str_replace( ' ', ' ', $this->support_user->get_expiration( $access, true, false ) ) ); |
|
471 | + $intro = sprintf( esc_html__( '%1$s has site access that expires in %2$s.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting( 'vendor/website' ) ) . '" target="_blank" rel="noopener noreferrer">' . $this->config->get_setting( 'vendor/title' ) . '</a>', str_replace( ' ', ' ', $this->support_user->get_expiration( $access, true, false ) ) ); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | return $intro; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | |
477 | 477 | if ( $this->is_login_screen() ) { |
478 | 478 | // translators: %1$s is replaced with the name of the software developer (e.g. "Acme Widgets") |
479 | - $intro = sprintf( esc_html__( '%1$s would like support access to this site.', 'gravityview' ), '<a href="'. esc_url( $this->config->get_setting( 'vendor/website' ) ) . '">' . $this->config->get_display_name() . '</a>' ); |
|
479 | + $intro = sprintf( esc_html__( '%1$s would like support access to this site.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting( 'vendor/website' ) ) . '">' . $this->config->get_display_name() . '</a>' ); |
|
480 | 480 | } else { |
481 | 481 | // translators: %1$s is replaced with the name of the software developer (e.g. "Acme Widgets") |
482 | 482 | $intro = sprintf( esc_html__( 'Grant %1$s access to this site.', 'gravityview' ), '<a href="' . esc_url( $this->config->get_setting( 'vendor/website' ) ) . '">' . $this->config->get_display_name() . '</a>' ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | */ |
570 | 570 | private function get_caps_section( $caps_array, $heading = '', $dashicon = '' ) { |
571 | 571 | |
572 | - $caps_array = array_filter( (array) $caps_array, array( $this->config, 'is_not_null' ) ); |
|
572 | + $caps_array = array_filter( (array)$caps_array, array( $this->config, 'is_not_null' ) ); |
|
573 | 573 | |
574 | 574 | if ( empty( $caps_array ) ) { |
575 | 575 | return ''; |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | $output .= '<h3>' . esc_html( $heading ) . '</h3>'; |
581 | 581 | $output .= '<ul>'; |
582 | 582 | |
583 | - foreach ( (array) $caps_array as $cap => $reason ) { |
|
583 | + foreach ( (array)$caps_array as $cap => $reason ) { |
|
584 | 584 | $dashicon = '<span class="dashicons ' . esc_attr( $dashicon ) . ' dashicons--small"></span>'; |
585 | 585 | $reason = empty( $reason ) ? '' : '<small>' . esc_html( $reason ) . '</small>'; |
586 | - $output .= sprintf( '<li>%s<span class="code">%s</span>%s</li>', $dashicon, esc_html( $cap ), $reason ); |
|
586 | + $output .= sprintf( '<li>%s<span class="code">%s</span>%s</li>', $dashicon, esc_html( $cap ), $reason ); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $output .= '</ul>'; |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | |
715 | 715 | // Allow SVGs for logos |
716 | 716 | $allowed_protocols = wp_allowed_protocols(); |
717 | - $allowed_protocols[] = 'data'; |
|
717 | + $allowed_protocols[ ] = 'data'; |
|
718 | 718 | |
719 | 719 | $output_html = wp_kses( $output_html, array( |
720 | 720 | 'a' => array( |
@@ -756,10 +756,10 @@ discard block |
||
756 | 756 | 'p' => array( 'class' => array(), 'id' => array() ), |
757 | 757 | 'h1' => array( 'class' => array(), 'id' => array() ), |
758 | 758 | 'h2' => array( 'class' => array(), 'id' => array() ), |
759 | - 'h3' => array( 'class' => array(), 'id' => array(), 'style' => array(), ), |
|
759 | + 'h3' => array( 'class' => array(), 'id' => array(), 'style' => array(),), |
|
760 | 760 | 'h4' => array( 'class' => array(), 'id' => array() ), |
761 | 761 | 'h5' => array( 'class' => array(), 'id' => array() ), |
762 | - 'div' => array( 'class' => array(), 'id' => array(), 'aria-live' => array(), 'style' => array(), ), |
|
762 | + 'div' => array( 'class' => array(), 'id' => array(), 'aria-live' => array(), 'style' => array(),), |
|
763 | 763 | 'small' => array( 'class' => array(), 'id' => array(), 'data-toggle' => array() ), |
764 | 764 | 'header' => array( 'class' => array(), 'id' => array() ), |
765 | 765 | 'footer' => array( 'class' => array(), 'id' => array() ), |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | |
881 | 881 | $atts = wp_parse_args( $atts, $defaults ); |
882 | 882 | |
883 | - switch ( $atts['size'] ) { |
|
883 | + switch ( $atts[ 'size' ] ) { |
|
884 | 884 | case '': |
885 | 885 | $css_class = ''; |
886 | 886 | break; |
@@ -888,17 +888,17 @@ discard block |
||
888 | 888 | $css_class = 'button'; |
889 | 889 | break; |
890 | 890 | default: |
891 | - if ( ! in_array( $atts['size'], $sizes ) ) { |
|
892 | - $atts['size'] = 'hero'; |
|
891 | + if ( ! in_array( $atts[ 'size' ], $sizes ) ) { |
|
892 | + $atts[ 'size' ] = 'hero'; |
|
893 | 893 | } |
894 | 894 | |
895 | - $css_class = 'button button-' . $atts['size']; |
|
895 | + $css_class = 'button button-' . $atts[ 'size' ]; |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | $_valid_tags = array( 'a', 'button', 'span' ); |
899 | 899 | |
900 | - if ( ! empty( $atts['tag'] ) && in_array( strtolower( $atts['tag'] ), $_valid_tags, true ) ) { |
|
901 | - $tag = $atts['tag']; |
|
900 | + if ( ! empty( $atts[ 'tag' ] ) && in_array( strtolower( $atts[ 'tag' ] ), $_valid_tags, true ) ) { |
|
901 | + $tag = $atts[ 'tag' ]; |
|
902 | 902 | } else { |
903 | 903 | $tag = 'a'; |
904 | 904 | } |
@@ -906,16 +906,16 @@ discard block |
||
906 | 906 | $data_atts = array(); |
907 | 907 | |
908 | 908 | if ( $this->support_user->get_all() ) { |
909 | - $text = '<span class="dashicons dashicons-update-alt"></span>' . esc_html( $atts['exists_text'] ); |
|
909 | + $text = '<span class="dashicons dashicons-update-alt"></span>' . esc_html( $atts[ 'exists_text' ] ); |
|
910 | 910 | $href = admin_url( 'users.php?role=' . $this->support_user->role->get_name() ); |
911 | - $data_atts['access'] = 'extend'; |
|
911 | + $data_atts[ 'access' ] = 'extend'; |
|
912 | 912 | } else { |
913 | - $text = esc_html( $atts['text'] ); |
|
914 | - $href = $atts['support_url']; |
|
915 | - $data_atts['access'] = 'grant'; |
|
913 | + $text = esc_html( $atts[ 'text' ] ); |
|
914 | + $href = $atts[ 'support_url' ]; |
|
915 | + $data_atts[ 'access' ] = 'grant'; |
|
916 | 916 | } |
917 | 917 | |
918 | - $css_class = implode( ' ', array( $css_class, $atts['class'] ) ); |
|
918 | + $css_class = implode( ' ', array( $css_class, $atts[ 'class' ] ) ); |
|
919 | 919 | $css_class = trim( $css_class ); |
920 | 920 | |
921 | 921 | $data_string = ''; |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | } |
925 | 925 | |
926 | 926 | $powered_by = ''; |
927 | - if ( $atts['powered_by'] ) { |
|
927 | + if ( $atts[ 'powered_by' ] ) { |
|
928 | 928 | $powered_by = sprintf( '<small><span class="trustedlogin-logo"></span>%s</small>', |
929 | 929 | esc_html__( 'Secured by TrustedLogin', 'gravityview' ) |
930 | 930 | ); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ); |
150 | 150 | |
151 | 151 | if ( ! empty( $data ) && ! in_array( $method, array( 'GET', 'HEAD' ), true ) ) { |
152 | - $request_options['body'] = wp_json_encode( $data ); |
|
152 | + $request_options[ 'body' ] = wp_json_encode( $data ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | try { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | return new WP_Error( 'invalid_response', esc_html__( 'Invalid response.', 'gravityview' ), $api_response ); |
262 | 262 | |
263 | 263 | default: |
264 | - return (int) $response_code; |
|
264 | + return (int)$response_code; |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -304,20 +304,20 @@ discard block |
||
304 | 304 | return new WP_Error( 'invalid_response', esc_html__( 'Invalid response.', 'gravityview' ), $response_body ); |
305 | 305 | } |
306 | 306 | |
307 | - if ( isset( $response_json['errors'] ) ) { |
|
307 | + if ( isset( $response_json[ 'errors' ] ) ) { |
|
308 | 308 | |
309 | 309 | $errors = ''; |
310 | 310 | |
311 | 311 | // Multi-dimensional; we flatten. |
312 | - foreach ( $response_json['errors'] as $key => $error ) { |
|
313 | - $error = is_array( $error ) ? reset( $error ) : $error; |
|
312 | + foreach ( $response_json[ 'errors' ] as $key => $error ) { |
|
313 | + $error = is_array( $error ) ? reset( $error ) : $error; |
|
314 | 314 | $errors .= $error; |
315 | 315 | } |
316 | 316 | |
317 | 317 | return new WP_Error( 'errors_in_response', esc_html( $errors ), $response_body ); |
318 | 318 | } |
319 | 319 | |
320 | - foreach ( (array) $required_keys as $required_key ) { |
|
320 | + foreach ( (array)$required_keys as $required_key ) { |
|
321 | 321 | if ( ! isset( $response_json[ $required_key ] ) ) { |
322 | 322 | return new WP_Error( 'missing_required_key', sprintf( esc_html__( 'Invalid response. Missing key: %s', 'gravityview' ), $required_key ), $response_body ); |
323 | 323 | } |