@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function process_save( $gv_data ) { |
288 | 288 | |
289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure the entry, view, and form IDs are all correct |
294 | 294 | $valid = $this->verify_nonce(); |
295 | 295 | |
296 | - if ( !$valid ) { |
|
296 | + if ( ! $valid ) { |
|
297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
303 | 303 | return; |
304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $this->validate(); |
311 | 311 | |
312 | - if( $this->is_valid ) { |
|
312 | + if ( $this->is_valid ) { |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
323 | 323 | */ |
324 | - unset( $_GET['page'] ); |
|
324 | + unset( $_GET[ 'page' ] ); |
|
325 | 325 | |
326 | - $date_created = $this->entry['date_created']; |
|
326 | + $date_created = $this->entry[ 'date_created' ]; |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
330 | 330 | * @since 1.17.2 |
331 | 331 | */ |
332 | - unset( $this->entry['date_created'] ); |
|
332 | + unset( $this->entry[ 'date_created' ] ); |
|
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | 336 | // Delete the values for hidden inputs |
337 | 337 | $this->unset_hidden_field_values(); |
338 | 338 | |
339 | - $this->entry['date_created'] = $date_created; |
|
339 | + $this->entry[ 'date_created' ] = $date_created; |
|
340 | 340 | |
341 | 341 | // Process calculation fields |
342 | 342 | $this->update_calculation_fields(); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param GravityView_Edit_Entry_Render $this This object |
359 | 359 | * @param GravityView_View_Data $gv_data The View data |
360 | 360 | */ |
361 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
361 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
362 | 362 | |
363 | 363 | } else { |
364 | 364 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -386,16 +386,16 @@ discard block |
||
386 | 386 | */ |
387 | 387 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
388 | 388 | |
389 | - if( ! $unset_hidden_field_values ) { |
|
389 | + if ( ! $unset_hidden_field_values ) { |
|
390 | 390 | return; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
394 | 394 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
395 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
395 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
396 | 396 | } else { |
397 | 397 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** No file is being uploaded. */ |
479 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
479 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
480 | 480 | /** So return the original upload */ |
481 | 481 | return $entry[ $input_id ]; |
482 | 482 | } |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | * @return mixed |
495 | 495 | */ |
496 | 496 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
497 | - if( ! $this->is_edit_entry() ) { |
|
497 | + if ( ! $this->is_edit_entry() ) { |
|
498 | 498 | return $plupload_init; |
499 | 499 | } |
500 | 500 | |
501 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
501 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
502 | 502 | |
503 | 503 | return $plupload_init; |
504 | 504 | } |
@@ -513,27 +513,27 @@ discard block |
||
513 | 513 | $form = $this->form; |
514 | 514 | |
515 | 515 | /** @var GF_Field $field */ |
516 | - foreach( $form['fields'] as $k => &$field ) { |
|
516 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
517 | 517 | |
518 | 518 | /** |
519 | 519 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
520 | 520 | * @since 1.16.3 |
521 | 521 | * @var GF_Field $field |
522 | 522 | */ |
523 | - if( $field->has_calculation() ) { |
|
524 | - unset( $form['fields'][ $k ] ); |
|
523 | + if ( $field->has_calculation() ) { |
|
524 | + unset( $form[ 'fields' ][ $k ] ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $field->adminOnly = false; |
528 | 528 | |
529 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
530 | - foreach( $field->inputs as $key => $input ) { |
|
531 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
529 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
530 | + foreach ( $field->inputs as $key => $input ) { |
|
531 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | - $form['fields'] = array_values( $form['fields'] ); |
|
536 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
537 | 537 | |
538 | 538 | return $form; |
539 | 539 | } |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | $update = false; |
546 | 546 | |
547 | 547 | // get the most up to date entry values |
548 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
548 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
549 | 549 | |
550 | 550 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
551 | 551 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
552 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
552 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
553 | 553 | } else { |
554 | 554 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
555 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
555 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | if ( ! empty( $this->fields_with_calculation ) ) { |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $inputs = $field->get_entry_inputs(); |
562 | 562 | if ( is_array( $inputs ) ) { |
563 | 563 | foreach ( $inputs as $input ) { |
564 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
564 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
565 | 565 | } |
566 | 566 | } else { |
567 | 567 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
@@ -597,19 +597,19 @@ discard block |
||
597 | 597 | |
598 | 598 | $input_name = 'input_' . $field_id; |
599 | 599 | |
600 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
600 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
601 | 601 | |
602 | 602 | // We have a new image |
603 | 603 | |
604 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
604 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
605 | 605 | |
606 | 606 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
607 | 607 | $ary = stripslashes_deep( $ary ); |
608 | 608 | $img_url = \GV\Utils::get( $ary, 0 ); |
609 | 609 | |
610 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
611 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
612 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
610 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
611 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
612 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
613 | 613 | |
614 | 614 | $image_meta = array( |
615 | 615 | 'post_excerpt' => $img_caption, |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
620 | 620 | if ( ! empty( $img_title ) ) { |
621 | - $image_meta['post_title'] = $img_title; |
|
621 | + $image_meta[ 'post_title' ] = $img_title; |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -676,15 +676,15 @@ discard block |
||
676 | 676 | */ |
677 | 677 | private function maybe_update_post_fields( $form ) { |
678 | 678 | |
679 | - if( empty( $this->entry['post_id'] ) ) { |
|
679 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
680 | 680 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
681 | 681 | return; |
682 | 682 | } |
683 | 683 | |
684 | - $post_id = $this->entry['post_id']; |
|
684 | + $post_id = $this->entry[ 'post_id' ]; |
|
685 | 685 | |
686 | 686 | // Security check |
687 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
687 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
688 | 688 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
689 | 689 | return; |
690 | 690 | } |
@@ -697,25 +697,25 @@ discard block |
||
697 | 697 | |
698 | 698 | $field = RGFormsModel::get_field( $form, $field_id ); |
699 | 699 | |
700 | - if( ! $field ) { |
|
700 | + if ( ! $field ) { |
|
701 | 701 | continue; |
702 | 702 | } |
703 | 703 | |
704 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
704 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
705 | 705 | |
706 | 706 | // Get the value of the field, including $_POSTed value |
707 | 707 | $value = RGFormsModel::get_field_value( $field ); |
708 | 708 | |
709 | 709 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
710 | 710 | $entry_tmp = $this->entry; |
711 | - $entry_tmp["{$field_id}"] = $value; |
|
711 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
712 | 712 | |
713 | - switch( $field->type ) { |
|
713 | + switch ( $field->type ) { |
|
714 | 714 | |
715 | 715 | case 'post_title': |
716 | 716 | $post_title = $value; |
717 | 717 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
718 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
718 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
719 | 719 | } |
720 | 720 | $updated_post->post_title = $post_title; |
721 | 721 | $updated_post->post_name = $post_title; |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | case 'post_content': |
726 | 726 | $post_content = $value; |
727 | 727 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
728 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
728 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
729 | 729 | } |
730 | 730 | $updated_post->post_content = $post_content; |
731 | 731 | unset( $post_content ); |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | $value = $value[ $field_id ]; |
744 | 744 | } |
745 | 745 | |
746 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
746 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
747 | 747 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
748 | 748 | } |
749 | 749 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | } |
762 | 762 | |
763 | 763 | // update entry after |
764 | - $this->entry["{$field_id}"] = $value; |
|
764 | + $this->entry[ "{$field_id}" ] = $value; |
|
765 | 765 | |
766 | 766 | $update_entry = true; |
767 | 767 | |
@@ -770,11 +770,11 @@ discard block |
||
770 | 770 | |
771 | 771 | } |
772 | 772 | |
773 | - if( $update_entry ) { |
|
773 | + if ( $update_entry ) { |
|
774 | 774 | |
775 | 775 | $return_entry = GFAPI::update_entry( $this->entry ); |
776 | 776 | |
777 | - if( is_wp_error( $return_entry ) ) { |
|
777 | + if ( is_wp_error( $return_entry ) ) { |
|
778 | 778 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
779 | 779 | } else { |
780 | 780 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | |
785 | 785 | $return_post = wp_update_post( $updated_post, true ); |
786 | 786 | |
787 | - if( is_wp_error( $return_post ) ) { |
|
787 | + if ( is_wp_error( $return_post ) ) { |
|
788 | 788 | $return_post->add_data( $updated_post, '$updated_post' ); |
789 | 789 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
790 | 790 | } else { |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | $input_type = RGFormsModel::get_input_type( $field ); |
807 | 807 | |
808 | 808 | // Only certain custom field types are supported |
809 | - switch( $input_type ) { |
|
809 | + switch ( $input_type ) { |
|
810 | 810 | case 'fileupload': |
811 | 811 | case 'list': |
812 | 812 | case 'multiselect': |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
844 | 844 | |
845 | 845 | // replace conditional shortcodes |
846 | - if( $do_shortcode ) { |
|
846 | + if ( $do_shortcode ) { |
|
847 | 847 | $output = do_shortcode( $output ); |
848 | 848 | } |
849 | 849 | |
@@ -862,19 +862,19 @@ discard block |
||
862 | 862 | */ |
863 | 863 | private function after_update() { |
864 | 864 | |
865 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
866 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
865 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
866 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
867 | 867 | |
868 | 868 | // Re-define the entry now that we've updated it. |
869 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
869 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
870 | 870 | |
871 | 871 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
872 | 872 | |
873 | 873 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
874 | 874 | // We need to clear the cache because Gravity Forms caches the field values, which |
875 | 875 | // we have just updated. |
876 | - foreach ($this->form['fields'] as $key => $field) { |
|
877 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
876 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
877 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | |
894 | 894 | <div class="gv-edit-entry-wrapper"><?php |
895 | 895 | |
896 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
896 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
897 | 897 | |
898 | 898 | /** |
899 | 899 | * Fixes weird wpautop() issue |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | * @param string $edit_entry_title Modify the "Edit Entry" title |
910 | 910 | * @param GravityView_Edit_Entry_Render $this This object |
911 | 911 | */ |
912 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
912 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
913 | 913 | |
914 | 914 | echo esc_attr( $edit_entry_title ); |
915 | 915 | ?></span> |
@@ -959,13 +959,13 @@ discard block |
||
959 | 959 | |
960 | 960 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
961 | 961 | |
962 | - if( ! $this->is_valid ){ |
|
962 | + if ( ! $this->is_valid ) { |
|
963 | 963 | |
964 | 964 | // Keeping this compatible with Gravity Forms. |
965 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
966 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
965 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
966 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
967 | 967 | |
968 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
968 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
969 | 969 | |
970 | 970 | } else { |
971 | 971 | $view = \GV\View::by_id( $this->view_id ); |
@@ -973,15 +973,15 @@ discard block |
||
973 | 973 | |
974 | 974 | if ( '0' === $edit_redirect ) { |
975 | 975 | $redirect_url = $back_link; |
976 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturning to Entry%s', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
976 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturning to Entry%s', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
977 | 977 | } else if ( '1' === $edit_redirect ) { |
978 | 978 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
979 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturning to %s%s', 'gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
979 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturning to %s%s', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
980 | 980 | } else if ( '' == $edit_redirect ) { |
981 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
981 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
982 | 982 | } else { |
983 | 983 | $redirect_url = $edit_redirect; |
984 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sRedirecting to %s%s', 'gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect ), '</a>' ); |
|
984 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sRedirecting to %s%s', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect ), '</a>' ); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | if ( isset( $redirect_url ) ) { |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | * @param array $entry Gravity Forms entry array |
997 | 997 | * @param string $back_link URL to return to the original entry. @since 1.6 |
998 | 998 | */ |
999 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
999 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1000 | 1000 | |
1001 | 1001 | echo GVCommon::generate_notice( $message ); |
1002 | 1002 | } |
@@ -1020,21 +1020,21 @@ discard block |
||
1020 | 1020 | */ |
1021 | 1021 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1022 | 1022 | |
1023 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1024 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1023 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1024 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1025 | 1025 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1026 | 1026 | |
1027 | 1027 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1028 | 1028 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1029 | 1029 | |
1030 | 1030 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1031 | - unset( $_GET['page'] ); |
|
1031 | + unset( $_GET[ 'page' ] ); |
|
1032 | 1032 | |
1033 | 1033 | // TODO: Verify multiple-page forms |
1034 | 1034 | |
1035 | 1035 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1036 | 1036 | |
1037 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1037 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1038 | 1038 | |
1039 | 1039 | ob_get_clean(); |
1040 | 1040 | |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | * @return string |
1061 | 1061 | */ |
1062 | 1062 | public function render_form_buttons() { |
1063 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1063 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | |
@@ -1080,10 +1080,10 @@ discard block |
||
1080 | 1080 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1081 | 1081 | |
1082 | 1082 | // In case we have validated the form, use it to inject the validation results into the form render |
1083 | - if( isset( $this->form_after_validation ) ) { |
|
1083 | + if ( isset( $this->form_after_validation ) ) { |
|
1084 | 1084 | $form = $this->form_after_validation; |
1085 | 1085 | } else { |
1086 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1086 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | $form = $this->filter_conditional_logic( $form ); |
@@ -1091,8 +1091,8 @@ discard block |
||
1091 | 1091 | $form = $this->prefill_conditional_logic( $form ); |
1092 | 1092 | |
1093 | 1093 | // for now we don't support Save and Continue feature. |
1094 | - if( ! self::$supports_save_and_continue ) { |
|
1095 | - unset( $form['save'] ); |
|
1094 | + if ( ! self::$supports_save_and_continue ) { |
|
1095 | + unset( $form[ 'save' ] ); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | $form = $this->unselect_default_values( $form ); |
@@ -1115,31 +1115,31 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1117 | 1117 | |
1118 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1118 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1119 | 1119 | return $field_content; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | $message = null; |
1123 | 1123 | |
1124 | 1124 | // First, make sure they have the capability to edit the post. |
1125 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1125 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1126 | 1126 | |
1127 | 1127 | /** |
1128 | 1128 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1129 | 1129 | * @param string $message The existing "You don't have permission..." text |
1130 | 1130 | */ |
1131 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1131 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1132 | 1132 | |
1133 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1133 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1134 | 1134 | /** |
1135 | 1135 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1136 | 1136 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1137 | 1137 | */ |
1138 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1138 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | - if( $message ) { |
|
1142 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1141 | + if ( $message ) { |
|
1142 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | return $field_content; |
@@ -1163,8 +1163,8 @@ discard block |
||
1163 | 1163 | |
1164 | 1164 | // If the form has been submitted, then we don't need to pre-fill the values, |
1165 | 1165 | // Except for fileupload type and when a field input is overridden- run always!! |
1166 | - if( |
|
1167 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1166 | + if ( |
|
1167 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1168 | 1168 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1169 | 1169 | && ! GFCommon::is_product_field( $field->type ) |
1170 | 1170 | || ! empty( $field_content ) |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | $return = null; |
1185 | 1185 | |
1186 | 1186 | /** @var GravityView_Field $gv_field */ |
1187 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1187 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1188 | 1188 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1189 | 1189 | } else { |
1190 | 1190 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | // If there was output, it's an error |
1194 | 1194 | $warnings = ob_get_clean(); |
1195 | 1195 | |
1196 | - if( !empty( $warnings ) ) { |
|
1196 | + if ( ! empty( $warnings ) ) { |
|
1197 | 1197 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1219 | 1219 | |
1220 | 1220 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1221 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1221 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1222 | 1222 | |
1223 | 1223 | $field_value = array(); |
1224 | 1224 | |
@@ -1227,10 +1227,10 @@ discard block |
||
1227 | 1227 | |
1228 | 1228 | foreach ( (array)$field->inputs as $input ) { |
1229 | 1229 | |
1230 | - $input_id = strval( $input['id'] ); |
|
1230 | + $input_id = strval( $input[ 'id' ] ); |
|
1231 | 1231 | |
1232 | 1232 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1233 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1233 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1234 | 1234 | $allow_pre_populated = false; |
1235 | 1235 | } |
1236 | 1236 | |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | |
1239 | 1239 | $pre_value = $field->get_value_submission( array(), false ); |
1240 | 1240 | |
1241 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1241 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1242 | 1242 | |
1243 | 1243 | } else { |
1244 | 1244 | |
@@ -1249,13 +1249,13 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1251 | 1251 | // or pre-populated value if not empty and set to override saved value |
1252 | - $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; |
|
1252 | + $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; |
|
1253 | 1253 | |
1254 | 1254 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1255 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1255 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1256 | 1256 | $categories = array(); |
1257 | 1257 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1258 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1258 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1259 | 1259 | } |
1260 | 1260 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1261 | 1261 | } |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | * @param GF_Field $field Gravity Forms field object |
1284 | 1284 | * @param GravityView_Edit_Entry_Render $this Current object |
1285 | 1285 | */ |
1286 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1286 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1287 | 1287 | |
1288 | 1288 | return $field_value; |
1289 | 1289 | } |
@@ -1300,12 +1300,12 @@ discard block |
||
1300 | 1300 | */ |
1301 | 1301 | public function gform_pre_validation( $form ) { |
1302 | 1302 | |
1303 | - if( ! $this->verify_nonce() ) { |
|
1303 | + if ( ! $this->verify_nonce() ) { |
|
1304 | 1304 | return $form; |
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | // Fix PHP warning regarding undefined index. |
1308 | - foreach ( $form['fields'] as &$field) { |
|
1308 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1309 | 1309 | |
1310 | 1310 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1311 | 1311 | // expects certain field array items to be set. |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1314 | 1314 | } |
1315 | 1315 | |
1316 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1316 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1317 | 1317 | |
1318 | 1318 | /** |
1319 | 1319 | * 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. |
@@ -1327,26 +1327,26 @@ discard block |
||
1327 | 1327 | // Set the previous value |
1328 | 1328 | $entry = $this->get_entry(); |
1329 | 1329 | |
1330 | - $input_name = 'input_'.$field->id; |
|
1331 | - $form_id = $form['id']; |
|
1330 | + $input_name = 'input_' . $field->id; |
|
1331 | + $form_id = $form[ 'id' ]; |
|
1332 | 1332 | |
1333 | 1333 | $value = NULL; |
1334 | 1334 | |
1335 | 1335 | // Use the previous entry value as the default. |
1336 | - if( isset( $entry[ $field->id ] ) ) { |
|
1336 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1337 | 1337 | $value = $entry[ $field->id ]; |
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | // If this is a single upload file |
1341 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1342 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1343 | - $value = $file_path['url']; |
|
1341 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1342 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1343 | + $value = $file_path[ 'url' ]; |
|
1344 | 1344 | |
1345 | 1345 | } else { |
1346 | 1346 | |
1347 | 1347 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1348 | 1348 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1349 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1349 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1350 | 1350 | |
1351 | 1351 | } |
1352 | 1352 | |
@@ -1354,10 +1354,10 @@ discard block |
||
1354 | 1354 | |
1355 | 1355 | // If there are fresh uploads, process and merge them. |
1356 | 1356 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1357 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1357 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1358 | 1358 | $value = empty( $value ) ? '[]' : $value; |
1359 | 1359 | $value = stripslashes_deep( $value ); |
1360 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1360 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | } else { |
@@ -1375,8 +1375,8 @@ discard block |
||
1375 | 1375 | |
1376 | 1376 | case 'number': |
1377 | 1377 | // Fix "undefined index" issue at line 1286 in form_display.php |
1378 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1379 | - $_POST['input_'.$field->id ] = NULL; |
|
1378 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1379 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1380 | 1380 | } |
1381 | 1381 | break; |
1382 | 1382 | } |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | * You can enter whatever you want! |
1414 | 1414 | * We try validating, and customize the results using `self::custom_validation()` |
1415 | 1415 | */ |
1416 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1416 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1417 | 1417 | |
1418 | 1418 | // Needed by the validate funtion |
1419 | 1419 | $failed_validation_page = NULL; |
@@ -1421,14 +1421,14 @@ discard block |
||
1421 | 1421 | |
1422 | 1422 | // Prevent entry limit from running when editing an entry, also |
1423 | 1423 | // prevent form scheduling from preventing editing |
1424 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1424 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1425 | 1425 | |
1426 | 1426 | // Hide fields depending on Edit Entry settings |
1427 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1427 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1428 | 1428 | |
1429 | 1429 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1430 | 1430 | |
1431 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1431 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1432 | 1432 | } |
1433 | 1433 | |
1434 | 1434 | |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | |
1452 | 1452 | $gv_valid = true; |
1453 | 1453 | |
1454 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1454 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1455 | 1455 | |
1456 | 1456 | $value = RGFormsModel::get_field_value( $field ); |
1457 | 1457 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1464,35 +1464,35 @@ discard block |
||
1464 | 1464 | case 'post_image': |
1465 | 1465 | |
1466 | 1466 | // in case nothing is uploaded but there are already files saved |
1467 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1467 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1468 | 1468 | $field->failed_validation = false; |
1469 | 1469 | unset( $field->validation_message ); |
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1473 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1473 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1474 | 1474 | |
1475 | 1475 | $input_name = 'input_' . $field->id; |
1476 | 1476 | //uploaded |
1477 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1477 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1478 | 1478 | |
1479 | 1479 | //existent |
1480 | 1480 | $entry = $this->get_entry(); |
1481 | 1481 | $value = NULL; |
1482 | - if( isset( $entry[ $field->id ] ) ) { |
|
1482 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1483 | 1483 | $value = json_decode( $entry[ $field->id ], true ); |
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | // count uploaded files and existent entry files |
1487 | 1487 | $count_files = count( $file_names ) + count( $value ); |
1488 | 1488 | |
1489 | - if( $count_files > $field->maxFiles ) { |
|
1489 | + if ( $count_files > $field->maxFiles ) { |
|
1490 | 1490 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1491 | 1491 | $field->failed_validation = 1; |
1492 | 1492 | $gv_valid = false; |
1493 | 1493 | |
1494 | 1494 | // in case of error make sure the newest upload files are removed from the upload input |
1495 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1495 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | } |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // This field has failed validation. |
1506 | - if( !empty( $field->failed_validation ) ) { |
|
1506 | + if ( ! empty( $field->failed_validation ) ) { |
|
1507 | 1507 | |
1508 | 1508 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1509 | 1509 | |
@@ -1521,19 +1521,19 @@ discard block |
||
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | // You can't continue inside a switch, so we do it after. |
1524 | - if( empty( $field->failed_validation ) ) { |
|
1524 | + if ( empty( $field->failed_validation ) ) { |
|
1525 | 1525 | continue; |
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | // checks if the No Duplicates option is not validating entry against itself, since |
1529 | 1529 | // we're editing a stored entry, it would also assume it's a duplicate. |
1530 | - if( !empty( $field->noDuplicates ) ) { |
|
1530 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1531 | 1531 | |
1532 | 1532 | $entry = $this->get_entry(); |
1533 | 1533 | |
1534 | 1534 | // If the value of the entry is the same as the stored value |
1535 | 1535 | // Then we can assume it's not a duplicate, it's the same. |
1536 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1536 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1537 | 1537 | //if value submitted was not changed, then don't validate |
1538 | 1538 | $field->failed_validation = false; |
1539 | 1539 | |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1549 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1549 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1550 | 1550 | unset( $field->validation_message ); |
1551 | 1551 | $field->validation_message = false; |
1552 | 1552 | continue; |
@@ -1558,12 +1558,12 @@ discard block |
||
1558 | 1558 | |
1559 | 1559 | } |
1560 | 1560 | |
1561 | - $validation_results['is_valid'] = $gv_valid; |
|
1561 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1562 | 1562 | |
1563 | 1563 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1564 | 1564 | |
1565 | 1565 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1566 | - $this->form_after_validation = $validation_results['form']; |
|
1566 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1567 | 1567 | |
1568 | 1568 | return $validation_results; |
1569 | 1569 | } |
@@ -1576,7 +1576,7 @@ discard block |
||
1576 | 1576 | */ |
1577 | 1577 | public function get_entry() { |
1578 | 1578 | |
1579 | - if( empty( $this->entry ) ) { |
|
1579 | + if ( empty( $this->entry ) ) { |
|
1580 | 1580 | // Get the database value of the entry that's being edited |
1581 | 1581 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1582 | 1582 | } |
@@ -1608,10 +1608,10 @@ discard block |
||
1608 | 1608 | } |
1609 | 1609 | |
1610 | 1610 | // If edit tab not yet configured, show all fields |
1611 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1611 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1612 | 1612 | |
1613 | 1613 | // Hide fields depending on admin settings |
1614 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1614 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1615 | 1615 | |
1616 | 1616 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1617 | 1617 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1643,7 +1643,7 @@ discard block |
||
1643 | 1643 | */ |
1644 | 1644 | private function filter_fields( $fields, $configured_fields ) { |
1645 | 1645 | |
1646 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1646 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1647 | 1647 | return $fields; |
1648 | 1648 | } |
1649 | 1649 | |
@@ -1656,18 +1656,18 @@ discard block |
||
1656 | 1656 | |
1657 | 1657 | // Remove the fields that have calculation properties and keep them to be used later |
1658 | 1658 | // @since 1.16.2 |
1659 | - if( $field->has_calculation() ) { |
|
1660 | - $this->fields_with_calculation[] = $field; |
|
1659 | + if ( $field->has_calculation() ) { |
|
1660 | + $this->fields_with_calculation[ ] = $field; |
|
1661 | 1661 | // don't remove the calculation fields on form render. |
1662 | 1662 | } |
1663 | 1663 | |
1664 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1664 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1665 | 1665 | unset( $fields[ $key ] ); |
1666 | 1666 | } |
1667 | 1667 | } |
1668 | 1668 | |
1669 | 1669 | // The Edit tab has not been configured, so we return all fields by default. |
1670 | - if( empty( $configured_fields ) ) { |
|
1670 | + if ( empty( $configured_fields ) ) { |
|
1671 | 1671 | return array_values( $fields ); |
1672 | 1672 | } |
1673 | 1673 | |
@@ -1676,8 +1676,8 @@ discard block |
||
1676 | 1676 | |
1677 | 1677 | /** @var GF_Field $field */ |
1678 | 1678 | foreach ( $fields as $field ) { |
1679 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1680 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1679 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1680 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1681 | 1681 | break; |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1700,14 +1700,14 @@ discard block |
||
1700 | 1700 | |
1701 | 1701 | $return_field = $field; |
1702 | 1702 | |
1703 | - if( empty( $field_setting['show_label'] ) ) { |
|
1703 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1704 | 1704 | $return_field->label = ''; |
1705 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1706 | - $return_field->label = $field_setting['custom_label']; |
|
1705 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1706 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1707 | 1707 | } |
1708 | 1708 | |
1709 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1710 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1709 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1710 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1711 | 1711 | } |
1712 | 1712 | |
1713 | 1713 | /** |
@@ -1745,16 +1745,16 @@ discard block |
||
1745 | 1745 | */ |
1746 | 1746 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1747 | 1747 | |
1748 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1749 | - foreach( $fields as $k => $field ) { |
|
1750 | - if( $field->adminOnly ) { |
|
1748 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1749 | + foreach ( $fields as $k => $field ) { |
|
1750 | + if ( $field->adminOnly ) { |
|
1751 | 1751 | unset( $fields[ $k ] ); |
1752 | 1752 | } |
1753 | 1753 | } |
1754 | 1754 | return array_values( $fields ); |
1755 | 1755 | } |
1756 | 1756 | |
1757 | - foreach( $fields as &$field ) { |
|
1757 | + foreach ( $fields as &$field ) { |
|
1758 | 1758 | $field->adminOnly = false; |
1759 | 1759 | } |
1760 | 1760 | |
@@ -1775,7 +1775,7 @@ discard block |
||
1775 | 1775 | */ |
1776 | 1776 | private function unselect_default_values( $form ) { |
1777 | 1777 | |
1778 | - foreach ( $form['fields'] as &$field ) { |
|
1778 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1779 | 1779 | |
1780 | 1780 | if ( empty( $field->choices ) ) { |
1781 | 1781 | continue; |
@@ -1783,7 +1783,7 @@ discard block |
||
1783 | 1783 | |
1784 | 1784 | foreach ( $field->choices as &$choice ) { |
1785 | 1785 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1786 | - $choice['isSelected'] = false; |
|
1786 | + $choice[ 'isSelected' ] = false; |
|
1787 | 1787 | } |
1788 | 1788 | } |
1789 | 1789 | } |
@@ -1808,22 +1808,22 @@ discard block |
||
1808 | 1808 | */ |
1809 | 1809 | function prefill_conditional_logic( $form ) { |
1810 | 1810 | |
1811 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1811 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1812 | 1812 | return $form; |
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | // Have Conditional Logic pre-fill fields as if the data were default values |
1816 | 1816 | /** @var GF_Field $field */ |
1817 | - foreach ( $form['fields'] as &$field ) { |
|
1817 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1818 | 1818 | |
1819 | - if( 'checkbox' === $field->type ) { |
|
1819 | + if ( 'checkbox' === $field->type ) { |
|
1820 | 1820 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1821 | - $input_id = $input['id']; |
|
1821 | + $input_id = $input[ 'id' ]; |
|
1822 | 1822 | $choice = $field->choices[ $key ]; |
1823 | 1823 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1824 | 1824 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1825 | - if( $match ) { |
|
1826 | - $field->choices[ $key ]['isSelected'] = true; |
|
1825 | + if ( $match ) { |
|
1826 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1827 | 1827 | } |
1828 | 1828 | } |
1829 | 1829 | } else { |
@@ -1831,15 +1831,15 @@ discard block |
||
1831 | 1831 | // We need to run through each field to set the default values |
1832 | 1832 | foreach ( $this->entry as $field_id => $field_value ) { |
1833 | 1833 | |
1834 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1834 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1835 | 1835 | |
1836 | - if( 'list' === $field->type ) { |
|
1836 | + if ( 'list' === $field->type ) { |
|
1837 | 1837 | $list_rows = maybe_unserialize( $field_value ); |
1838 | 1838 | |
1839 | 1839 | $list_field_value = array(); |
1840 | - foreach ( (array) $list_rows as $row ) { |
|
1841 | - foreach ( (array) $row as $column ) { |
|
1842 | - $list_field_value[] = $column; |
|
1840 | + foreach ( (array)$list_rows as $row ) { |
|
1841 | + foreach ( (array)$row as $column ) { |
|
1842 | + $list_field_value[ ] = $column; |
|
1843 | 1843 | } |
1844 | 1844 | } |
1845 | 1845 | |
@@ -1874,16 +1874,16 @@ discard block |
||
1874 | 1874 | */ |
1875 | 1875 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1876 | 1876 | |
1877 | - if( $use_conditional_logic ) { |
|
1877 | + if ( $use_conditional_logic ) { |
|
1878 | 1878 | return $form; |
1879 | 1879 | } |
1880 | 1880 | |
1881 | - foreach( $form['fields'] as &$field ) { |
|
1881 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1882 | 1882 | /* @var GF_Field $field */ |
1883 | 1883 | $field->conditionalLogic = null; |
1884 | 1884 | } |
1885 | 1885 | |
1886 | - unset( $form['button']['conditionalLogic'] ); |
|
1886 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1887 | 1887 | |
1888 | 1888 | return $form; |
1889 | 1889 | |
@@ -1900,7 +1900,7 @@ discard block |
||
1900 | 1900 | */ |
1901 | 1901 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1902 | 1902 | |
1903 | - if( ! $this->is_edit_entry() ) { |
|
1903 | + if ( ! $this->is_edit_entry() ) { |
|
1904 | 1904 | return $has_conditional_logic; |
1905 | 1905 | } |
1906 | 1906 | |
@@ -1932,44 +1932,44 @@ discard block |
||
1932 | 1932 | * 2. There are two entries embedded using oEmbed |
1933 | 1933 | * 3. One of the entries has just been saved |
1934 | 1934 | */ |
1935 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1935 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1936 | 1936 | |
1937 | 1937 | $error = true; |
1938 | 1938 | |
1939 | 1939 | } |
1940 | 1940 | |
1941 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1941 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1942 | 1942 | |
1943 | 1943 | $error = true; |
1944 | 1944 | |
1945 | - } elseif( ! $this->verify_nonce() ) { |
|
1945 | + } elseif ( ! $this->verify_nonce() ) { |
|
1946 | 1946 | |
1947 | 1947 | /** |
1948 | 1948 | * If the Entry is embedded, there may be two entries on the same page. |
1949 | 1949 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1950 | 1950 | */ |
1951 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1951 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1952 | 1952 | $error = true; |
1953 | 1953 | } else { |
1954 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1954 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1955 | 1955 | } |
1956 | 1956 | |
1957 | 1957 | } |
1958 | 1958 | |
1959 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1960 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1959 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1960 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | - if( $this->entry['status'] === 'trash' ) { |
|
1964 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1963 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1964 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1965 | 1965 | } |
1966 | 1966 | |
1967 | 1967 | // No errors; everything's fine here! |
1968 | - if( empty( $error ) ) { |
|
1968 | + if ( empty( $error ) ) { |
|
1969 | 1969 | return true; |
1970 | 1970 | } |
1971 | 1971 | |
1972 | - if( $echo && $error !== true ) { |
|
1972 | + if ( $echo && $error !== true ) { |
|
1973 | 1973 | |
1974 | 1974 | $error = esc_html( $error ); |
1975 | 1975 | |
@@ -1977,10 +1977,10 @@ discard block |
||
1977 | 1977 | * @since 1.9 |
1978 | 1978 | */ |
1979 | 1979 | if ( ! empty( $this->entry ) ) { |
1980 | - $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;" ) ); |
|
1980 | + $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;" ) ); |
|
1981 | 1981 | } |
1982 | 1982 | |
1983 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1983 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2000,17 +2000,17 @@ discard block |
||
2000 | 2000 | |
2001 | 2001 | $error = NULL; |
2002 | 2002 | |
2003 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2004 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2003 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2004 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2005 | 2005 | } |
2006 | 2006 | |
2007 | 2007 | // No errors; everything's fine here! |
2008 | - if( empty( $error ) ) { |
|
2008 | + if ( empty( $error ) ) { |
|
2009 | 2009 | return true; |
2010 | 2010 | } |
2011 | 2011 | |
2012 | - if( $echo ) { |
|
2013 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2012 | + if ( $echo ) { |
|
2013 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2014 | 2014 | } |
2015 | 2015 | |
2016 | 2016 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2031,14 +2031,14 @@ discard block |
||
2031 | 2031 | private function check_user_cap_edit_field( $field ) { |
2032 | 2032 | |
2033 | 2033 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2034 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2034 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2035 | 2035 | return true; |
2036 | 2036 | } |
2037 | 2037 | |
2038 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2038 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2039 | 2039 | |
2040 | - if( $field_cap ) { |
|
2041 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2040 | + if ( $field_cap ) { |
|
2041 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2042 | 2042 | } |
2043 | 2043 | |
2044 | 2044 | return false; |
@@ -2052,17 +2052,17 @@ discard block |
||
2052 | 2052 | public function verify_nonce() { |
2053 | 2053 | |
2054 | 2054 | // Verify form submitted for editing single |
2055 | - if( $this->is_edit_entry_submission() ) { |
|
2055 | + if ( $this->is_edit_entry_submission() ) { |
|
2056 | 2056 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | // Verify |
2060 | - else if( ! $this->is_edit_entry() ) { |
|
2060 | + else if ( ! $this->is_edit_entry() ) { |
|
2061 | 2061 | $valid = false; |
2062 | 2062 | } |
2063 | 2063 | |
2064 | 2064 | else { |
2065 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2065 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2066 | 2066 | } |
2067 | 2067 | |
2068 | 2068 | /** |