@@ -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,16 +208,16 @@ 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(); |
| 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 |
||
| 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,15 +321,15 @@ 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 | /** |
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -525,27 +525,27 @@ discard block |
||
| 525 | 525 | $form = $this->form; |
| 526 | 526 | |
| 527 | 527 | /** @var GF_Field $field */ |
| 528 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 528 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 529 | 529 | |
| 530 | 530 | /** |
| 531 | 531 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 532 | 532 | * @since 1.16.3 |
| 533 | 533 | * @var GF_Field $field |
| 534 | 534 | */ |
| 535 | - if( $field->has_calculation() ) { |
|
| 536 | - unset( $form['fields'][ $k ] ); |
|
| 535 | + if ( $field->has_calculation() ) { |
|
| 536 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | $field->adminOnly = false; |
| 540 | 540 | |
| 541 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 542 | - foreach( $field->inputs as $key => $input ) { |
|
| 543 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 541 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 542 | + foreach ( $field->inputs as $key => $input ) { |
|
| 543 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 548 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 549 | 549 | |
| 550 | 550 | return $form; |
| 551 | 551 | } |
@@ -557,14 +557,14 @@ discard block |
||
| 557 | 557 | $update = false; |
| 558 | 558 | |
| 559 | 559 | // get the most up to date entry values |
| 560 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 560 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 561 | 561 | |
| 562 | 562 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 563 | 563 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 564 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 564 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 565 | 565 | } else { |
| 566 | 566 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 567 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 567 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -576,24 +576,24 @@ discard block |
||
| 576 | 576 | $inputs = $field->get_entry_inputs(); |
| 577 | 577 | if ( is_array( $inputs ) ) { |
| 578 | 578 | foreach ( $inputs as $input ) { |
| 579 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
| 579 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
| 580 | 580 | |
| 581 | 581 | if ( 'product' === $field->type ) { |
| 582 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 582 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 583 | 583 | |
| 584 | 584 | // Only allow quantity to be set if it's allowed to be edited |
| 585 | 585 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 586 | 586 | } else { // otherwise set to what it previously was |
| 587 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 587 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 588 | 588 | } |
| 589 | 589 | } else { |
| 590 | 590 | // Set to what it previously was if it's not editable |
| 591 | 591 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
| 592 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 592 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 596 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
| 597 | 597 | } |
| 598 | 598 | } else { |
| 599 | 599 | // Set to what it previously was if it's not editable |
@@ -633,19 +633,19 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | $input_name = 'input_' . $field_id; |
| 635 | 635 | |
| 636 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 636 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 637 | 637 | |
| 638 | 638 | // We have a new image |
| 639 | 639 | |
| 640 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 640 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 641 | 641 | |
| 642 | 642 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 643 | 643 | $ary = stripslashes_deep( $ary ); |
| 644 | 644 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 645 | 645 | |
| 646 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 647 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 648 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 646 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 647 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 648 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 649 | 649 | |
| 650 | 650 | $image_meta = array( |
| 651 | 651 | 'post_excerpt' => $img_caption, |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 656 | 656 | if ( ! empty( $img_title ) ) { |
| 657 | - $image_meta['post_title'] = $img_title; |
|
| 657 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -712,15 +712,15 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | private function maybe_update_post_fields( $form ) { |
| 714 | 714 | |
| 715 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 715 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 716 | 716 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 717 | 717 | return; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - $post_id = $this->entry['post_id']; |
|
| 720 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 721 | 721 | |
| 722 | 722 | // Security check |
| 723 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 723 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 724 | 724 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 725 | 725 | return; |
| 726 | 726 | } |
@@ -733,25 +733,25 @@ discard block |
||
| 733 | 733 | |
| 734 | 734 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 735 | 735 | |
| 736 | - if( ! $field ) { |
|
| 736 | + if ( ! $field ) { |
|
| 737 | 737 | continue; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 740 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 741 | 741 | |
| 742 | 742 | // Get the value of the field, including $_POSTed value |
| 743 | 743 | $value = RGFormsModel::get_field_value( $field ); |
| 744 | 744 | |
| 745 | 745 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 746 | 746 | $entry_tmp = $this->entry; |
| 747 | - $entry_tmp["{$field_id}"] = $value; |
|
| 747 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 748 | 748 | |
| 749 | - switch( $field->type ) { |
|
| 749 | + switch ( $field->type ) { |
|
| 750 | 750 | |
| 751 | 751 | case 'post_title': |
| 752 | 752 | $post_title = $value; |
| 753 | 753 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 754 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 754 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 755 | 755 | } |
| 756 | 756 | $updated_post->post_title = $post_title; |
| 757 | 757 | $updated_post->post_name = $post_title; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | case 'post_content': |
| 762 | 762 | $post_content = $value; |
| 763 | 763 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 764 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 764 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 765 | 765 | } |
| 766 | 766 | $updated_post->post_content = $post_content; |
| 767 | 767 | unset( $post_content ); |
@@ -779,11 +779,11 @@ discard block |
||
| 779 | 779 | $value = $value[ $field_id ]; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 782 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 783 | 783 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
| 786 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
| 787 | 787 | |
| 788 | 788 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
| 789 | 789 | break; |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | // update entry after |
| 798 | - $this->entry["{$field_id}"] = $value; |
|
| 798 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 799 | 799 | |
| 800 | 800 | $update_entry = true; |
| 801 | 801 | |
@@ -804,11 +804,11 @@ discard block |
||
| 804 | 804 | |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - if( $update_entry ) { |
|
| 807 | + if ( $update_entry ) { |
|
| 808 | 808 | |
| 809 | 809 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 810 | 810 | |
| 811 | - if( is_wp_error( $return_entry ) ) { |
|
| 811 | + if ( is_wp_error( $return_entry ) ) { |
|
| 812 | 812 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 813 | 813 | } else { |
| 814 | 814 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | $return_post = wp_update_post( $updated_post, true ); |
| 820 | 820 | |
| 821 | - if( is_wp_error( $return_post ) ) { |
|
| 821 | + if ( is_wp_error( $return_post ) ) { |
|
| 822 | 822 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 823 | 823 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 824 | 824 | } else { |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 853 | 853 | |
| 854 | 854 | // replace conditional shortcodes |
| 855 | - if( $do_shortcode ) { |
|
| 855 | + if ( $do_shortcode ) { |
|
| 856 | 856 | $output = do_shortcode( $output ); |
| 857 | 857 | } |
| 858 | 858 | |
@@ -871,19 +871,19 @@ discard block |
||
| 871 | 871 | */ |
| 872 | 872 | private function after_update() { |
| 873 | 873 | |
| 874 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 875 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 874 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 875 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 876 | 876 | |
| 877 | 877 | // Re-define the entry now that we've updated it. |
| 878 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 878 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 879 | 879 | |
| 880 | 880 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
| 881 | 881 | |
| 882 | 882 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 883 | 883 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 884 | 884 | // we have just updated. |
| 885 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 886 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 885 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 886 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | |
| 903 | 903 | <div class="gv-edit-entry-wrapper"><?php |
| 904 | 904 | |
| 905 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 905 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 906 | 906 | |
| 907 | 907 | /** |
| 908 | 908 | * Fixes weird wpautop() issue |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 919 | 919 | * @param GravityView_Edit_Entry_Render $this This object |
| 920 | 920 | */ |
| 921 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 921 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 922 | 922 | |
| 923 | 923 | echo esc_attr( $edit_entry_title ); |
| 924 | 924 | ?></span> |
@@ -968,13 +968,13 @@ discard block |
||
| 968 | 968 | |
| 969 | 969 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 970 | 970 | |
| 971 | - if( ! $this->is_valid ){ |
|
| 971 | + if ( ! $this->is_valid ) { |
|
| 972 | 972 | |
| 973 | 973 | // Keeping this compatible with Gravity Forms. |
| 974 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 975 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 974 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 975 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 976 | 976 | |
| 977 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 977 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 978 | 978 | |
| 979 | 979 | } else { |
| 980 | 980 | $view = \GV\View::by_id( $this->view_id ); |
@@ -985,23 +985,23 @@ discard block |
||
| 985 | 985 | |
| 986 | 986 | case '0': |
| 987 | 987 | $redirect_url = $back_link; |
| 988 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 988 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
| 989 | 989 | break; |
| 990 | 990 | |
| 991 | 991 | case '1': |
| 992 | 992 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
| 993 | - $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>' ); |
|
| 993 | + $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>' ); |
|
| 994 | 994 | break; |
| 995 | 995 | |
| 996 | 996 | case '2': |
| 997 | 997 | $redirect_url = $edit_redirect_url; |
| 998 | 998 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
| 999 | - $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>' ); |
|
| 999 | + $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>' ); |
|
| 1000 | 1000 | break; |
| 1001 | 1001 | |
| 1002 | 1002 | case '': |
| 1003 | 1003 | default: |
| 1004 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1004 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 1005 | 1005 | break; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | * @param array $entry Gravity Forms entry array |
| 1018 | 1018 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 1019 | 1019 | */ |
| 1020 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 1020 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 1021 | 1021 | |
| 1022 | 1022 | echo GVCommon::generate_notice( $message ); |
| 1023 | 1023 | } |
@@ -1041,21 +1041,21 @@ discard block |
||
| 1041 | 1041 | */ |
| 1042 | 1042 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1043 | 1043 | |
| 1044 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1045 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1044 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1045 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1046 | 1046 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1047 | 1047 | |
| 1048 | 1048 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1049 | 1049 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1050 | 1050 | |
| 1051 | 1051 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1052 | - unset( $_GET['page'] ); |
|
| 1052 | + unset( $_GET[ 'page' ] ); |
|
| 1053 | 1053 | |
| 1054 | 1054 | // TODO: Verify multiple-page forms |
| 1055 | 1055 | |
| 1056 | 1056 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1057 | 1057 | |
| 1058 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1058 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1059 | 1059 | |
| 1060 | 1060 | ob_get_clean(); |
| 1061 | 1061 | |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | * @return string |
| 1082 | 1082 | */ |
| 1083 | 1083 | public function render_form_buttons() { |
| 1084 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1084 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | |
@@ -1101,10 +1101,10 @@ discard block |
||
| 1101 | 1101 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1102 | 1102 | |
| 1103 | 1103 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1104 | - if( isset( $this->form_after_validation ) ) { |
|
| 1104 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1105 | 1105 | $form = $this->form_after_validation; |
| 1106 | 1106 | } else { |
| 1107 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1107 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | $form = $this->filter_conditional_logic( $form ); |
@@ -1112,8 +1112,8 @@ discard block |
||
| 1112 | 1112 | $form = $this->prefill_conditional_logic( $form ); |
| 1113 | 1113 | |
| 1114 | 1114 | // for now we don't support Save and Continue feature. |
| 1115 | - if( ! self::$supports_save_and_continue ) { |
|
| 1116 | - unset( $form['save'] ); |
|
| 1115 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1116 | + unset( $form[ 'save' ] ); |
|
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | $form = $this->unselect_default_values( $form ); |
@@ -1136,31 +1136,31 @@ discard block |
||
| 1136 | 1136 | */ |
| 1137 | 1137 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1138 | 1138 | |
| 1139 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1139 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1140 | 1140 | return $field_content; |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | $message = null; |
| 1144 | 1144 | |
| 1145 | 1145 | // First, make sure they have the capability to edit the post. |
| 1146 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1146 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1147 | 1147 | |
| 1148 | 1148 | /** |
| 1149 | 1149 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1150 | 1150 | * @param string $message The existing "You don't have permission..." text |
| 1151 | 1151 | */ |
| 1152 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1152 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1153 | 1153 | |
| 1154 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1154 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1155 | 1155 | /** |
| 1156 | 1156 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1157 | 1157 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1158 | 1158 | */ |
| 1159 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1159 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | - if( $message ) { |
|
| 1163 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1162 | + if ( $message ) { |
|
| 1163 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | return $field_content; |
@@ -1184,8 +1184,8 @@ discard block |
||
| 1184 | 1184 | |
| 1185 | 1185 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1186 | 1186 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1187 | - if( |
|
| 1188 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1187 | + if ( |
|
| 1188 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1189 | 1189 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1190 | 1190 | && ! GFCommon::is_product_field( $field->type ) |
| 1191 | 1191 | || ! empty( $field_content ) |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | $return = null; |
| 1206 | 1206 | |
| 1207 | 1207 | /** @var GravityView_Field $gv_field */ |
| 1208 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1208 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1209 | 1209 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1210 | 1210 | } else { |
| 1211 | 1211 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | // If there was output, it's an error |
| 1215 | 1215 | $warnings = ob_get_clean(); |
| 1216 | 1216 | |
| 1217 | - if( !empty( $warnings ) ) { |
|
| 1217 | + if ( ! empty( $warnings ) ) { |
|
| 1218 | 1218 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1219 | 1219 | } |
| 1220 | 1220 | |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1240 | 1240 | |
| 1241 | 1241 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1242 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1242 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1243 | 1243 | |
| 1244 | 1244 | $field_value = array(); |
| 1245 | 1245 | |
@@ -1248,10 +1248,10 @@ discard block |
||
| 1248 | 1248 | |
| 1249 | 1249 | foreach ( (array)$field->inputs as $input ) { |
| 1250 | 1250 | |
| 1251 | - $input_id = strval( $input['id'] ); |
|
| 1251 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1252 | 1252 | |
| 1253 | 1253 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1254 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1254 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1255 | 1255 | $allow_pre_populated = false; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -1259,7 +1259,7 @@ discard block |
||
| 1259 | 1259 | |
| 1260 | 1260 | $pre_value = $field->get_value_submission( array(), false ); |
| 1261 | 1261 | |
| 1262 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1262 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1263 | 1263 | |
| 1264 | 1264 | } else { |
| 1265 | 1265 | |
@@ -1270,13 +1270,13 @@ discard block |
||
| 1270 | 1270 | |
| 1271 | 1271 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1272 | 1272 | // or pre-populated value if not empty and set to override saved value |
| 1273 | - $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; |
|
| 1273 | + $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; |
|
| 1274 | 1274 | |
| 1275 | 1275 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1276 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1276 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1277 | 1277 | $categories = array(); |
| 1278 | 1278 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1279 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1279 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1282 | 1282 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
| 1304 | 1304 | * @param GF_Field $field Gravity Forms field object |
| 1305 | 1305 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1306 | 1306 | */ |
| 1307 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1307 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1308 | 1308 | |
| 1309 | 1309 | return $field_value; |
| 1310 | 1310 | } |
@@ -1321,12 +1321,12 @@ discard block |
||
| 1321 | 1321 | */ |
| 1322 | 1322 | public function gform_pre_validation( $form ) { |
| 1323 | 1323 | |
| 1324 | - if( ! $this->verify_nonce() ) { |
|
| 1324 | + if ( ! $this->verify_nonce() ) { |
|
| 1325 | 1325 | return $form; |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | 1328 | // Fix PHP warning regarding undefined index. |
| 1329 | - foreach ( $form['fields'] as &$field) { |
|
| 1329 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1330 | 1330 | |
| 1331 | 1331 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1332 | 1332 | // expects certain field array items to be set. |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1337 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1338 | 1338 | |
| 1339 | 1339 | /** |
| 1340 | 1340 | * 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. |
@@ -1348,26 +1348,26 @@ discard block |
||
| 1348 | 1348 | // Set the previous value |
| 1349 | 1349 | $entry = $this->get_entry(); |
| 1350 | 1350 | |
| 1351 | - $input_name = 'input_'.$field->id; |
|
| 1352 | - $form_id = $form['id']; |
|
| 1351 | + $input_name = 'input_' . $field->id; |
|
| 1352 | + $form_id = $form[ 'id' ]; |
|
| 1353 | 1353 | |
| 1354 | 1354 | $value = NULL; |
| 1355 | 1355 | |
| 1356 | 1356 | // Use the previous entry value as the default. |
| 1357 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1357 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1358 | 1358 | $value = $entry[ $field->id ]; |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | // If this is a single upload file |
| 1362 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1363 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1364 | - $value = $file_path['url']; |
|
| 1362 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1363 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1364 | + $value = $file_path[ 'url' ]; |
|
| 1365 | 1365 | |
| 1366 | 1366 | } else { |
| 1367 | 1367 | |
| 1368 | 1368 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1369 | 1369 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1370 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1370 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1371 | 1371 | |
| 1372 | 1372 | } |
| 1373 | 1373 | |
@@ -1375,10 +1375,10 @@ discard block |
||
| 1375 | 1375 | |
| 1376 | 1376 | // If there are fresh uploads, process and merge them. |
| 1377 | 1377 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1378 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1378 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1379 | 1379 | $value = empty( $value ) ? '[]' : $value; |
| 1380 | 1380 | $value = stripslashes_deep( $value ); |
| 1381 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1381 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | } else { |
@@ -1396,8 +1396,8 @@ discard block |
||
| 1396 | 1396 | |
| 1397 | 1397 | case 'number': |
| 1398 | 1398 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1399 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1400 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1399 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1400 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1401 | 1401 | } |
| 1402 | 1402 | break; |
| 1403 | 1403 | } |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | * You can enter whatever you want! |
| 1435 | 1435 | * We try validating, and customize the results using `self::custom_validation()` |
| 1436 | 1436 | */ |
| 1437 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1437 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1438 | 1438 | |
| 1439 | 1439 | // Needed by the validate funtion |
| 1440 | 1440 | $failed_validation_page = NULL; |
@@ -1442,14 +1442,14 @@ discard block |
||
| 1442 | 1442 | |
| 1443 | 1443 | // Prevent entry limit from running when editing an entry, also |
| 1444 | 1444 | // prevent form scheduling from preventing editing |
| 1445 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1445 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1446 | 1446 | |
| 1447 | 1447 | // Hide fields depending on Edit Entry settings |
| 1448 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1448 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1449 | 1449 | |
| 1450 | 1450 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1451 | 1451 | |
| 1452 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1452 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | |
@@ -1472,7 +1472,7 @@ discard block |
||
| 1472 | 1472 | |
| 1473 | 1473 | $gv_valid = true; |
| 1474 | 1474 | |
| 1475 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1475 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1476 | 1476 | |
| 1477 | 1477 | $value = RGFormsModel::get_field_value( $field ); |
| 1478 | 1478 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1485,35 +1485,35 @@ discard block |
||
| 1485 | 1485 | case 'post_image': |
| 1486 | 1486 | |
| 1487 | 1487 | // in case nothing is uploaded but there are already files saved |
| 1488 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1488 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1489 | 1489 | $field->failed_validation = false; |
| 1490 | 1490 | unset( $field->validation_message ); |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1494 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1494 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1495 | 1495 | |
| 1496 | 1496 | $input_name = 'input_' . $field->id; |
| 1497 | 1497 | //uploaded |
| 1498 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1498 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1499 | 1499 | |
| 1500 | 1500 | //existent |
| 1501 | 1501 | $entry = $this->get_entry(); |
| 1502 | 1502 | $value = NULL; |
| 1503 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1503 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1504 | 1504 | $value = json_decode( $entry[ $field->id ], true ); |
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | // count uploaded files and existent entry files |
| 1508 | 1508 | $count_files = count( $file_names ) + count( $value ); |
| 1509 | 1509 | |
| 1510 | - if( $count_files > $field->maxFiles ) { |
|
| 1510 | + if ( $count_files > $field->maxFiles ) { |
|
| 1511 | 1511 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1512 | 1512 | $field->failed_validation = 1; |
| 1513 | 1513 | $gv_valid = false; |
| 1514 | 1514 | |
| 1515 | 1515 | // in case of error make sure the newest upload files are removed from the upload input |
| 1516 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1516 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | } |
@@ -1524,7 +1524,7 @@ discard block |
||
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | // This field has failed validation. |
| 1527 | - if( !empty( $field->failed_validation ) ) { |
|
| 1527 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1528 | 1528 | |
| 1529 | 1529 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1530 | 1530 | |
@@ -1542,19 +1542,19 @@ discard block |
||
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | // You can't continue inside a switch, so we do it after. |
| 1545 | - if( empty( $field->failed_validation ) ) { |
|
| 1545 | + if ( empty( $field->failed_validation ) ) { |
|
| 1546 | 1546 | continue; |
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | 1549 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1550 | 1550 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1551 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1551 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1552 | 1552 | |
| 1553 | 1553 | $entry = $this->get_entry(); |
| 1554 | 1554 | |
| 1555 | 1555 | // If the value of the entry is the same as the stored value |
| 1556 | 1556 | // Then we can assume it's not a duplicate, it's the same. |
| 1557 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1557 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1558 | 1558 | //if value submitted was not changed, then don't validate |
| 1559 | 1559 | $field->failed_validation = false; |
| 1560 | 1560 | |
@@ -1567,7 +1567,7 @@ discard block |
||
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1570 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1570 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1571 | 1571 | unset( $field->validation_message ); |
| 1572 | 1572 | $field->validation_message = false; |
| 1573 | 1573 | continue; |
@@ -1579,12 +1579,12 @@ discard block |
||
| 1579 | 1579 | |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1582 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1583 | 1583 | |
| 1584 | 1584 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1585 | 1585 | |
| 1586 | 1586 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1587 | - $this->form_after_validation = $validation_results['form']; |
|
| 1587 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1588 | 1588 | |
| 1589 | 1589 | return $validation_results; |
| 1590 | 1590 | } |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | */ |
| 1598 | 1598 | public function get_entry() { |
| 1599 | 1599 | |
| 1600 | - if( empty( $this->entry ) ) { |
|
| 1600 | + if ( empty( $this->entry ) ) { |
|
| 1601 | 1601 | // Get the database value of the entry that's being edited |
| 1602 | 1602 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1603 | 1603 | } |
@@ -1629,10 +1629,10 @@ discard block |
||
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | // If edit tab not yet configured, show all fields |
| 1632 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1632 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1633 | 1633 | |
| 1634 | 1634 | // Hide fields depending on admin settings |
| 1635 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1635 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1636 | 1636 | |
| 1637 | 1637 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1638 | 1638 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1664,7 +1664,7 @@ discard block |
||
| 1664 | 1664 | */ |
| 1665 | 1665 | private function filter_fields( $fields, $configured_fields ) { |
| 1666 | 1666 | |
| 1667 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1667 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1668 | 1668 | return $fields; |
| 1669 | 1669 | } |
| 1670 | 1670 | |
@@ -1677,18 +1677,18 @@ discard block |
||
| 1677 | 1677 | |
| 1678 | 1678 | // Remove the fields that have calculation properties and keep them to be used later |
| 1679 | 1679 | // @since 1.16.2 |
| 1680 | - if( $field->has_calculation() ) { |
|
| 1681 | - $this->fields_with_calculation[] = $field; |
|
| 1680 | + if ( $field->has_calculation() ) { |
|
| 1681 | + $this->fields_with_calculation[ ] = $field; |
|
| 1682 | 1682 | // don't remove the calculation fields on form render. |
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1685 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1686 | 1686 | unset( $fields[ $key ] ); |
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | // The Edit tab has not been configured, so we return all fields by default. |
| 1691 | - if( empty( $configured_fields ) ) { |
|
| 1691 | + if ( empty( $configured_fields ) ) { |
|
| 1692 | 1692 | return array_values( $fields ); |
| 1693 | 1693 | } |
| 1694 | 1694 | |
@@ -1697,8 +1697,8 @@ discard block |
||
| 1697 | 1697 | |
| 1698 | 1698 | /** @var GF_Field $field */ |
| 1699 | 1699 | foreach ( $fields as $field ) { |
| 1700 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1701 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1700 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1701 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1702 | 1702 | break; |
| 1703 | 1703 | } |
| 1704 | 1704 | |
@@ -1721,14 +1721,14 @@ discard block |
||
| 1721 | 1721 | |
| 1722 | 1722 | $return_field = $field; |
| 1723 | 1723 | |
| 1724 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1724 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1725 | 1725 | $return_field->label = ''; |
| 1726 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1727 | - $return_field->label = $field_setting['custom_label']; |
|
| 1726 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1727 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1728 | 1728 | } |
| 1729 | 1729 | |
| 1730 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1731 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1730 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1731 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | 1734 | /** |
@@ -1766,16 +1766,16 @@ discard block |
||
| 1766 | 1766 | */ |
| 1767 | 1767 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1768 | 1768 | |
| 1769 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1770 | - foreach( $fields as $k => $field ) { |
|
| 1771 | - if( $field->adminOnly ) { |
|
| 1769 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1770 | + foreach ( $fields as $k => $field ) { |
|
| 1771 | + if ( $field->adminOnly ) { |
|
| 1772 | 1772 | unset( $fields[ $k ] ); |
| 1773 | 1773 | } |
| 1774 | 1774 | } |
| 1775 | 1775 | return array_values( $fields ); |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | - foreach( $fields as &$field ) { |
|
| 1778 | + foreach ( $fields as &$field ) { |
|
| 1779 | 1779 | $field->adminOnly = false; |
| 1780 | 1780 | } |
| 1781 | 1781 | |
@@ -1796,7 +1796,7 @@ discard block |
||
| 1796 | 1796 | */ |
| 1797 | 1797 | private function unselect_default_values( $form ) { |
| 1798 | 1798 | |
| 1799 | - foreach ( $form['fields'] as &$field ) { |
|
| 1799 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1800 | 1800 | |
| 1801 | 1801 | if ( empty( $field->choices ) ) { |
| 1802 | 1802 | continue; |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | |
| 1805 | 1805 | foreach ( $field->choices as &$choice ) { |
| 1806 | 1806 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1807 | - $choice['isSelected'] = false; |
|
| 1807 | + $choice[ 'isSelected' ] = false; |
|
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | 1810 | } |
@@ -1829,22 +1829,22 @@ discard block |
||
| 1829 | 1829 | */ |
| 1830 | 1830 | function prefill_conditional_logic( $form ) { |
| 1831 | 1831 | |
| 1832 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1832 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1833 | 1833 | return $form; |
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1837 | 1837 | /** @var GF_Field $field */ |
| 1838 | - foreach ( $form['fields'] as &$field ) { |
|
| 1838 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1839 | 1839 | |
| 1840 | - if( 'checkbox' === $field->type ) { |
|
| 1840 | + if ( 'checkbox' === $field->type ) { |
|
| 1841 | 1841 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1842 | - $input_id = $input['id']; |
|
| 1842 | + $input_id = $input[ 'id' ]; |
|
| 1843 | 1843 | $choice = $field->choices[ $key ]; |
| 1844 | 1844 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1845 | 1845 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1846 | - if( $match ) { |
|
| 1847 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1846 | + if ( $match ) { |
|
| 1847 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1848 | 1848 | } |
| 1849 | 1849 | } |
| 1850 | 1850 | } else { |
@@ -1852,15 +1852,15 @@ discard block |
||
| 1852 | 1852 | // We need to run through each field to set the default values |
| 1853 | 1853 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1854 | 1854 | |
| 1855 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1855 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1856 | 1856 | |
| 1857 | - if( 'list' === $field->type ) { |
|
| 1857 | + if ( 'list' === $field->type ) { |
|
| 1858 | 1858 | $list_rows = maybe_unserialize( $field_value ); |
| 1859 | 1859 | |
| 1860 | 1860 | $list_field_value = array(); |
| 1861 | - foreach ( (array) $list_rows as $row ) { |
|
| 1862 | - foreach ( (array) $row as $column ) { |
|
| 1863 | - $list_field_value[] = $column; |
|
| 1861 | + foreach ( (array)$list_rows as $row ) { |
|
| 1862 | + foreach ( (array)$row as $column ) { |
|
| 1863 | + $list_field_value[ ] = $column; |
|
| 1864 | 1864 | } |
| 1865 | 1865 | } |
| 1866 | 1866 | |
@@ -1895,16 +1895,16 @@ discard block |
||
| 1895 | 1895 | */ |
| 1896 | 1896 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1897 | 1897 | |
| 1898 | - if( $use_conditional_logic ) { |
|
| 1898 | + if ( $use_conditional_logic ) { |
|
| 1899 | 1899 | return $form; |
| 1900 | 1900 | } |
| 1901 | 1901 | |
| 1902 | - foreach( $form['fields'] as &$field ) { |
|
| 1902 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1903 | 1903 | /* @var GF_Field $field */ |
| 1904 | 1904 | $field->conditionalLogic = null; |
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1907 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1908 | 1908 | |
| 1909 | 1909 | return $form; |
| 1910 | 1910 | |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | */ |
| 1922 | 1922 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1923 | 1923 | |
| 1924 | - if( ! $this->is_edit_entry() ) { |
|
| 1924 | + if ( ! $this->is_edit_entry() ) { |
|
| 1925 | 1925 | return $has_conditional_logic; |
| 1926 | 1926 | } |
| 1927 | 1927 | |
@@ -1953,44 +1953,44 @@ discard block |
||
| 1953 | 1953 | * 2. There are two entries embedded using oEmbed |
| 1954 | 1954 | * 3. One of the entries has just been saved |
| 1955 | 1955 | */ |
| 1956 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1956 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1957 | 1957 | |
| 1958 | 1958 | $error = true; |
| 1959 | 1959 | |
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1962 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1963 | 1963 | |
| 1964 | 1964 | $error = true; |
| 1965 | 1965 | |
| 1966 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1966 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1967 | 1967 | |
| 1968 | 1968 | /** |
| 1969 | 1969 | * If the Entry is embedded, there may be two entries on the same page. |
| 1970 | 1970 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1971 | 1971 | */ |
| 1972 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1972 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1973 | 1973 | $error = true; |
| 1974 | 1974 | } else { |
| 1975 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1975 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1976 | 1976 | } |
| 1977 | 1977 | |
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1981 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1980 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1981 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1985 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1984 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1985 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | 1988 | // No errors; everything's fine here! |
| 1989 | - if( empty( $error ) ) { |
|
| 1989 | + if ( empty( $error ) ) { |
|
| 1990 | 1990 | return true; |
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | - if( $echo && $error !== true ) { |
|
| 1993 | + if ( $echo && $error !== true ) { |
|
| 1994 | 1994 | |
| 1995 | 1995 | $error = esc_html( $error ); |
| 1996 | 1996 | |
@@ -1998,10 +1998,10 @@ discard block |
||
| 1998 | 1998 | * @since 1.9 |
| 1999 | 1999 | */ |
| 2000 | 2000 | if ( ! empty( $this->entry ) ) { |
| 2001 | - $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;" ) ); |
|
| 2001 | + $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;" ) ); |
|
| 2002 | 2002 | } |
| 2003 | 2003 | |
| 2004 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2004 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | 2007 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2021,17 +2021,17 @@ discard block |
||
| 2021 | 2021 | |
| 2022 | 2022 | $error = NULL; |
| 2023 | 2023 | |
| 2024 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2025 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2024 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2025 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | // No errors; everything's fine here! |
| 2029 | - if( empty( $error ) ) { |
|
| 2029 | + if ( empty( $error ) ) { |
|
| 2030 | 2030 | return true; |
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | - if( $echo ) { |
|
| 2034 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2033 | + if ( $echo ) { |
|
| 2034 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2052,14 +2052,14 @@ discard block |
||
| 2052 | 2052 | private function check_user_cap_edit_field( $field ) { |
| 2053 | 2053 | |
| 2054 | 2054 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2055 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2055 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2056 | 2056 | return true; |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2059 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2060 | 2060 | |
| 2061 | - if( $field_cap ) { |
|
| 2062 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2061 | + if ( $field_cap ) { |
|
| 2062 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | 2065 | return false; |
@@ -2073,17 +2073,17 @@ discard block |
||
| 2073 | 2073 | public function verify_nonce() { |
| 2074 | 2074 | |
| 2075 | 2075 | // Verify form submitted for editing single |
| 2076 | - if( $this->is_edit_entry_submission() ) { |
|
| 2076 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2077 | 2077 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | // Verify |
| 2081 | - else if( ! $this->is_edit_entry() ) { |
|
| 2081 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2082 | 2082 | $valid = false; |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | else { |
| 2086 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2086 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2087 | 2087 | } |
| 2088 | 2088 | |
| 2089 | 2089 | /** |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | if ( 'address' === \GV\Utils::get( $search_field, 'type' ) ) { |
| 62 | 62 | |
| 63 | - $field_id = intval( floor( $search_field['key'] ) ); |
|
| 64 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] ); |
|
| 63 | + $field_id = intval( floor( $search_field[ 'key' ] ) ); |
|
| 64 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] ); |
|
| 65 | 65 | $form = GravityView_View::getInstance()->getForm(); |
| 66 | 66 | |
| 67 | 67 | /** @var GF_Field_Address $address_field */ |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $choices = array(); |
| 71 | 71 | |
| 72 | 72 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id ); |
| 73 | - if( method_exists( $this, $method_name ) ) { |
|
| 73 | + if ( method_exists( $this, $method_name ) ) { |
|
| 74 | 74 | /** |
| 75 | 75 | * @uses GravityView_Field_Address::get_choices_country() |
| 76 | 76 | * @uses GravityView_Field_Address::get_choices_state() |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | $choices = $this->{$method_name}( $address_field, $form ); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if( ! empty( $choices ) ) { |
|
| 82 | - $search_field['choices'] = $choices; |
|
| 83 | - $search_field['type'] = \GV\Utils::get( $search_field, 'input'); |
|
| 81 | + if ( ! empty( $choices ) ) { |
|
| 82 | + $search_field[ 'choices' ] = $choices; |
|
| 83 | + $search_field[ 'type' ] = \GV\Utils::get( $search_field, 'input' ); |
|
| 84 | 84 | } else { |
| 85 | - $search_field['type'] = 'text'; |
|
| 86 | - $search_field['input'] = 'input_text'; |
|
| 85 | + $search_field[ 'type' ] = 'text'; |
|
| 86 | + $search_field[ 'input' ] = 'input_text'; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $country_choices = array(); |
| 110 | 110 | |
| 111 | 111 | foreach ( $countries as $key => $country ) { |
| 112 | - $country_choices[] = array( |
|
| 112 | + $country_choices[ ] = array( |
|
| 113 | 113 | 'value' => $country, |
| 114 | 114 | 'text' => $country, |
| 115 | 115 | ); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function get_choices_state( $address_field, $form ) { |
| 136 | 136 | |
| 137 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType; |
|
| 137 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType; |
|
| 138 | 138 | |
| 139 | 139 | $state_choices = array(); |
| 140 | 140 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | $states = GFCommon::get_canadian_provinces(); |
| 147 | 147 | break; |
| 148 | 148 | default: |
| 149 | - $address_types = $address_field->get_address_types( $form['id'] ); |
|
| 150 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states']; |
|
| 149 | + $address_types = $address_field->get_address_types( $form[ 'id' ] ); |
|
| 150 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ]; |
|
| 151 | 151 | break; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | $state_subchoices = array(); |
| 157 | 157 | |
| 158 | 158 | foreach ( $state as $substate ) { |
| 159 | - $state_subchoices[] = array( |
|
| 159 | + $state_subchoices[ ] = array( |
|
| 160 | 160 | 'value' => $substate, |
| 161 | 161 | 'text' => $substate, |
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $state_choices[] = array( |
|
| 165 | + $state_choices[ ] = array( |
|
| 166 | 166 | 'text' => $key, |
| 167 | 167 | 'value' => $state_subchoices, |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | 170 | } else { |
| 171 | - $state_choices[] = array( |
|
| 171 | + $state_choices[ ] = array( |
|
| 172 | 172 | 'value' => $state, |
| 173 | 173 | 'text' => $state, |
| 174 | 174 | ); |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | // Use the same inputs as the "text" input type allows |
| 193 | 193 | $text_inputs = \GV\Utils::get( $input_types, 'text' ); |
| 194 | 194 | |
| 195 | - $input_types['street'] = $text_inputs; |
|
| 196 | - $input_types['street2'] = $text_inputs; |
|
| 197 | - $input_types['city'] = $text_inputs; |
|
| 195 | + $input_types[ 'street' ] = $text_inputs; |
|
| 196 | + $input_types[ 'street2' ] = $text_inputs; |
|
| 197 | + $input_types[ 'city' ] = $text_inputs; |
|
| 198 | 198 | |
| 199 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 200 | - $input_types['zip'] = array( 'input_text' ); |
|
| 201 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 199 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 200 | + $input_types[ 'zip' ] = array( 'input_text' ); |
|
| 201 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
| 202 | 202 | |
| 203 | 203 | return $input_types; |
| 204 | 204 | } |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)? |
| 220 | 220 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
| 221 | 221 | |
| 222 | - if( 'address' === $field_type && $input_id ) { |
|
| 222 | + if ( 'address' === $field_type && $input_id ) { |
|
| 223 | 223 | |
| 224 | 224 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type. |
| 225 | - if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
| 225 | + if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
| 226 | 226 | $input_type = $address_field_name; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -271,20 +271,20 @@ discard block |
||
| 271 | 271 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
| 272 | 272 | |
| 273 | 273 | // If this is NOT the full address field, return default options. |
| 274 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 274 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 275 | 275 | return $field_options; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if( 'edit' === $context ) { |
|
| 278 | + if ( 'edit' === $context ) { |
|
| 279 | 279 | return $field_options; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | $add_options = array(); |
| 283 | 283 | |
| 284 | - $add_options['show_map_link'] = array( |
|
| 284 | + $add_options[ 'show_map_link' ] = array( |
|
| 285 | 285 | 'type' => 'checkbox', |
| 286 | 286 | 'label' => __( 'Show Map Link:', 'gravityview' ), |
| 287 | - 'desc' => __('Display a "Map It" link below the address', 'gravityview'), |
|
| 287 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ), |
|
| 288 | 288 | 'value' => true, |
| 289 | 289 | 'merge_tags' => false, |
| 290 | 290 | ); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $supports = array( 'title', 'revisions' ); |
| 126 | 126 | |
| 127 | 127 | if ( $is_hierarchical ) { |
| 128 | - $supports[] = 'page-attributes'; |
|
| 128 | + $supports[ ] = 'page-attributes'; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -227,11 +227,11 @@ discard block |
||
| 227 | 227 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
| 228 | 228 | |
| 229 | 229 | add_filter( 'query_vars', function( $query_vars ) { |
| 230 | - $query_vars[] = 'csv'; |
|
| 230 | + $query_vars[ ] = 'csv'; |
|
| 231 | 231 | return $query_vars; |
| 232 | 232 | } ); |
| 233 | 233 | |
| 234 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
| 234 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
| 235 | 235 | call_user_func_array( 'add_rewrite_rule', $rule ); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | return $content; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 303 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 304 | 304 | |
| 305 | 305 | /** |
| 306 | 306 | * Editing a single entry. |
| 307 | 307 | */ |
| 308 | 308 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
| 309 | - if ( $entry['status'] != 'active' ) { |
|
| 309 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 310 | 310 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 311 | 311 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 312 | 312 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 320 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 320 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 321 | 321 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 322 | 322 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 323 | 323 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | foreach ( $entryset as $e ) { |
| 342 | 342 | |
| 343 | - if ( 'active' !== $e['status'] ) { |
|
| 343 | + if ( 'active' !== $e[ 'status' ] ) { |
|
| 344 | 344 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
| 345 | 345 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 346 | 346 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
| 354 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 354 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 355 | 355 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
| 356 | 356 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 357 | 357 | } |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
| 527 | 527 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
| 528 | 528 | |
| 529 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
| 529 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | return $joins; |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | foreach ( $_fields as $field ) { |
| 624 | - if ( ! empty( $field['unions'] ) ) { |
|
| 625 | - foreach ( $field['unions'] as $form_id => $field_id ) { |
|
| 624 | + if ( ! empty( $field[ 'unions' ] ) ) { |
|
| 625 | + foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
| 626 | 626 | if ( ! isset( $unions[ $form_id ] ) ) { |
| 627 | 627 | $unions[ $form_id ] = array(); |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - $unions[ $form_id ][ $field['id'] ] = |
|
| 630 | + $unions[ $form_id ][ $field[ 'id' ] ] = |
|
| 631 | 631 | is_numeric( $field_id ) ? \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
| 632 | 632 | } |
| 633 | 633 | } |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | if ( ! $view->form ) { |
| 677 | 677 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
| 678 | 678 | 'view_id' => $view->ID, |
| 679 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
| 679 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
| 680 | 680 | ) ); |
| 681 | 681 | } |
| 682 | 682 | |
@@ -911,43 +911,42 @@ discard block |
||
| 911 | 911 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
| 912 | 912 | */ |
| 913 | 913 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
| 914 | - $parameters['context_view_id'] = $this->ID; |
|
| 914 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
| 915 | 915 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
| 916 | 916 | |
| 917 | 917 | if ( $request instanceof REST\Request ) { |
| 918 | 918 | $atts = $this->settings->as_atts(); |
| 919 | 919 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
| 920 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
| 920 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
| 921 | 921 | ) ); |
| 922 | - $parameters['paging'] = $paging_parameters['paging']; |
|
| 922 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
| 926 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
| 925 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
| 927 | 926 | |
| 928 | 927 | /** |
| 929 | 928 | * Cleanup duplicate field_filter parameters to simplify the query. |
| 930 | 929 | */ |
| 931 | 930 | $unique_field_filters = array(); |
| 932 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
| 931 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
| 933 | 932 | if ( 'mode' === $key ) { |
| 934 | - $unique_field_filters['mode'] = $filter; |
|
| 933 | + $unique_field_filters[ 'mode' ] = $filter; |
|
| 935 | 934 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
| 936 | - $unique_field_filters[] = $filter; |
|
| 935 | + $unique_field_filters[ ] = $filter; |
|
| 937 | 936 | } |
| 938 | 937 | } |
| 939 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
| 938 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
| 940 | 939 | |
| 941 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
| 940 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 942 | 941 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
| 943 | 942 | } |
| 944 | 943 | |
| 945 | 944 | if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) { |
| 946 | 945 | $query_class = $this->get_query_class(); |
| 947 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
| 946 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
| 948 | 947 | |
| 949 | - $query->limit( $parameters['paging']['page_size'] ) |
|
| 950 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
| 948 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 949 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
| 951 | 950 | |
| 952 | 951 | /** |
| 953 | 952 | * Any joins? |
@@ -970,7 +969,7 @@ discard block |
||
| 970 | 969 | |
| 971 | 970 | $query_parameters = $query->_introspect(); |
| 972 | 971 | |
| 973 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
| 972 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
| 974 | 973 | } |
| 975 | 974 | |
| 976 | 975 | |
@@ -985,7 +984,7 @@ discard block |
||
| 985 | 984 | |
| 986 | 985 | $query_parameters = $query->_introspect(); |
| 987 | 986 | |
| 988 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
| 987 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
| 989 | 988 | } |
| 990 | 989 | } |
| 991 | 990 | |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | $conditions = array(); |
| 1010 | 1009 | |
| 1011 | 1010 | foreach ( $condition->expressions as $_condition ) { |
| 1012 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
| 1011 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
| 1013 | 1012 | } |
| 1014 | 1013 | |
| 1015 | 1014 | return call_user_func_array( |
@@ -1038,10 +1037,10 @@ discard block |
||
| 1038 | 1037 | $q = new $query_class( $form_id ); |
| 1039 | 1038 | |
| 1040 | 1039 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
| 1041 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
| 1040 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
| 1042 | 1041 | |
| 1043 | 1042 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
| 1044 | - foreach ( $query_parameters['order'] as $order ) { |
|
| 1043 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
| 1045 | 1044 | list( $column, $_order ) = $order; |
| 1046 | 1045 | |
| 1047 | 1046 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1055,15 +1054,15 @@ discard block |
||
| 1055 | 1054 | |
| 1056 | 1055 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
| 1057 | 1056 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
| 1058 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
| 1057 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
| 1059 | 1058 | |
| 1060 | 1059 | // Record the SQL |
| 1061 | - $unions_sql[] = array( |
|
| 1060 | + $unions_sql[ ] = array( |
|
| 1062 | 1061 | // Remove columns, we'll rebuild them |
| 1063 | 1062 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
| 1064 | - 'from' => $sql['from'], |
|
| 1065 | - 'join' => $sql['join'], |
|
| 1066 | - 'where' => $sql['where'], |
|
| 1063 | + 'from' => $sql[ 'from' ], |
|
| 1064 | + 'join' => $sql[ 'join' ], |
|
| 1065 | + 'where' => $sql[ 'where' ], |
|
| 1067 | 1066 | // Remove order and limit |
| 1068 | 1067 | ); |
| 1069 | 1068 | |
@@ -1080,11 +1079,11 @@ discard block |
||
| 1080 | 1079 | |
| 1081 | 1080 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
| 1082 | 1081 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
| 1083 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
| 1082 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
| 1084 | 1083 | |
| 1085 | 1084 | // Remove columns, we'll rebuild them |
| 1086 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
| 1087 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
| 1085 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
| 1086 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
| 1088 | 1087 | |
| 1089 | 1088 | $unions = array(); |
| 1090 | 1089 | |
@@ -1095,30 +1094,30 @@ discard block |
||
| 1095 | 1094 | }; |
| 1096 | 1095 | |
| 1097 | 1096 | // Add all the order columns into the selects, so we can order by the whole union group |
| 1098 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
| 1097 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
| 1099 | 1098 | |
| 1100 | 1099 | $columns = array( |
| 1101 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
| 1100 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
| 1102 | 1101 | ); |
| 1103 | 1102 | |
| 1104 | 1103 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
| 1105 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
| 1104 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
| 1106 | 1105 | |
| 1107 | 1106 | // Rewrite the order columns to the shared aliases |
| 1108 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
| 1107 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
| 1109 | 1108 | } |
| 1110 | 1109 | |
| 1111 | 1110 | $columns = array_unique( $columns ); |
| 1112 | 1111 | |
| 1113 | 1112 | // Add the columns to every UNION |
| 1114 | 1113 | foreach ( $unions_sql as $union_sql ) { |
| 1115 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
| 1116 | - $unions []= implode( ' ', $union_sql ); |
|
| 1114 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
| 1115 | + $unions [ ] = implode( ' ', $union_sql ); |
|
| 1117 | 1116 | } |
| 1118 | 1117 | |
| 1119 | 1118 | // Add the columns to the main SELECT, but only grab the entry id column |
| 1120 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
| 1121 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
| 1119 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
| 1120 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
| 1122 | 1121 | |
| 1123 | 1122 | return $sql; |
| 1124 | 1123 | } ); |
@@ -1159,15 +1158,15 @@ discard block |
||
| 1159 | 1158 | } ); |
| 1160 | 1159 | } else { |
| 1161 | 1160 | $entries = $this->form->entries |
| 1162 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
| 1161 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
| 1163 | 1162 | ->offset( $this->settings->get( 'offset' ) ) |
| 1164 | - ->limit( $parameters['paging']['page_size'] ) |
|
| 1163 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 1165 | 1164 | ->page( $page ); |
| 1166 | 1165 | |
| 1167 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
| 1166 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
| 1168 | 1167 | $field = new \GV\Field(); |
| 1169 | - $field->ID = $parameters['sorting']['key']; |
|
| 1170 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 1168 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
| 1169 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 1171 | 1170 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
| 1172 | 1171 | } |
| 1173 | 1172 | } |
@@ -1238,7 +1237,7 @@ discard block |
||
| 1238 | 1237 | $allowed = $headers = array(); |
| 1239 | 1238 | |
| 1240 | 1239 | foreach ( $view->fields->by_position( "directory_*" )->by_visible()->all() as $id => $field ) { |
| 1241 | - $allowed[] = $field; |
|
| 1240 | + $allowed[ ] = $field; |
|
| 1242 | 1241 | } |
| 1243 | 1242 | |
| 1244 | 1243 | $renderer = new Field_Renderer(); |
@@ -1260,17 +1259,17 @@ discard block |
||
| 1260 | 1259 | } ); |
| 1261 | 1260 | |
| 1262 | 1261 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
| 1263 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 1262 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 1264 | 1263 | } |
| 1265 | 1264 | |
| 1266 | 1265 | foreach ( $allowed as $field ) { |
| 1267 | 1266 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
| 1268 | 1267 | |
| 1269 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
| 1268 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
| 1270 | 1269 | |
| 1271 | 1270 | if ( ! $headers_done ) { |
| 1272 | 1271 | $label = $field->get_label( $view, $source, $entry ); |
| 1273 | - $headers[] = $label ? $label : $field->ID; |
|
| 1272 | + $headers[ ] = $label ? $label : $field->ID; |
|
| 1274 | 1273 | } |
| 1275 | 1274 | } |
| 1276 | 1275 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | 'total' => wp_count_posts( 'gravityview' )->publish, |
| 64 | 64 | ); |
| 65 | 65 | foreach ( $items as $item ) { |
| 66 | - $data['views'][] = $this->prepare_view_for_response( $item, $request ); |
|
| 66 | + $data[ 'views' ][ ] = $this->prepare_view_for_response( $item, $request ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | return new \WP_REST_Response( $data, 200 ); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $url = $request->get_url_params(); |
| 84 | 84 | |
| 85 | - $view_id = intval( $url['id'] ); |
|
| 85 | + $view_id = intval( $url[ 'id' ] ); |
|
| 86 | 86 | |
| 87 | 87 | $item = get_post( $view_id ); |
| 88 | 88 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // Only output the fields that should be displayed. |
| 115 | 115 | $allowed = array(); |
| 116 | 116 | foreach ( $view->fields->by_position( "{$context}_*" )->by_visible()->all() as $field ) { |
| 117 | - $allowed[] = $field; |
|
| 117 | + $allowed[ ] = $field; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | // Tack on additional fields if needed |
| 135 | 135 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
| 136 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 136 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $r = new Request( $request ); |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | public function get_sub_items( $request ) { |
| 202 | 202 | |
| 203 | 203 | $url = $request->get_url_params(); |
| 204 | - $view_id = intval( $url['id'] ); |
|
| 204 | + $view_id = intval( $url[ 'id' ] ); |
|
| 205 | 205 | $format = \GV\Utils::get( $url, 'format', 'json' ); |
| 206 | 206 | |
| 207 | - if( $post_id = $request->get_param('post_id') ) { |
|
| 207 | + if ( $post_id = $request->get_param( 'post_id' ) ) { |
|
| 208 | 208 | global $post; |
| 209 | 209 | |
| 210 | 210 | $post = get_post( $post_id ); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $data = array( 'entries' => $entries->all(), 'total' => $entries->total() ); |
| 304 | 304 | |
| 305 | - foreach ( $data['entries'] as &$entry ) { |
|
| 305 | + foreach ( $data[ 'entries' ] as &$entry ) { |
|
| 306 | 306 | $entry = $this->prepare_entry_for_response( $view, $entry, $request, 'directory' ); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function get_sub_item( $request ) { |
| 323 | 323 | $url = $request->get_url_params(); |
| 324 | - $view_id = intval( $url['id'] ); |
|
| 325 | - $entry_id = intval( $url['s_id'] ); |
|
| 324 | + $view_id = intval( $url[ 'id' ] ); |
|
| 325 | + $entry_id = intval( $url[ 's_id' ] ); |
|
| 326 | 326 | $format = \GV\Utils::get( $url, 'format', 'json' ); |
| 327 | 327 | |
| 328 | 328 | $view = \GV\View::by_id( $view_id ); |
@@ -357,32 +357,32 @@ discard block |
||
| 357 | 357 | // Add all the WP_Post data |
| 358 | 358 | $view_post = $view_post->to_array(); |
| 359 | 359 | |
| 360 | - unset( $view_post['to_ping'], $view_post['ping_status'], $view_post['pinged'], $view_post['post_type'], $view_post['filter'], $view_post['post_category'], $view_post['tags_input'], $view_post['post_content'], $view_post['post_content_filtered'] ); |
|
| 360 | + unset( $view_post[ 'to_ping' ], $view_post[ 'ping_status' ], $view_post[ 'pinged' ], $view_post[ 'post_type' ], $view_post[ 'filter' ], $view_post[ 'post_category' ], $view_post[ 'tags_input' ], $view_post[ 'post_content' ], $view_post[ 'post_content_filtered' ] ); |
|
| 361 | 361 | |
| 362 | 362 | $return = wp_parse_args( $item, $view_post ); |
| 363 | 363 | |
| 364 | - $return['title'] = $return['post_title']; |
|
| 364 | + $return[ 'title' ] = $return[ 'post_title' ]; |
|
| 365 | 365 | |
| 366 | - $return['settings'] = isset( $return['atts'] ) ? $return['atts'] : array(); |
|
| 367 | - unset( $return['atts'], $return['view_id'] ); |
|
| 366 | + $return[ 'settings' ] = isset( $return[ 'atts' ] ) ? $return[ 'atts' ] : array(); |
|
| 367 | + unset( $return[ 'atts' ], $return[ 'view_id' ] ); |
|
| 368 | 368 | |
| 369 | - $return['search_criteria'] = array( |
|
| 369 | + $return[ 'search_criteria' ] = array( |
|
| 370 | 370 | 'page_size' => rgars( $return, 'settings/page_size' ), |
| 371 | 371 | 'sort_field' => rgars( $return, 'settings/sort_field' ), |
| 372 | 372 | 'sort_direction' => rgars( $return, 'settings/sort_direction' ), |
| 373 | 373 | 'offset' => rgars( $return, 'settings/offset' ), |
| 374 | 374 | ); |
| 375 | 375 | |
| 376 | - unset( $return['settings']['page_size'], $return['settings']['sort_field'], $return['settings']['sort_direction'] ); |
|
| 376 | + unset( $return[ 'settings' ][ 'page_size' ], $return[ 'settings' ][ 'sort_field' ], $return[ 'settings' ][ 'sort_direction' ] ); |
|
| 377 | 377 | |
| 378 | 378 | // Redact for non-logged ins |
| 379 | 379 | if ( ! \GVCommon::has_cap( 'edit_others_gravityviews' ) ) { |
| 380 | - unset( $return['settings'] ); |
|
| 381 | - unset( $return['search_criteria'] ); |
|
| 380 | + unset( $return[ 'settings' ] ); |
|
| 381 | + unset( $return[ 'search_criteria' ] ); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | if ( ! \GFCommon::current_user_can_any( 'gravityforms_edit_forms' ) ) { |
| 385 | - unset( $return['form'] ); |
|
| 385 | + unset( $return[ 'form' ] ); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | return $return; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $view_id = func_get_arg( 1 ); // $view_id override |
| 399 | 399 | } else { |
| 400 | 400 | $url = $request->get_url_params(); |
| 401 | - $view_id = intval( $url['id'] ); |
|
| 401 | + $view_id = intval( $url[ 'id' ] ); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | if ( ! $view = \GV\View::by_id( $view_id ) ) { |
@@ -444,8 +444,8 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | $url = $request->get_url_params(); |
| 447 | - $view_id = intval( $url['id'] ); |
|
| 448 | - $entry_id = intval( $url['s_id'] ); |
|
| 447 | + $view_id = intval( $url[ 'id' ] ); |
|
| 448 | + $entry_id = intval( $url[ 's_id' ] ); |
|
| 449 | 449 | |
| 450 | 450 | $view = \GV\View::by_id( $view_id ); |
| 451 | 451 | |
@@ -453,11 +453,11 @@ discard block |
||
| 453 | 453 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if ( $entry['form_id'] != $view->form->ID ) { |
|
| 456 | + if ( $entry[ 'form_id' ] != $view->form->ID ) { |
|
| 457 | 457 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( $entry['status'] != 'active' ) { |
|
| 460 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 461 | 461 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 462 | 462 | } |
| 463 | 463 | |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 468 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 469 | 469 | |
| 470 | 470 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 471 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 471 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 472 | 472 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 473 | 473 | } |
| 474 | 474 | } |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | $search_field = $gravityview_view->search_field; |
| 11 | 11 | |
| 12 | 12 | // Make sure that there are choices to display |
| 13 | -if( empty( $search_field['choices'] ) ) { |
|
| 13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
| 14 | 14 | gravityview()->log->debug( 'search-field-select.php - No choices for field' ); |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if( is_array( $search_field['value'] ) ) { |
|
| 18 | +if ( is_array( $search_field[ 'value' ] ) ) { |
|
| 19 | 19 | gravityview()->log->debug( 'search-field-select.php - Array values passed; using first value.' ); |
| 20 | - $search_field['value'] = reset( $search_field['value'] ); |
|
| 20 | + $search_field[ 'value' ] = reset( $search_field[ 'value' ] ); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -26,26 +26,26 @@ discard block |
||
| 26 | 26 | * @param string $default_option Default: `—` (—) |
| 27 | 27 | * @param string $field_type Field type: "select" or "multiselect" |
| 28 | 28 | */ |
| 29 | -$default_option = apply_filters('gravityview/extension/search/select_default', '—', 'select' ); |
|
| 29 | +$default_option = apply_filters( 'gravityview/extension/search/select_default', '—', 'select' ); |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | <div class="gv-search-box gv-search-field-select"> |
| 33 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
| 34 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
| 33 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
| 34 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
| 35 | 35 | <?php } ?> |
| 36 | 36 | <p> |
| 37 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"> |
|
| 38 | - <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
| 37 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"> |
|
| 38 | + <option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
| 39 | 39 | <?php |
| 40 | - foreach( $search_field['choices'] as $choice ) { ?> |
|
| 41 | - <?php if ( is_array( $choice['value'] ) ) { ?> |
|
| 42 | - <optgroup label="<?php echo esc_attr( $choice['text'] ); ?>"> |
|
| 43 | - <?php foreach ( $choice['value'] as $subchoice ): ?> |
|
| 44 | - <option value="<?php echo esc_attr( $subchoice['value'] ); ?>"><?php echo esc_html( $subchoice['text'] ); ?></option> |
|
| 40 | + foreach ( $search_field[ 'choices' ] as $choice ) { ?> |
|
| 41 | + <?php if ( is_array( $choice[ 'value' ] ) ) { ?> |
|
| 42 | + <optgroup label="<?php echo esc_attr( $choice[ 'text' ] ); ?>"> |
|
| 43 | + <?php foreach ( $choice[ 'value' ] as $subchoice ): ?> |
|
| 44 | + <option value="<?php echo esc_attr( $subchoice[ 'value' ] ); ?>"><?php echo esc_html( $subchoice[ 'text' ] ); ?></option> |
|
| 45 | 45 | <?php endforeach; ?> |
| 46 | 46 | </optgroup> |
| 47 | 47 | <?php } else { ?> |
| 48 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
| 48 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field[ 'value' ] ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
| 49 | 49 | <?php } ?> |
| 50 | 50 | <?php } ?> |
| 51 | 51 | </select> |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @var string The hash key used to generate secure message history |
| 16 | - * @since 2.2.5 |
|
| 16 | + * @since 2.2.5 |
|
| 17 | 17 | */ |
| 18 | 18 | const beacon_key = 'lCXlwbQR707kipR+J0MCqcxrhGOHjGF0ldD6yNbGM0w='; |
| 19 | 19 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | 'payment_id' => '', |
| 111 | 111 | 'customer_name' => '', |
| 112 | 112 | 'customer_email' => '', |
| 113 | - 'price_id' => '0', |
|
| 113 | + 'price_id' => '0', |
|
| 114 | 114 | ) ); |
| 115 | 115 | |
| 116 | 116 | // This is just HTML we don't need. |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | case 3: |
| 128 | 128 | $package = 'All Access'; |
| 129 | 129 | break; |
| 130 | - case 4: |
|
| 131 | - $package = 'Lifetime'; |
|
| 132 | - break; |
|
| 130 | + case 4: |
|
| 131 | + $package = 'Lifetime'; |
|
| 132 | + break; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $current_user = wp_get_current_user(); |
@@ -159,27 +159,27 @@ discard block |
||
| 159 | 159 | // Help Scout length limit is 200 characters |
| 160 | 160 | foreach( $data as $key => $value ) { |
| 161 | 161 | if ( ! is_string( $value ) ) { |
| 162 | - continue; |
|
| 162 | + continue; |
|
| 163 | 163 | } |
| 164 | - $data[ $key ] = mb_substr( $value, 0, 200 ); |
|
| 165 | - } |
|
| 164 | + $data[ $key ] = mb_substr( $value, 0, 200 ); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | $localization_data = array( |
| 168 | 168 | 'contactEnabled' => (int)GVCommon::has_cap( 'gravityview_contact_support' ), |
| 169 | 169 | 'data' => $data, |
| 170 | 170 | 'translation' => $translation, |
| 171 | - 'suggest' => array(), |
|
| 171 | + 'suggest' => array(), |
|
| 172 | 172 | ); |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * @filter `gravityview/support_port/localization_data` Filter data passed to the Support Port, before localize_script is run |
|
| 175 | + * @filter `gravityview/support_port/localization_data` Filter data passed to the Support Port, before localize_script is run |
|
| 176 | 176 | * @since 2.0 |
| 177 | - * @param array $localization_data { |
|
| 178 | - * @type int $contactEnabled Can the user contact support? |
|
| 179 | - * @type array $data Support/license info |
|
| 180 | - * @type array $translation i18n strings |
|
| 181 | - * @type array $suggest Article IDs to recommend to the user (per page in the admin |
|
| 182 | - * } |
|
| 177 | + * @param array $localization_data { |
|
| 178 | + * @type int $contactEnabled Can the user contact support? |
|
| 179 | + * @type array $data Support/license info |
|
| 180 | + * @type array $translation i18n strings |
|
| 181 | + * @type array $suggest Article IDs to recommend to the user (per page in the admin |
|
| 182 | + * } |
|
| 183 | 183 | */ |
| 184 | 184 | $localization_data = apply_filters( 'gravityview/support_port/localization_data', $localization_data ); |
| 185 | 185 | |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * If the user doesn't have the `gravityview_support_port` capability, returns false; then |
| 195 | 195 | * If global setting is "hide", returns false; then |
| 196 | - * If user preference is not set, return global setting; then |
|
| 197 | - * If user preference is set, return that setting. |
|
| 196 | + * If user preference is not set, return global setting; then |
|
| 197 | + * If user preference is set, return that setting. |
|
| 198 | 198 | * |
| 199 | 199 | * @since 1.15 |
| 200 | - * @since 1.17.5 Changed behavior to respect global setting |
|
| 200 | + * @since 1.17.5 Changed behavior to respect global setting |
|
| 201 | 201 | * |
| 202 | 202 | * @param int $user Optional. ID of the user to check, defaults to 0 for current user. |
| 203 | 203 | * |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $global_setting = gravityview()->plugin->settings->get( 'support_port' ); |
| 213 | 213 | |
| 214 | 214 | if ( empty( $global_setting ) ) { |
| 215 | - return false; |
|
| 215 | + return false; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Get the per-user Support Port setting |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * Modifies the output of profile.php to add GravityView Support preference |
| 249 | 249 | * |
| 250 | 250 | * @since 1.15 |
| 251 | - * @since 1.17.5 Only show if global setting is active |
|
| 251 | + * @since 1.17.5 Only show if global setting is active |
|
| 252 | 252 | * |
| 253 | 253 | * @param WP_User $user Current user info |
| 254 | 254 | * |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $global_setting = gravityview()->plugin->settings->get( 'support_port' ); |
| 260 | 260 | |
| 261 | 261 | if ( empty( $global_setting ) ) { |
| 262 | - return; |
|
| 262 | + return; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | ) ); |
| 115 | 115 | |
| 116 | 116 | // This is just HTML we don't need. |
| 117 | - unset( $response['message'] ); |
|
| 117 | + unset( $response[ 'message' ] ); |
|
| 118 | 118 | |
| 119 | - switch ( intval( $response['price_id'] ) ) { |
|
| 119 | + switch ( intval( $response[ 'price_id' ] ) ) { |
|
| 120 | 120 | default: |
| 121 | 121 | case 1: |
| 122 | 122 | $package = 'Core'; |
@@ -142,12 +142,12 @@ discard block |
||
| 142 | 142 | 'email' => $current_user->user_email, |
| 143 | 143 | 'name' => mb_substr( $current_user->display_name, 0, 80 ), |
| 144 | 144 | 'signature' => hash_hmac( 'sha256', $current_user->user_email, self::beacon_key ), |
| 145 | - 'License Key' => $response['license_key'] . ' (' . ucwords( $response['license'] ) . ')', |
|
| 145 | + 'License Key' => $response[ 'license_key' ] . ' (' . ucwords( $response[ 'license' ] ) . ')', |
|
| 146 | 146 | 'License Level' => $package, |
| 147 | 147 | 'Alt Emails' => sprintf( "Admin: %s, GV Support: %s", get_bloginfo( 'admin_email' ), gravityview()->plugin->settings->get( 'support-email' ) ), |
| 148 | - 'Payment Details' => $response['customer_name'] . ' ' . $response['customer_email'], |
|
| 148 | + 'Payment Details' => $response[ 'customer_name' ] . ' ' . $response[ 'customer_email' ], |
|
| 149 | 149 | 'WordPress Version' => get_bloginfo( 'version', 'display' ), |
| 150 | - 'PHP Version' => phpversion() . ' on ' . esc_html( $_SERVER['SERVER_SOFTWARE'] ), |
|
| 150 | + 'PHP Version' => phpversion() . ' on ' . esc_html( $_SERVER[ 'SERVER_SOFTWARE' ] ), |
|
| 151 | 151 | 'No-Conflict Mode' => empty( $no_conflict_mode ) ? 'Disabled' : 'Enabled', |
| 152 | 152 | 'GravityView Version' => \GV\Plugin::$version, |
| 153 | 153 | 'Gravity Forms Version' => GFForms::$version, |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | ob_get_clean(); |
| 158 | 158 | |
| 159 | 159 | // Help Scout length limit is 200 characters |
| 160 | - foreach( $data as $key => $value ) { |
|
| 160 | + foreach ( $data as $key => $value ) { |
|
| 161 | 161 | if ( ! is_string( $value ) ) { |
| 162 | 162 | continue; |
| 163 | 163 | } |