@@ -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, true ); |
|
65 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
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 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $nonce = \GV\Utils::_POST( 'nonce' ); |
107 | 107 | |
108 | 108 | // Valid status |
109 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
109 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
110 | 110 | |
111 | 111 | gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) ); |
112 | 112 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
139 | 139 | |
140 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
140 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Set default |
191 | - self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] ); |
|
191 | + self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] ); |
|
192 | 192 | |
193 | 193 | // Then check for if there is an approval column, and use that value instead |
194 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
194 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
207 | 207 | |
208 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
208 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * If the form doesn't contain the approve field, don't assume anything. |
212 | 212 | */ |
213 | - if( empty( $approved_column ) ) { |
|
213 | + if ( empty( $approved_column ) ) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $value = GravityView_Entry_Approval_Status::APPROVED; |
225 | 225 | } |
226 | 226 | |
227 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
227 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
244 | 244 | |
245 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
245 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
246 | 246 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
247 | 247 | return NULL; |
248 | 248 | } |
249 | 249 | |
250 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
250 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
251 | 251 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
252 | 252 | return NULL; |
253 | 253 | } |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | $approved_column_id = self::get_approved_column( $form_id ); |
263 | 263 | |
264 | 264 | $success = true; |
265 | - foreach( $entries as $entry_id ) { |
|
265 | + foreach ( $entries as $entry_id ) { |
|
266 | 266 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
267 | 267 | |
268 | - if( ! $update_success ) { |
|
268 | + if ( ! $update_success ) { |
|
269 | 269 | $success = false; |
270 | 270 | } |
271 | 271 | } |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
291 | 291 | |
292 | - if( !class_exists( 'GFAPI' ) ) { |
|
292 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
293 | 293 | gravityview()->log->error( 'GFAPI does not exist' ); |
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | |
297 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
297 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
298 | 298 | gravityview()->log->error( 'Not a valid approval value.' ); |
299 | 299 | return false; |
300 | 300 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // If the form has an Approve/Reject field, update that value |
312 | 312 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
313 | 313 | |
314 | - if( is_wp_error( $result ) ) { |
|
314 | + if ( is_wp_error( $result ) ) { |
|
315 | 315 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
316 | 316 | return false; |
317 | 317 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | // add note to entry if approval field updating worked or there was no approved field |
325 | 325 | // There's no validation for the meta |
326 | - if( true === $result ) { |
|
326 | + if ( true === $result ) { |
|
327 | 327 | |
328 | 328 | // Add an entry note |
329 | 329 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | |
377 | 377 | $note_id = false; |
378 | 378 | |
379 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
379 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
380 | 380 | |
381 | 381 | $current_user = wp_get_current_user(); |
382 | 382 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
400 | 400 | |
401 | - if( empty( $approvedcolumn ) ) { |
|
401 | + if ( empty( $approvedcolumn ) ) { |
|
402 | 402 | $approvedcolumn = self::get_approved_column( $form_id ); |
403 | 403 | } |
404 | 404 | |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
422 | 422 | |
423 | 423 | $new_value = ''; |
424 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
424 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
425 | 425 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
426 | 426 | } |
427 | 427 | |
428 | 428 | //update entry |
429 | - $entry["{$approvedcolumn}"] = $new_value; |
|
429 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
430 | 430 | |
431 | 431 | /** |
432 | 432 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | // If the user has enabled a different value than the label (for some reason), use it. |
458 | 458 | // This is highly unlikely |
459 | 459 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
460 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
460 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | // Otherwise, fall back on the inputs array |
464 | 464 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
465 | - return $field->inputs[0]['label']; |
|
465 | + return $field->inputs[ 0 ][ 'label' ]; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | return null; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @since 1.18 Added "unapproved" |
516 | 516 | * @param int $entry_id ID of the Gravity Forms entry |
517 | 517 | */ |
518 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
518 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | */ |
529 | 529 | static public function get_approved_column( $form ) { |
530 | 530 | |
531 | - if( empty( $form ) ) { |
|
531 | + if ( empty( $form ) ) { |
|
532 | 532 | return null; |
533 | 533 | } |
534 | 534 | |
535 | - if( !is_array( $form ) ) { |
|
535 | + if ( ! is_array( $form ) ) { |
|
536 | 536 | $form = GVCommon::get_form( $form ); |
537 | 537 | } |
538 | 538 | |
@@ -542,22 +542,22 @@ discard block |
||
542 | 542 | * @var string $key |
543 | 543 | * @var GF_Field $field |
544 | 544 | */ |
545 | - foreach( $form['fields'] as $key => $field ) { |
|
545 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
546 | 546 | |
547 | 547 | $inputs = $field->get_entry_inputs(); |
548 | 548 | |
549 | - if( !empty( $field->gravityview_approved ) ) { |
|
550 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
551 | - $approved_column_id = $inputs[0]['id']; |
|
549 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
550 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
551 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
552 | 552 | break; |
553 | 553 | } |
554 | 554 | } |
555 | 555 | |
556 | 556 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
557 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
557 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
558 | 558 | foreach ( $inputs as $input ) { |
559 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
560 | - $approved_column_id = $input['id']; |
|
559 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
560 | + $approved_column_id = $input[ 'id' ]; |
|
561 | 561 | break; |
562 | 562 | } |
563 | 563 | } |