@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * @see RGFormsModel::update_lead_property() Trigger when any entry property changes |
81 | 81 | */ |
82 | - foreach( $this->lead_db_columns as $column ) { |
|
82 | + foreach ( $this->lead_db_columns as $column ) { |
|
83 | 83 | add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 ); |
84 | 84 | } |
85 | 85 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
115 | + do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry[ 'form_id' ] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
116 | 116 | |
117 | - $this->blacklist_add( $entry['form_id'] ); |
|
117 | + $this->blacklist_add( $entry[ 'form_id' ] ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function entry_updated( $form, $lead_id ) { |
129 | 129 | |
130 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
130 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
131 | 131 | |
132 | - $this->blacklist_add( $form['id'] ); |
|
132 | + $this->blacklist_add( $form[ 'id' ] ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function entry_created( $entry, $form ) { |
146 | 146 | |
147 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' ); |
|
147 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $entry[ 'id' ] . ' was created' ); |
|
148 | 148 | |
149 | - $this->blacklist_add( $form['id'] ); |
|
149 | + $this->blacklist_add( $form[ 'id' ] ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | // Normally just one form, but supports multiple forms |
166 | 166 | // |
167 | 167 | // Array of IDs 12, 5, 14 would result in `f-12f-5f-14` |
168 | - $forms = 'f:' . implode( '&f:', (array) $form_ids ); |
|
168 | + $forms = 'f:' . implode( '&f:', (array)$form_ids ); |
|
169 | 169 | |
170 | 170 | // Prefix for transient keys |
171 | 171 | // Now the prefix would be: `gv-cache-f-12f-5f-14` |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | ) ); |
223 | 223 | |
224 | 224 | // Add the passed form IDs |
225 | - $blacklist = array_merge( (array) $blacklist, $form_ids ); |
|
225 | + $blacklist = array_merge( (array)$blacklist, $form_ids ); |
|
226 | 226 | |
227 | 227 | // Don't duplicate |
228 | 228 | $blacklist = array_unique( $blacklist ); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
244 | 244 | |
245 | - $updated_list = array_diff( $blacklist, (array) $form_ids ); |
|
245 | + $updated_list = array_diff( $blacklist, (array)$form_ids ); |
|
246 | 246 | |
247 | 247 | do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
248 | 248 | '$form_ids' => $form_ids, |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | - foreach ( (array) $form_ids as $form_id ) { |
|
278 | + foreach ( (array)$form_ids as $form_id ) { |
|
279 | 279 | |
280 | 280 | if ( in_array( $form_id, $blacklist ) ) { |
281 | 281 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache |
348 | 348 | * @param int $time_in_seconds Default: `DAY_IN_SECONDS` |
349 | 349 | */ |
350 | - $cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
350 | + $cache_time = (int)apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
351 | 351 | |
352 | 352 | do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' ); |
353 | 353 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - foreach ( (array) $form_ids as $form_id ) { |
|
386 | + foreach ( (array)$form_ids as $form_id ) { |
|
387 | 387 | |
388 | 388 | $key = $this->get_cache_key_prefix( $form_id ); |
389 | 389 | |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | |
498 | 498 | if ( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
499 | 499 | |
500 | - if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) { |
|
500 | + if ( isset( $_GET[ 'cache' ] ) || isset( $_GET[ 'nocache' ] ) ) { |
|
501 | 501 | |
502 | 502 | do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' ); |
503 | 503 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | */ |
527 | 527 | $use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this ); |
528 | 528 | |
529 | - return (boolean) $use_cache; |
|
529 | + return (boolean)$use_cache; |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | do_action( 'gravityview_log_debug', __FUNCTION__ . ' $passed_atts: ', $passed_atts ); |
50 | 50 | |
51 | 51 | // Get details about the current View |
52 | - if( !empty( $passed_atts['detail'] ) ) { |
|
53 | - return $this->get_view_detail( $passed_atts['detail'] ); |
|
52 | + if ( ! empty( $passed_atts[ 'detail' ] ) ) { |
|
53 | + return $this->get_view_detail( $passed_atts[ 'detail' ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $atts = $this->parse_and_sanitize_atts( $passed_atts ); |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
87 | 87 | |
88 | 88 | // Only keep the passed attributes after making sure that they're valid pairs |
89 | - $filtered_atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( (array) $passed_atts, $filtered_atts ) : $filtered_atts; |
|
89 | + $filtered_atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( (array)$passed_atts, $filtered_atts ) : $filtered_atts; |
|
90 | 90 | |
91 | 91 | $atts = array(); |
92 | 92 | |
93 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
93 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
94 | 94 | |
95 | 95 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
96 | 96 | $passed_value = GravityView_Merge_Tags::replace_variables( $passed_value ); |
97 | 97 | |
98 | - switch( $defaults[ $key ]['type'] ) { |
|
98 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Make sure number fields are numeric. |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
104 | 104 | */ |
105 | 105 | case 'number': |
106 | - if( is_numeric( $passed_value ) ) { |
|
106 | + if ( is_numeric( $passed_value ) ) { |
|
107 | 107 | $atts[ $key ] = ( $passed_value + 0 ); |
108 | 108 | } |
109 | 109 | break; |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | */ |
119 | 119 | case 'select': |
120 | 120 | case 'radio': |
121 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
122 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
121 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
122 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
123 | 123 | $atts[ $key ] = $passed_value; |
124 | 124 | } |
125 | 125 | break; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $gravityview_view = GravityView_View::getInstance(); |
149 | 149 | $return = ''; |
150 | 150 | |
151 | - switch( $detail ) { |
|
151 | + switch ( $detail ) { |
|
152 | 152 | case 'total_entries': |
153 | 153 | $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
154 | 154 | break; |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | private function add_hooks() { |
40 | 40 | |
41 | 41 | // in case entry is edited (on admin or frontend) |
42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
43 | 43 | |
44 | 44 | // when using the User opt-in field, check on entry submission |
45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
46 | 46 | |
47 | 47 | // process ajax approve entry requests |
48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
49 | 49 | |
50 | 50 | } |
51 | 51 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
64 | 64 | |
65 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry ); |
|
65 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry ); |
|
66 | 66 | |
67 | 67 | $status = gform_get_meta( $entry_id, self::meta_key ); |
68 | 68 | |
69 | 69 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
70 | 70 | |
71 | - if( 'value' === $value_or_label ) { |
|
71 | + if ( 'value' === $value_or_label ) { |
|
72 | 72 | return $status; |
73 | 73 | } |
74 | 74 | |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function ajax_update_approved() { |
95 | 95 | |
96 | - $form_id = intval( rgpost('form_id') ); |
|
96 | + $form_id = intval( rgpost( 'form_id' ) ); |
|
97 | 97 | |
98 | - $entry_id = GVCommon::get_entry_id( rgpost('entry_slug') ); |
|
98 | + $entry_id = GVCommon::get_entry_id( rgpost( 'entry_slug' ) ); |
|
99 | 99 | |
100 | - $approval_status = rgpost('approved'); |
|
100 | + $approval_status = rgpost( 'approved' ); |
|
101 | 101 | |
102 | - $nonce = rgpost('nonce'); |
|
102 | + $nonce = rgpost( 'nonce' ); |
|
103 | 103 | |
104 | 104 | // Valid status |
105 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
105 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
106 | 106 | |
107 | 107 | do_action( 'gravityview_log_error', __METHOD__ . ': Invalid approval status', $_POST ); |
108 | 108 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
135 | 135 | |
136 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
136 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param $form array Gravity Forms form object |
167 | 167 | */ |
168 | 168 | public function after_submission( $entry, $form ) { |
169 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
169 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
182 | 182 | |
183 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
183 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * If the form doesn't contain the approve field, don't assume anything. |
187 | 187 | */ |
188 | - if( empty( $approved_column ) ) { |
|
188 | + if ( empty( $approved_column ) ) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $entry = GFAPI::get_entry( $entry_id ); |
193 | 193 | |
194 | - self::update_approved_meta( $entry_id, $entry[ (string)$approved_column ], $form['id'] ); |
|
194 | + self::update_approved_meta( $entry_id, $entry[ (string)$approved_column ], $form[ 'id' ] ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | $success = true; |
232 | 232 | foreach ( $entries as $entry_id ) { |
233 | - $update_success = self::update_approved( (int) $entry_id, $approved, $form_id, $approved_column_id ); |
|
233 | + $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
|
234 | 234 | |
235 | 235 | if ( ! $update_success ) { |
236 | 236 | $success = false; |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
258 | 258 | |
259 | - if( !class_exists( 'GFAPI' ) ) { |
|
259 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
260 | 260 | do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
261 | 261 | return false; |
262 | 262 | } |
263 | 263 | |
264 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
264 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
265 | 265 | do_action( 'gravityview_log_error', __METHOD__ . ': Not a valid approval value.' ); |
266 | 266 | return false; |
267 | 267 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // If the form has an Approve/Reject field, update that value |
279 | 279 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
280 | 280 | |
281 | - if( is_wp_error( $result ) ) { |
|
281 | + if ( is_wp_error( $result ) ) { |
|
282 | 282 | do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
283 | 283 | return false; |
284 | 284 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | |
291 | 291 | // add note to entry if approval field updating worked or there was no approved field |
292 | 292 | // There's no validation for the meta |
293 | - if( true === $result ) { |
|
293 | + if ( true === $result ) { |
|
294 | 294 | |
295 | 295 | // Add an entry note |
296 | 296 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | $note_id = false; |
345 | 345 | |
346 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
346 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
347 | 347 | |
348 | 348 | $current_user = wp_get_current_user(); |
349 | 349 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
367 | 367 | |
368 | - if( empty( $approvedcolumn ) ) { |
|
368 | + if ( empty( $approvedcolumn ) ) { |
|
369 | 369 | $approvedcolumn = self::get_approved_column( $form_id ); |
370 | 370 | } |
371 | 371 | |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | private static function update_approved_meta( $entry_id, $status, $form_id = 0 ) { |
414 | 414 | |
415 | 415 | if ( ! GravityView_Entry_Approval_Status::is_valid( $status ) ) { |
416 | - do_action('gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
416 | + do_action( 'gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | |
420 | 420 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
421 | 421 | |
422 | 422 | // update entry meta |
423 | - if( function_exists('gform_update_meta') ) { |
|
423 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
424 | 424 | |
425 | - if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
425 | + if ( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
426 | 426 | gform_delete_meta( $entry_id, self::meta_key ); |
427 | 427 | } else { |
428 | 428 | gform_update_meta( $entry_id, self::meta_key, $status, $form_id ); |
@@ -445,11 +445,11 @@ discard block |
||
445 | 445 | * @since 1.18 Added "unapproved" |
446 | 446 | * @param int $entry_id ID of the Gravity Forms entry |
447 | 447 | */ |
448 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
448 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
449 | 449 | |
450 | 450 | } else { |
451 | 451 | |
452 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
452 | + do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
453 | 453 | |
454 | 454 | } |
455 | 455 | } |
@@ -464,29 +464,29 @@ discard block |
||
464 | 464 | */ |
465 | 465 | static public function get_approved_column( $form ) { |
466 | 466 | |
467 | - if( empty( $form ) ) { |
|
467 | + if ( empty( $form ) ) { |
|
468 | 468 | return null; |
469 | 469 | } |
470 | 470 | |
471 | - if( !is_array( $form ) ) { |
|
471 | + if ( ! is_array( $form ) ) { |
|
472 | 472 | $form = GVCommon::get_form( $form ); |
473 | 473 | } |
474 | 474 | |
475 | - foreach( $form['fields'] as $key => $field ) { |
|
475 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
476 | 476 | |
477 | - $field = (array) $field; |
|
477 | + $field = (array)$field; |
|
478 | 478 | |
479 | - if( !empty( $field['gravityview_approved'] ) ) { |
|
480 | - if( !empty($field['inputs'][0]['id']) ) { |
|
481 | - return $field['inputs'][0]['id']; |
|
479 | + if ( ! empty( $field[ 'gravityview_approved' ] ) ) { |
|
480 | + if ( ! empty( $field[ 'inputs' ][ 0 ][ 'id' ] ) ) { |
|
481 | + return $field[ 'inputs' ][ 0 ][ 'id' ]; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | 485 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
486 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
487 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
488 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
489 | - return $input['id']; |
|
486 | + if ( 'checkbox' == $field[ 'type' ] && isset( $field[ 'inputs' ] ) && is_array( $field[ 'inputs' ] ) ) { |
|
487 | + foreach ( $field[ 'inputs' ] as $key2 => $input ) { |
|
488 | + if ( strtolower( $input[ 'label' ] ) == 'approved' ) { |
|
489 | + return $input[ 'id' ]; |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 1.11 |
53 | 53 | * @param boolean $boolean Whether to trigger update on user registration (default: true) |
54 | 54 | */ |
55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
55 | + if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
56 | 56 | |
57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
57 | + add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 ); |
|
58 | 58 | |
59 | 59 | // last resort in case the current user display name don't match any of the defaults |
60 | 60 | add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function update_user( $form = array(), $entry_id = 0 ) { |
74 | 74 | |
75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) { |
|
75 | + if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | */ |
102 | 102 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
103 | 103 | |
104 | - if( $preserve_role ) { |
|
105 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
104 | + if ( $preserve_role ) { |
|
105 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Make sure the current display name is not changed with the update user method. |
110 | 110 | * @since 1.15 |
111 | 111 | */ |
112 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
112 | + $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | /** |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | |
124 | 124 | |
125 | 125 | // Make sure the feed is active |
126 | - if ( ! $config['is_active'] ) { |
|
126 | + if ( ! $config[ 'is_active' ] ) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // If an Update feed, make sure the conditions are met. |
131 | - if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
132 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
131 | + if ( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
132 | + if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
166 | 166 | // trigger last resort method at the 'gform_user_updated' hook |
167 | - if( false === $format || 'nickname' === $format ) { |
|
167 | + if ( false === $format || 'nickname' === $format ) { |
|
168 | 168 | $this->_user_before_update = $user; |
169 | 169 | $format = 'nickname'; |
170 | 170 | } |
@@ -184,18 +184,18 @@ discard block |
||
184 | 184 | public function generate_display_names( $profileuser ) { |
185 | 185 | |
186 | 186 | $public_display = array(); |
187 | - $public_display['nickname'] = $profileuser->nickname; |
|
188 | - $public_display['username'] = $profileuser->user_login; |
|
187 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
188 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
189 | 189 | |
190 | - if ( !empty($profileuser->first_name) ) |
|
191 | - $public_display['firstname'] = $profileuser->first_name; |
|
190 | + if ( ! empty( $profileuser->first_name ) ) |
|
191 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
192 | 192 | |
193 | - if ( !empty($profileuser->last_name) ) |
|
194 | - $public_display['lastname'] = $profileuser->last_name; |
|
193 | + if ( ! empty( $profileuser->last_name ) ) |
|
194 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
195 | 195 | |
196 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
197 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
198 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
196 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
197 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
198 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $public_display = array_map( 'trim', $public_display ); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
227 | 227 | |
228 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
228 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' ); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Don't restore display name: |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * - or we don't need as we found the correct format before updating user. |
235 | 235 | * @since 1.14.4 |
236 | 236 | */ |
237 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
237 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | |
261 | 261 | $updated = wp_update_user( $restored_user ); |
262 | 262 | |
263 | - if( is_wp_error( $updated ) ) { |
|
264 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
263 | + if ( is_wp_error( $updated ) ) { |
|
264 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
265 | 265 | } else { |
266 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
266 | + do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | $this->_user_before_update = null; |