|
@@ -115,16 +115,16 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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,16 +208,16 @@ discard block |
|
|
block discarded – undo |
|
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(); |
|
216
|
|
- $this->form_id = $this->entry['form_id']; |
|
|
216
|
+ $this->form_id = $this->entry[ 'form_id' ]; |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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,15 +321,15 @@ discard block |
|
|
block discarded – undo |
|
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
|
/** |
|
335
|
335
|
* @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
|
@@ -339,14 +339,14 @@ discard block |
|
|
block discarded – undo |
|
339
|
339
|
* @param GravityView_Edit_Entry_Render $this This object |
|
340
|
340
|
* @param GravityView_View_Data $gv_data The View data |
|
341
|
341
|
*/ |
|
342
|
|
- do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
|
342
|
+ do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
343
|
343
|
|
|
344
|
344
|
GFFormsModel::save_lead( $form, $this->entry ); |
|
345
|
345
|
|
|
346
|
346
|
// Delete the values for hidden inputs |
|
347
|
347
|
$this->unset_hidden_field_values(); |
|
348
|
348
|
|
|
349
|
|
- $this->entry['date_created'] = $date_created; |
|
|
349
|
+ $this->entry[ 'date_created' ] = $date_created; |
|
350
|
350
|
|
|
351
|
351
|
// Process calculation fields |
|
352
|
352
|
$this->update_calculation_fields(); |
|
@@ -368,7 +368,7 @@ discard block |
|
|
block discarded – undo |
|
368
|
368
|
* @param GravityView_Edit_Entry_Render $this This object |
|
369
|
369
|
* @param GravityView_View_Data $gv_data The View data |
|
370
|
370
|
*/ |
|
371
|
|
- do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
|
371
|
+ do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
372
|
372
|
|
|
373
|
373
|
} else { |
|
374
|
374
|
gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
|
@@ -396,16 +396,16 @@ discard block |
|
|
block discarded – undo |
|
396
|
396
|
*/ |
|
397
|
397
|
$unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
|
398
|
398
|
|
|
399
|
|
- if( ! $unset_hidden_field_values ) { |
|
|
399
|
+ if ( ! $unset_hidden_field_values ) { |
|
400
|
400
|
return; |
|
401
|
401
|
} |
|
402
|
402
|
|
|
403
|
403
|
if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
|
404
|
404
|
$entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
|
405
|
|
- $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
|
405
|
+ $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
406
|
406
|
} else { |
|
407
|
407
|
$lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
|
408
|
|
- $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
|
408
|
+ $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
409
|
409
|
} |
|
410
|
410
|
|
|
411
|
411
|
foreach ( $this->entry as $input_id => $field_value ) { |
|
@@ -418,7 +418,7 @@ discard block |
|
|
block discarded – undo |
|
418
|
418
|
|
|
419
|
419
|
$empty_value = $field->get_value_save_entry( |
|
420
|
420
|
is_array( $field->get_entry_inputs() ) ? array() : '', |
|
421
|
|
- $this->form, '', $this->entry['id'], $this->entry |
|
|
421
|
+ $this->form, '', $this->entry[ 'id' ], $this->entry |
|
422
|
422
|
); |
|
423
|
423
|
|
|
424
|
424
|
$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
@@ -488,7 +488,7 @@ discard block |
|
|
block discarded – undo |
|
488
|
488
|
} |
|
489
|
489
|
|
|
490
|
490
|
/** No file is being uploaded. */ |
|
491
|
|
- if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
|
491
|
+ if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
492
|
492
|
/** So return the original upload */ |
|
493
|
493
|
return $entry[ $input_id ]; |
|
494
|
494
|
} |
|
@@ -506,11 +506,11 @@ discard block |
|
|
block discarded – undo |
|
506
|
506
|
* @return mixed |
|
507
|
507
|
*/ |
|
508
|
508
|
public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
|
509
|
|
- if( ! $this->is_edit_entry() ) { |
|
|
509
|
+ if ( ! $this->is_edit_entry() ) { |
|
510
|
510
|
return $plupload_init; |
|
511
|
511
|
} |
|
512
|
512
|
|
|
513
|
|
- $plupload_init['gf_vars']['max_files'] = 0; |
|
|
513
|
+ $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
514
|
514
|
|
|
515
|
515
|
return $plupload_init; |
|
516
|
516
|
} |
|
@@ -527,22 +527,22 @@ discard block |
|
|
block discarded – undo |
|
527
|
527
|
$non_submitted_fields = array(); |
|
528
|
528
|
|
|
529
|
529
|
/** @var GF_Field $field */ |
|
530
|
|
- foreach( $form['fields'] as $k => &$field ) { |
|
|
530
|
+ foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
531
|
531
|
|
|
532
|
532
|
/** |
|
533
|
533
|
* Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
|
534
|
534
|
* @since 1.16.3 |
|
535
|
535
|
* @var GF_Field $field |
|
536
|
536
|
*/ |
|
537
|
|
- if( $field->has_calculation() ) { |
|
538
|
|
- unset( $form['fields'][ $k ] ); |
|
|
537
|
+ if ( $field->has_calculation() ) { |
|
|
538
|
+ unset( $form[ 'fields' ][ $k ] ); |
|
539
|
539
|
} |
|
540
|
540
|
|
|
541
|
541
|
$field->adminOnly = false; |
|
542
|
542
|
|
|
543
|
|
- if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
544
|
|
- foreach( $field->inputs as $key => $input ) { |
|
545
|
|
- $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
|
543
|
+ if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
|
544
|
+ foreach ( $field->inputs as $key => $input ) { |
|
|
545
|
+ $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
546
|
546
|
} |
|
547
|
547
|
} |
|
548
|
548
|
|
|
@@ -551,11 +551,11 @@ discard block |
|
|
block discarded – undo |
|
551
|
551
|
* are not present in the edit view fields. |
|
552
|
552
|
* @since develop |
|
553
|
553
|
*/ |
|
554
|
|
- if ( ! empty( $field['conditionalLogic'] ) && ! empty( $field['conditionalLogic']['rules'] ) ) { |
|
555
|
|
- foreach ( wp_list_pluck( $field['conditionalLogic']['rules'], 'fieldId' ) as $conditional_id ) { |
|
|
554
|
+ if ( ! empty( $field[ 'conditionalLogic' ] ) && ! empty( $field[ 'conditionalLogic' ][ 'rules' ] ) ) { |
|
|
555
|
+ foreach ( wp_list_pluck( $field[ 'conditionalLogic' ][ 'rules' ], 'fieldId' ) as $conditional_id ) { |
|
556
|
556
|
$post_input_id = 'input_' . str_replace( '.', '_', $conditional_id ); |
|
557
|
557
|
if ( ! isset( $_POST[ $post_input_id ] ) ) { |
|
558
|
|
- $non_submitted_fields []= $conditional_id; |
|
|
558
|
+ $non_submitted_fields [ ] = $conditional_id; |
|
559
|
559
|
} |
|
560
|
560
|
} |
|
561
|
561
|
} |
|
@@ -567,13 +567,13 @@ discard block |
|
|
block discarded – undo |
|
567
|
567
|
* (or need) to remove all fields that are not being submitted. Or look |
|
568
|
568
|
* at the view edit configuration. |
|
569
|
569
|
*/ |
|
570
|
|
- foreach ( $form['fields'] as $k => $field ) { |
|
571
|
|
- if ( in_array( $field['id'], $non_submitted_fields ) ) { |
|
572
|
|
- unset( $form['fields'][ $k ] ); |
|
|
570
|
+ foreach ( $form[ 'fields' ] as $k => $field ) { |
|
|
571
|
+ if ( in_array( $field[ 'id' ], $non_submitted_fields ) ) { |
|
|
572
|
+ unset( $form[ 'fields' ][ $k ] ); |
|
573
|
573
|
} |
|
574
|
574
|
} |
|
575
|
575
|
|
|
576
|
|
- $form['fields'] = array_values( $form['fields'] ); |
|
|
576
|
+ $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
577
|
577
|
|
|
578
|
578
|
return $form; |
|
579
|
579
|
} |
|
@@ -585,14 +585,14 @@ discard block |
|
|
block discarded – undo |
|
585
|
585
|
$update = false; |
|
586
|
586
|
|
|
587
|
587
|
// get the most up to date entry values |
|
588
|
|
- $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
|
588
|
+ $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
589
|
589
|
|
|
590
|
590
|
if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
|
591
|
591
|
$entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
|
592
|
|
- $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
|
592
|
+ $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
593
|
593
|
} else { |
|
594
|
594
|
$lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
|
595
|
|
- $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
|
595
|
+ $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
596
|
596
|
} |
|
597
|
597
|
|
|
598
|
598
|
|
|
@@ -604,24 +604,24 @@ discard block |
|
|
block discarded – undo |
|
604
|
604
|
$inputs = $field->get_entry_inputs(); |
|
605
|
605
|
if ( is_array( $inputs ) ) { |
|
606
|
606
|
foreach ( $inputs as $input ) { |
|
607
|
|
- list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
|
607
|
+ list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
608
|
608
|
|
|
609
|
609
|
if ( 'product' === $field->type ) { |
|
610
|
|
- $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
|
610
|
+ $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
611
|
611
|
|
|
612
|
612
|
// Only allow quantity to be set if it's allowed to be edited |
|
613
|
613
|
if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
|
614
|
614
|
} else { // otherwise set to what it previously was |
|
615
|
|
- $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
|
615
|
+ $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
616
|
616
|
} |
|
617
|
617
|
} else { |
|
618
|
618
|
// Set to what it previously was if it's not editable |
|
619
|
619
|
if ( ! in_array( $field_id, $allowed_fields ) ) { |
|
620
|
|
- $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
|
620
|
+ $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
621
|
621
|
} |
|
622
|
622
|
} |
|
623
|
623
|
|
|
624
|
|
- GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
|
624
|
+ GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
625
|
625
|
} |
|
626
|
626
|
} else { |
|
627
|
627
|
// Set to what it previously was if it's not editable |
|
@@ -661,19 +661,19 @@ discard block |
|
|
block discarded – undo |
|
661
|
661
|
|
|
662
|
662
|
$input_name = 'input_' . $field_id; |
|
663
|
663
|
|
|
664
|
|
- if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
|
664
|
+ if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
665
|
665
|
|
|
666
|
666
|
// We have a new image |
|
667
|
667
|
|
|
668
|
|
- $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
|
668
|
+ $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
669
|
669
|
|
|
670
|
670
|
$ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
|
671
|
671
|
$ary = stripslashes_deep( $ary ); |
|
672
|
672
|
$img_url = \GV\Utils::get( $ary, 0 ); |
|
673
|
673
|
|
|
674
|
|
- $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
675
|
|
- $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
676
|
|
- $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
|
674
|
+ $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
|
675
|
+ $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
|
676
|
+ $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
677
|
677
|
|
|
678
|
678
|
$image_meta = array( |
|
679
|
679
|
'post_excerpt' => $img_caption, |
|
@@ -682,7 +682,7 @@ discard block |
|
|
block discarded – undo |
|
682
|
682
|
|
|
683
|
683
|
//adding title only if it is not empty. It will default to the file name if it is not in the array |
|
684
|
684
|
if ( ! empty( $img_title ) ) { |
|
685
|
|
- $image_meta['post_title'] = $img_title; |
|
|
685
|
+ $image_meta[ 'post_title' ] = $img_title; |
|
686
|
686
|
} |
|
687
|
687
|
|
|
688
|
688
|
/** |
|
@@ -740,15 +740,15 @@ discard block |
|
|
block discarded – undo |
|
740
|
740
|
*/ |
|
741
|
741
|
private function maybe_update_post_fields( $form ) { |
|
742
|
742
|
|
|
743
|
|
- if( empty( $this->entry['post_id'] ) ) { |
|
|
743
|
+ if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
744
|
744
|
gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
745
|
745
|
return; |
|
746
|
746
|
} |
|
747
|
747
|
|
|
748
|
|
- $post_id = $this->entry['post_id']; |
|
|
748
|
+ $post_id = $this->entry[ 'post_id' ]; |
|
749
|
749
|
|
|
750
|
750
|
// Security check |
|
751
|
|
- if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
|
751
|
+ if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
752
|
752
|
gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
|
753
|
753
|
return; |
|
754
|
754
|
} |
|
@@ -761,25 +761,25 @@ discard block |
|
|
block discarded – undo |
|
761
|
761
|
|
|
762
|
762
|
$field = RGFormsModel::get_field( $form, $field_id ); |
|
763
|
763
|
|
|
764
|
|
- if( ! $field ) { |
|
|
764
|
+ if ( ! $field ) { |
|
765
|
765
|
continue; |
|
766
|
766
|
} |
|
767
|
767
|
|
|
768
|
|
- if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
|
768
|
+ if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
769
|
769
|
|
|
770
|
770
|
// Get the value of the field, including $_POSTed value |
|
771
|
771
|
$value = RGFormsModel::get_field_value( $field ); |
|
772
|
772
|
|
|
773
|
773
|
// Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
|
774
|
774
|
$entry_tmp = $this->entry; |
|
775
|
|
- $entry_tmp["{$field_id}"] = $value; |
|
|
775
|
+ $entry_tmp[ "{$field_id}" ] = $value; |
|
776
|
776
|
|
|
777
|
|
- switch( $field->type ) { |
|
|
777
|
+ switch ( $field->type ) { |
|
778
|
778
|
|
|
779
|
779
|
case 'post_title': |
|
780
|
780
|
$post_title = $value; |
|
781
|
781
|
if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
782
|
|
- $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
|
782
|
+ $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
783
|
783
|
} |
|
784
|
784
|
$updated_post->post_title = $post_title; |
|
785
|
785
|
$updated_post->post_name = $post_title; |
|
@@ -789,7 +789,7 @@ discard block |
|
|
block discarded – undo |
|
789
|
789
|
case 'post_content': |
|
790
|
790
|
$post_content = $value; |
|
791
|
791
|
if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
792
|
|
- $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
|
792
|
+ $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
793
|
793
|
} |
|
794
|
794
|
$updated_post->post_content = $post_content; |
|
795
|
795
|
unset( $post_content ); |
|
@@ -807,11 +807,11 @@ discard block |
|
|
block discarded – undo |
|
807
|
807
|
$value = $value[ $field_id ]; |
|
808
|
808
|
} |
|
809
|
809
|
|
|
810
|
|
- if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
|
810
|
+ if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
811
|
811
|
$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
812
|
812
|
} |
|
813
|
813
|
|
|
814
|
|
- $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
|
814
|
+ $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
815
|
815
|
|
|
816
|
816
|
update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
817
|
817
|
break; |
|
@@ -823,7 +823,7 @@ discard block |
|
|
block discarded – undo |
|
823
|
823
|
} |
|
824
|
824
|
|
|
825
|
825
|
// update entry after |
|
826
|
|
- $this->entry["{$field_id}"] = $value; |
|
|
826
|
+ $this->entry[ "{$field_id}" ] = $value; |
|
827
|
827
|
|
|
828
|
828
|
$update_entry = true; |
|
829
|
829
|
|
|
@@ -832,11 +832,11 @@ discard block |
|
|
block discarded – undo |
|
832
|
832
|
|
|
833
|
833
|
} |
|
834
|
834
|
|
|
835
|
|
- if( $update_entry ) { |
|
|
835
|
+ if ( $update_entry ) { |
|
836
|
836
|
|
|
837
|
837
|
$return_entry = GFAPI::update_entry( $this->entry ); |
|
838
|
838
|
|
|
839
|
|
- if( is_wp_error( $return_entry ) ) { |
|
|
839
|
+ if ( is_wp_error( $return_entry ) ) { |
|
840
|
840
|
gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
|
841
|
841
|
} else { |
|
842
|
842
|
gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
|
@@ -846,7 +846,7 @@ discard block |
|
|
block discarded – undo |
|
846
|
846
|
|
|
847
|
847
|
$return_post = wp_update_post( $updated_post, true ); |
|
848
|
848
|
|
|
849
|
|
- if( is_wp_error( $return_post ) ) { |
|
|
849
|
+ if ( is_wp_error( $return_post ) ) { |
|
850
|
850
|
$return_post->add_data( $updated_post, '$updated_post' ); |
|
851
|
851
|
gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
|
852
|
852
|
} else { |
|
@@ -880,7 +880,7 @@ discard block |
|
|
block discarded – undo |
|
880
|
880
|
$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
|
881
|
881
|
|
|
882
|
882
|
// replace conditional shortcodes |
|
883
|
|
- if( $do_shortcode ) { |
|
|
883
|
+ if ( $do_shortcode ) { |
|
884
|
884
|
$output = do_shortcode( $output ); |
|
885
|
885
|
} |
|
886
|
886
|
|
|
@@ -899,19 +899,19 @@ discard block |
|
|
block discarded – undo |
|
899
|
899
|
*/ |
|
900
|
900
|
private function after_update() { |
|
901
|
901
|
|
|
902
|
|
- do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
903
|
|
- do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
|
902
|
+ do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
|
903
|
+ do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
904
|
904
|
|
|
905
|
905
|
// Re-define the entry now that we've updated it. |
|
906
|
|
- $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
|
906
|
+ $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
907
|
907
|
|
|
908
|
908
|
$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
|
909
|
909
|
|
|
910
|
910
|
if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
|
911
|
911
|
// We need to clear the cache because Gravity Forms caches the field values, which |
|
912
|
912
|
// we have just updated. |
|
913
|
|
- foreach ($this->form['fields'] as $key => $field) { |
|
914
|
|
- GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
|
913
|
+ foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
|
914
|
+ GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
915
|
915
|
} |
|
916
|
916
|
} |
|
917
|
917
|
|
|
@@ -930,7 +930,7 @@ discard block |
|
|
block discarded – undo |
|
930
|
930
|
|
|
931
|
931
|
<div class="gv-edit-entry-wrapper"><?php |
|
932
|
932
|
|
|
933
|
|
- $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
|
933
|
+ $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
934
|
934
|
|
|
935
|
935
|
/** |
|
936
|
936
|
* Fixes weird wpautop() issue |
|
@@ -946,7 +946,7 @@ discard block |
|
|
block discarded – undo |
|
946
|
946
|
* @param string $edit_entry_title Modify the "Edit Entry" title |
|
947
|
947
|
* @param GravityView_Edit_Entry_Render $this This object |
|
948
|
948
|
*/ |
|
949
|
|
- $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
|
949
|
+ $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
950
|
950
|
|
|
951
|
951
|
echo esc_attr( $edit_entry_title ); |
|
952
|
952
|
?></span> |
|
@@ -996,13 +996,13 @@ discard block |
|
|
block discarded – undo |
|
996
|
996
|
|
|
997
|
997
|
$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
|
998
|
998
|
|
|
999
|
|
- if( ! $this->is_valid ){ |
|
|
999
|
+ if ( ! $this->is_valid ) { |
|
1000
|
1000
|
|
|
1001
|
1001
|
// Keeping this compatible with Gravity Forms. |
|
1002
|
|
- $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
1003
|
|
- $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
|
1002
|
+ $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
|
1003
|
+ $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
1004
|
1004
|
|
|
1005
|
|
- echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
|
1005
|
+ echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
1006
|
1006
|
|
|
1007
|
1007
|
} else { |
|
1008
|
1008
|
$view = \GV\View::by_id( $this->view_id ); |
|
@@ -1013,23 +1013,23 @@ discard block |
|
|
block discarded – undo |
|
1013
|
1013
|
|
|
1014
|
1014
|
case '0': |
|
1015
|
1015
|
$redirect_url = $back_link; |
|
1016
|
|
- $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
|
1016
|
+ $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
1017
|
1017
|
break; |
|
1018
|
1018
|
|
|
1019
|
1019
|
case '1': |
|
1020
|
1020
|
$redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1021
|
|
- $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>' ); |
|
|
1021
|
+ $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>' ); |
|
1022
|
1022
|
break; |
|
1023
|
1023
|
|
|
1024
|
1024
|
case '2': |
|
1025
|
1025
|
$redirect_url = $edit_redirect_url; |
|
1026
|
1026
|
$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1027
|
|
- $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>' ); |
|
|
1027
|
+ $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>' ); |
|
1028
|
1028
|
break; |
|
1029
|
1029
|
|
|
1030
|
1030
|
case '': |
|
1031
|
1031
|
default: |
|
1032
|
|
- $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
|
1032
|
+ $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
1033
|
1033
|
break; |
|
1034
|
1034
|
} |
|
1035
|
1035
|
|
|
@@ -1045,7 +1045,7 @@ discard block |
|
|
block discarded – undo |
|
1045
|
1045
|
* @param array $entry Gravity Forms entry array |
|
1046
|
1046
|
* @param string $back_link URL to return to the original entry. @since 1.6 |
|
1047
|
1047
|
*/ |
|
1048
|
|
- $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
|
1048
|
+ $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1049
|
1049
|
|
|
1050
|
1050
|
echo GVCommon::generate_notice( $message ); |
|
1051
|
1051
|
} |
|
@@ -1069,21 +1069,21 @@ discard block |
|
|
block discarded – undo |
|
1069
|
1069
|
*/ |
|
1070
|
1070
|
do_action( 'gravityview/edit-entry/render/before', $this ); |
|
1071
|
1071
|
|
|
1072
|
|
- add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1073
|
|
- add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
|
1072
|
+ add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
|
1073
|
+ add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1074
|
1074
|
add_filter( 'gform_disable_view_counter', '__return_true' ); |
|
1075
|
1075
|
|
|
1076
|
1076
|
add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
|
1077
|
1077
|
add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
|
1078
|
1078
|
|
|
1079
|
1079
|
// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
|
1080
|
|
- unset( $_GET['page'] ); |
|
|
1080
|
+ unset( $_GET[ 'page' ] ); |
|
1081
|
1081
|
|
|
1082
|
1082
|
// TODO: Verify multiple-page forms |
|
1083
|
1083
|
|
|
1084
|
1084
|
ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
|
1085
|
1085
|
|
|
1086
|
|
- $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
|
1086
|
+ $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1087
|
1087
|
|
|
1088
|
1088
|
ob_get_clean(); |
|
1089
|
1089
|
|
|
@@ -1109,7 +1109,7 @@ discard block |
|
|
block discarded – undo |
|
1109
|
1109
|
* @return string |
|
1110
|
1110
|
*/ |
|
1111
|
1111
|
public function render_form_buttons() { |
|
1112
|
|
- return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
|
1112
|
+ return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1113
|
1113
|
} |
|
1114
|
1114
|
|
|
1115
|
1115
|
|
|
@@ -1129,10 +1129,10 @@ discard block |
|
|
block discarded – undo |
|
1129
|
1129
|
public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
|
1130
|
1130
|
|
|
1131
|
1131
|
// In case we have validated the form, use it to inject the validation results into the form render |
|
1132
|
|
- if( isset( $this->form_after_validation ) ) { |
|
|
1132
|
+ if ( isset( $this->form_after_validation ) ) { |
|
1133
|
1133
|
$form = $this->form_after_validation; |
|
1134
|
1134
|
} else { |
|
1135
|
|
- $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
|
1135
|
+ $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1136
|
1136
|
} |
|
1137
|
1137
|
|
|
1138
|
1138
|
$form = $this->filter_conditional_logic( $form ); |
|
@@ -1140,8 +1140,8 @@ discard block |
|
|
block discarded – undo |
|
1140
|
1140
|
$form = $this->prefill_conditional_logic( $form ); |
|
1141
|
1141
|
|
|
1142
|
1142
|
// for now we don't support Save and Continue feature. |
|
1143
|
|
- if( ! self::$supports_save_and_continue ) { |
|
1144
|
|
- unset( $form['save'] ); |
|
|
1143
|
+ if ( ! self::$supports_save_and_continue ) { |
|
|
1144
|
+ unset( $form[ 'save' ] ); |
|
1145
|
1145
|
} |
|
1146
|
1146
|
|
|
1147
|
1147
|
$form = $this->unselect_default_values( $form ); |
|
@@ -1164,31 +1164,31 @@ discard block |
|
|
block discarded – undo |
|
1164
|
1164
|
*/ |
|
1165
|
1165
|
public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
|
1166
|
1166
|
|
|
1167
|
|
- if( ! GFCommon::is_post_field( $field ) ) { |
|
|
1167
|
+ if ( ! GFCommon::is_post_field( $field ) ) { |
|
1168
|
1168
|
return $field_content; |
|
1169
|
1169
|
} |
|
1170
|
1170
|
|
|
1171
|
1171
|
$message = null; |
|
1172
|
1172
|
|
|
1173
|
1173
|
// First, make sure they have the capability to edit the post. |
|
1174
|
|
- if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
|
1174
|
+ if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1175
|
1175
|
|
|
1176
|
1176
|
/** |
|
1177
|
1177
|
* @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1178
|
1178
|
* @param string $message The existing "You don't have permission..." text |
|
1179
|
1179
|
*/ |
|
1180
|
|
- $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
|
1180
|
+ $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1181
|
1181
|
|
|
1182
|
|
- } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
|
1182
|
+ } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1183
|
1183
|
/** |
|
1184
|
1184
|
* @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1185
|
1185
|
* @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1186
|
1186
|
*/ |
|
1187
|
|
- $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
|
1187
|
+ $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1188
|
1188
|
} |
|
1189
|
1189
|
|
|
1190
|
|
- if( $message ) { |
|
1191
|
|
- $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
|
1190
|
+ if ( $message ) { |
|
|
1191
|
+ $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1192
|
1192
|
} |
|
1193
|
1193
|
|
|
1194
|
1194
|
return $field_content; |
|
@@ -1212,8 +1212,8 @@ discard block |
|
|
block discarded – undo |
|
1212
|
1212
|
|
|
1213
|
1213
|
// If the form has been submitted, then we don't need to pre-fill the values, |
|
1214
|
1214
|
// Except for fileupload type and when a field input is overridden- run always!! |
|
1215
|
|
- if( |
|
1216
|
|
- ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
|
1215
|
+ if ( |
|
|
1216
|
+ ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1217
|
1217
|
&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
|
1218
|
1218
|
&& ! GFCommon::is_product_field( $field->type ) |
|
1219
|
1219
|
|| ! empty( $field_content ) |
|
@@ -1233,7 +1233,7 @@ discard block |
|
|
block discarded – undo |
|
1233
|
1233
|
$return = null; |
|
1234
|
1234
|
|
|
1235
|
1235
|
/** @var GravityView_Field $gv_field */ |
|
1236
|
|
- if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
|
1236
|
+ if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1237
|
1237
|
$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
|
1238
|
1238
|
} else { |
|
1239
|
1239
|
$return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
@@ -1242,7 +1242,7 @@ discard block |
|
|
block discarded – undo |
|
1242
|
1242
|
// If there was output, it's an error |
|
1243
|
1243
|
$warnings = ob_get_clean(); |
|
1244
|
1244
|
|
|
1245
|
|
- if( !empty( $warnings ) ) { |
|
|
1245
|
+ if ( ! empty( $warnings ) ) { |
|
1246
|
1246
|
gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1247
|
1247
|
} |
|
1248
|
1248
|
|
|
@@ -1267,7 +1267,7 @@ discard block |
|
|
block discarded – undo |
|
1267
|
1267
|
$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
|
1268
|
1268
|
|
|
1269
|
1269
|
// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
|
1270
|
|
- if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
|
1270
|
+ if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1271
|
1271
|
|
|
1272
|
1272
|
$field_value = array(); |
|
1273
|
1273
|
|
|
@@ -1276,10 +1276,10 @@ discard block |
|
|
block discarded – undo |
|
1276
|
1276
|
|
|
1277
|
1277
|
foreach ( (array)$field->inputs as $input ) { |
|
1278
|
1278
|
|
|
1279
|
|
- $input_id = strval( $input['id'] ); |
|
|
1279
|
+ $input_id = strval( $input[ 'id' ] ); |
|
1280
|
1280
|
|
|
1281
|
1281
|
if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
|
1282
|
|
- $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
|
1282
|
+ $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1283
|
1283
|
$allow_pre_populated = false; |
|
1284
|
1284
|
} |
|
1285
|
1285
|
|
|
@@ -1287,7 +1287,7 @@ discard block |
|
|
block discarded – undo |
|
1287
|
1287
|
|
|
1288
|
1288
|
$pre_value = $field->get_value_submission( array(), false ); |
|
1289
|
1289
|
|
|
1290
|
|
- $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
|
1290
|
+ $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1291
|
1291
|
|
|
1292
|
1292
|
} else { |
|
1293
|
1293
|
|
|
@@ -1298,13 +1298,13 @@ discard block |
|
|
block discarded – undo |
|
1298
|
1298
|
|
|
1299
|
1299
|
// saved field entry value (if empty, fallback to the pre-populated value, if exists) |
|
1300
|
1300
|
// or pre-populated value if not empty and set to override saved value |
|
1301
|
|
- $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; |
|
|
1301
|
+ $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; |
|
1302
|
1302
|
|
|
1303
|
1303
|
// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
|
1304
|
|
- if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
|
1304
|
+ if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1305
|
1305
|
$categories = array(); |
|
1306
|
1306
|
foreach ( explode( ',', $field_value ) as $cat_string ) { |
|
1307
|
|
- $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
|
1307
|
+ $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1308
|
1308
|
} |
|
1309
|
1309
|
$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
|
1310
|
1310
|
} |
|
@@ -1332,7 +1332,7 @@ discard block |
|
|
block discarded – undo |
|
1332
|
1332
|
* @param GF_Field $field Gravity Forms field object |
|
1333
|
1333
|
* @param GravityView_Edit_Entry_Render $this Current object |
|
1334
|
1334
|
*/ |
|
1335
|
|
- $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
|
1335
|
+ $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1336
|
1336
|
|
|
1337
|
1337
|
return $field_value; |
|
1338
|
1338
|
} |
|
@@ -1349,12 +1349,12 @@ discard block |
|
|
block discarded – undo |
|
1349
|
1349
|
*/ |
|
1350
|
1350
|
public function gform_pre_validation( $form ) { |
|
1351
|
1351
|
|
|
1352
|
|
- if( ! $this->verify_nonce() ) { |
|
|
1352
|
+ if ( ! $this->verify_nonce() ) { |
|
1353
|
1353
|
return $form; |
|
1354
|
1354
|
} |
|
1355
|
1355
|
|
|
1356
|
1356
|
// Fix PHP warning regarding undefined index. |
|
1357
|
|
- foreach ( $form['fields'] as &$field) { |
|
|
1357
|
+ foreach ( $form[ 'fields' ] as &$field ) { |
|
1358
|
1358
|
|
|
1359
|
1359
|
// This is because we're doing admin form pretending to be front-end, so Gravity Forms |
|
1360
|
1360
|
// expects certain field array items to be set. |
|
@@ -1362,7 +1362,7 @@ discard block |
|
|
block discarded – undo |
|
1362
|
1362
|
$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1363
|
1363
|
} |
|
1364
|
1364
|
|
|
1365
|
|
- switch( RGFormsModel::get_input_type( $field ) ) { |
|
|
1365
|
+ switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1366
|
1366
|
|
|
1367
|
1367
|
/** |
|
1368
|
1368
|
* 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. |
|
@@ -1376,26 +1376,26 @@ discard block |
|
|
block discarded – undo |
|
1376
|
1376
|
// Set the previous value |
|
1377
|
1377
|
$entry = $this->get_entry(); |
|
1378
|
1378
|
|
|
1379
|
|
- $input_name = 'input_'.$field->id; |
|
1380
|
|
- $form_id = $form['id']; |
|
|
1379
|
+ $input_name = 'input_' . $field->id; |
|
|
1380
|
+ $form_id = $form[ 'id' ]; |
|
1381
|
1381
|
|
|
1382
|
1382
|
$value = NULL; |
|
1383
|
1383
|
|
|
1384
|
1384
|
// Use the previous entry value as the default. |
|
1385
|
|
- if( isset( $entry[ $field->id ] ) ) { |
|
|
1385
|
+ if ( isset( $entry[ $field->id ] ) ) { |
|
1386
|
1386
|
$value = $entry[ $field->id ]; |
|
1387
|
1387
|
} |
|
1388
|
1388
|
|
|
1389
|
1389
|
// If this is a single upload file |
|
1390
|
|
- if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1391
|
|
- $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1392
|
|
- $value = $file_path['url']; |
|
|
1390
|
+ if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
|
1391
|
+ $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
|
1392
|
+ $value = $file_path[ 'url' ]; |
|
1393
|
1393
|
|
|
1394
|
1394
|
} else { |
|
1395
|
1395
|
|
|
1396
|
1396
|
// Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1397
|
1397
|
// Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1398
|
|
- $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
|
1398
|
+ $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1399
|
1399
|
|
|
1400
|
1400
|
} |
|
1401
|
1401
|
|
|
@@ -1403,10 +1403,10 @@ discard block |
|
|
block discarded – undo |
|
1403
|
1403
|
|
|
1404
|
1404
|
// If there are fresh uploads, process and merge them. |
|
1405
|
1405
|
// Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1406
|
|
- if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
|
1406
|
+ if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1407
|
1407
|
$value = empty( $value ) ? '[]' : $value; |
|
1408
|
1408
|
$value = stripslashes_deep( $value ); |
|
1409
|
|
- $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
|
1409
|
+ $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1410
|
1410
|
} |
|
1411
|
1411
|
|
|
1412
|
1412
|
} else { |
|
@@ -1424,8 +1424,8 @@ discard block |
|
|
block discarded – undo |
|
1424
|
1424
|
|
|
1425
|
1425
|
case 'number': |
|
1426
|
1426
|
// Fix "undefined index" issue at line 1286 in form_display.php |
|
1427
|
|
- if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1428
|
|
- $_POST['input_'.$field->id ] = NULL; |
|
|
1427
|
+ if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
|
1428
|
+ $_POST[ 'input_' . $field->id ] = NULL; |
|
1429
|
1429
|
} |
|
1430
|
1430
|
break; |
|
1431
|
1431
|
} |
|
@@ -1462,7 +1462,7 @@ discard block |
|
|
block discarded – undo |
|
1462
|
1462
|
* You can enter whatever you want! |
|
1463
|
1463
|
* We try validating, and customize the results using `self::custom_validation()` |
|
1464
|
1464
|
*/ |
|
1465
|
|
- add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
|
1465
|
+ add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1466
|
1466
|
|
|
1467
|
1467
|
// Needed by the validate funtion |
|
1468
|
1468
|
$failed_validation_page = NULL; |
|
@@ -1470,14 +1470,14 @@ discard block |
|
|
block discarded – undo |
|
1470
|
1470
|
|
|
1471
|
1471
|
// Prevent entry limit from running when editing an entry, also |
|
1472
|
1472
|
// prevent form scheduling from preventing editing |
|
1473
|
|
- unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
|
1473
|
+ unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1474
|
1474
|
|
|
1475
|
1475
|
// Hide fields depending on Edit Entry settings |
|
1476
|
|
- $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
|
1476
|
+ $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1477
|
1477
|
|
|
1478
|
1478
|
$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
|
1479
|
1479
|
|
|
1480
|
|
- remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
|
1480
|
+ remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1481
|
1481
|
} |
|
1482
|
1482
|
|
|
1483
|
1483
|
|
|
@@ -1500,7 +1500,7 @@ discard block |
|
|
block discarded – undo |
|
1500
|
1500
|
|
|
1501
|
1501
|
$gv_valid = true; |
|
1502
|
1502
|
|
|
1503
|
|
- foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
|
1503
|
+ foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1504
|
1504
|
|
|
1505
|
1505
|
$value = RGFormsModel::get_field_value( $field ); |
|
1506
|
1506
|
$field_type = RGFormsModel::get_input_type( $field ); |
|
@@ -1513,35 +1513,35 @@ discard block |
|
|
block discarded – undo |
|
1513
|
1513
|
case 'post_image': |
|
1514
|
1514
|
|
|
1515
|
1515
|
// in case nothing is uploaded but there are already files saved |
|
1516
|
|
- if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
|
1516
|
+ if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1517
|
1517
|
$field->failed_validation = false; |
|
1518
|
1518
|
unset( $field->validation_message ); |
|
1519
|
1519
|
} |
|
1520
|
1520
|
|
|
1521
|
1521
|
// validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1522
|
|
- if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
|
1522
|
+ if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1523
|
1523
|
|
|
1524
|
1524
|
$input_name = 'input_' . $field->id; |
|
1525
|
1525
|
//uploaded |
|
1526
|
|
- $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
|
1526
|
+ $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1527
|
1527
|
|
|
1528
|
1528
|
//existent |
|
1529
|
1529
|
$entry = $this->get_entry(); |
|
1530
|
1530
|
$value = NULL; |
|
1531
|
|
- if( isset( $entry[ $field->id ] ) ) { |
|
|
1531
|
+ if ( isset( $entry[ $field->id ] ) ) { |
|
1532
|
1532
|
$value = json_decode( $entry[ $field->id ], true ); |
|
1533
|
1533
|
} |
|
1534
|
1534
|
|
|
1535
|
1535
|
// count uploaded files and existent entry files |
|
1536
|
1536
|
$count_files = count( $file_names ) + count( $value ); |
|
1537
|
1537
|
|
|
1538
|
|
- if( $count_files > $field->maxFiles ) { |
|
|
1538
|
+ if ( $count_files > $field->maxFiles ) { |
|
1539
|
1539
|
$field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1540
|
1540
|
$field->failed_validation = 1; |
|
1541
|
1541
|
$gv_valid = false; |
|
1542
|
1542
|
|
|
1543
|
1543
|
// in case of error make sure the newest upload files are removed from the upload input |
|
1544
|
|
- GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
|
1544
|
+ GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1545
|
1545
|
} |
|
1546
|
1546
|
|
|
1547
|
1547
|
} |
|
@@ -1552,7 +1552,7 @@ discard block |
|
|
block discarded – undo |
|
1552
|
1552
|
} |
|
1553
|
1553
|
|
|
1554
|
1554
|
// This field has failed validation. |
|
1555
|
|
- if( !empty( $field->failed_validation ) ) { |
|
|
1555
|
+ if ( ! empty( $field->failed_validation ) ) { |
|
1556
|
1556
|
|
|
1557
|
1557
|
gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
|
1558
|
1558
|
|
|
@@ -1570,19 +1570,19 @@ discard block |
|
|
block discarded – undo |
|
1570
|
1570
|
} |
|
1571
|
1571
|
|
|
1572
|
1572
|
// You can't continue inside a switch, so we do it after. |
|
1573
|
|
- if( empty( $field->failed_validation ) ) { |
|
|
1573
|
+ if ( empty( $field->failed_validation ) ) { |
|
1574
|
1574
|
continue; |
|
1575
|
1575
|
} |
|
1576
|
1576
|
|
|
1577
|
1577
|
// checks if the No Duplicates option is not validating entry against itself, since |
|
1578
|
1578
|
// we're editing a stored entry, it would also assume it's a duplicate. |
|
1579
|
|
- if( !empty( $field->noDuplicates ) ) { |
|
|
1579
|
+ if ( ! empty( $field->noDuplicates ) ) { |
|
1580
|
1580
|
|
|
1581
|
1581
|
$entry = $this->get_entry(); |
|
1582
|
1582
|
|
|
1583
|
1583
|
// If the value of the entry is the same as the stored value |
|
1584
|
1584
|
// Then we can assume it's not a duplicate, it's the same. |
|
1585
|
|
- if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
|
1585
|
+ if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1586
|
1586
|
//if value submitted was not changed, then don't validate |
|
1587
|
1587
|
$field->failed_validation = false; |
|
1588
|
1588
|
|
|
@@ -1595,7 +1595,7 @@ discard block |
|
|
block discarded – undo |
|
1595
|
1595
|
} |
|
1596
|
1596
|
|
|
1597
|
1597
|
// if here then probably we are facing the validation 'At least one field must be filled out' |
|
1598
|
|
- if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
|
1598
|
+ if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1599
|
1599
|
unset( $field->validation_message ); |
|
1600
|
1600
|
$field->validation_message = false; |
|
1601
|
1601
|
continue; |
|
@@ -1607,12 +1607,12 @@ discard block |
|
|
block discarded – undo |
|
1607
|
1607
|
|
|
1608
|
1608
|
} |
|
1609
|
1609
|
|
|
1610
|
|
- $validation_results['is_valid'] = $gv_valid; |
|
|
1610
|
+ $validation_results[ 'is_valid' ] = $gv_valid; |
|
1611
|
1611
|
|
|
1612
|
1612
|
gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
|
1613
|
1613
|
|
|
1614
|
1614
|
// We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
|
1615
|
|
- $this->form_after_validation = $validation_results['form']; |
|
|
1615
|
+ $this->form_after_validation = $validation_results[ 'form' ]; |
|
1616
|
1616
|
|
|
1617
|
1617
|
return $validation_results; |
|
1618
|
1618
|
} |
|
@@ -1625,7 +1625,7 @@ discard block |
|
|
block discarded – undo |
|
1625
|
1625
|
*/ |
|
1626
|
1626
|
public function get_entry() { |
|
1627
|
1627
|
|
|
1628
|
|
- if( empty( $this->entry ) ) { |
|
|
1628
|
+ if ( empty( $this->entry ) ) { |
|
1629
|
1629
|
// Get the database value of the entry that's being edited |
|
1630
|
1630
|
$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
|
1631
|
1631
|
} |
|
@@ -1657,10 +1657,10 @@ discard block |
|
|
block discarded – undo |
|
1657
|
1657
|
} |
|
1658
|
1658
|
|
|
1659
|
1659
|
// If edit tab not yet configured, show all fields |
|
1660
|
|
- $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
|
1660
|
+ $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1661
|
1661
|
|
|
1662
|
1662
|
// Hide fields depending on admin settings |
|
1663
|
|
- $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
|
1663
|
+ $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1664
|
1664
|
|
|
1665
|
1665
|
// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1666
|
1666
|
$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
@@ -1692,7 +1692,7 @@ discard block |
|
|
block discarded – undo |
|
1692
|
1692
|
*/ |
|
1693
|
1693
|
private function filter_fields( $fields, $configured_fields ) { |
|
1694
|
1694
|
|
|
1695
|
|
- if( empty( $fields ) || !is_array( $fields ) ) { |
|
|
1695
|
+ if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1696
|
1696
|
return $fields; |
|
1697
|
1697
|
} |
|
1698
|
1698
|
|
|
@@ -1705,18 +1705,18 @@ discard block |
|
|
block discarded – undo |
|
1705
|
1705
|
|
|
1706
|
1706
|
// Remove the fields that have calculation properties and keep them to be used later |
|
1707
|
1707
|
// @since 1.16.2 |
|
1708
|
|
- if( $field->has_calculation() ) { |
|
1709
|
|
- $this->fields_with_calculation[] = $field; |
|
|
1708
|
+ if ( $field->has_calculation() ) { |
|
|
1709
|
+ $this->fields_with_calculation[ ] = $field; |
|
1710
|
1710
|
// don't remove the calculation fields on form render. |
|
1711
|
1711
|
} |
|
1712
|
1712
|
|
|
1713
|
|
- if( in_array( $field->type, $field_type_blacklist ) ) { |
|
|
1713
|
+ if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1714
|
1714
|
unset( $fields[ $key ] ); |
|
1715
|
1715
|
} |
|
1716
|
1716
|
} |
|
1717
|
1717
|
|
|
1718
|
1718
|
// The Edit tab has not been configured, so we return all fields by default. |
|
1719
|
|
- if( empty( $configured_fields ) ) { |
|
|
1719
|
+ if ( empty( $configured_fields ) ) { |
|
1720
|
1720
|
return array_values( $fields ); |
|
1721
|
1721
|
} |
|
1722
|
1722
|
|
|
@@ -1725,8 +1725,8 @@ discard block |
|
|
block discarded – undo |
|
1725
|
1725
|
|
|
1726
|
1726
|
/** @var GF_Field $field */ |
|
1727
|
1727
|
foreach ( $fields as $field ) { |
|
1728
|
|
- if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1729
|
|
- $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
|
1728
|
+ if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
|
1729
|
+ $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1730
|
1730
|
break; |
|
1731
|
1731
|
} |
|
1732
|
1732
|
|
|
@@ -1749,14 +1749,14 @@ discard block |
|
|
block discarded – undo |
|
1749
|
1749
|
|
|
1750
|
1750
|
$return_field = $field; |
|
1751
|
1751
|
|
|
1752
|
|
- if( empty( $field_setting['show_label'] ) ) { |
|
|
1752
|
+ if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1753
|
1753
|
$return_field->label = ''; |
|
1754
|
|
- } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1755
|
|
- $return_field->label = $field_setting['custom_label']; |
|
|
1754
|
+ } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
|
1755
|
+ $return_field->label = $field_setting[ 'custom_label' ]; |
|
1756
|
1756
|
} |
|
1757
|
1757
|
|
|
1758
|
|
- if( !empty( $field_setting['custom_class'] ) ) { |
|
1759
|
|
- $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
|
1758
|
+ if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
|
1759
|
+ $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1760
|
1760
|
} |
|
1761
|
1761
|
|
|
1762
|
1762
|
/** |
|
@@ -1794,16 +1794,16 @@ discard block |
|
|
block discarded – undo |
|
1794
|
1794
|
*/ |
|
1795
|
1795
|
$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1796
|
1796
|
|
|
1797
|
|
- if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1798
|
|
- foreach( $fields as $k => $field ) { |
|
1799
|
|
- if( $field->adminOnly ) { |
|
|
1797
|
+ if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
|
1798
|
+ foreach ( $fields as $k => $field ) { |
|
|
1799
|
+ if ( $field->adminOnly ) { |
|
1800
|
1800
|
unset( $fields[ $k ] ); |
|
1801
|
1801
|
} |
|
1802
|
1802
|
} |
|
1803
|
1803
|
return array_values( $fields ); |
|
1804
|
1804
|
} |
|
1805
|
1805
|
|
|
1806
|
|
- foreach( $fields as &$field ) { |
|
|
1806
|
+ foreach ( $fields as &$field ) { |
|
1807
|
1807
|
$field->adminOnly = false; |
|
1808
|
1808
|
} |
|
1809
|
1809
|
|
|
@@ -1824,7 +1824,7 @@ discard block |
|
|
block discarded – undo |
|
1824
|
1824
|
*/ |
|
1825
|
1825
|
private function unselect_default_values( $form ) { |
|
1826
|
1826
|
|
|
1827
|
|
- foreach ( $form['fields'] as &$field ) { |
|
|
1827
|
+ foreach ( $form[ 'fields' ] as &$field ) { |
|
1828
|
1828
|
|
|
1829
|
1829
|
if ( empty( $field->choices ) ) { |
|
1830
|
1830
|
continue; |
|
@@ -1832,7 +1832,7 @@ discard block |
|
|
block discarded – undo |
|
1832
|
1832
|
|
|
1833
|
1833
|
foreach ( $field->choices as &$choice ) { |
|
1834
|
1834
|
if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
|
1835
|
|
- $choice['isSelected'] = false; |
|
|
1835
|
+ $choice[ 'isSelected' ] = false; |
|
1836
|
1836
|
} |
|
1837
|
1837
|
} |
|
1838
|
1838
|
} |
|
@@ -1857,22 +1857,22 @@ discard block |
|
|
block discarded – undo |
|
1857
|
1857
|
*/ |
|
1858
|
1858
|
function prefill_conditional_logic( $form ) { |
|
1859
|
1859
|
|
|
1860
|
|
- if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
|
1860
|
+ if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1861
|
1861
|
return $form; |
|
1862
|
1862
|
} |
|
1863
|
1863
|
|
|
1864
|
1864
|
// Have Conditional Logic pre-fill fields as if the data were default values |
|
1865
|
1865
|
/** @var GF_Field $field */ |
|
1866
|
|
- foreach ( $form['fields'] as &$field ) { |
|
|
1866
|
+ foreach ( $form[ 'fields' ] as &$field ) { |
|
1867
|
1867
|
|
|
1868
|
|
- if( 'checkbox' === $field->type ) { |
|
|
1868
|
+ if ( 'checkbox' === $field->type ) { |
|
1869
|
1869
|
foreach ( $field->get_entry_inputs() as $key => $input ) { |
|
1870
|
|
- $input_id = $input['id']; |
|
|
1870
|
+ $input_id = $input[ 'id' ]; |
|
1871
|
1871
|
$choice = $field->choices[ $key ]; |
|
1872
|
1872
|
$value = \GV\Utils::get( $this->entry, $input_id ); |
|
1873
|
1873
|
$match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1874
|
|
- if( $match ) { |
|
1875
|
|
- $field->choices[ $key ]['isSelected'] = true; |
|
|
1874
|
+ if ( $match ) { |
|
|
1875
|
+ $field->choices[ $key ][ 'isSelected' ] = true; |
|
1876
|
1876
|
} |
|
1877
|
1877
|
} |
|
1878
|
1878
|
} else { |
|
@@ -1880,15 +1880,15 @@ discard block |
|
|
block discarded – undo |
|
1880
|
1880
|
// We need to run through each field to set the default values |
|
1881
|
1881
|
foreach ( $this->entry as $field_id => $field_value ) { |
|
1882
|
1882
|
|
|
1883
|
|
- if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
|
1883
|
+ if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1884
|
1884
|
|
|
1885
|
|
- if( 'list' === $field->type ) { |
|
|
1885
|
+ if ( 'list' === $field->type ) { |
|
1886
|
1886
|
$list_rows = maybe_unserialize( $field_value ); |
|
1887
|
1887
|
|
|
1888
|
1888
|
$list_field_value = array(); |
|
1889
|
|
- foreach ( (array) $list_rows as $row ) { |
|
1890
|
|
- foreach ( (array) $row as $column ) { |
|
1891
|
|
- $list_field_value[] = $column; |
|
|
1889
|
+ foreach ( (array)$list_rows as $row ) { |
|
|
1890
|
+ foreach ( (array)$row as $column ) { |
|
|
1891
|
+ $list_field_value[ ] = $column; |
|
1892
|
1892
|
} |
|
1893
|
1893
|
} |
|
1894
|
1894
|
|
|
@@ -1923,16 +1923,16 @@ discard block |
|
|
block discarded – undo |
|
1923
|
1923
|
*/ |
|
1924
|
1924
|
$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
|
1925
|
1925
|
|
|
1926
|
|
- if( $use_conditional_logic ) { |
|
|
1926
|
+ if ( $use_conditional_logic ) { |
|
1927
|
1927
|
return $form; |
|
1928
|
1928
|
} |
|
1929
|
1929
|
|
|
1930
|
|
- foreach( $form['fields'] as &$field ) { |
|
|
1930
|
+ foreach ( $form[ 'fields' ] as &$field ) { |
|
1931
|
1931
|
/* @var GF_Field $field */ |
|
1932
|
1932
|
$field->conditionalLogic = null; |
|
1933
|
1933
|
} |
|
1934
|
1934
|
|
|
1935
|
|
- unset( $form['button']['conditionalLogic'] ); |
|
|
1935
|
+ unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1936
|
1936
|
|
|
1937
|
1937
|
return $form; |
|
1938
|
1938
|
|
|
@@ -1949,7 +1949,7 @@ discard block |
|
|
block discarded – undo |
|
1949
|
1949
|
*/ |
|
1950
|
1950
|
public function manage_conditional_logic( $has_conditional_logic, $form ) { |
|
1951
|
1951
|
|
|
1952
|
|
- if( ! $this->is_edit_entry() ) { |
|
|
1952
|
+ if ( ! $this->is_edit_entry() ) { |
|
1953
|
1953
|
return $has_conditional_logic; |
|
1954
|
1954
|
} |
|
1955
|
1955
|
|
|
@@ -1981,44 +1981,44 @@ discard block |
|
|
block discarded – undo |
|
1981
|
1981
|
* 2. There are two entries embedded using oEmbed |
|
1982
|
1982
|
* 3. One of the entries has just been saved |
|
1983
|
1983
|
*/ |
|
1984
|
|
- if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
|
1984
|
+ if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1985
|
1985
|
|
|
1986
|
1986
|
$error = true; |
|
1987
|
1987
|
|
|
1988
|
1988
|
} |
|
1989
|
1989
|
|
|
1990
|
|
- if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
|
1990
|
+ if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1991
|
1991
|
|
|
1992
|
1992
|
$error = true; |
|
1993
|
1993
|
|
|
1994
|
|
- } elseif( ! $this->verify_nonce() ) { |
|
|
1994
|
+ } elseif ( ! $this->verify_nonce() ) { |
|
1995
|
1995
|
|
|
1996
|
1996
|
/** |
|
1997
|
1997
|
* If the Entry is embedded, there may be two entries on the same page. |
|
1998
|
1998
|
* If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
|
1999
|
1999
|
*/ |
|
2000
|
|
- if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
|
2000
|
+ if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2001
|
2001
|
$error = true; |
|
2002
|
2002
|
} else { |
|
2003
|
|
- $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
|
2003
|
+ $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
2004
|
2004
|
} |
|
2005
|
2005
|
|
|
2006
|
2006
|
} |
|
2007
|
2007
|
|
|
2008
|
|
- if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2009
|
|
- $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
|
2008
|
+ if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
|
2009
|
+ $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
2010
|
2010
|
} |
|
2011
|
2011
|
|
|
2012
|
|
- if( $this->entry['status'] === 'trash' ) { |
|
2013
|
|
- $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
|
2012
|
+ if ( $this->entry[ 'status' ] === 'trash' ) { |
|
|
2013
|
+ $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2014
|
2014
|
} |
|
2015
|
2015
|
|
|
2016
|
2016
|
// No errors; everything's fine here! |
|
2017
|
|
- if( empty( $error ) ) { |
|
|
2017
|
+ if ( empty( $error ) ) { |
|
2018
|
2018
|
return true; |
|
2019
|
2019
|
} |
|
2020
|
2020
|
|
|
2021
|
|
- if( $echo && $error !== true ) { |
|
|
2021
|
+ if ( $echo && $error !== true ) { |
|
2022
|
2022
|
|
|
2023
|
2023
|
$error = esc_html( $error ); |
|
2024
|
2024
|
|
|
@@ -2026,10 +2026,10 @@ discard block |
|
|
block discarded – undo |
|
2026
|
2026
|
* @since 1.9 |
|
2027
|
2027
|
*/ |
|
2028
|
2028
|
if ( ! empty( $this->entry ) ) { |
|
2029
|
|
- $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;" ) ); |
|
|
2029
|
+ $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;" ) ); |
|
2030
|
2030
|
} |
|
2031
|
2031
|
|
|
2032
|
|
- echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
|
2032
|
+ echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
2033
|
2033
|
} |
|
2034
|
2034
|
|
|
2035
|
2035
|
gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
|
@@ -2049,17 +2049,17 @@ discard block |
|
|
block discarded – undo |
|
2049
|
2049
|
|
|
2050
|
2050
|
$error = NULL; |
|
2051
|
2051
|
|
|
2052
|
|
- if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2053
|
|
- $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
|
2052
|
+ if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
|
2053
|
+ $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2054
|
2054
|
} |
|
2055
|
2055
|
|
|
2056
|
2056
|
// No errors; everything's fine here! |
|
2057
|
|
- if( empty( $error ) ) { |
|
|
2057
|
+ if ( empty( $error ) ) { |
|
2058
|
2058
|
return true; |
|
2059
|
2059
|
} |
|
2060
|
2060
|
|
|
2061
|
|
- if( $echo ) { |
|
2062
|
|
- echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
|
2061
|
+ if ( $echo ) { |
|
|
2062
|
+ echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2063
|
2063
|
} |
|
2064
|
2064
|
|
|
2065
|
2065
|
gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
|
@@ -2080,14 +2080,14 @@ discard block |
|
|
block discarded – undo |
|
2080
|
2080
|
private function check_user_cap_edit_field( $field ) { |
|
2081
|
2081
|
|
|
2082
|
2082
|
// If they can edit any entries (as defined in Gravity Forms), we're good. |
|
2083
|
|
- if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
|
2083
|
+ if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2084
|
2084
|
return true; |
|
2085
|
2085
|
} |
|
2086
|
2086
|
|
|
2087
|
|
- $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
|
2087
|
+ $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2088
|
2088
|
|
|
2089
|
|
- if( $field_cap ) { |
|
2090
|
|
- return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
|
2089
|
+ if ( $field_cap ) { |
|
|
2090
|
+ return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2091
|
2091
|
} |
|
2092
|
2092
|
|
|
2093
|
2093
|
return false; |
|
@@ -2101,17 +2101,17 @@ discard block |
|
|
block discarded – undo |
|
2101
|
2101
|
public function verify_nonce() { |
|
2102
|
2102
|
|
|
2103
|
2103
|
// Verify form submitted for editing single |
|
2104
|
|
- if( $this->is_edit_entry_submission() ) { |
|
|
2104
|
+ if ( $this->is_edit_entry_submission() ) { |
|
2105
|
2105
|
$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
|
2106
|
2106
|
} |
|
2107
|
2107
|
|
|
2108
|
2108
|
// Verify |
|
2109
|
|
- else if( ! $this->is_edit_entry() ) { |
|
|
2109
|
+ else if ( ! $this->is_edit_entry() ) { |
|
2110
|
2110
|
$valid = false; |
|
2111
|
2111
|
} |
|
2112
|
2112
|
|
|
2113
|
2113
|
else { |
|
2114
|
|
- $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
|
2114
|
+ $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2115
|
2115
|
} |
|
2116
|
2116
|
|
|
2117
|
2117
|
/** |