@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | function load() { |
124 | 124 | |
125 | 125 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
126 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
126 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
127 | 127 | |
128 | 128 | // Don't display an embedded form when editing an entry |
129 | 129 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
130 | 130 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
131 | 131 | |
132 | 132 | // Stop Gravity Forms processing what is ours! |
133 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
133 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
134 | 134 | |
135 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
135 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
136 | 136 | |
137 | 137 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
144 | 144 | |
145 | 145 | // Add fields expected by GFFormDisplay::validate() |
146 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
146 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
147 | 147 | |
148 | 148 | // Fix multiselect value for GF 2.2 |
149 | 149 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | public function prevent_render_form() { |
163 | - if( $this->is_edit_entry() ) { |
|
164 | - if( 'wp_head' === current_filter() ) { |
|
163 | + if ( $this->is_edit_entry() ) { |
|
164 | + if ( 'wp_head' === current_filter() ) { |
|
165 | 165 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
166 | 166 | } else { |
167 | 167 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function prevent_maybe_process_form() { |
178 | 178 | |
179 | - if( ! $this->is_edit_entry_submission() ) { |
|
179 | + if ( ! $this->is_edit_entry_submission() ) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | 183 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
184 | 184 | |
185 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
186 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
185 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
186 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function is_edit_entry() { |
194 | 194 | |
195 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
195 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
196 | 196 | |
197 | 197 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return boolean |
204 | 204 | */ |
205 | 205 | public function is_edit_entry_submission() { |
206 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
206 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | |
217 | 217 | |
218 | 218 | $entries = $gravityview_view->getEntries(); |
219 | - self::$original_entry = $entries[0]; |
|
220 | - $this->entry = $entries[0]; |
|
219 | + self::$original_entry = $entries[ 0 ]; |
|
220 | + $this->entry = $entries[ 0 ]; |
|
221 | 221 | |
222 | 222 | self::$original_form = $gravityview_view->getForm(); |
223 | 223 | $this->form = $gravityview_view->getForm(); |
224 | - $this->form_id = $this->entry['form_id']; |
|
224 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
225 | 225 | $this->view_id = $gravityview_view->getViewId(); |
226 | 226 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
227 | 227 | |
228 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
228 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | private function print_scripts() { |
285 | 285 | $gravityview_view = GravityView_View::getInstance(); |
286 | 286 | |
287 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
287 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
288 | 288 | |
289 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
289 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
290 | 290 | |
291 | 291 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
292 | 292 | |
@@ -302,19 +302,19 @@ discard block |
||
302 | 302 | */ |
303 | 303 | private function process_save( $gv_data ) { |
304 | 304 | |
305 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
305 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
309 | 309 | // Make sure the entry, view, and form IDs are all correct |
310 | 310 | $valid = $this->verify_nonce(); |
311 | 311 | |
312 | - if ( !$valid ) { |
|
312 | + if ( ! $valid ) { |
|
313 | 313 | gravityview()->log->error( 'Nonce validation failed.' ); |
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
317 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
318 | 318 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
319 | 319 | return; |
320 | 320 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | $this->validate(); |
327 | 327 | |
328 | - if( $this->is_valid ) { |
|
328 | + if ( $this->is_valid ) { |
|
329 | 329 | |
330 | 330 | gravityview()->log->debug( 'Submission is valid.' ); |
331 | 331 | |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | /** |
338 | 338 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
339 | 339 | */ |
340 | - unset( $_GET['page'] ); |
|
340 | + unset( $_GET[ 'page' ] ); |
|
341 | 341 | |
342 | - $date_created = $this->entry['date_created']; |
|
342 | + $date_created = $this->entry[ 'date_created' ]; |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
346 | 346 | * @since 1.17.2 |
347 | 347 | */ |
348 | - unset( $this->entry['date_created'] ); |
|
348 | + unset( $this->entry[ 'date_created' ] ); |
|
349 | 349 | |
350 | 350 | /** |
351 | 351 | * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | * @param GravityView_Edit_Entry_Render $this This object |
356 | 356 | * @param GravityView_View_Data $gv_data The View data |
357 | 357 | */ |
358 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
358 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
359 | 359 | |
360 | 360 | GFFormsModel::save_lead( $form, $this->entry ); |
361 | 361 | |
362 | 362 | // Delete the values for hidden inputs |
363 | 363 | $this->unset_hidden_field_values(); |
364 | 364 | |
365 | - $this->entry['date_created'] = $date_created; |
|
365 | + $this->entry[ 'date_created' ] = $date_created; |
|
366 | 366 | |
367 | 367 | // Process calculation fields |
368 | 368 | $this->update_calculation_fields(); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param GravityView_Edit_Entry_Render $this This object |
385 | 385 | * @param GravityView_View_Data $gv_data The View data |
386 | 386 | */ |
387 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
387 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
388 | 388 | |
389 | 389 | } else { |
390 | 390 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -412,16 +412,16 @@ discard block |
||
412 | 412 | */ |
413 | 413 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
414 | 414 | |
415 | - if( ! $unset_hidden_field_values ) { |
|
415 | + if ( ! $unset_hidden_field_values ) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | 419 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
420 | 420 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
421 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
421 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
422 | 422 | } else { |
423 | 423 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
424 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
424 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | $empty_value = $field->get_value_save_entry( |
440 | 440 | is_array( $field->get_entry_inputs() ) ? array() : '', |
441 | - $this->form, '', $this->entry['id'], $this->entry |
|
441 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
442 | 442 | ); |
443 | 443 | |
444 | 444 | $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | } |
509 | 509 | |
510 | 510 | /** No file is being uploaded. */ |
511 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
511 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
512 | 512 | /** So return the original upload */ |
513 | 513 | return $entry[ $input_id ]; |
514 | 514 | } |
@@ -526,11 +526,11 @@ discard block |
||
526 | 526 | * @return mixed |
527 | 527 | */ |
528 | 528 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
529 | - if( ! $this->is_edit_entry() ) { |
|
529 | + if ( ! $this->is_edit_entry() ) { |
|
530 | 530 | return $plupload_init; |
531 | 531 | } |
532 | 532 | |
533 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
533 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
534 | 534 | |
535 | 535 | return $plupload_init; |
536 | 536 | } |
@@ -545,27 +545,27 @@ discard block |
||
545 | 545 | $form = $this->filter_conditional_logic( $this->form ); |
546 | 546 | |
547 | 547 | /** @var GF_Field $field */ |
548 | - foreach( $form['fields'] as $k => &$field ) { |
|
548 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
552 | 552 | * @since 1.16.3 |
553 | 553 | * @var GF_Field $field |
554 | 554 | */ |
555 | - if( $field->has_calculation() ) { |
|
556 | - unset( $form['fields'][ $k ] ); |
|
555 | + if ( $field->has_calculation() ) { |
|
556 | + unset( $form[ 'fields' ][ $k ] ); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | $field->adminOnly = false; |
560 | 560 | |
561 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
562 | - foreach( $field->inputs as $key => $input ) { |
|
563 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
561 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
562 | + foreach ( $field->inputs as $key => $input ) { |
|
563 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
568 | - $form['fields'] = array_values( $form['fields'] ); |
|
568 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
569 | 569 | |
570 | 570 | return $form; |
571 | 571 | } |
@@ -577,14 +577,14 @@ discard block |
||
577 | 577 | $update = false; |
578 | 578 | |
579 | 579 | // get the most up to date entry values |
580 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
580 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
581 | 581 | |
582 | 582 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
583 | 583 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
584 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
584 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
585 | 585 | } else { |
586 | 586 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
587 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
587 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
@@ -596,24 +596,24 @@ discard block |
||
596 | 596 | $inputs = $field->get_entry_inputs(); |
597 | 597 | if ( is_array( $inputs ) ) { |
598 | 598 | foreach ( $inputs as $input ) { |
599 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
599 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
600 | 600 | |
601 | 601 | if ( 'product' === $field->type ) { |
602 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
602 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
603 | 603 | |
604 | 604 | // Only allow quantity to be set if it's allowed to be edited |
605 | 605 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
606 | 606 | } else { // otherwise set to what it previously was |
607 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
607 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
608 | 608 | } |
609 | 609 | } else { |
610 | 610 | // Set to what it previously was if it's not editable |
611 | 611 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
612 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
612 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
616 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
616 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
617 | 617 | } |
618 | 618 | } else { |
619 | 619 | // Set to what it previously was if it's not editable |
@@ -653,19 +653,19 @@ discard block |
||
653 | 653 | |
654 | 654 | $input_name = 'input_' . $field_id; |
655 | 655 | |
656 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
656 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
657 | 657 | |
658 | 658 | // We have a new image |
659 | 659 | |
660 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
660 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
661 | 661 | |
662 | 662 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
663 | 663 | $ary = stripslashes_deep( $ary ); |
664 | 664 | $img_url = \GV\Utils::get( $ary, 0 ); |
665 | 665 | |
666 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
667 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
668 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
666 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
667 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
668 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
669 | 669 | |
670 | 670 | $image_meta = array( |
671 | 671 | 'post_excerpt' => $img_caption, |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
676 | 676 | if ( ! empty( $img_title ) ) { |
677 | - $image_meta['post_title'] = $img_title; |
|
677 | + $image_meta[ 'post_title' ] = $img_title; |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
@@ -732,15 +732,15 @@ discard block |
||
732 | 732 | */ |
733 | 733 | private function maybe_update_post_fields( $form ) { |
734 | 734 | |
735 | - if( empty( $this->entry['post_id'] ) ) { |
|
735 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
736 | 736 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
737 | 737 | return; |
738 | 738 | } |
739 | 739 | |
740 | - $post_id = $this->entry['post_id']; |
|
740 | + $post_id = $this->entry[ 'post_id' ]; |
|
741 | 741 | |
742 | 742 | // Security check |
743 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
743 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
744 | 744 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
745 | 745 | return; |
746 | 746 | } |
@@ -753,25 +753,25 @@ discard block |
||
753 | 753 | |
754 | 754 | $field = RGFormsModel::get_field( $form, $field_id ); |
755 | 755 | |
756 | - if( ! $field ) { |
|
756 | + if ( ! $field ) { |
|
757 | 757 | continue; |
758 | 758 | } |
759 | 759 | |
760 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
760 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
761 | 761 | |
762 | 762 | // Get the value of the field, including $_POSTed value |
763 | 763 | $value = RGFormsModel::get_field_value( $field ); |
764 | 764 | |
765 | 765 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
766 | 766 | $entry_tmp = $this->entry; |
767 | - $entry_tmp["{$field_id}"] = $value; |
|
767 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
768 | 768 | |
769 | - switch( $field->type ) { |
|
769 | + switch ( $field->type ) { |
|
770 | 770 | |
771 | 771 | case 'post_title': |
772 | 772 | $post_title = $value; |
773 | 773 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
774 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
774 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
775 | 775 | } |
776 | 776 | $updated_post->post_title = $post_title; |
777 | 777 | $updated_post->post_name = $post_title; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | case 'post_content': |
782 | 782 | $post_content = $value; |
783 | 783 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
784 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
784 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
785 | 785 | } |
786 | 786 | $updated_post->post_content = $post_content; |
787 | 787 | unset( $post_content ); |
@@ -799,11 +799,11 @@ discard block |
||
799 | 799 | $value = $value[ $field_id ]; |
800 | 800 | } |
801 | 801 | |
802 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
802 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
803 | 803 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
804 | 804 | } |
805 | 805 | |
806 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
806 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
807 | 807 | |
808 | 808 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
809 | 809 | break; |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | } |
816 | 816 | |
817 | 817 | // update entry after |
818 | - $this->entry["{$field_id}"] = $value; |
|
818 | + $this->entry[ "{$field_id}" ] = $value; |
|
819 | 819 | |
820 | 820 | $update_entry = true; |
821 | 821 | |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | |
825 | 825 | } |
826 | 826 | |
827 | - if( $update_entry ) { |
|
827 | + if ( $update_entry ) { |
|
828 | 828 | |
829 | 829 | $return_entry = GFAPI::update_entry( $this->entry ); |
830 | 830 | |
831 | - if( is_wp_error( $return_entry ) ) { |
|
831 | + if ( is_wp_error( $return_entry ) ) { |
|
832 | 832 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
833 | 833 | } else { |
834 | 834 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | |
839 | 839 | $return_post = wp_update_post( $updated_post, true ); |
840 | 840 | |
841 | - if( is_wp_error( $return_post ) ) { |
|
841 | + if ( is_wp_error( $return_post ) ) { |
|
842 | 842 | $return_post->add_data( $updated_post, '$updated_post' ); |
843 | 843 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
844 | 844 | } else { |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
873 | 873 | |
874 | 874 | // replace conditional shortcodes |
875 | - if( $do_shortcode ) { |
|
875 | + if ( $do_shortcode ) { |
|
876 | 876 | $output = do_shortcode( $output ); |
877 | 877 | } |
878 | 878 | |
@@ -891,19 +891,19 @@ discard block |
||
891 | 891 | */ |
892 | 892 | private function after_update() { |
893 | 893 | |
894 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
895 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
894 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
895 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
896 | 896 | |
897 | 897 | // Re-define the entry now that we've updated it. |
898 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
898 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
899 | 899 | |
900 | 900 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
901 | 901 | |
902 | 902 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
903 | 903 | // We need to clear the cache because Gravity Forms caches the field values, which |
904 | 904 | // we have just updated. |
905 | - foreach ($this->form['fields'] as $key => $field) { |
|
906 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
905 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
906 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
@@ -913,11 +913,11 @@ discard block |
||
913 | 913 | * @since develop |
914 | 914 | */ |
915 | 915 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
916 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
916 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
917 | 917 | if ( ! is_wp_error( $feeds ) ) { |
918 | 918 | $registered_feeds = array(); |
919 | 919 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
920 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
920 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
921 | 921 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
922 | 922 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
923 | 923 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | } |
926 | 926 | } |
927 | 927 | foreach ( $feeds as $feed ) { |
928 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
929 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
928 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
929 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
930 | 930 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
931 | 931 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
932 | 932 | $entry = $returned_entry; |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | |
957 | 957 | <div class="gv-edit-entry-wrapper"><?php |
958 | 958 | |
959 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
959 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
960 | 960 | |
961 | 961 | /** |
962 | 962 | * Fixes weird wpautop() issue |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | * @param string $edit_entry_title Modify the "Edit Entry" title |
973 | 973 | * @param GravityView_Edit_Entry_Render $this This object |
974 | 974 | */ |
975 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
975 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
976 | 976 | |
977 | 977 | echo esc_attr( $edit_entry_title ); |
978 | 978 | ?></span> |
@@ -1022,13 +1022,13 @@ discard block |
||
1022 | 1022 | |
1023 | 1023 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
1024 | 1024 | |
1025 | - if( ! $this->is_valid ){ |
|
1025 | + if ( ! $this->is_valid ) { |
|
1026 | 1026 | |
1027 | 1027 | // Keeping this compatible with Gravity Forms. |
1028 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
1029 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
1028 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
1029 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
1030 | 1030 | |
1031 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
1031 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
1032 | 1032 | |
1033 | 1033 | } else { |
1034 | 1034 | $view = \GV\View::by_id( $this->view_id ); |
@@ -1039,23 +1039,23 @@ discard block |
||
1039 | 1039 | |
1040 | 1040 | case '0': |
1041 | 1041 | $redirect_url = $back_link; |
1042 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1042 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
1043 | 1043 | break; |
1044 | 1044 | |
1045 | 1045 | case '1': |
1046 | 1046 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
1047 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1047 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1048 | 1048 | break; |
1049 | 1049 | |
1050 | 1050 | case '2': |
1051 | 1051 | $redirect_url = $edit_redirect_url; |
1052 | 1052 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
1053 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1053 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1054 | 1054 | break; |
1055 | 1055 | |
1056 | 1056 | case '': |
1057 | 1057 | default: |
1058 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1058 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
1059 | 1059 | break; |
1060 | 1060 | } |
1061 | 1061 | |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | * @param array $entry Gravity Forms entry array |
1072 | 1072 | * @param string $back_link URL to return to the original entry. @since 1.6 |
1073 | 1073 | */ |
1074 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
1074 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1075 | 1075 | |
1076 | 1076 | echo GVCommon::generate_notice( $message ); |
1077 | 1077 | } |
@@ -1095,21 +1095,21 @@ discard block |
||
1095 | 1095 | */ |
1096 | 1096 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1097 | 1097 | |
1098 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1099 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1098 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1099 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1100 | 1100 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1101 | 1101 | |
1102 | 1102 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1103 | 1103 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1104 | 1104 | |
1105 | 1105 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1106 | - unset( $_GET['page'] ); |
|
1106 | + unset( $_GET[ 'page' ] ); |
|
1107 | 1107 | |
1108 | 1108 | // TODO: Verify multiple-page forms |
1109 | 1109 | |
1110 | 1110 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1111 | 1111 | |
1112 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1112 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1113 | 1113 | |
1114 | 1114 | ob_get_clean(); |
1115 | 1115 | |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | * @return string |
1136 | 1136 | */ |
1137 | 1137 | public function render_form_buttons() { |
1138 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1138 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | |
@@ -1155,10 +1155,10 @@ discard block |
||
1155 | 1155 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1156 | 1156 | |
1157 | 1157 | // In case we have validated the form, use it to inject the validation results into the form render |
1158 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
1158 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
1159 | 1159 | $form = $this->form_after_validation; |
1160 | 1160 | } else { |
1161 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1161 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | $form = $this->filter_conditional_logic( $form ); |
@@ -1166,8 +1166,8 @@ discard block |
||
1166 | 1166 | $form = $this->prefill_conditional_logic( $form ); |
1167 | 1167 | |
1168 | 1168 | // for now we don't support Save and Continue feature. |
1169 | - if( ! self::$supports_save_and_continue ) { |
|
1170 | - unset( $form['save'] ); |
|
1169 | + if ( ! self::$supports_save_and_continue ) { |
|
1170 | + unset( $form[ 'save' ] ); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | $form = $this->unselect_default_values( $form ); |
@@ -1190,31 +1190,31 @@ discard block |
||
1190 | 1190 | */ |
1191 | 1191 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1192 | 1192 | |
1193 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1193 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1194 | 1194 | return $field_content; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | $message = null; |
1198 | 1198 | |
1199 | 1199 | // First, make sure they have the capability to edit the post. |
1200 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1200 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1201 | 1201 | |
1202 | 1202 | /** |
1203 | 1203 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1204 | 1204 | * @param string $message The existing "You don't have permission..." text |
1205 | 1205 | */ |
1206 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1206 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1207 | 1207 | |
1208 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1208 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1209 | 1209 | /** |
1210 | 1210 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1211 | 1211 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1212 | 1212 | */ |
1213 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1213 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1214 | 1214 | } |
1215 | 1215 | |
1216 | - if( $message ) { |
|
1217 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1216 | + if ( $message ) { |
|
1217 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | return $field_content; |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | |
1239 | 1239 | // If the form has been submitted, then we don't need to pre-fill the values, |
1240 | 1240 | // Except for fileupload type and when a field input is overridden- run always!! |
1241 | - if( |
|
1242 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1241 | + if ( |
|
1242 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1243 | 1243 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1244 | 1244 | && ! GFCommon::is_product_field( $field->type ) |
1245 | 1245 | || ! empty( $field_content ) |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | $return = null; |
1260 | 1260 | |
1261 | 1261 | /** @var GravityView_Field $gv_field */ |
1262 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1262 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1263 | 1263 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1264 | 1264 | } else { |
1265 | 1265 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | // If there was output, it's an error |
1269 | 1269 | $warnings = ob_get_clean(); |
1270 | 1270 | |
1271 | - if( !empty( $warnings ) ) { |
|
1271 | + if ( ! empty( $warnings ) ) { |
|
1272 | 1272 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1273 | 1273 | } |
1274 | 1274 | |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1294 | 1294 | |
1295 | 1295 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1296 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1296 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1297 | 1297 | |
1298 | 1298 | $field_value = array(); |
1299 | 1299 | |
@@ -1302,10 +1302,10 @@ discard block |
||
1302 | 1302 | |
1303 | 1303 | foreach ( (array)$field->inputs as $input ) { |
1304 | 1304 | |
1305 | - $input_id = strval( $input['id'] ); |
|
1305 | + $input_id = strval( $input[ 'id' ] ); |
|
1306 | 1306 | |
1307 | 1307 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1308 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1308 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1309 | 1309 | $allow_pre_populated = false; |
1310 | 1310 | } |
1311 | 1311 | |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | |
1314 | 1314 | $pre_value = $field->get_value_submission( array(), false ); |
1315 | 1315 | |
1316 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1316 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1317 | 1317 | |
1318 | 1318 | } else { |
1319 | 1319 | |
@@ -1324,13 +1324,13 @@ discard block |
||
1324 | 1324 | |
1325 | 1325 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1326 | 1326 | // or pre-populated value if not empty and set to override saved value |
1327 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1327 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1328 | 1328 | |
1329 | 1329 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1330 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1330 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1331 | 1331 | $categories = array(); |
1332 | 1332 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1333 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1333 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1334 | 1334 | } |
1335 | 1335 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1336 | 1336 | } |
@@ -1358,7 +1358,7 @@ discard block |
||
1358 | 1358 | * @param GF_Field $field Gravity Forms field object |
1359 | 1359 | * @param GravityView_Edit_Entry_Render $this Current object |
1360 | 1360 | */ |
1361 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1361 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1362 | 1362 | |
1363 | 1363 | return $field_value; |
1364 | 1364 | } |
@@ -1375,12 +1375,12 @@ discard block |
||
1375 | 1375 | */ |
1376 | 1376 | public function gform_pre_validation( $form ) { |
1377 | 1377 | |
1378 | - if( ! $this->verify_nonce() ) { |
|
1378 | + if ( ! $this->verify_nonce() ) { |
|
1379 | 1379 | return $form; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | // Fix PHP warning regarding undefined index. |
1383 | - foreach ( $form['fields'] as &$field) { |
|
1383 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1384 | 1384 | |
1385 | 1385 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1386 | 1386 | // expects certain field array items to be set. |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1389 | 1389 | } |
1390 | 1390 | |
1391 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1391 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1392 | 1392 | |
1393 | 1393 | /** |
1394 | 1394 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1402,26 +1402,26 @@ discard block |
||
1402 | 1402 | // Set the previous value |
1403 | 1403 | $entry = $this->get_entry(); |
1404 | 1404 | |
1405 | - $input_name = 'input_'.$field->id; |
|
1406 | - $form_id = $form['id']; |
|
1405 | + $input_name = 'input_' . $field->id; |
|
1406 | + $form_id = $form[ 'id' ]; |
|
1407 | 1407 | |
1408 | 1408 | $value = NULL; |
1409 | 1409 | |
1410 | 1410 | // Use the previous entry value as the default. |
1411 | - if( isset( $entry[ $field->id ] ) ) { |
|
1411 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1412 | 1412 | $value = $entry[ $field->id ]; |
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | // If this is a single upload file |
1416 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1417 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1418 | - $value = $file_path['url']; |
|
1416 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1417 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1418 | + $value = $file_path[ 'url' ]; |
|
1419 | 1419 | |
1420 | 1420 | } else { |
1421 | 1421 | |
1422 | 1422 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1423 | 1423 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1424 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1424 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1425 | 1425 | |
1426 | 1426 | } |
1427 | 1427 | |
@@ -1429,10 +1429,10 @@ discard block |
||
1429 | 1429 | |
1430 | 1430 | // If there are fresh uploads, process and merge them. |
1431 | 1431 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1432 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1432 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1433 | 1433 | $value = empty( $value ) ? '[]' : $value; |
1434 | 1434 | $value = stripslashes_deep( $value ); |
1435 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1435 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | } else { |
@@ -1450,8 +1450,8 @@ discard block |
||
1450 | 1450 | |
1451 | 1451 | case 'number': |
1452 | 1452 | // Fix "undefined index" issue at line 1286 in form_display.php |
1453 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1454 | - $_POST['input_'.$field->id ] = NULL; |
|
1453 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1454 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1455 | 1455 | } |
1456 | 1456 | break; |
1457 | 1457 | } |
@@ -1488,7 +1488,7 @@ discard block |
||
1488 | 1488 | * You can enter whatever you want! |
1489 | 1489 | * We try validating, and customize the results using `self::custom_validation()` |
1490 | 1490 | */ |
1491 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1491 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1492 | 1492 | |
1493 | 1493 | // Needed by the validate funtion |
1494 | 1494 | $failed_validation_page = NULL; |
@@ -1496,14 +1496,14 @@ discard block |
||
1496 | 1496 | |
1497 | 1497 | // Prevent entry limit from running when editing an entry, also |
1498 | 1498 | // prevent form scheduling from preventing editing |
1499 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1499 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1500 | 1500 | |
1501 | 1501 | // Hide fields depending on Edit Entry settings |
1502 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1502 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1503 | 1503 | |
1504 | 1504 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1505 | 1505 | |
1506 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1506 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1507 | 1507 | } |
1508 | 1508 | |
1509 | 1509 | |
@@ -1526,7 +1526,7 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | $gv_valid = true; |
1528 | 1528 | |
1529 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1529 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1530 | 1530 | |
1531 | 1531 | $value = RGFormsModel::get_field_value( $field ); |
1532 | 1532 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1539,22 +1539,22 @@ discard block |
||
1539 | 1539 | case 'post_image': |
1540 | 1540 | |
1541 | 1541 | // in case nothing is uploaded but there are already files saved |
1542 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1542 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1543 | 1543 | $field->failed_validation = false; |
1544 | 1544 | unset( $field->validation_message ); |
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1548 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1548 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1549 | 1549 | |
1550 | 1550 | $input_name = 'input_' . $field->id; |
1551 | 1551 | //uploaded |
1552 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1552 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1553 | 1553 | |
1554 | 1554 | //existent |
1555 | 1555 | $entry = $this->get_entry(); |
1556 | 1556 | $value = NULL; |
1557 | - if( isset( $entry[ $field->id ] ) ) { |
|
1557 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1558 | 1558 | $value = json_decode( $entry[ $field->id ], true ); |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1562,13 +1562,13 @@ discard block |
||
1562 | 1562 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
1563 | 1563 | ( is_array( $value ) ? count( $value ) : 0 ); |
1564 | 1564 | |
1565 | - if( $count_files > $field->maxFiles ) { |
|
1565 | + if ( $count_files > $field->maxFiles ) { |
|
1566 | 1566 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1567 | 1567 | $field->failed_validation = 1; |
1568 | 1568 | $gv_valid = false; |
1569 | 1569 | |
1570 | 1570 | // in case of error make sure the newest upload files are removed from the upload input |
1571 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1571 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | // This field has failed validation. |
1582 | - if( !empty( $field->failed_validation ) ) { |
|
1582 | + if ( ! empty( $field->failed_validation ) ) { |
|
1583 | 1583 | |
1584 | 1584 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1585 | 1585 | |
@@ -1597,19 +1597,19 @@ discard block |
||
1597 | 1597 | } |
1598 | 1598 | |
1599 | 1599 | // You can't continue inside a switch, so we do it after. |
1600 | - if( empty( $field->failed_validation ) ) { |
|
1600 | + if ( empty( $field->failed_validation ) ) { |
|
1601 | 1601 | continue; |
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | // checks if the No Duplicates option is not validating entry against itself, since |
1605 | 1605 | // we're editing a stored entry, it would also assume it's a duplicate. |
1606 | - if( !empty( $field->noDuplicates ) ) { |
|
1606 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1607 | 1607 | |
1608 | 1608 | $entry = $this->get_entry(); |
1609 | 1609 | |
1610 | 1610 | // If the value of the entry is the same as the stored value |
1611 | 1611 | // Then we can assume it's not a duplicate, it's the same. |
1612 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1612 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1613 | 1613 | //if value submitted was not changed, then don't validate |
1614 | 1614 | $field->failed_validation = false; |
1615 | 1615 | |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1625 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1625 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1626 | 1626 | unset( $field->validation_message ); |
1627 | 1627 | $field->validation_message = false; |
1628 | 1628 | continue; |
@@ -1634,12 +1634,12 @@ discard block |
||
1634 | 1634 | |
1635 | 1635 | } |
1636 | 1636 | |
1637 | - $validation_results['is_valid'] = $gv_valid; |
|
1637 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1638 | 1638 | |
1639 | 1639 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1640 | 1640 | |
1641 | 1641 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1642 | - $this->form_after_validation = $validation_results['form']; |
|
1642 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1643 | 1643 | |
1644 | 1644 | return $validation_results; |
1645 | 1645 | } |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | */ |
1653 | 1653 | public function get_entry() { |
1654 | 1654 | |
1655 | - if( empty( $this->entry ) ) { |
|
1655 | + if ( empty( $this->entry ) ) { |
|
1656 | 1656 | // Get the database value of the entry that's being edited |
1657 | 1657 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1658 | 1658 | } |
@@ -1684,10 +1684,10 @@ discard block |
||
1684 | 1684 | } |
1685 | 1685 | |
1686 | 1686 | // If edit tab not yet configured, show all fields |
1687 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1687 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1688 | 1688 | |
1689 | 1689 | // Hide fields depending on admin settings |
1690 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1690 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1691 | 1691 | |
1692 | 1692 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1693 | 1693 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | */ |
1721 | 1721 | private function filter_fields( $fields, $configured_fields ) { |
1722 | 1722 | |
1723 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1723 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1724 | 1724 | return $fields; |
1725 | 1725 | } |
1726 | 1726 | |
@@ -1733,12 +1733,12 @@ discard block |
||
1733 | 1733 | |
1734 | 1734 | // Remove the fields that have calculation properties and keep them to be used later |
1735 | 1735 | // @since 1.16.2 |
1736 | - if( $field->has_calculation() ) { |
|
1737 | - $this->fields_with_calculation[] = $field; |
|
1736 | + if ( $field->has_calculation() ) { |
|
1737 | + $this->fields_with_calculation[ ] = $field; |
|
1738 | 1738 | // don't remove the calculation fields on form render. |
1739 | 1739 | } |
1740 | 1740 | |
1741 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1741 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1742 | 1742 | unset( $fields[ $key ] ); |
1743 | 1743 | } |
1744 | 1744 | } |
@@ -1756,7 +1756,7 @@ discard block |
||
1756 | 1756 | continue; // Same |
1757 | 1757 | } |
1758 | 1758 | |
1759 | - $out_fields[] = $field; |
|
1759 | + $out_fields[ ] = $field; |
|
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | return array_values( $out_fields ); |
@@ -1767,8 +1767,8 @@ discard block |
||
1767 | 1767 | |
1768 | 1768 | /** @var GF_Field $field */ |
1769 | 1769 | foreach ( $fields as $field ) { |
1770 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1771 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1770 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1771 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1772 | 1772 | break; |
1773 | 1773 | } |
1774 | 1774 | |
@@ -1791,14 +1791,14 @@ discard block |
||
1791 | 1791 | |
1792 | 1792 | $return_field = $field; |
1793 | 1793 | |
1794 | - if( empty( $field_setting['show_label'] ) ) { |
|
1794 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1795 | 1795 | $return_field->label = ''; |
1796 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1797 | - $return_field->label = $field_setting['custom_label']; |
|
1796 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1797 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1798 | 1798 | } |
1799 | 1799 | |
1800 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1801 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1800 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1801 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | /** |
@@ -1836,16 +1836,16 @@ discard block |
||
1836 | 1836 | */ |
1837 | 1837 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1838 | 1838 | |
1839 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1840 | - foreach( $fields as $k => $field ) { |
|
1841 | - if( $field->adminOnly ) { |
|
1839 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1840 | + foreach ( $fields as $k => $field ) { |
|
1841 | + if ( $field->adminOnly ) { |
|
1842 | 1842 | unset( $fields[ $k ] ); |
1843 | 1843 | } |
1844 | 1844 | } |
1845 | 1845 | return array_values( $fields ); |
1846 | 1846 | } |
1847 | 1847 | |
1848 | - foreach( $fields as &$field ) { |
|
1848 | + foreach ( $fields as &$field ) { |
|
1849 | 1849 | $field->adminOnly = false; |
1850 | 1850 | } |
1851 | 1851 | |
@@ -1866,7 +1866,7 @@ discard block |
||
1866 | 1866 | */ |
1867 | 1867 | private function unselect_default_values( $form ) { |
1868 | 1868 | |
1869 | - foreach ( $form['fields'] as &$field ) { |
|
1869 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1870 | 1870 | |
1871 | 1871 | if ( empty( $field->choices ) ) { |
1872 | 1872 | continue; |
@@ -1874,7 +1874,7 @@ discard block |
||
1874 | 1874 | |
1875 | 1875 | foreach ( $field->choices as &$choice ) { |
1876 | 1876 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1877 | - $choice['isSelected'] = false; |
|
1877 | + $choice[ 'isSelected' ] = false; |
|
1878 | 1878 | } |
1879 | 1879 | } |
1880 | 1880 | } |
@@ -1899,22 +1899,22 @@ discard block |
||
1899 | 1899 | */ |
1900 | 1900 | function prefill_conditional_logic( $form ) { |
1901 | 1901 | |
1902 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1902 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1903 | 1903 | return $form; |
1904 | 1904 | } |
1905 | 1905 | |
1906 | 1906 | // Have Conditional Logic pre-fill fields as if the data were default values |
1907 | 1907 | /** @var GF_Field $field */ |
1908 | - foreach ( $form['fields'] as &$field ) { |
|
1908 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1909 | 1909 | |
1910 | - if( 'checkbox' === $field->type ) { |
|
1910 | + if ( 'checkbox' === $field->type ) { |
|
1911 | 1911 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1912 | - $input_id = $input['id']; |
|
1912 | + $input_id = $input[ 'id' ]; |
|
1913 | 1913 | $choice = $field->choices[ $key ]; |
1914 | 1914 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1915 | 1915 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1916 | - if( $match ) { |
|
1917 | - $field->choices[ $key ]['isSelected'] = true; |
|
1916 | + if ( $match ) { |
|
1917 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1918 | 1918 | } |
1919 | 1919 | } |
1920 | 1920 | } else { |
@@ -1922,15 +1922,15 @@ discard block |
||
1922 | 1922 | // We need to run through each field to set the default values |
1923 | 1923 | foreach ( $this->entry as $field_id => $field_value ) { |
1924 | 1924 | |
1925 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1925 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1926 | 1926 | |
1927 | - if( 'list' === $field->type ) { |
|
1927 | + if ( 'list' === $field->type ) { |
|
1928 | 1928 | $list_rows = maybe_unserialize( $field_value ); |
1929 | 1929 | |
1930 | 1930 | $list_field_value = array(); |
1931 | - foreach ( (array) $list_rows as $row ) { |
|
1932 | - foreach ( (array) $row as $column ) { |
|
1933 | - $list_field_value[] = $column; |
|
1931 | + foreach ( (array)$list_rows as $row ) { |
|
1932 | + foreach ( (array)$row as $column ) { |
|
1933 | + $list_field_value[ ] = $column; |
|
1934 | 1934 | } |
1935 | 1935 | } |
1936 | 1936 | |
@@ -1963,32 +1963,32 @@ discard block |
||
1963 | 1963 | * @see https://github.com/gravityview/GravityView/issues/840 |
1964 | 1964 | * @since develop |
1965 | 1965 | */ |
1966 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
1966 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
1967 | 1967 | $editable_ids = array(); |
1968 | - foreach ( $form['fields'] as $field ) { |
|
1969 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
1968 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1969 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
1970 | 1970 | } |
1971 | 1971 | $remove_conditions_rule = array(); |
1972 | - foreach ( $the_form['fields'] as $field ) { |
|
1973 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
1974 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
1975 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
1972 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
1973 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
1974 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
1975 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
1976 | 1976 | /** |
1977 | 1977 | * This conditional field is not editable in this View. |
1978 | 1978 | * We need to remove the rule, but only if it matches. |
1979 | 1979 | */ |
1980 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
1980 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
1981 | 1981 | $value = $_field->get_value_export( $this->entry ); |
1982 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
1983 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
1982 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
1983 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
1984 | 1984 | } else { |
1985 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
1985 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
1986 | 1986 | } |
1987 | 1987 | |
1988 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
1988 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
1989 | 1989 | |
1990 | 1990 | if ( $match ) { |
1991 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
1991 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
1992 | 1992 | } |
1993 | 1993 | } |
1994 | 1994 | } |
@@ -1996,21 +1996,21 @@ discard block |
||
1996 | 1996 | } |
1997 | 1997 | |
1998 | 1998 | if ( $remove_conditions_rule ) { |
1999 | - foreach ( $form['fields'] as &$field ) { |
|
1999 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2000 | 2000 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2001 | 2001 | |
2002 | 2002 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
2003 | 2003 | |
2004 | - if ( $field['id'] == $rule_field_id ) { |
|
2005 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
2006 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
2004 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
2005 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
2006 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
2007 | 2007 | } |
2008 | 2008 | } |
2009 | 2009 | } |
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | /** Normalize the indices... */ |
2013 | - $form['fields'] = array_values( $form['fields'] ); |
|
2013 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
2014 | 2014 | |
2015 | 2015 | /** |
2016 | 2016 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2020,16 +2020,16 @@ discard block |
||
2020 | 2020 | */ |
2021 | 2021 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
2022 | 2022 | |
2023 | - if( $use_conditional_logic ) { |
|
2023 | + if ( $use_conditional_logic ) { |
|
2024 | 2024 | return $form; |
2025 | 2025 | } |
2026 | 2026 | |
2027 | - foreach( $form['fields'] as &$field ) { |
|
2027 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2028 | 2028 | /* @var GF_Field $field */ |
2029 | 2029 | $field->conditionalLogic = null; |
2030 | 2030 | } |
2031 | 2031 | |
2032 | - unset( $form['button']['conditionalLogic'] ); |
|
2032 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
2033 | 2033 | |
2034 | 2034 | return $form; |
2035 | 2035 | |
@@ -2046,7 +2046,7 @@ discard block |
||
2046 | 2046 | */ |
2047 | 2047 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
2048 | 2048 | |
2049 | - if( ! $this->is_edit_entry() ) { |
|
2049 | + if ( ! $this->is_edit_entry() ) { |
|
2050 | 2050 | return $has_conditional_logic; |
2051 | 2051 | } |
2052 | 2052 | |
@@ -2078,44 +2078,44 @@ discard block |
||
2078 | 2078 | * 2. There are two entries embedded using oEmbed |
2079 | 2079 | * 3. One of the entries has just been saved |
2080 | 2080 | */ |
2081 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
2081 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
2082 | 2082 | |
2083 | 2083 | $error = true; |
2084 | 2084 | |
2085 | 2085 | } |
2086 | 2086 | |
2087 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
2087 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
2088 | 2088 | |
2089 | 2089 | $error = true; |
2090 | 2090 | |
2091 | - } elseif( ! $this->verify_nonce() ) { |
|
2091 | + } elseif ( ! $this->verify_nonce() ) { |
|
2092 | 2092 | |
2093 | 2093 | /** |
2094 | 2094 | * If the Entry is embedded, there may be two entries on the same page. |
2095 | 2095 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
2096 | 2096 | */ |
2097 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2097 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2098 | 2098 | $error = true; |
2099 | 2099 | } else { |
2100 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
2100 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
2101 | 2101 | } |
2102 | 2102 | |
2103 | 2103 | } |
2104 | 2104 | |
2105 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2106 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
2105 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2106 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
2107 | 2107 | } |
2108 | 2108 | |
2109 | - if( $this->entry['status'] === 'trash' ) { |
|
2110 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2109 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
2110 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2111 | 2111 | } |
2112 | 2112 | |
2113 | 2113 | // No errors; everything's fine here! |
2114 | - if( empty( $error ) ) { |
|
2114 | + if ( empty( $error ) ) { |
|
2115 | 2115 | return true; |
2116 | 2116 | } |
2117 | 2117 | |
2118 | - if( $echo && $error !== true ) { |
|
2118 | + if ( $echo && $error !== true ) { |
|
2119 | 2119 | |
2120 | 2120 | $error = esc_html( $error ); |
2121 | 2121 | |
@@ -2123,10 +2123,10 @@ discard block |
||
2123 | 2123 | * @since 1.9 |
2124 | 2124 | */ |
2125 | 2125 | if ( ! empty( $this->entry ) ) { |
2126 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2126 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2127 | 2127 | } |
2128 | 2128 | |
2129 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
2129 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
2130 | 2130 | } |
2131 | 2131 | |
2132 | 2132 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2146,17 +2146,17 @@ discard block |
||
2146 | 2146 | |
2147 | 2147 | $error = NULL; |
2148 | 2148 | |
2149 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2150 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2149 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2150 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2151 | 2151 | } |
2152 | 2152 | |
2153 | 2153 | // No errors; everything's fine here! |
2154 | - if( empty( $error ) ) { |
|
2154 | + if ( empty( $error ) ) { |
|
2155 | 2155 | return true; |
2156 | 2156 | } |
2157 | 2157 | |
2158 | - if( $echo ) { |
|
2159 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2158 | + if ( $echo ) { |
|
2159 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2160 | 2160 | } |
2161 | 2161 | |
2162 | 2162 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2177,14 +2177,14 @@ discard block |
||
2177 | 2177 | private function check_user_cap_edit_field( $field ) { |
2178 | 2178 | |
2179 | 2179 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2180 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2180 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2181 | 2181 | return true; |
2182 | 2182 | } |
2183 | 2183 | |
2184 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2184 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2185 | 2185 | |
2186 | - if( $field_cap ) { |
|
2187 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2186 | + if ( $field_cap ) { |
|
2187 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | 2190 | return false; |
@@ -2198,17 +2198,17 @@ discard block |
||
2198 | 2198 | public function verify_nonce() { |
2199 | 2199 | |
2200 | 2200 | // Verify form submitted for editing single |
2201 | - if( $this->is_edit_entry_submission() ) { |
|
2201 | + if ( $this->is_edit_entry_submission() ) { |
|
2202 | 2202 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2203 | 2203 | } |
2204 | 2204 | |
2205 | 2205 | // Verify |
2206 | - else if( ! $this->is_edit_entry() ) { |
|
2206 | + else if ( ! $this->is_edit_entry() ) { |
|
2207 | 2207 | $valid = false; |
2208 | 2208 | } |
2209 | 2209 | |
2210 | 2210 | else { |
2211 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2211 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2212 | 2212 | } |
2213 | 2213 | |
2214 | 2214 | /** |