@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @param int $entry_id ID of the Gravity Forms entry |
372 | 372 | * @param string $status String whether entry is approved or not. `0` for not approved, `Approved` for approved. |
373 | 373 | * @param int $form_id ID of the form of the entry being updated. Improves query performance. |
374 | - * @param string $approvedcolumn Gravity Forms Field ID |
|
374 | + * @param integer $approvedcolumn Gravity Forms Field ID |
|
375 | 375 | * |
376 | 376 | * @return true|WP_Error |
377 | 377 | */ |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @since 1.19 |
426 | 426 | * |
427 | - * @param array|int $form Form ID or form array |
|
427 | + * @param integer $form Form ID or form array |
|
428 | 428 | * @param string $approved_column Approved column field ID |
429 | 429 | * |
430 | 430 | * @return string|null |
@@ -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 | // autounapprove |
51 | 51 | add_action( 'gravityview/edit_entry/after_update', array( __CLASS__, 'autounapprove' ), 10, 4 ); |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
67 | 67 | |
68 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
68 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
69 | 69 | |
70 | 70 | $status = gform_get_meta( $entry_id, self::meta_key ); |
71 | 71 | |
72 | 72 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
73 | 73 | |
74 | - if( 'value' === $value_or_label ) { |
|
74 | + if ( 'value' === $value_or_label ) { |
|
75 | 75 | return $status; |
76 | 76 | } |
77 | 77 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $nonce = \GV\Utils::_POST( 'nonce' ); |
110 | 110 | |
111 | 111 | // Valid status |
112 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
112 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
113 | 113 | |
114 | 114 | gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) ); |
115 | 115 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
142 | 142 | |
143 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
143 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | // Set default |
194 | - self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] ); |
|
194 | + self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] ); |
|
195 | 195 | |
196 | 196 | // Then check for if there is an approval column, and use that value instead |
197 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
197 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
210 | 210 | |
211 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
211 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
212 | 212 | |
213 | 213 | /** |
214 | 214 | * If the form doesn't contain the approve field, don't assume anything. |
215 | 215 | */ |
216 | - if( empty( $approved_column ) ) { |
|
216 | + if ( empty( $approved_column ) ) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $value = GravityView_Entry_Approval_Status::APPROVED; |
228 | 228 | } |
229 | 229 | |
230 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
230 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
247 | 247 | |
248 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
248 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
249 | 249 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
250 | 250 | return NULL; |
251 | 251 | } |
252 | 252 | |
253 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
253 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
254 | 254 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
255 | 255 | return NULL; |
256 | 256 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | $approved_column_id = self::get_approved_column( $form_id ); |
266 | 266 | |
267 | 267 | $success = true; |
268 | - foreach( $entries as $entry_id ) { |
|
268 | + foreach ( $entries as $entry_id ) { |
|
269 | 269 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
270 | 270 | |
271 | - if( ! $update_success ) { |
|
271 | + if ( ! $update_success ) { |
|
272 | 272 | $success = false; |
273 | 273 | } |
274 | 274 | } |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
294 | 294 | |
295 | - if( !class_exists( 'GFAPI' ) ) { |
|
295 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
296 | 296 | gravityview()->log->error( 'GFAPI does not exist' ); |
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
300 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
301 | 301 | gravityview()->log->error( 'Not a valid approval value.' ); |
302 | 302 | return false; |
303 | 303 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | // If the form has an Approve/Reject field, update that value |
315 | 315 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
316 | 316 | |
317 | - if( is_wp_error( $result ) ) { |
|
317 | + if ( is_wp_error( $result ) ) { |
|
318 | 318 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
319 | 319 | return false; |
320 | 320 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | // add note to entry if approval field updating worked or there was no approved field |
328 | 328 | // There's no validation for the meta |
329 | - if( true === $result ) { |
|
329 | + if ( true === $result ) { |
|
330 | 330 | |
331 | 331 | // Add an entry note |
332 | 332 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | $note_id = false; |
381 | 381 | |
382 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
382 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
383 | 383 | |
384 | 384 | $current_user = wp_get_current_user(); |
385 | 385 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
403 | 403 | |
404 | - if( empty( $approvedcolumn ) ) { |
|
404 | + if ( empty( $approvedcolumn ) ) { |
|
405 | 405 | $approvedcolumn = self::get_approved_column( $form_id ); |
406 | 406 | } |
407 | 407 | |
@@ -424,12 +424,12 @@ discard block |
||
424 | 424 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
425 | 425 | |
426 | 426 | $new_value = ''; |
427 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
427 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
428 | 428 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
429 | 429 | } |
430 | 430 | |
431 | 431 | //update entry |
432 | - $entry["{$approvedcolumn}"] = $new_value; |
|
432 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
433 | 433 | |
434 | 434 | /** |
435 | 435 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | // If the user has enabled a different value than the label (for some reason), use it. |
461 | 461 | // This is highly unlikely |
462 | 462 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
463 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
463 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | // Otherwise, fall back on the inputs array |
467 | 467 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
468 | - return $field->inputs[0]['label']; |
|
468 | + return $field->inputs[ 0 ][ 'label' ]; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | return null; |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @since 1.18 Added "unapproved" |
519 | 519 | * @param int $entry_id ID of the Gravity Forms entry |
520 | 520 | */ |
521 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
521 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,11 +531,11 @@ discard block |
||
531 | 531 | */ |
532 | 532 | static public function get_approved_column( $form ) { |
533 | 533 | |
534 | - if( empty( $form ) ) { |
|
534 | + if ( empty( $form ) ) { |
|
535 | 535 | return null; |
536 | 536 | } |
537 | 537 | |
538 | - if( !is_array( $form ) ) { |
|
538 | + if ( ! is_array( $form ) ) { |
|
539 | 539 | $form = GVCommon::get_form( $form ); |
540 | 540 | } |
541 | 541 | |
@@ -545,22 +545,22 @@ discard block |
||
545 | 545 | * @var string $key |
546 | 546 | * @var GF_Field $field |
547 | 547 | */ |
548 | - foreach( $form['fields'] as $key => $field ) { |
|
548 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
549 | 549 | |
550 | 550 | $inputs = $field->get_entry_inputs(); |
551 | 551 | |
552 | - if( !empty( $field->gravityview_approved ) ) { |
|
553 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
554 | - $approved_column_id = $inputs[0]['id']; |
|
552 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
553 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
554 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
555 | 555 | break; |
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | 559 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
560 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
560 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
561 | 561 | foreach ( $inputs as $input ) { |
562 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
563 | - $approved_column_id = $input['id']; |
|
562 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
563 | + $approved_column_id = $input[ 'id' ]; |
|
564 | 564 | break; |
565 | 565 | } |
566 | 566 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | $view_keys = array_keys( $gv_data->get_views() ); |
588 | 588 | |
589 | - $view = \GV\View::by_id( $view_keys[0] ); |
|
589 | + $view = \GV\View::by_id( $view_keys[ 0 ] ); |
|
590 | 590 | |
591 | 591 | if ( ! $view->settings->get( 'unapprove_edit' ) ) { |
592 | 592 | return; |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | return; |
597 | 597 | } |
598 | 598 | |
599 | - self::update_approved_meta( $entry_id, GravityView_Entry_Approval_Status::UNAPPROVED, $form['id'] ); |
|
599 | + self::update_approved_meta( $entry_id, GravityView_Entry_Approval_Status::UNAPPROVED, $form[ 'id' ] ); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | } |