@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * ID of the current post. May also be ID of the current View. |
| 105 | - * |
|
| 106 | - * @since 2.0.13 |
|
| 107 | 105 | * |
| 108 | - * @var int |
|
| 106 | + * @since 2.0.13 |
|
| 107 | + * |
|
| 108 | + * @var int |
|
| 109 | 109 | */ |
| 110 | 110 | public $post_id; |
| 111 | 111 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function prevent_maybe_process_form() { |
| 191 | 191 | |
| 192 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 192 | + if( ! $this->is_edit_entry_submission() ) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | GFFormsModel::save_lead( $form, $this->entry ); |
| 398 | 398 | |
| 399 | - // Delete the values for hidden inputs |
|
| 400 | - $this->unset_hidden_field_values(); |
|
| 399 | + // Delete the values for hidden inputs |
|
| 400 | + $this->unset_hidden_field_values(); |
|
| 401 | 401 | |
| 402 | 402 | $this->entry['date_created'] = $date_created; |
| 403 | 403 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | // Perform actions normally performed after updating a lead |
| 411 | 411 | $this->after_update(); |
| 412 | 412 | |
| 413 | - /** |
|
| 413 | + /** |
|
| 414 | 414 | * Must be AFTER after_update()! |
| 415 | 415 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 416 | 416 | */ |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 421 | - * @since 2.1 Added $gv_data parameter |
|
| 421 | + * @since 2.1 Added $gv_data parameter |
|
| 422 | 422 | * @param array $form Gravity Forms form array |
| 423 | 423 | * @param string $entry_id Numeric ID of the entry that was updated |
| 424 | 424 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | * @return void |
| 443 | 443 | */ |
| 444 | 444 | private function unset_hidden_field_values() { |
| 445 | - global $wpdb; |
|
| 445 | + global $wpdb; |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 469 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 470 | 470 | |
| 471 | 471 | if ( ! is_numeric( $input_id ) ) { |
| 472 | 472 | continue; |
@@ -476,8 +476,8 @@ discard block |
||
| 476 | 476 | continue; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - // Reset fields that are or would be hidden |
|
| 480 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
| 479 | + // Reset fields that are or would be hidden |
|
| 480 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
| 481 | 481 | |
| 482 | 482 | $empty_value = $field->get_value_save_entry( |
| 483 | 483 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -489,16 +489,16 @@ discard block |
||
| 489 | 489 | $empty_value = ''; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 492 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 493 | 493 | |
| 494 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 494 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 495 | 495 | |
| 496 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 496 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 497 | 497 | // after submission |
| 498 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 499 | - $_POST[ $post_input_id ] = ''; |
|
| 500 | - } |
|
| 501 | - } |
|
| 498 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 499 | + $_POST[ $post_input_id ] = ''; |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | $form = $this->filter_conditional_logic( $this->form ); |
| 655 | 655 | |
| 656 | - /** @type GF_Field $field */ |
|
| 656 | + /** @type GF_Field $field */ |
|
| 657 | 657 | foreach( $form['fields'] as $k => &$field ) { |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | |
| 669 | 669 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 670 | 670 | foreach( $field->inputs as $key => $input ) { |
| 671 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 671 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | } |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | $inputs = $field->get_entry_inputs(); |
| 710 | 710 | if ( is_array( $inputs ) ) { |
| 711 | - foreach ( $inputs as $input ) { |
|
| 711 | + foreach ( $inputs as $input ) { |
|
| 712 | 712 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
| 713 | 713 | |
| 714 | 714 | if ( 'product' === $field->type ) { |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 730 | - } |
|
| 730 | + } |
|
| 731 | 731 | } else { |
| 732 | 732 | // Set to what it previously was if it's not editable |
| 733 | 733 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 774 | 774 | |
| 775 | 775 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 776 | - $ary = stripslashes_deep( $ary ); |
|
| 776 | + $ary = stripslashes_deep( $ary ); |
|
| 777 | 777 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 778 | 778 | |
| 779 | 779 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | private function maybe_update_post_fields( $form ) { |
| 847 | 847 | |
| 848 | 848 | if( empty( $this->entry['post_id'] ) ) { |
| 849 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 849 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 850 | 850 | return; |
| 851 | 851 | } |
| 852 | 852 | |
@@ -881,49 +881,49 @@ discard block |
||
| 881 | 881 | |
| 882 | 882 | switch( $field->type ) { |
| 883 | 883 | |
| 884 | - case 'post_title': |
|
| 885 | - $post_title = $value; |
|
| 886 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 887 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 888 | - } |
|
| 889 | - $updated_post->post_title = $post_title; |
|
| 890 | - $updated_post->post_name = $post_title; |
|
| 891 | - unset( $post_title ); |
|
| 892 | - break; |
|
| 893 | - |
|
| 894 | - case 'post_content': |
|
| 895 | - $post_content = $value; |
|
| 896 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 897 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 898 | - } |
|
| 899 | - $updated_post->post_content = $post_content; |
|
| 900 | - unset( $post_content ); |
|
| 901 | - break; |
|
| 902 | - case 'post_excerpt': |
|
| 903 | - $updated_post->post_excerpt = $value; |
|
| 904 | - break; |
|
| 905 | - case 'post_tags': |
|
| 906 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 907 | - break; |
|
| 908 | - case 'post_category': |
|
| 909 | - break; |
|
| 910 | - case 'post_custom_field': |
|
| 884 | + case 'post_title': |
|
| 885 | + $post_title = $value; |
|
| 886 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 887 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 888 | + } |
|
| 889 | + $updated_post->post_title = $post_title; |
|
| 890 | + $updated_post->post_name = $post_title; |
|
| 891 | + unset( $post_title ); |
|
| 892 | + break; |
|
| 893 | + |
|
| 894 | + case 'post_content': |
|
| 895 | + $post_content = $value; |
|
| 896 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 897 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 898 | + } |
|
| 899 | + $updated_post->post_content = $post_content; |
|
| 900 | + unset( $post_content ); |
|
| 901 | + break; |
|
| 902 | + case 'post_excerpt': |
|
| 903 | + $updated_post->post_excerpt = $value; |
|
| 904 | + break; |
|
| 905 | + case 'post_tags': |
|
| 906 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 907 | + break; |
|
| 908 | + case 'post_category': |
|
| 909 | + break; |
|
| 910 | + case 'post_custom_field': |
|
| 911 | 911 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 912 | 912 | $value = $value[ $field_id ]; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 916 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 917 | - } |
|
| 915 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 916 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 917 | + } |
|
| 918 | 918 | |
| 919 | 919 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
| 920 | 920 | |
| 921 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 922 | - break; |
|
| 921 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 922 | + break; |
|
| 923 | 923 | |
| 924 | - case 'post_image': |
|
| 925 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 926 | - break; |
|
| 924 | + case 'post_image': |
|
| 925 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 926 | + break; |
|
| 927 | 927 | |
| 928 | 928 | } |
| 929 | 929 | |
@@ -1093,14 +1093,14 @@ discard block |
||
| 1093 | 1093 | ?><h2 class="gv-edit-entry-title"> |
| 1094 | 1094 | <span><?php |
| 1095 | 1095 | |
| 1096 | - /** |
|
| 1097 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 1098 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 1099 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 1100 | - */ |
|
| 1101 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1096 | + /** |
|
| 1097 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 1098 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 1099 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 1100 | + */ |
|
| 1101 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1102 | 1102 | |
| 1103 | - echo esc_attr( $edit_entry_title ); |
|
| 1103 | + echo esc_attr( $edit_entry_title ); |
|
| 1104 | 1104 | ?></span> |
| 1105 | 1105 | </h2> |
| 1106 | 1106 | |
@@ -1166,13 +1166,13 @@ discard block |
||
| 1166 | 1166 | ); |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
| 1169 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1170 | - * @since 1.16.3 |
|
| 1171 | - * @param array $labels Default button labels associative array |
|
| 1172 | - * @param array $form The Gravity Forms form |
|
| 1173 | - * @param array $entry The Gravity Forms entry |
|
| 1174 | - * @param int $view_id The current View ID |
|
| 1175 | - */ |
|
| 1169 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1170 | + * @since 1.16.3 |
|
| 1171 | + * @param array $labels Default button labels associative array |
|
| 1172 | + * @param array $form The Gravity Forms form |
|
| 1173 | + * @param array $entry The Gravity Forms entry |
|
| 1174 | + * @param int $view_id The current View ID |
|
| 1175 | + */ |
|
| 1176 | 1176 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1177 | 1177 | |
| 1178 | 1178 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1295,13 +1295,13 @@ discard block |
||
| 1295 | 1295 | ); |
| 1296 | 1296 | |
| 1297 | 1297 | /** |
| 1298 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1299 | - * @since 1.16.3 |
|
| 1300 | - * @param array $labels Default button labels associative array |
|
| 1301 | - * @param array $form The Gravity Forms form |
|
| 1302 | - * @param array $entry The Gravity Forms entry |
|
| 1303 | - * @param int $view_id The current View ID |
|
| 1304 | - */ |
|
| 1298 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1299 | + * @since 1.16.3 |
|
| 1300 | + * @param array $labels Default button labels associative array |
|
| 1301 | + * @param array $form The Gravity Forms form |
|
| 1302 | + * @param array $entry The Gravity Forms entry |
|
| 1303 | + * @param int $view_id The current View ID |
|
| 1304 | + */ |
|
| 1305 | 1305 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1306 | 1306 | |
| 1307 | 1307 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | |
| 1348 | 1348 | ob_get_clean(); |
| 1349 | 1349 | |
| 1350 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1350 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1351 | 1351 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1352 | 1352 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1353 | 1353 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | |
| 1408 | 1408 | // for now we don't support Save and Continue feature. |
| 1409 | 1409 | if( ! self::$supports_save_and_continue ) { |
| 1410 | - unset( $form['save'] ); |
|
| 1410 | + unset( $form['save'] ); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | $form = $this->unselect_default_values( $form ); |
@@ -1434,30 +1434,30 @@ discard block |
||
| 1434 | 1434 | return $field_content; |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | - $message = null; |
|
| 1437 | + $message = null; |
|
| 1438 | 1438 | |
| 1439 | - // First, make sure they have the capability to edit the post. |
|
| 1440 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1439 | + // First, make sure they have the capability to edit the post. |
|
| 1440 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1441 | 1441 | |
| 1442 | - /** |
|
| 1443 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1444 | - * @param string $message The existing "You don't have permission..." text |
|
| 1445 | - */ |
|
| 1446 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1442 | + /** |
|
| 1443 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1444 | + * @param string $message The existing "You don't have permission..." text |
|
| 1445 | + */ |
|
| 1446 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1447 | 1447 | |
| 1448 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1449 | - /** |
|
| 1450 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1451 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1452 | - */ |
|
| 1453 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1454 | - } |
|
| 1448 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1449 | + /** |
|
| 1450 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1451 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1452 | + */ |
|
| 1453 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1454 | + } |
|
| 1455 | 1455 | |
| 1456 | - if( $message ) { |
|
| 1457 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1458 | - } |
|
| 1456 | + if( $message ) { |
|
| 1457 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1458 | + } |
|
| 1459 | 1459 | |
| 1460 | - return $field_content; |
|
| 1460 | + return $field_content; |
|
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | 1463 | /** |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | || ! empty( $field_content ) |
| 1486 | 1486 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1487 | 1487 | ) { |
| 1488 | - return $field_content; |
|
| 1488 | + return $field_content; |
|
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | 1491 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1493,24 +1493,24 @@ discard block |
||
| 1493 | 1493 | |
| 1494 | 1494 | $field_value = $this->get_field_value( $field ); |
| 1495 | 1495 | |
| 1496 | - // Prevent any PHP warnings, like undefined index |
|
| 1497 | - ob_start(); |
|
| 1496 | + // Prevent any PHP warnings, like undefined index |
|
| 1497 | + ob_start(); |
|
| 1498 | 1498 | |
| 1499 | - $return = null; |
|
| 1499 | + $return = null; |
|
| 1500 | 1500 | |
| 1501 | 1501 | /** @var GravityView_Field $gv_field */ |
| 1502 | 1502 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1503 | 1503 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1504 | 1504 | } else { |
| 1505 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1506 | - } |
|
| 1505 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1506 | + } |
|
| 1507 | 1507 | |
| 1508 | - // If there was output, it's an error |
|
| 1509 | - $warnings = ob_get_clean(); |
|
| 1508 | + // If there was output, it's an error |
|
| 1509 | + $warnings = ob_get_clean(); |
|
| 1510 | 1510 | |
| 1511 | - if( !empty( $warnings ) ) { |
|
| 1512 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1513 | - } |
|
| 1511 | + if( !empty( $warnings ) ) { |
|
| 1512 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1513 | + } |
|
| 1514 | 1514 | |
| 1515 | 1515 | return $return; |
| 1516 | 1516 | } |
@@ -1545,8 +1545,8 @@ discard block |
||
| 1545 | 1545 | $input_id = strval( $input['id'] ); |
| 1546 | 1546 | |
| 1547 | 1547 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1548 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1549 | - $allow_pre_populated = false; |
|
| 1548 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1549 | + $allow_pre_populated = false; |
|
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | } |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1571 | 1571 | $categories = array(); |
| 1572 | 1572 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1573 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1573 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1574 | 1574 | } |
| 1575 | 1575 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1576 | 1576 | } |
@@ -1580,25 +1580,25 @@ discard block |
||
| 1580 | 1580 | // if value is empty get the default value if defined |
| 1581 | 1581 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1582 | 1582 | |
| 1583 | - /** |
|
| 1584 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1585 | - * @since 1.11 |
|
| 1586 | - * @since 1.20 Added third param |
|
| 1587 | - * @param mixed $field_value field value used to populate the input |
|
| 1588 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1589 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1590 | - */ |
|
| 1591 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1592 | - |
|
| 1593 | - /** |
|
| 1594 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1595 | - * @since 1.17 |
|
| 1596 | - * @since 1.20 Added third param |
|
| 1597 | - * @param mixed $field_value field value used to populate the input |
|
| 1598 | - * @param GF_Field $field Gravity Forms field object |
|
| 1599 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1600 | - */ |
|
| 1601 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1583 | + /** |
|
| 1584 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1585 | + * @since 1.11 |
|
| 1586 | + * @since 1.20 Added third param |
|
| 1587 | + * @param mixed $field_value field value used to populate the input |
|
| 1588 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1589 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1590 | + */ |
|
| 1591 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1592 | + |
|
| 1593 | + /** |
|
| 1594 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1595 | + * @since 1.17 |
|
| 1596 | + * @since 1.20 Added third param |
|
| 1597 | + * @param mixed $field_value field value used to populate the input |
|
| 1598 | + * @param GF_Field $field Gravity Forms field object |
|
| 1599 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1600 | + */ |
|
| 1601 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1602 | 1602 | |
| 1603 | 1603 | return $field_value; |
| 1604 | 1604 | } |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1626 | 1626 | // expects certain field array items to be set. |
| 1627 | 1627 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1628 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1628 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1639,31 +1639,31 @@ discard block |
||
| 1639 | 1639 | */ |
| 1640 | 1640 | case 'fileupload': |
| 1641 | 1641 | |
| 1642 | - // Set the previous value |
|
| 1643 | - $entry = $this->get_entry(); |
|
| 1642 | + // Set the previous value |
|
| 1643 | + $entry = $this->get_entry(); |
|
| 1644 | 1644 | |
| 1645 | - $input_name = 'input_'.$field->id; |
|
| 1646 | - $form_id = $form['id']; |
|
| 1645 | + $input_name = 'input_'.$field->id; |
|
| 1646 | + $form_id = $form['id']; |
|
| 1647 | 1647 | |
| 1648 | - $value = NULL; |
|
| 1648 | + $value = NULL; |
|
| 1649 | 1649 | |
| 1650 | - // Use the previous entry value as the default. |
|
| 1651 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1652 | - $value = $entry[ $field->id ]; |
|
| 1653 | - } |
|
| 1650 | + // Use the previous entry value as the default. |
|
| 1651 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1652 | + $value = $entry[ $field->id ]; |
|
| 1653 | + } |
|
| 1654 | 1654 | |
| 1655 | - // If this is a single upload file |
|
| 1656 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1657 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1658 | - $value = $file_path['url']; |
|
| 1655 | + // If this is a single upload file |
|
| 1656 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1657 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1658 | + $value = $file_path['url']; |
|
| 1659 | 1659 | |
| 1660 | - } else { |
|
| 1660 | + } else { |
|
| 1661 | 1661 | |
| 1662 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1663 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1664 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1662 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1663 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1664 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1665 | 1665 | |
| 1666 | - } |
|
| 1666 | + } |
|
| 1667 | 1667 | |
| 1668 | 1668 | if ( \GV\Utils::get( $field, 'multipleFiles' ) ) { |
| 1669 | 1669 | // If there are fresh uploads, process and merge them. |
@@ -1684,17 +1684,17 @@ discard block |
||
| 1684 | 1684 | GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | - $this->entry[ $input_name ] = $value; |
|
| 1688 | - $_POST[ $input_name ] = $value; |
|
| 1687 | + $this->entry[ $input_name ] = $value; |
|
| 1688 | + $_POST[ $input_name ] = $value; |
|
| 1689 | 1689 | |
| 1690 | - break; |
|
| 1690 | + break; |
|
| 1691 | 1691 | |
| 1692 | 1692 | case 'number': |
| 1693 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1694 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1695 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1696 | - } |
|
| 1697 | - break; |
|
| 1693 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1694 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1695 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1696 | + } |
|
| 1697 | + break; |
|
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | } |
@@ -1815,7 +1815,7 @@ discard block |
||
| 1815 | 1815 | |
| 1816 | 1816 | // count uploaded files and existent entry files |
| 1817 | 1817 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
| 1818 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1818 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1819 | 1819 | |
| 1820 | 1820 | if ( $count_files > $field->maxFiles ) { |
| 1821 | 1821 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
@@ -1837,47 +1837,47 @@ discard block |
||
| 1837 | 1837 | |
| 1838 | 1838 | switch ( $field_type ) { |
| 1839 | 1839 | |
| 1840 | - // Captchas don't need to be re-entered. |
|
| 1841 | - case 'captcha': |
|
| 1840 | + // Captchas don't need to be re-entered. |
|
| 1841 | + case 'captcha': |
|
| 1842 | 1842 | |
| 1843 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1844 | - case 'post_image': |
|
| 1845 | - $field->failed_validation = false; |
|
| 1846 | - unset( $field->validation_message ); |
|
| 1847 | - break; |
|
| 1843 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1844 | + case 'post_image': |
|
| 1845 | + $field->failed_validation = false; |
|
| 1846 | + unset( $field->validation_message ); |
|
| 1847 | + break; |
|
| 1848 | 1848 | |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | 1851 | // You can't continue inside a switch, so we do it after. |
| 1852 | 1852 | if( empty( $field->failed_validation ) ) { |
| 1853 | - continue; |
|
| 1853 | + continue; |
|
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | 1856 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1857 | 1857 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1858 | 1858 | if( !empty( $field->noDuplicates ) ) { |
| 1859 | 1859 | |
| 1860 | - $entry = $this->get_entry(); |
|
| 1860 | + $entry = $this->get_entry(); |
|
| 1861 | 1861 | |
| 1862 | - // If the value of the entry is the same as the stored value |
|
| 1863 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1864 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1865 | - //if value submitted was not changed, then don't validate |
|
| 1866 | - $field->failed_validation = false; |
|
| 1862 | + // If the value of the entry is the same as the stored value |
|
| 1863 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1864 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1865 | + //if value submitted was not changed, then don't validate |
|
| 1866 | + $field->failed_validation = false; |
|
| 1867 | 1867 | |
| 1868 | - unset( $field->validation_message ); |
|
| 1868 | + unset( $field->validation_message ); |
|
| 1869 | 1869 | |
| 1870 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1870 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1871 | 1871 | |
| 1872 | - continue; |
|
| 1873 | - } |
|
| 1872 | + continue; |
|
| 1873 | + } |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1877 | 1877 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1878 | - unset( $field->validation_message ); |
|
| 1878 | + unset( $field->validation_message ); |
|
| 1879 | 1879 | $field->failed_validation = false; |
| 1880 | - continue; |
|
| 1880 | + continue; |
|
| 1881 | 1881 | } |
| 1882 | 1882 | |
| 1883 | 1883 | $gv_valid = false; |
@@ -1941,8 +1941,8 @@ discard block |
||
| 1941 | 1941 | // Hide fields depending on admin settings |
| 1942 | 1942 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1943 | 1943 | |
| 1944 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1945 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1944 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1945 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1946 | 1946 | |
| 1947 | 1947 | /** |
| 1948 | 1948 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -2033,11 +2033,11 @@ discard block |
||
| 2033 | 2033 | // The edit tab has been configured, so we loop through to configured settings |
| 2034 | 2034 | foreach ( $configured_fields as $configured_field ) { |
| 2035 | 2035 | |
| 2036 | - /** @var GF_Field $field */ |
|
| 2037 | - foreach ( $fields as $field ) { |
|
| 2036 | + /** @var GF_Field $field */ |
|
| 2037 | + foreach ( $fields as $field ) { |
|
| 2038 | 2038 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 2039 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 2040 | - break; |
|
| 2039 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 2040 | + break; |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | } |
@@ -2093,28 +2093,28 @@ discard block |
||
| 2093 | 2093 | */ |
| 2094 | 2094 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 2095 | 2095 | |
| 2096 | - /** |
|
| 2096 | + /** |
|
| 2097 | 2097 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
| 2098 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 2099 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 2100 | - * @since 1.9.1 |
|
| 2101 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
| 2102 | - * @param array $form GF Form array |
|
| 2103 | - * @param int $view_id View ID |
|
| 2104 | - */ |
|
| 2105 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 2106 | - |
|
| 2107 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 2098 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 2099 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 2100 | + * @since 1.9.1 |
|
| 2101 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
| 2102 | + * @param array $form GF Form array |
|
| 2103 | + * @param int $view_id View ID |
|
| 2104 | + */ |
|
| 2105 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 2106 | + |
|
| 2107 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 2108 | 2108 | foreach( $fields as $k => $field ) { |
| 2109 | 2109 | if( $field->adminOnly ) { |
| 2110 | - unset( $fields[ $k ] ); |
|
| 2110 | + unset( $fields[ $k ] ); |
|
| 2111 | 2111 | } |
| 2112 | 2112 | } |
| 2113 | 2113 | return array_values( $fields ); |
| 2114 | 2114 | } |
| 2115 | 2115 | |
| 2116 | - foreach( $fields as &$field ) { |
|
| 2117 | - $field->adminOnly = false; |
|
| 2116 | + foreach( $fields as &$field ) { |
|
| 2117 | + $field->adminOnly = false; |
|
| 2118 | 2118 | } |
| 2119 | 2119 | |
| 2120 | 2120 | return $fields; |
@@ -2134,13 +2134,13 @@ discard block |
||
| 2134 | 2134 | */ |
| 2135 | 2135 | private function unselect_default_values( $form ) { |
| 2136 | 2136 | |
| 2137 | - foreach ( $form['fields'] as &$field ) { |
|
| 2137 | + foreach ( $form['fields'] as &$field ) { |
|
| 2138 | 2138 | |
| 2139 | 2139 | if ( empty( $field->choices ) ) { |
| 2140 | - continue; |
|
| 2140 | + continue; |
|
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | - foreach ( $field->choices as &$choice ) { |
|
| 2143 | + foreach ( $field->choices as &$choice ) { |
|
| 2144 | 2144 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 2145 | 2145 | $choice['isSelected'] = false; |
| 2146 | 2146 | } |
@@ -2177,36 +2177,36 @@ discard block |
||
| 2177 | 2177 | |
| 2178 | 2178 | if( 'checkbox' === $field->type ) { |
| 2179 | 2179 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2180 | - $input_id = $input['id']; |
|
| 2181 | - $choice = $field->choices[ $key ]; |
|
| 2182 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2183 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2184 | - if( $match ) { |
|
| 2185 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2186 | - } |
|
| 2180 | + $input_id = $input['id']; |
|
| 2181 | + $choice = $field->choices[ $key ]; |
|
| 2182 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2183 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2184 | + if( $match ) { |
|
| 2185 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 2186 | + } |
|
| 2187 | 2187 | } |
| 2188 | 2188 | } else { |
| 2189 | 2189 | |
| 2190 | 2190 | // We need to run through each field to set the default values |
| 2191 | 2191 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2192 | 2192 | |
| 2193 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2193 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2194 | 2194 | |
| 2195 | - if( 'list' === $field->type ) { |
|
| 2196 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 2195 | + if( 'list' === $field->type ) { |
|
| 2196 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 2197 | 2197 | |
| 2198 | - $list_field_value = array(); |
|
| 2199 | - foreach ( (array) $list_rows as $row ) { |
|
| 2200 | - foreach ( (array) $row as $column ) { |
|
| 2201 | - $list_field_value[] = $column; |
|
| 2202 | - } |
|
| 2203 | - } |
|
| 2198 | + $list_field_value = array(); |
|
| 2199 | + foreach ( (array) $list_rows as $row ) { |
|
| 2200 | + foreach ( (array) $row as $column ) { |
|
| 2201 | + $list_field_value[] = $column; |
|
| 2202 | + } |
|
| 2203 | + } |
|
| 2204 | 2204 | |
| 2205 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 2206 | - } else { |
|
| 2207 | - $field->defaultValue = $field_value; |
|
| 2208 | - } |
|
| 2209 | - } |
|
| 2205 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 2206 | + } else { |
|
| 2207 | + $field->defaultValue = $field_value; |
|
| 2208 | + } |
|
| 2209 | + } |
|
| 2210 | 2210 | } |
| 2211 | 2211 | } |
| 2212 | 2212 | } |
@@ -2267,7 +2267,7 @@ discard block |
||
| 2267 | 2267 | foreach ( $form['fields'] as &$field ) { |
| 2268 | 2268 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2269 | 2269 | |
| 2270 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2270 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2271 | 2271 | |
| 2272 | 2272 | if ( $field['id'] == $rule_field_id ) { |
| 2273 | 2273 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2318,7 +2318,7 @@ discard block |
||
| 2318 | 2318 | return $has_conditional_logic; |
| 2319 | 2319 | } |
| 2320 | 2320 | |
| 2321 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2321 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2322 | 2322 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 2323 | 2323 | } |
| 2324 | 2324 | |
@@ -2385,14 +2385,14 @@ discard block |
||
| 2385 | 2385 | |
| 2386 | 2386 | if( $echo && $error !== true ) { |
| 2387 | 2387 | |
| 2388 | - $error = esc_html( $error ); |
|
| 2388 | + $error = esc_html( $error ); |
|
| 2389 | 2389 | |
| 2390 | - /** |
|
| 2391 | - * @since 1.9 |
|
| 2392 | - */ |
|
| 2393 | - if ( ! empty( $this->entry ) ) { |
|
| 2394 | - $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;" ) ); |
|
| 2395 | - } |
|
| 2390 | + /** |
|
| 2391 | + * @since 1.9 |
|
| 2392 | + */ |
|
| 2393 | + if ( ! empty( $this->entry ) ) { |
|
| 2394 | + $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;" ) ); |
|
| 2395 | + } |
|
| 2396 | 2396 | |
| 2397 | 2397 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2398 | 2398 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | function load() { |
| 136 | 136 | |
| 137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 139 | 139 | |
| 140 | 140 | // Don't display an embedded form when editing an entry |
| 141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | add_action( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
| 146 | 146 | add_action( 'admin_init', array( $this, 'prevent_maybe_process_form' ), 8 ); |
| 147 | 147 | |
| 148 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 148 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 149 | 149 | |
| 150 | 150 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
| 151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 157 | 157 | |
| 158 | 158 | // Add fields expected by GFFormDisplay::validate() |
| 159 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 159 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 160 | 160 | |
| 161 | 161 | // Fix multiselect value for GF 2.2 |
| 162 | 162 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @return void |
| 174 | 174 | */ |
| 175 | 175 | public function prevent_render_form() { |
| 176 | - if( $this->is_edit_entry() ) { |
|
| 177 | - if( 'wp_head' === current_filter() ) { |
|
| 176 | + if ( $this->is_edit_entry() ) { |
|
| 177 | + if ( 'wp_head' === current_filter() ) { |
|
| 178 | 178 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 179 | 179 | } else { |
| 180 | 180 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -189,17 +189,17 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function prevent_maybe_process_form() { |
| 191 | 191 | |
| 192 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 192 | + if ( ! $this->is_edit_entry_submission() ) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
| 197 | 197 | |
| 198 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 199 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 198 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 199 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 200 | 200 | |
| 201 | - remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 202 | - remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 201 | + remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 202 | + remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | $is_edit_entry = |
| 212 | 212 | ( GravityView_frontend::is_single_entry() || gravityview()->request->is_entry() ) |
| 213 | - && ( ! empty( $_GET['edit'] ) ); |
|
| 213 | + && ( ! empty( $_GET[ 'edit' ] ) ); |
|
| 214 | 214 | |
| 215 | 215 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 216 | 216 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return boolean |
| 222 | 222 | */ |
| 223 | 223 | public function is_edit_entry_submission() { |
| 224 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 224 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -243,20 +243,20 @@ discard block |
||
| 243 | 243 | } else { |
| 244 | 244 | $gravityview_view = GravityView_View::getInstance(); |
| 245 | 245 | $entries = $gravityview_view->getEntries(); |
| 246 | - self::$original_entry = $entries[0]; |
|
| 247 | - $this->entry = $entries[0]; |
|
| 246 | + self::$original_entry = $entries[ 0 ]; |
|
| 247 | + $this->entry = $entries[ 0 ]; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
|
| 250 | + self::$original_form = GFAPI::get_form( $this->entry[ 'form_id' ] ); |
|
| 251 | 251 | $this->form = self::$original_form; |
| 252 | 252 | |
| 253 | - $this->form_id = $this->entry['form_id']; |
|
| 253 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
| 254 | 254 | |
| 255 | 255 | $this->view_id = $view ? $view->ID : $gravityview_view->getViewId(); |
| 256 | 256 | |
| 257 | 257 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 258 | 258 | |
| 259 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 259 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | private function print_scripts() { |
| 319 | 319 | $gravityview_view = GravityView_View::getInstance(); |
| 320 | 320 | |
| 321 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 321 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 322 | 322 | |
| 323 | 323 | GFFormDisplay::enqueue_form_scripts( $this->form ? $this->form : $gravityview_view->getForm(), false ); |
| 324 | 324 | |
@@ -339,19 +339,19 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | private function process_save( $gv_data ) { |
| 341 | 341 | |
| 342 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 342 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 343 | 343 | return; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | // Make sure the entry, view, and form IDs are all correct |
| 347 | 347 | $valid = $this->verify_nonce(); |
| 348 | 348 | |
| 349 | - if ( !$valid ) { |
|
| 349 | + if ( ! $valid ) { |
|
| 350 | 350 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 351 | 351 | return; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 354 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 355 | 355 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 356 | 356 | return; |
| 357 | 357 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | $this->validate(); |
| 364 | 364 | |
| 365 | - if( $this->is_valid ) { |
|
| 365 | + if ( $this->is_valid ) { |
|
| 366 | 366 | |
| 367 | 367 | gravityview()->log->debug( 'Submission is valid.' ); |
| 368 | 368 | |
@@ -374,15 +374,15 @@ discard block |
||
| 374 | 374 | /** |
| 375 | 375 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 376 | 376 | */ |
| 377 | - unset( $_GET['page'] ); |
|
| 377 | + unset( $_GET[ 'page' ] ); |
|
| 378 | 378 | |
| 379 | - $date_created = $this->entry['date_created']; |
|
| 379 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 383 | 383 | * @since 1.17.2 |
| 384 | 384 | */ |
| 385 | - unset( $this->entry['date_created'] ); |
|
| 385 | + unset( $this->entry[ 'date_created' ] ); |
|
| 386 | 386 | |
| 387 | 387 | /** |
| 388 | 388 | * @action `gravityview/edit_entry/before_update` Perform an action before the entry has been updated using Edit Entry |
@@ -392,14 +392,14 @@ discard block |
||
| 392 | 392 | * @param GravityView_Edit_Entry_Render $this This object |
| 393 | 393 | * @param GravityView_View_Data $gv_data The View data |
| 394 | 394 | */ |
| 395 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
| 395 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 396 | 396 | |
| 397 | 397 | GFFormsModel::save_lead( $form, $this->entry ); |
| 398 | 398 | |
| 399 | 399 | // Delete the values for hidden inputs |
| 400 | 400 | $this->unset_hidden_field_values(); |
| 401 | 401 | |
| 402 | - $this->entry['date_created'] = $date_created; |
|
| 402 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 403 | 403 | |
| 404 | 404 | // Process calculation fields |
| 405 | 405 | $this->update_calculation_fields(); |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @param GravityView_Edit_Entry_Render $this This object |
| 425 | 425 | * @param GravityView_View_Data $gv_data The View data |
| 426 | 426 | */ |
| 427 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 427 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 428 | 428 | |
| 429 | 429 | } else { |
| 430 | 430 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -460,10 +460,10 @@ discard block |
||
| 460 | 460 | |
| 461 | 461 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 462 | 462 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 463 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 463 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 464 | 464 | } else { |
| 465 | 465 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 466 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 466 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -481,11 +481,11 @@ discard block |
||
| 481 | 481 | |
| 482 | 482 | $empty_value = $field->get_value_save_entry( |
| 483 | 483 | is_array( $field->get_entry_inputs() ) ? array() : '', |
| 484 | - $this->form, '', $this->entry['id'], $this->entry |
|
| 484 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
| 485 | 485 | ); |
| 486 | 486 | |
| 487 | 487 | if ( $field->has_calculation() ) { |
| 488 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
| 488 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
| 489 | 489 | $empty_value = ''; |
| 490 | 490 | } |
| 491 | 491 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | private function preset_approval_fields() { |
| 515 | 515 | $has_approved_field = false; |
| 516 | 516 | |
| 517 | - foreach ( self::$original_form['fields'] as $field ) { |
|
| 517 | + foreach ( self::$original_form[ 'fields' ] as $field ) { |
|
| 518 | 518 | if ( $field->gravityview_approved ) { |
| 519 | 519 | $has_approved_field = true; |
| 520 | 520 | break; |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | $is_field_hidden = true; |
| 529 | 529 | |
| 530 | - foreach ( $this->form['fields'] as $field ) { |
|
| 530 | + foreach ( $this->form[ 'fields' ] as $field ) { |
|
| 531 | 531 | if ( $field->gravityview_approved ) { |
| 532 | 532 | $is_field_hidden = false; |
| 533 | 533 | break; |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | remove_filter( 'gravityview/approve_entries/update_unapproved_meta', array( $this, 'prevent_update_unapproved_meta' ), 9 ); |
| 554 | 554 | |
| 555 | - if ( ! $value = gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
| 555 | + if ( ! $value = gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
| 556 | 556 | |
| 557 | 557 | $value = GravityView_Entry_Approval_Status::UNAPPROVED; |
| 558 | 558 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** No file is being uploaded. */ |
| 620 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 620 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 621 | 621 | /** So return the original upload, with $value as backup (it can be empty during edit form rendering) */ |
| 622 | 622 | return rgar( $entry, $input_id, $value ); |
| 623 | 623 | } |
@@ -635,11 +635,11 @@ discard block |
||
| 635 | 635 | * @return mixed |
| 636 | 636 | */ |
| 637 | 637 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 638 | - if( ! $this->is_edit_entry() ) { |
|
| 638 | + if ( ! $this->is_edit_entry() ) { |
|
| 639 | 639 | return $plupload_init; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 642 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 643 | 643 | |
| 644 | 644 | return $plupload_init; |
| 645 | 645 | } |
@@ -654,26 +654,26 @@ discard block |
||
| 654 | 654 | $form = $this->filter_conditional_logic( $this->form ); |
| 655 | 655 | |
| 656 | 656 | /** @type GF_Field $field */ |
| 657 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 657 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 658 | 658 | |
| 659 | 659 | /** |
| 660 | 660 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 661 | 661 | * @since 1.16.3 |
| 662 | 662 | */ |
| 663 | - if( $field->has_calculation() ) { |
|
| 664 | - unset( $form['fields'][ $k ] ); |
|
| 663 | + if ( $field->has_calculation() ) { |
|
| 664 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | $field->adminOnly = false; |
| 668 | 668 | |
| 669 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 670 | - foreach( $field->inputs as $key => $input ) { |
|
| 671 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 669 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 670 | + foreach ( $field->inputs as $key => $input ) { |
|
| 671 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 676 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 677 | 677 | |
| 678 | 678 | return $form; |
| 679 | 679 | } |
@@ -685,14 +685,14 @@ discard block |
||
| 685 | 685 | $update = false; |
| 686 | 686 | |
| 687 | 687 | // get the most up to date entry values |
| 688 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 688 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 689 | 689 | |
| 690 | 690 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 691 | 691 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 692 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 692 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 693 | 693 | } else { |
| 694 | 694 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 695 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 695 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | |
@@ -709,24 +709,24 @@ discard block |
||
| 709 | 709 | $inputs = $field->get_entry_inputs(); |
| 710 | 710 | if ( is_array( $inputs ) ) { |
| 711 | 711 | foreach ( $inputs as $input ) { |
| 712 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
| 712 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
| 713 | 713 | |
| 714 | 714 | if ( 'product' === $field->type ) { |
| 715 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 715 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 716 | 716 | |
| 717 | 717 | // Only allow quantity to be set if it's allowed to be edited |
| 718 | 718 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 719 | 719 | } else { // otherwise set to what it previously was |
| 720 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 720 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 721 | 721 | } |
| 722 | 722 | } else { |
| 723 | 723 | // Set to what it previously was if it's not editable |
| 724 | 724 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
| 725 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 725 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 726 | 726 | } |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 729 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
| 730 | 730 | } |
| 731 | 731 | } else { |
| 732 | 732 | // Set to what it previously was if it's not editable |
@@ -766,19 +766,19 @@ discard block |
||
| 766 | 766 | |
| 767 | 767 | $input_name = 'input_' . $field_id; |
| 768 | 768 | |
| 769 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 769 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 770 | 770 | |
| 771 | 771 | // We have a new image |
| 772 | 772 | |
| 773 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 773 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 774 | 774 | |
| 775 | 775 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 776 | 776 | $ary = stripslashes_deep( $ary ); |
| 777 | 777 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 778 | 778 | |
| 779 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 780 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 781 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 779 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 780 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 781 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 782 | 782 | |
| 783 | 783 | $image_meta = array( |
| 784 | 784 | 'post_excerpt' => $img_caption, |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 789 | 789 | if ( ! empty( $img_title ) ) { |
| 790 | - $image_meta['post_title'] = $img_title; |
|
| 790 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -845,15 +845,15 @@ discard block |
||
| 845 | 845 | */ |
| 846 | 846 | private function maybe_update_post_fields( $form ) { |
| 847 | 847 | |
| 848 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 848 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 849 | 849 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 850 | 850 | return; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - $post_id = $this->entry['post_id']; |
|
| 853 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 854 | 854 | |
| 855 | 855 | // Security check |
| 856 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 856 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 857 | 857 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 858 | 858 | return; |
| 859 | 859 | } |
@@ -866,25 +866,25 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 868 | 868 | |
| 869 | - if( ! $field ) { |
|
| 869 | + if ( ! $field ) { |
|
| 870 | 870 | continue; |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 873 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 874 | 874 | |
| 875 | 875 | // Get the value of the field, including $_POSTed value |
| 876 | 876 | $value = RGFormsModel::get_field_value( $field ); |
| 877 | 877 | |
| 878 | 878 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 879 | 879 | $entry_tmp = $this->entry; |
| 880 | - $entry_tmp["{$field_id}"] = $value; |
|
| 880 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 881 | 881 | |
| 882 | - switch( $field->type ) { |
|
| 882 | + switch ( $field->type ) { |
|
| 883 | 883 | |
| 884 | 884 | case 'post_title': |
| 885 | 885 | $post_title = $value; |
| 886 | 886 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 887 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 887 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 888 | 888 | } |
| 889 | 889 | $updated_post->post_title = $post_title; |
| 890 | 890 | $updated_post->post_name = $post_title; |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | case 'post_content': |
| 895 | 895 | $post_content = $value; |
| 896 | 896 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 897 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 897 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 898 | 898 | } |
| 899 | 899 | $updated_post->post_content = $post_content; |
| 900 | 900 | unset( $post_content ); |
@@ -912,11 +912,11 @@ discard block |
||
| 912 | 912 | $value = $value[ $field_id ]; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 915 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 916 | 916 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
| 919 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
| 920 | 920 | |
| 921 | 921 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
| 922 | 922 | break; |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | // update entry after |
| 931 | - $this->entry["{$field_id}"] = $value; |
|
| 931 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 932 | 932 | |
| 933 | 933 | $update_entry = true; |
| 934 | 934 | |
@@ -937,11 +937,11 @@ discard block |
||
| 937 | 937 | |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - if( $update_entry ) { |
|
| 940 | + if ( $update_entry ) { |
|
| 941 | 941 | |
| 942 | 942 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 943 | 943 | |
| 944 | - if( is_wp_error( $return_entry ) ) { |
|
| 944 | + if ( is_wp_error( $return_entry ) ) { |
|
| 945 | 945 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 946 | 946 | } else { |
| 947 | 947 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | |
| 952 | 952 | $return_post = wp_update_post( $updated_post, true ); |
| 953 | 953 | |
| 954 | - if( is_wp_error( $return_post ) ) { |
|
| 954 | + if ( is_wp_error( $return_post ) ) { |
|
| 955 | 955 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 956 | 956 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 957 | 957 | } else { |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 986 | 986 | |
| 987 | 987 | // replace conditional shortcodes |
| 988 | - if( $do_shortcode ) { |
|
| 988 | + if ( $do_shortcode ) { |
|
| 989 | 989 | $output = do_shortcode( $output ); |
| 990 | 990 | } |
| 991 | 991 | |
@@ -1004,19 +1004,19 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | private function after_update() { |
| 1006 | 1006 | |
| 1007 | - do_action( 'gform_after_update_entry', self::$original_form, $this->entry['id'], self::$original_entry ); |
|
| 1008 | - do_action( "gform_after_update_entry_{$this->form['id']}", self::$original_form, $this->entry['id'], self::$original_entry ); |
|
| 1007 | + do_action( 'gform_after_update_entry', self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 1008 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 1009 | 1009 | |
| 1010 | 1010 | // Re-define the entry now that we've updated it. |
| 1011 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 1011 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 1012 | 1012 | |
| 1013 | 1013 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
| 1014 | 1014 | |
| 1015 | 1015 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 1016 | 1016 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 1017 | 1017 | // we have just updated. |
| 1018 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 1019 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 1018 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 1019 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | 1022 | |
@@ -1026,11 +1026,11 @@ discard block |
||
| 1026 | 1026 | * @since develop |
| 1027 | 1027 | */ |
| 1028 | 1028 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
| 1029 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
| 1029 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
| 1030 | 1030 | if ( ! is_wp_error( $feeds ) ) { |
| 1031 | 1031 | $registered_feeds = array(); |
| 1032 | 1032 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
| 1033 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 1033 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 1034 | 1034 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
| 1035 | 1035 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
| 1036 | 1036 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -1038,8 +1038,8 @@ discard block |
||
| 1038 | 1038 | } |
| 1039 | 1039 | } |
| 1040 | 1040 | foreach ( $feeds as $feed ) { |
| 1041 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
| 1042 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
| 1041 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
| 1042 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
| 1043 | 1043 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
| 1044 | 1044 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
| 1045 | 1045 | $entry = $returned_entry; |
@@ -1067,9 +1067,9 @@ discard block |
||
| 1067 | 1067 | |
| 1068 | 1068 | $view = \GV\View::by_id( $this->view_id ); |
| 1069 | 1069 | |
| 1070 | - if( $view->settings->get( 'edit_locking' ) ) { |
|
| 1070 | + if ( $view->settings->get( 'edit_locking' ) ) { |
|
| 1071 | 1071 | $locking = new GravityView_Edit_Entry_Locking(); |
| 1072 | - $locking->maybe_lock_object( $this->entry['id'] ); |
|
| 1072 | + $locking->maybe_lock_object( $this->entry[ 'id' ] ); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | ?> |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | |
| 1083 | 1083 | <div class="gv-edit-entry-wrapper"><?php |
| 1084 | 1084 | |
| 1085 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 1085 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 1086 | 1086 | |
| 1087 | 1087 | /** |
| 1088 | 1088 | * Fixes weird wpautop() issue |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 1099 | 1099 | * @param GravityView_Edit_Entry_Render $this This object |
| 1100 | 1100 | */ |
| 1101 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1101 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 1102 | 1102 | |
| 1103 | 1103 | echo esc_attr( $edit_entry_title ); |
| 1104 | 1104 | ?></span> |
@@ -1175,18 +1175,18 @@ discard block |
||
| 1175 | 1175 | */ |
| 1176 | 1176 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1177 | 1177 | |
| 1178 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
| 1178 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | $back_link = remove_query_arg( array( 'page', 'view', 'edit', 'gvid' ) ); |
| 1182 | 1182 | |
| 1183 | - if( ! $this->is_valid ){ |
|
| 1183 | + if ( ! $this->is_valid ) { |
|
| 1184 | 1184 | |
| 1185 | 1185 | // Keeping this compatible with Gravity Forms. |
| 1186 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 1187 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 1186 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 1187 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 1188 | 1188 | |
| 1189 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 1189 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 1190 | 1190 | |
| 1191 | 1191 | } elseif ( false === $this->is_paged_submitted ) { |
| 1192 | 1192 | // Paged form that hasn't been submitted on the last page yet |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | * @param int $view_id View ID |
| 1200 | 1200 | * @param array $entry Gravity Forms entry array |
| 1201 | 1201 | */ |
| 1202 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
| 1202 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
| 1203 | 1203 | |
| 1204 | 1204 | echo GVCommon::generate_notice( $message ); |
| 1205 | 1205 | } else { |
@@ -1211,23 +1211,23 @@ discard block |
||
| 1211 | 1211 | |
| 1212 | 1212 | case '0': |
| 1213 | 1213 | $redirect_url = $back_link; |
| 1214 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1214 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
| 1215 | 1215 | break; |
| 1216 | 1216 | |
| 1217 | 1217 | case '1': |
| 1218 | 1218 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
| 1219 | - $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>' ); |
|
| 1219 | + $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>' ); |
|
| 1220 | 1220 | break; |
| 1221 | 1221 | |
| 1222 | 1222 | case '2': |
| 1223 | 1223 | $redirect_url = $edit_redirect_url; |
| 1224 | 1224 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
| 1225 | - $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>' ); |
|
| 1225 | + $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>' ); |
|
| 1226 | 1226 | break; |
| 1227 | 1227 | |
| 1228 | 1228 | case '': |
| 1229 | 1229 | default: |
| 1230 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1230 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 1231 | 1231 | break; |
| 1232 | 1232 | } |
| 1233 | 1233 | |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | */ |
| 1269 | 1269 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1270 | 1270 | |
| 1271 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1272 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1271 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1272 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1273 | 1273 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1274 | 1274 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
| 1275 | 1275 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1278,14 +1278,14 @@ discard block |
||
| 1278 | 1278 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1279 | 1279 | |
| 1280 | 1280 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1281 | - unset( $_GET['page'] ); |
|
| 1281 | + unset( $_GET[ 'page' ] ); |
|
| 1282 | 1282 | |
| 1283 | 1283 | $this->show_next_button = false; |
| 1284 | 1284 | $this->show_previous_button = false; |
| 1285 | 1285 | |
| 1286 | 1286 | // TODO: Verify multiple-page forms |
| 1287 | 1287 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
| 1288 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
| 1288 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
| 1289 | 1289 | |
| 1290 | 1290 | $labels = array( |
| 1291 | 1291 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1304,20 +1304,20 @@ discard block |
||
| 1304 | 1304 | */ |
| 1305 | 1305 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1306 | 1306 | |
| 1307 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
| 1308 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
| 1307 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
| 1308 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
| 1309 | 1309 | |
| 1310 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
| 1310 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
| 1311 | 1311 | $last_page = \GFFormDisplay::get_max_page_number( $this->form ); |
| 1312 | 1312 | |
| 1313 | 1313 | while ( ++$page_number < $last_page && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
| 1314 | 1314 | } // Advance to next visible page |
| 1315 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
| 1315 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
| 1316 | 1316 | while ( --$page_number > 1 && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
| 1317 | 1317 | } // Advance to next visible page |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - GFFormDisplay::$submission[ $this->form['id'] ]['page_number'] = $page_number; |
|
| 1320 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | |
| 1344 | 1344 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1345 | 1345 | |
| 1346 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1346 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1347 | 1347 | |
| 1348 | 1348 | ob_get_clean(); |
| 1349 | 1349 | |
@@ -1371,7 +1371,7 @@ discard block |
||
| 1371 | 1371 | * @return string |
| 1372 | 1372 | */ |
| 1373 | 1373 | public function render_form_buttons() { |
| 1374 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1374 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | 1377 | |
@@ -1390,15 +1390,15 @@ discard block |
||
| 1390 | 1390 | */ |
| 1391 | 1391 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1392 | 1392 | |
| 1393 | - if( $form['id'] != $this->form_id ) { |
|
| 1393 | + if ( $form[ 'id' ] != $this->form_id ) { |
|
| 1394 | 1394 | return $form; |
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1398 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
| 1398 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
| 1399 | 1399 | $form = $this->form_after_validation; |
| 1400 | 1400 | } else { |
| 1401 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1401 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | 1404 | $form = $this->filter_conditional_logic( $form ); |
@@ -1406,8 +1406,8 @@ discard block |
||
| 1406 | 1406 | $form = $this->prefill_conditional_logic( $form ); |
| 1407 | 1407 | |
| 1408 | 1408 | // for now we don't support Save and Continue feature. |
| 1409 | - if( ! self::$supports_save_and_continue ) { |
|
| 1410 | - unset( $form['save'] ); |
|
| 1409 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1410 | + unset( $form[ 'save' ] ); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | $form = $this->unselect_default_values( $form ); |
@@ -1430,31 +1430,31 @@ discard block |
||
| 1430 | 1430 | */ |
| 1431 | 1431 | public function verify_user_can_edit_post( $field_content = '', $field = null, $value = '', $lead_id = 0, $form_id = 0 ) { |
| 1432 | 1432 | |
| 1433 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1433 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1434 | 1434 | return $field_content; |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | 1437 | $message = null; |
| 1438 | 1438 | |
| 1439 | 1439 | // First, make sure they have the capability to edit the post. |
| 1440 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1440 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1441 | 1441 | |
| 1442 | 1442 | /** |
| 1443 | 1443 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1444 | 1444 | * @param string $message The existing "You don't have permission..." text |
| 1445 | 1445 | */ |
| 1446 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1446 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1447 | 1447 | |
| 1448 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1448 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1449 | 1449 | /** |
| 1450 | 1450 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1451 | 1451 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1452 | 1452 | */ |
| 1453 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1453 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | - if( $message ) { |
|
| 1457 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1456 | + if ( $message ) { |
|
| 1457 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | return $field_content; |
@@ -1478,8 +1478,8 @@ discard block |
||
| 1478 | 1478 | |
| 1479 | 1479 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1480 | 1480 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1481 | - if( |
|
| 1482 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1481 | + if ( |
|
| 1482 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1483 | 1483 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1484 | 1484 | && ! GFCommon::is_product_field( $field->type ) |
| 1485 | 1485 | || ! empty( $field_content ) |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | $return = null; |
| 1500 | 1500 | |
| 1501 | 1501 | /** @var GravityView_Field $gv_field */ |
| 1502 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1502 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1503 | 1503 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1504 | 1504 | } else { |
| 1505 | 1505 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | // If there was output, it's an error |
| 1509 | 1509 | $warnings = ob_get_clean(); |
| 1510 | 1510 | |
| 1511 | - if( !empty( $warnings ) ) { |
|
| 1511 | + if ( ! empty( $warnings ) ) { |
|
| 1512 | 1512 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1513 | 1513 | } |
| 1514 | 1514 | |
@@ -1533,7 +1533,7 @@ discard block |
||
| 1533 | 1533 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1534 | 1534 | |
| 1535 | 1535 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1536 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1536 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1537 | 1537 | |
| 1538 | 1538 | $field_value = array(); |
| 1539 | 1539 | |
@@ -1542,10 +1542,10 @@ discard block |
||
| 1542 | 1542 | |
| 1543 | 1543 | foreach ( (array)$field->inputs as $input ) { |
| 1544 | 1544 | |
| 1545 | - $input_id = strval( $input['id'] ); |
|
| 1545 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1546 | 1546 | |
| 1547 | 1547 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1548 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1548 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1549 | 1549 | $allow_pre_populated = false; |
| 1550 | 1550 | } |
| 1551 | 1551 | |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | |
| 1554 | 1554 | $pre_value = $field->get_value_submission( array(), false ); |
| 1555 | 1555 | |
| 1556 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1556 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1557 | 1557 | |
| 1558 | 1558 | } else { |
| 1559 | 1559 | |
@@ -1564,13 +1564,13 @@ discard block |
||
| 1564 | 1564 | |
| 1565 | 1565 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1566 | 1566 | // or pre-populated value if not empty and set to override saved value |
| 1567 | - $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; |
|
| 1567 | + $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; |
|
| 1568 | 1568 | |
| 1569 | 1569 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1570 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1570 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1571 | 1571 | $categories = array(); |
| 1572 | 1572 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1573 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1573 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1574 | 1574 | } |
| 1575 | 1575 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1576 | 1576 | } |
@@ -1598,7 +1598,7 @@ discard block |
||
| 1598 | 1598 | * @param GF_Field $field Gravity Forms field object |
| 1599 | 1599 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1600 | 1600 | */ |
| 1601 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1601 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1602 | 1602 | |
| 1603 | 1603 | return $field_value; |
| 1604 | 1604 | } |
@@ -1615,12 +1615,12 @@ discard block |
||
| 1615 | 1615 | */ |
| 1616 | 1616 | public function gform_pre_validation( $form ) { |
| 1617 | 1617 | |
| 1618 | - if( ! $this->verify_nonce() ) { |
|
| 1618 | + if ( ! $this->verify_nonce() ) { |
|
| 1619 | 1619 | return $form; |
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | // Fix PHP warning regarding undefined index. |
| 1623 | - foreach ( $form['fields'] as &$field) { |
|
| 1623 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1624 | 1624 | |
| 1625 | 1625 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1626 | 1626 | // expects certain field array items to be set. |
@@ -1628,7 +1628,7 @@ discard block |
||
| 1628 | 1628 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1631 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1632 | 1632 | |
| 1633 | 1633 | /** |
| 1634 | 1634 | * 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. |
@@ -1642,26 +1642,26 @@ discard block |
||
| 1642 | 1642 | // Set the previous value |
| 1643 | 1643 | $entry = $this->get_entry(); |
| 1644 | 1644 | |
| 1645 | - $input_name = 'input_'.$field->id; |
|
| 1646 | - $form_id = $form['id']; |
|
| 1645 | + $input_name = 'input_' . $field->id; |
|
| 1646 | + $form_id = $form[ 'id' ]; |
|
| 1647 | 1647 | |
| 1648 | 1648 | $value = NULL; |
| 1649 | 1649 | |
| 1650 | 1650 | // Use the previous entry value as the default. |
| 1651 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1651 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1652 | 1652 | $value = $entry[ $field->id ]; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | 1655 | // If this is a single upload file |
| 1656 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1657 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1658 | - $value = $file_path['url']; |
|
| 1656 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1657 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1658 | + $value = $file_path[ 'url' ]; |
|
| 1659 | 1659 | |
| 1660 | 1660 | } else { |
| 1661 | 1661 | |
| 1662 | 1662 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1663 | 1663 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1664 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1664 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1665 | 1665 | |
| 1666 | 1666 | } |
| 1667 | 1667 | |
@@ -1671,7 +1671,7 @@ discard block |
||
| 1671 | 1671 | if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
| 1672 | 1672 | $value = empty( $value ) ? '[]' : $value; |
| 1673 | 1673 | $value = stripslashes_deep( $value ); |
| 1674 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array() ); |
|
| 1674 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1675 | 1675 | } else if ( GFCommon::is_json( $value ) ) { |
| 1676 | 1676 | // Existing file; let GF derive the value from the `$_gf_uploaded_files` object (see `\GF_Field_FileUpload::get_multifile_value()`) |
| 1677 | 1677 | global $_gf_uploaded_files; |
@@ -1691,8 +1691,8 @@ discard block |
||
| 1691 | 1691 | |
| 1692 | 1692 | case 'number': |
| 1693 | 1693 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1694 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1695 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1694 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1695 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1696 | 1696 | } |
| 1697 | 1697 | break; |
| 1698 | 1698 | } |
@@ -1729,7 +1729,7 @@ discard block |
||
| 1729 | 1729 | * You can enter whatever you want! |
| 1730 | 1730 | * We try validating, and customize the results using `self::custom_validation()` |
| 1731 | 1731 | */ |
| 1732 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1732 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1733 | 1733 | |
| 1734 | 1734 | // Needed by the validate funtion |
| 1735 | 1735 | $failed_validation_page = NULL; |
@@ -1737,14 +1737,14 @@ discard block |
||
| 1737 | 1737 | |
| 1738 | 1738 | // Prevent entry limit from running when editing an entry, also |
| 1739 | 1739 | // prevent form scheduling from preventing editing |
| 1740 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1740 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1741 | 1741 | |
| 1742 | 1742 | // Hide fields depending on Edit Entry settings |
| 1743 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1743 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1744 | 1744 | |
| 1745 | 1745 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1746 | 1746 | |
| 1747 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1747 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | |
@@ -1772,7 +1772,7 @@ discard block |
||
| 1772 | 1772 | |
| 1773 | 1773 | $gv_valid = true; |
| 1774 | 1774 | |
| 1775 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1775 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1776 | 1776 | $value = RGFormsModel::get_field_value( $field ); |
| 1777 | 1777 | $field_type = RGFormsModel::get_input_type( $field ); |
| 1778 | 1778 | $is_required = ! empty( $field->isRequired ); |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | |
| 1781 | 1781 | // Manually validate required fields as they can be skipped be skipped by GF's validation |
| 1782 | 1782 | // This can happen when the field is considered "hidden" (see `GFFormDisplay::validate`) due to unmet conditional logic |
| 1783 | - if ( $is_required && !$failed_validation && rgblank( $value ) ) { |
|
| 1783 | + if ( $is_required && ! $failed_validation && rgblank( $value ) ) { |
|
| 1784 | 1784 | $field->failed_validation = true; |
| 1785 | 1785 | $field->validation_message = esc_html__( 'This field is required.', 'gravityview' ); |
| 1786 | 1786 | |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
| 1805 | 1805 | $input_name = 'input_' . $field->id; |
| 1806 | 1806 | //uploaded |
| 1807 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1807 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1808 | 1808 | |
| 1809 | 1809 | //existent |
| 1810 | 1810 | $entry = $this->get_entry(); |
@@ -1823,7 +1823,7 @@ discard block |
||
| 1823 | 1823 | $gv_valid = false; |
| 1824 | 1824 | |
| 1825 | 1825 | // in case of error make sure the newest upload files are removed from the upload input |
| 1826 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1826 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1827 | 1827 | } |
| 1828 | 1828 | } |
| 1829 | 1829 | |
@@ -1831,7 +1831,7 @@ discard block |
||
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | 1833 | // This field has failed validation. |
| 1834 | - if( !empty( $field->failed_validation ) ) { |
|
| 1834 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1835 | 1835 | |
| 1836 | 1836 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1837 | 1837 | |
@@ -1849,19 +1849,19 @@ discard block |
||
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | 1851 | // You can't continue inside a switch, so we do it after. |
| 1852 | - if( empty( $field->failed_validation ) ) { |
|
| 1852 | + if ( empty( $field->failed_validation ) ) { |
|
| 1853 | 1853 | continue; |
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | 1856 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1857 | 1857 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1858 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1858 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1859 | 1859 | |
| 1860 | 1860 | $entry = $this->get_entry(); |
| 1861 | 1861 | |
| 1862 | 1862 | // If the value of the entry is the same as the stored value |
| 1863 | 1863 | // Then we can assume it's not a duplicate, it's the same. |
| 1864 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1864 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1865 | 1865 | //if value submitted was not changed, then don't validate |
| 1866 | 1866 | $field->failed_validation = false; |
| 1867 | 1867 | |
@@ -1874,7 +1874,7 @@ discard block |
||
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1877 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1877 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1878 | 1878 | unset( $field->validation_message ); |
| 1879 | 1879 | $field->failed_validation = false; |
| 1880 | 1880 | continue; |
@@ -1886,12 +1886,12 @@ discard block |
||
| 1886 | 1886 | |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1889 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1890 | 1890 | |
| 1891 | 1891 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1892 | 1892 | |
| 1893 | 1893 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1894 | - $this->form_after_validation = $validation_results['form']; |
|
| 1894 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1895 | 1895 | |
| 1896 | 1896 | return $validation_results; |
| 1897 | 1897 | } |
@@ -1904,7 +1904,7 @@ discard block |
||
| 1904 | 1904 | */ |
| 1905 | 1905 | public function get_entry() { |
| 1906 | 1906 | |
| 1907 | - if( empty( $this->entry ) ) { |
|
| 1907 | + if ( empty( $this->entry ) ) { |
|
| 1908 | 1908 | // Get the database value of the entry that's being edited |
| 1909 | 1909 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1910 | 1910 | } |
@@ -1936,10 +1936,10 @@ discard block |
||
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | // If edit tab not yet configured, show all fields |
| 1939 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1939 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1940 | 1940 | |
| 1941 | 1941 | // Hide fields depending on admin settings |
| 1942 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1942 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1943 | 1943 | |
| 1944 | 1944 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1945 | 1945 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1972,7 +1972,7 @@ discard block |
||
| 1972 | 1972 | */ |
| 1973 | 1973 | private function filter_fields( $fields, $configured_fields ) { |
| 1974 | 1974 | |
| 1975 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1975 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1976 | 1976 | return $fields; |
| 1977 | 1977 | } |
| 1978 | 1978 | |
@@ -1989,12 +1989,12 @@ discard block |
||
| 1989 | 1989 | |
| 1990 | 1990 | // Remove the fields that have calculation properties and keep them to be used later |
| 1991 | 1991 | // @since 1.16.2 |
| 1992 | - if( $field->has_calculation() ) { |
|
| 1993 | - $this->fields_with_calculation[] = $field; |
|
| 1992 | + if ( $field->has_calculation() ) { |
|
| 1993 | + $this->fields_with_calculation[ ] = $field; |
|
| 1994 | 1994 | // don't remove the calculation fields on form render. |
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | - if( in_array( $field->type, $field_type_blocklist ) ) { |
|
| 1997 | + if ( in_array( $field->type, $field_type_blocklist ) ) { |
|
| 1998 | 1998 | unset( $fields[ $key ] ); |
| 1999 | 1999 | } |
| 2000 | 2000 | } |
@@ -2024,7 +2024,7 @@ discard block |
||
| 2024 | 2024 | continue; // Never include when no fields are configured |
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | - $out_fields[] = $field; |
|
| 2027 | + $out_fields[ ] = $field; |
|
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | 2030 | return array_values( $out_fields ); |
@@ -2035,8 +2035,8 @@ discard block |
||
| 2035 | 2035 | |
| 2036 | 2036 | /** @var GF_Field $field */ |
| 2037 | 2037 | foreach ( $fields as $field ) { |
| 2038 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 2039 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 2038 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 2039 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 2040 | 2040 | break; |
| 2041 | 2041 | } |
| 2042 | 2042 | |
@@ -2059,14 +2059,14 @@ discard block |
||
| 2059 | 2059 | |
| 2060 | 2060 | $return_field = $field; |
| 2061 | 2061 | |
| 2062 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 2062 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 2063 | 2063 | $return_field->label = ''; |
| 2064 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 2065 | - $return_field->label = $field_setting['custom_label']; |
|
| 2064 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 2065 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 2069 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 2068 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 2069 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | /** |
@@ -2104,16 +2104,16 @@ discard block |
||
| 2104 | 2104 | */ |
| 2105 | 2105 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 2106 | 2106 | |
| 2107 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 2108 | - foreach( $fields as $k => $field ) { |
|
| 2109 | - if( $field->adminOnly ) { |
|
| 2107 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 2108 | + foreach ( $fields as $k => $field ) { |
|
| 2109 | + if ( $field->adminOnly ) { |
|
| 2110 | 2110 | unset( $fields[ $k ] ); |
| 2111 | 2111 | } |
| 2112 | 2112 | } |
| 2113 | 2113 | return array_values( $fields ); |
| 2114 | 2114 | } |
| 2115 | 2115 | |
| 2116 | - foreach( $fields as &$field ) { |
|
| 2116 | + foreach ( $fields as &$field ) { |
|
| 2117 | 2117 | $field->adminOnly = false; |
| 2118 | 2118 | } |
| 2119 | 2119 | |
@@ -2134,7 +2134,7 @@ discard block |
||
| 2134 | 2134 | */ |
| 2135 | 2135 | private function unselect_default_values( $form ) { |
| 2136 | 2136 | |
| 2137 | - foreach ( $form['fields'] as &$field ) { |
|
| 2137 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2138 | 2138 | |
| 2139 | 2139 | if ( empty( $field->choices ) ) { |
| 2140 | 2140 | continue; |
@@ -2142,7 +2142,7 @@ discard block |
||
| 2142 | 2142 | |
| 2143 | 2143 | foreach ( $field->choices as &$choice ) { |
| 2144 | 2144 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 2145 | - $choice['isSelected'] = false; |
|
| 2145 | + $choice[ 'isSelected' ] = false; |
|
| 2146 | 2146 | } |
| 2147 | 2147 | } |
| 2148 | 2148 | } |
@@ -2167,22 +2167,22 @@ discard block |
||
| 2167 | 2167 | */ |
| 2168 | 2168 | function prefill_conditional_logic( $form ) { |
| 2169 | 2169 | |
| 2170 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 2170 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 2171 | 2171 | return $form; |
| 2172 | 2172 | } |
| 2173 | 2173 | |
| 2174 | 2174 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 2175 | 2175 | /** @var GF_Field $field */ |
| 2176 | - foreach ( $form['fields'] as &$field ) { |
|
| 2176 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2177 | 2177 | |
| 2178 | - if( 'checkbox' === $field->type ) { |
|
| 2178 | + if ( 'checkbox' === $field->type ) { |
|
| 2179 | 2179 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2180 | - $input_id = $input['id']; |
|
| 2180 | + $input_id = $input[ 'id' ]; |
|
| 2181 | 2181 | $choice = $field->choices[ $key ]; |
| 2182 | 2182 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 2183 | 2183 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 2184 | - if( $match ) { |
|
| 2185 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2184 | + if ( $match ) { |
|
| 2185 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 2186 | 2186 | } |
| 2187 | 2187 | } |
| 2188 | 2188 | } else { |
@@ -2190,15 +2190,15 @@ discard block |
||
| 2190 | 2190 | // We need to run through each field to set the default values |
| 2191 | 2191 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2192 | 2192 | |
| 2193 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2193 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2194 | 2194 | |
| 2195 | - if( 'list' === $field->type ) { |
|
| 2195 | + if ( 'list' === $field->type ) { |
|
| 2196 | 2196 | $list_rows = maybe_unserialize( $field_value ); |
| 2197 | 2197 | |
| 2198 | 2198 | $list_field_value = array(); |
| 2199 | - foreach ( (array) $list_rows as $row ) { |
|
| 2200 | - foreach ( (array) $row as $column ) { |
|
| 2201 | - $list_field_value[] = $column; |
|
| 2199 | + foreach ( (array)$list_rows as $row ) { |
|
| 2200 | + foreach ( (array)$row as $column ) { |
|
| 2201 | + $list_field_value[ ] = $column; |
|
| 2202 | 2202 | } |
| 2203 | 2203 | } |
| 2204 | 2204 | |
@@ -2231,32 +2231,32 @@ discard block |
||
| 2231 | 2231 | * @see https://github.com/gravityview/GravityView/issues/840 |
| 2232 | 2232 | * @since develop |
| 2233 | 2233 | */ |
| 2234 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
| 2234 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
| 2235 | 2235 | $editable_ids = array(); |
| 2236 | - foreach ( $form['fields'] as $field ) { |
|
| 2237 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
| 2236 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 2237 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
| 2238 | 2238 | } |
| 2239 | 2239 | $remove_conditions_rule = array(); |
| 2240 | - foreach ( $the_form['fields'] as $field ) { |
|
| 2241 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
| 2242 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
| 2243 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
| 2240 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
| 2241 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
| 2242 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
| 2243 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
| 2244 | 2244 | /** |
| 2245 | 2245 | * This conditional field is not editable in this View. |
| 2246 | 2246 | * We need to remove the rule, but only if it matches. |
| 2247 | 2247 | */ |
| 2248 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
| 2248 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
| 2249 | 2249 | $value = $_field->get_value_export( $this->entry ); |
| 2250 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
| 2251 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
| 2250 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
| 2251 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
| 2252 | 2252 | } else { |
| 2253 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
| 2253 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
| 2254 | 2254 | } |
| 2255 | 2255 | |
| 2256 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
| 2256 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
| 2257 | 2257 | |
| 2258 | 2258 | if ( $match ) { |
| 2259 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
| 2259 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
| 2260 | 2260 | } |
| 2261 | 2261 | } |
| 2262 | 2262 | } |
@@ -2264,21 +2264,21 @@ discard block |
||
| 2264 | 2264 | } |
| 2265 | 2265 | |
| 2266 | 2266 | if ( $remove_conditions_rule ) { |
| 2267 | - foreach ( $form['fields'] as &$field ) { |
|
| 2267 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2268 | 2268 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2269 | 2269 | |
| 2270 | 2270 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
| 2271 | 2271 | |
| 2272 | - if ( $field['id'] == $rule_field_id ) { |
|
| 2273 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
| 2274 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
| 2272 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
| 2273 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
| 2274 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
| 2275 | 2275 | } |
| 2276 | 2276 | } |
| 2277 | 2277 | } |
| 2278 | 2278 | } |
| 2279 | 2279 | |
| 2280 | 2280 | /** Normalize the indices... */ |
| 2281 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 2281 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 2282 | 2282 | |
| 2283 | 2283 | /** |
| 2284 | 2284 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2288,16 +2288,16 @@ discard block |
||
| 2288 | 2288 | */ |
| 2289 | 2289 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 2290 | 2290 | |
| 2291 | - if( $use_conditional_logic ) { |
|
| 2291 | + if ( $use_conditional_logic ) { |
|
| 2292 | 2292 | return $form; |
| 2293 | 2293 | } |
| 2294 | 2294 | |
| 2295 | - foreach( $form['fields'] as &$field ) { |
|
| 2295 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2296 | 2296 | /* @var GF_Field $field */ |
| 2297 | 2297 | $field->conditionalLogic = null; |
| 2298 | 2298 | } |
| 2299 | 2299 | |
| 2300 | - unset( $form['button']['conditionalLogic'] ); |
|
| 2300 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 2301 | 2301 | |
| 2302 | 2302 | return $form; |
| 2303 | 2303 | |
@@ -2314,7 +2314,7 @@ discard block |
||
| 2314 | 2314 | */ |
| 2315 | 2315 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 2316 | 2316 | |
| 2317 | - if( ! $this->is_edit_entry() ) { |
|
| 2317 | + if ( ! $this->is_edit_entry() ) { |
|
| 2318 | 2318 | return $has_conditional_logic; |
| 2319 | 2319 | } |
| 2320 | 2320 | |
@@ -2346,44 +2346,44 @@ discard block |
||
| 2346 | 2346 | * 2. There are two entries embedded using oEmbed |
| 2347 | 2347 | * 3. One of the entries has just been saved |
| 2348 | 2348 | */ |
| 2349 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 2349 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 2350 | 2350 | |
| 2351 | 2351 | $error = true; |
| 2352 | 2352 | |
| 2353 | 2353 | } |
| 2354 | 2354 | |
| 2355 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 2355 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 2356 | 2356 | |
| 2357 | 2357 | $error = true; |
| 2358 | 2358 | |
| 2359 | - } elseif( ! $this->verify_nonce() ) { |
|
| 2359 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 2360 | 2360 | |
| 2361 | 2361 | /** |
| 2362 | 2362 | * If the Entry is embedded, there may be two entries on the same page. |
| 2363 | 2363 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 2364 | 2364 | */ |
| 2365 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2365 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2366 | 2366 | $error = true; |
| 2367 | 2367 | } else { |
| 2368 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 2368 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | 2371 | } |
| 2372 | 2372 | |
| 2373 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2374 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 2373 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2374 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 2375 | 2375 | } |
| 2376 | 2376 | |
| 2377 | - if( $this->entry['status'] === 'trash' ) { |
|
| 2378 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2377 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 2378 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2379 | 2379 | } |
| 2380 | 2380 | |
| 2381 | 2381 | // No errors; everything's fine here! |
| 2382 | - if( empty( $error ) ) { |
|
| 2382 | + if ( empty( $error ) ) { |
|
| 2383 | 2383 | return true; |
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | - if( $echo && $error !== true ) { |
|
| 2386 | + if ( $echo && $error !== true ) { |
|
| 2387 | 2387 | |
| 2388 | 2388 | $error = esc_html( $error ); |
| 2389 | 2389 | |
@@ -2391,10 +2391,10 @@ discard block |
||
| 2391 | 2391 | * @since 1.9 |
| 2392 | 2392 | */ |
| 2393 | 2393 | if ( ! empty( $this->entry ) ) { |
| 2394 | - $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;" ) ); |
|
| 2394 | + $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;" ) ); |
|
| 2395 | 2395 | } |
| 2396 | 2396 | |
| 2397 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2397 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2398 | 2398 | } |
| 2399 | 2399 | |
| 2400 | 2400 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2414,17 +2414,17 @@ discard block |
||
| 2414 | 2414 | |
| 2415 | 2415 | $error = NULL; |
| 2416 | 2416 | |
| 2417 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2418 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2417 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2418 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2419 | 2419 | } |
| 2420 | 2420 | |
| 2421 | 2421 | // No errors; everything's fine here! |
| 2422 | - if( empty( $error ) ) { |
|
| 2422 | + if ( empty( $error ) ) { |
|
| 2423 | 2423 | return true; |
| 2424 | 2424 | } |
| 2425 | 2425 | |
| 2426 | - if( $echo ) { |
|
| 2427 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2426 | + if ( $echo ) { |
|
| 2427 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2428 | 2428 | } |
| 2429 | 2429 | |
| 2430 | 2430 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2445,14 +2445,14 @@ discard block |
||
| 2445 | 2445 | private function check_user_cap_edit_field( $field ) { |
| 2446 | 2446 | |
| 2447 | 2447 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2448 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2448 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2449 | 2449 | return true; |
| 2450 | 2450 | } |
| 2451 | 2451 | |
| 2452 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2452 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2453 | 2453 | |
| 2454 | - if( $field_cap ) { |
|
| 2455 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2454 | + if ( $field_cap ) { |
|
| 2455 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2456 | 2456 | } |
| 2457 | 2457 | |
| 2458 | 2458 | return false; |
@@ -2466,17 +2466,17 @@ discard block |
||
| 2466 | 2466 | public function verify_nonce() { |
| 2467 | 2467 | |
| 2468 | 2468 | // Verify form submitted for editing single |
| 2469 | - if( $this->is_edit_entry_submission() ) { |
|
| 2469 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2470 | 2470 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | // Verify |
| 2474 | - else if( ! $this->is_edit_entry() ) { |
|
| 2474 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2475 | 2475 | $valid = false; |
| 2476 | 2476 | } |
| 2477 | 2477 | |
| 2478 | 2478 | else { |
| 2479 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2479 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2480 | 2480 | } |
| 2481 | 2481 | |
| 2482 | 2482 | /** |
@@ -2536,7 +2536,7 @@ discard block |
||
| 2536 | 2536 | */ |
| 2537 | 2537 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 2538 | 2538 | |
| 2539 | - return (array) $labels; |
|
| 2539 | + return (array)$labels; |
|
| 2540 | 2540 | } |
| 2541 | 2541 | |
| 2542 | 2542 | } //end class |
@@ -716,7 +716,8 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | // Only allow quantity to be set if it's allowed to be edited |
| 718 | 718 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 719 | - } else { // otherwise set to what it previously was |
|
| 719 | + } else { |
|
| 720 | +// otherwise set to what it previously was |
|
| 720 | 721 | $_POST[ $input_name ] = $entry[ $input['id'] ]; |
| 721 | 722 | } |
| 722 | 723 | } else { |
@@ -1180,7 +1181,7 @@ discard block |
||
| 1180 | 1181 | |
| 1181 | 1182 | $back_link = remove_query_arg( array( 'page', 'view', 'edit', 'gvid' ) ); |
| 1182 | 1183 | |
| 1183 | - if( ! $this->is_valid ){ |
|
| 1184 | + if( ! $this->is_valid ) { |
|
| 1184 | 1185 | |
| 1185 | 1186 | // Keeping this compatible with Gravity Forms. |
| 1186 | 1187 | $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
@@ -2473,9 +2474,7 @@ discard block |
||
| 2473 | 2474 | // Verify |
| 2474 | 2475 | else if( ! $this->is_edit_entry() ) { |
| 2475 | 2476 | $valid = false; |
| 2476 | - } |
|
| 2477 | - |
|
| 2478 | - else { |
|
| 2477 | + } else { |
|
| 2479 | 2478 | $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
| 2480 | 2479 | } |
| 2481 | 2480 | |
@@ -26,52 +26,52 @@ |
||
| 26 | 26 | |
| 27 | 27 | <?php // list all the available templates (type= fresh or custom ) ?> |
| 28 | 28 | <div class="gv-grid"> |
| 29 | - <?php foreach( $templates as $id => $template ) { |
|
| 29 | + <?php foreach ( $templates as $id => $template ) { |
|
| 30 | 30 | $selected = ( $id == $current_template ) ? ' gv-selected' : ''; |
| 31 | - $placeholder = ! empty( $template['buy_source'] ); |
|
| 32 | - $is_included = ! empty( $template['included'] ); |
|
| 31 | + $placeholder = ! empty( $template[ 'buy_source' ] ); |
|
| 32 | + $is_included = ! empty( $template[ 'included' ] ); |
|
| 33 | 33 | $plugin_data = GravityView_Admin_Installer::get_wp_plugins_data( \GV\Utils::get( $template, 'textdomain', '' ) ); |
| 34 | 34 | $button_text = empty( $plugin_data ) ? esc_html__( 'Install Layout', 'gravityview' ) : esc_html__( 'Activate & Select Layout', 'gravityview' ); |
| 35 | 35 | $button_class = 'gv-layout-' . ( empty( $plugin_data ) ? 'install' : 'activate' ); |
| 36 | - $template_path = isset($plugin_data['path']) ? $plugin_data['path'] : ''; |
|
| 36 | + $template_path = isset( $plugin_data[ 'path' ] ) ? $plugin_data[ 'path' ] : ''; |
|
| 37 | 37 | |
| 38 | 38 | ?> |
| 39 | 39 | <div class="gv-grid-col-1-4"> |
| 40 | - <div class="gv-view-types-module<?php echo $selected; if( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template['type'] ); ?>"> |
|
| 40 | + <div class="gv-view-types-module<?php echo $selected; if ( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template[ 'type' ] ); ?>"> |
|
| 41 | 41 | <div class="gv-view-types-normal"> |
| 42 | - <img src="<?php echo esc_url( $template['logo'] ); ?>" alt="<?php echo esc_attr( $template['label'] ); ?>"> |
|
| 43 | - <h5><?php echo esc_html( $template['label'] ); ?></h5> |
|
| 44 | - <p class="description"><?php echo esc_html( $template['description'] ); ?></p> |
|
| 42 | + <img src="<?php echo esc_url( $template[ 'logo' ] ); ?>" alt="<?php echo esc_attr( $template[ 'label' ] ); ?>"> |
|
| 43 | + <h5><?php echo esc_html( $template[ 'label' ] ); ?></h5> |
|
| 44 | + <p class="description"><?php echo esc_html( $template[ 'description' ] ); ?></p> |
|
| 45 | 45 | </div> |
| 46 | 46 | <div class="gv-view-types-hover"> |
| 47 | 47 | <div> |
| 48 | 48 | <?php |
| 49 | - if( $is_included ) { |
|
| 49 | + if ( $is_included ) { |
|
| 50 | 50 | ?> |
| 51 | 51 | <p><a href="<?php echo esc_url( admin_url( 'edit.php?post_type=gravityview&page=gv-admin-installer' ) ); ?>" class="button button-secondary button-hero <?php echo $button_class; ?>" rel="internal" data-template-path="<?php echo $template_path; ?>"><?php echo $button_text; ?></a></p> |
| 52 | - <?php if( !empty( $template['license'] ) ) { ?> |
|
| 53 | - <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', ' ', $template['license'] ) ) ); ?></p> |
|
| 52 | + <?php if ( ! empty( $template[ 'license' ] ) ) { ?> |
|
| 53 | + <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', ' ', $template[ 'license' ] ) ) ); ?></p> |
|
| 54 | 54 | <?php } ?> |
| 55 | 55 | <?php |
| 56 | - } elseif( $placeholder ) { |
|
| 57 | - $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template['license'] ) . '&utm_content=' . urlencode( $template['slug'] ); |
|
| 56 | + } elseif ( $placeholder ) { |
|
| 57 | + $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template[ 'license' ] ) . '&utm_content=' . urlencode( $template[ 'slug' ] ); |
|
| 58 | 58 | ?> |
| 59 | - <p><a href="<?php echo esc_url( $template['buy_source'] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview'); ?></a></p> |
|
| 59 | + <p><a href="<?php echo esc_url( $template[ 'buy_source' ] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview' ); ?></a></p> |
|
| 60 | 60 | |
| 61 | - <?php if( !empty( $template['preview'] ) ) { ?> |
|
| 62 | - <p><a href="<?php echo esc_url( $template['preview'] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview'); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p> |
|
| 61 | + <?php if ( ! empty( $template[ 'preview' ] ) ) { ?> |
|
| 62 | + <p><a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview' ); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p> |
|
| 63 | 63 | <?php } ?> |
| 64 | 64 | |
| 65 | - <?php if( ! empty( $template['license'] ) ) { ?> |
|
| 66 | - <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://www.gravitykit.com/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', ' ', $template['license'] ) ) . '</a>' ); ?></p> |
|
| 65 | + <?php if ( ! empty( $template[ 'license' ] ) ) { ?> |
|
| 66 | + <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://www.gravitykit.com/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', ' ', $template[ 'license' ] ) ) . '</a>' ); ?></p> |
|
| 67 | 67 | <?php } ?> |
| 68 | 68 | <?php } |
| 69 | 69 | |
| 70 | - if ($placeholder || $is_included) { ?> </div><div class="hidden"> <?php } ?> |
|
| 70 | + if ( $placeholder || $is_included ) { ?> </div><div class="hidden"> <?php } ?> |
|
| 71 | 71 | |
| 72 | - <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview'); ?></a></p> |
|
| 73 | - <?php if( !empty( $template['preview'] ) ) { ?> |
|
| 74 | - <a href="<?php echo esc_url( $template['preview'] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-welcome-view-site" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview'); ?>"></i></a> |
|
| 72 | + <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview' ); ?></a></p> |
|
| 73 | + <?php if ( ! empty( $template[ 'preview' ] ) ) { ?> |
|
| 74 | + <a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-welcome-view-site" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview' ); ?>"></i></a> |
|
| 75 | 75 | <?php } ?> |
| 76 | 76 | </div> |
| 77 | 77 | </div> |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function add_downloads_data_filters() { |
| 68 | 68 | |
| 69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 70 | 70 | |
| 71 | - if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
| 71 | + if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function add_admin_menu() { |
| 99 | 99 | |
| 100 | - $menu_text = _x( 'Manage Add-Ons', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 100 | + $menu_text = _x( 'Manage Add-Ons', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 101 | 101 | |
| 102 | 102 | $menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
| 103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | - * |
|
| 115 | + * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | + * |
|
| 117 | 117 | * @param array $notice |
| 118 | 118 | * |
| 119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
| 122 | 122 | |
| 123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
| 124 | - return $notice; |
|
| 125 | - } |
|
| 124 | + return $notice; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -167,43 +167,43 @@ discard block |
||
| 167 | 167 | * Get downloads data from transient or from API; save transient after getting data from API |
| 168 | 168 | * |
| 169 | 169 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
| 170 | - * @type array $info { |
|
| 171 | - * @type string $id int 17 |
|
| 172 | - * @type string $slug Extension slug |
|
| 173 | - * @type string $title Extension title |
|
| 174 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 175 | - * @type string $modified_date |
|
| 176 | - * @type string $status |
|
| 177 | - * @type string $link URL to public plugin page |
|
| 178 | - * @type string $content |
|
| 179 | - * @type string $excerpt |
|
| 180 | - * @type string $thumbnail URL to thumbnail |
|
| 181 | - * @type array $category Taxonomy details for the plugin's category { |
|
| 182 | - * @type int $term_id => int 30 |
|
| 183 | - * @type string $name => string 'Plugins' (length=7) |
|
| 184 | - * @type string $slug => string 'plugins' (length=7) |
|
| 185 | - * @type int $term_group => int 0 |
|
| 186 | - * @type int $term_taxonomy_id => int 30 |
|
| 187 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
| 188 | - * @type string $description => string '' (length=0) |
|
| 189 | - * @type int $parent => int 0 |
|
| 190 | - * @type int $count => int 4 |
|
| 191 | - * @type string $filter => string 'raw' (length=3) |
|
| 192 | - * } |
|
| 193 | - * @type array $tags {see $category above} |
|
| 194 | - * @type string $textdomain string 'gravityview' (length=11) |
|
| 195 | - * } |
|
| 196 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 197 | - * @type array $licensing { |
|
| 198 | - * @type bool $enabled Is licensing enabled for the extension |
|
| 199 | - * @type string $version Version number |
|
| 200 | - * @type string $exp_unit Expiration unit ('years') |
|
| 201 | - * @type string $exp_length Expiration length ('1') |
|
| 202 | - * } |
|
| 203 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 204 | - * @type string $file string URL of the file download |
|
| 205 | - * } |
|
| 206 | - * } |
|
| 170 | + * @type array $info { |
|
| 171 | + * @type string $id int 17 |
|
| 172 | + * @type string $slug Extension slug |
|
| 173 | + * @type string $title Extension title |
|
| 174 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 175 | + * @type string $modified_date |
|
| 176 | + * @type string $status |
|
| 177 | + * @type string $link URL to public plugin page |
|
| 178 | + * @type string $content |
|
| 179 | + * @type string $excerpt |
|
| 180 | + * @type string $thumbnail URL to thumbnail |
|
| 181 | + * @type array $category Taxonomy details for the plugin's category { |
|
| 182 | + * @type int $term_id => int 30 |
|
| 183 | + * @type string $name => string 'Plugins' (length=7) |
|
| 184 | + * @type string $slug => string 'plugins' (length=7) |
|
| 185 | + * @type int $term_group => int 0 |
|
| 186 | + * @type int $term_taxonomy_id => int 30 |
|
| 187 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
| 188 | + * @type string $description => string '' (length=0) |
|
| 189 | + * @type int $parent => int 0 |
|
| 190 | + * @type int $count => int 4 |
|
| 191 | + * @type string $filter => string 'raw' (length=3) |
|
| 192 | + * } |
|
| 193 | + * @type array $tags {see $category above} |
|
| 194 | + * @type string $textdomain string 'gravityview' (length=11) |
|
| 195 | + * } |
|
| 196 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 197 | + * @type array $licensing { |
|
| 198 | + * @type bool $enabled Is licensing enabled for the extension |
|
| 199 | + * @type string $version Version number |
|
| 200 | + * @type string $exp_unit Expiration unit ('years') |
|
| 201 | + * @type string $exp_length Expiration length ('1') |
|
| 202 | + * } |
|
| 203 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 204 | + * @type string $file string URL of the file download |
|
| 205 | + * } |
|
| 206 | + * } |
|
| 207 | 207 | */ |
| 208 | 208 | public function get_downloads_data() { |
| 209 | 209 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | ) ); |
| 236 | 236 | |
| 237 | 237 | if ( is_wp_error( $response ) ) { |
| 238 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 238 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 239 | 239 | return $response; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | <div class="gv-admin-installer-notice notice inline error"> |
| 289 | 289 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
| 290 | 290 | <?php |
| 291 | - if ( is_wp_error( $downloads_data ) ) { |
|
| 292 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 293 | - } |
|
| 294 | - ?> |
|
| 291 | + if ( is_wp_error( $downloads_data ) ) { |
|
| 292 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 293 | + } |
|
| 294 | + ?> |
|
| 295 | 295 | </div> |
| 296 | 296 | </div> |
| 297 | 297 | <?php |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | protected function render_download( $download, $wp_plugins ) { |
| 383 | 383 | |
| 384 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 384 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 385 | 385 | |
| 386 | - $download_info = $details['download_info']; |
|
| 386 | + $download_info = $details['download_info']; |
|
| 387 | 387 | |
| 388 | 388 | ?> |
| 389 | 389 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -407,45 +407,45 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | <div class="addon-excerpt"><?php |
| 409 | 409 | |
| 410 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 410 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 411 | 411 | |
| 412 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 413 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 414 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 412 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 413 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 414 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 415 | 415 | |
| 416 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 417 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 416 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 417 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 418 | 418 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
| 419 | 419 | |
| 420 | 420 | echo wpautop( $excerpt ); |
| 421 | - ?></div> |
|
| 421 | + ?></div> |
|
| 422 | 422 | </div> |
| 423 | 423 | </div> |
| 424 | 424 | <?php |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 429 | - * |
|
| 428 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 429 | + * |
|
| 430 | 430 | * @since 2.10 Allow managing installed add-ons whether or not the user's license shows they have access. |
| 431 | 431 | * |
| 432 | 432 | * @param array $download Single download, as returned by {@see get_downloads_data} |
| 433 | 433 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
| 434 | 434 | * |
| 435 | 435 | * @return array { |
| 436 | - * @type array $download_info |
|
| 437 | - * @type string $plugin_path |
|
| 438 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 439 | - * @type string $status_label |
|
| 440 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 441 | - * @type string $button_class CSS class to use for the button |
|
| 442 | - * @type string $button_label Text to use for the download's anchor link |
|
| 443 | - * @type string $href URL for the download's button |
|
| 444 | - * @type bool $spinner Whether to show the spinner icon |
|
| 445 | - * @type string $item_class CSS class for the download container |
|
| 446 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 447 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 448 | - * } |
|
| 436 | + * @type array $download_info |
|
| 437 | + * @type string $plugin_path |
|
| 438 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 439 | + * @type string $status_label |
|
| 440 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 441 | + * @type string $button_class CSS class to use for the button |
|
| 442 | + * @type string $button_label Text to use for the download's anchor link |
|
| 443 | + * @type string $href URL for the download's button |
|
| 444 | + * @type bool $spinner Whether to show the spinner icon |
|
| 445 | + * @type string $item_class CSS class for the download container |
|
| 446 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 447 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 448 | + * } |
|
| 449 | 449 | */ |
| 450 | 450 | private function get_download_display_details( $download, $wp_plugins ) { |
| 451 | 451 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | 'slug' => '', |
| 457 | 457 | 'excerpt' => '', |
| 458 | 458 | 'link' => '', |
| 459 | - 'coming_soon' => false, |
|
| 459 | + 'coming_soon' => false, |
|
| 460 | 460 | 'installer_title' => null, // May not be defined |
| 461 | 461 | 'installer_excerpt' => null, // May not be defined |
| 462 | 462 | ) ); |
@@ -500,14 +500,14 @@ discard block |
||
| 500 | 500 | $href = 'https://www.gravitykit.com/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 504 | - $spinner = false; |
|
| 505 | - $status = 'notinstalled'; |
|
| 506 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 507 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
| 508 | - $button_class = 'button-primary button-large'; |
|
| 509 | - $href = \GV\Utils::get( $download_info, 'link', 'https://www.gravitykit.com/extensions/' ); |
|
| 510 | - } |
|
| 503 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 504 | + $spinner = false; |
|
| 505 | + $status = 'notinstalled'; |
|
| 506 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 507 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
| 508 | + $button_class = 'button-primary button-large'; |
|
| 509 | + $href = \GV\Utils::get( $download_info, 'link', 'https://www.gravitykit.com/extensions/' ); |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | 512 | // Access but the plugin is not installed |
| 513 | 513 | elseif ( ! $wp_plugin ) { |
@@ -553,18 +553,18 @@ discard block |
||
| 553 | 553 | $download_info['link'] = add_query_arg( array( 'license_key' => $license_key ), $download_info['link'] ); |
| 554 | 554 | |
| 555 | 555 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
| 556 | - } |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | /** |
| 559 | - * Returns the base price for an extension |
|
| 560 | - * |
|
| 559 | + * Returns the base price for an extension |
|
| 560 | + * |
|
| 561 | 561 | * @param array $download |
| 562 | 562 | * |
| 563 | 563 | * @return float Base price for an extension. If not for sale separately, returns 0 |
| 564 | 564 | */ |
| 565 | 565 | private function get_download_base_price( $download ) { |
| 566 | 566 | |
| 567 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 567 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 568 | 568 | $base_price = \GFCommon::to_number( $base_price ); |
| 569 | 569 | |
| 570 | 570 | unset( $download['pricing']['amount'] ); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | return floatval( $base_price ); |
| 578 | - } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | /** |
| 581 | 581 | * Handle AJAX request to activate extension |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
| 595 | 595 | wp_send_json_error( array( |
| 596 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 597 | - ) ); |
|
| 596 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 597 | + ) ); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | wp_send_json_success(); |
@@ -615,10 +615,10 @@ discard block |
||
| 615 | 615 | deactivate_plugins( $data['path'] ); |
| 616 | 616 | |
| 617 | 617 | if( is_plugin_active( $data['path'] ) ) { |
| 618 | - wp_send_json_error( array( |
|
| 619 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 620 | - ) ); |
|
| 621 | - } |
|
| 618 | + wp_send_json_error( array( |
|
| 619 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 620 | + ) ); |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | 623 | wp_send_json_success(); |
| 624 | 624 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function register_noconflict( $items ) { |
| 55 | 55 | |
| 56 | - $items[] = 'gravityview-admin-installer'; |
|
| 56 | + $items[ ] = 'gravityview-admin-installer'; |
|
| 57 | 57 | |
| 58 | 58 | return $items; |
| 59 | 59 | } |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
| 70 | 70 | |
| 71 | - if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
| 71 | + if ( ! $downloads_data && ! isset( $_GET[ 'cache' ] ) ) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
| 75 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
| 76 | 76 | foreach ( $downloads_data as $extension ) { |
| 77 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
| 77 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return (object) array( |
|
| 82 | - 'slug' => $extension['info']['slug'], |
|
| 83 | - 'name' => $extension['info']['title'], |
|
| 84 | - 'version' => $extension['licensing']['version'], |
|
| 85 | - 'download_link' => $extension['files'][0]['file'], |
|
| 81 | + return (object)array( |
|
| 82 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
| 83 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
| 84 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
| 85 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | foreach ( $all_plugins as $path => $plugin ) { |
| 151 | 151 | |
| 152 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
| 152 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
| 153 | 153 | continue; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
| 156 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
| 157 | 157 | 'path' => $path, |
| 158 | - 'version' => $plugin['Version'], |
|
| 158 | + 'version' => $plugin[ 'Version' ], |
|
| 159 | 159 | 'activated' => is_plugin_active( $path ) |
| 160 | 160 | ); |
| 161 | 161 | } |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
| 211 | 211 | |
| 212 | - if ( $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
| 212 | + if ( $downloads_data && ! isset( $_GET[ 'cache' ] ) ) { |
|
| 213 | 213 | return $downloads_data; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if( \GV\Plugin::is_network_activated() ) { |
|
| 216 | + if ( \GV\Plugin::is_network_activated() ) { |
|
| 217 | 217 | $home_url = network_home_url(); |
| 218 | 218 | } else { |
| 219 | 219 | $home_url = home_url(); |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
| 243 | 243 | |
| 244 | - if ( empty( $downloads_data['products'] ) ) { |
|
| 244 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
| 245 | 245 | return array(); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
| 248 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
| 249 | 249 | |
| 250 | - return $downloads_data['products']; |
|
| 250 | + return $downloads_data[ 'products' ]; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | <h2><?php esc_html_e( 'The following plugins extend GravityView and Gravity Forms functionality:', 'gravityview' ); ?></h2> |
| 309 | 309 | |
| 310 | - <a class="button button-secondary gv-admin-installer-refresh-link" href="<?php echo add_query_arg(array( 'cache' => 1 ) ); ?>"><i class="dashicons dashicons-update" style="margin-top: .2em"></i> <?php esc_html_e( 'Refresh', 'gravityview' ); ?></a> |
|
| 310 | + <a class="button button-secondary gv-admin-installer-refresh-link" href="<?php echo add_query_arg( array( 'cache' => 1 ) ); ?>"><i class="dashicons dashicons-update" style="margin-top: .2em"></i> <?php esc_html_e( 'Refresh', 'gravityview' ); ?></a> |
|
| 311 | 311 | |
| 312 | 312 | <hr class="wp-header-end" /> |
| 313 | 313 | |
@@ -324,11 +324,11 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | $this->render_section( 'extensions', esc_html__( 'GravityView Extensions', 'gravityview' ), $downloads_data, $wp_plugins ); |
| 326 | 326 | |
| 327 | - $this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
| 327 | + $this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
| 328 | 328 | |
| 329 | - $this->render_section( 'labs', esc_html__( 'GravityView Labs', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
| 329 | + $this->render_section( 'labs', esc_html__( 'GravityView Labs', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
| 330 | 330 | |
| 331 | - $this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
| 331 | + $this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
| 332 | 332 | ?> |
| 333 | 333 | </div> |
| 334 | 334 | </div> |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - if ( empty( $download['info'] ) ) { |
|
| 358 | + if ( empty( $download[ 'info' ] ) ) { |
|
| 359 | 359 | continue; |
| 360 | 360 | } |
| 361 | 361 | |
@@ -383,31 +383,31 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
| 385 | 385 | |
| 386 | - $download_info = $details['download_info']; |
|
| 386 | + $download_info = $details[ 'download_info' ]; |
|
| 387 | 387 | |
| 388 | 388 | ?> |
| 389 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
| 389 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
| 390 | 390 | <div class="addon-inner"> |
| 391 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
| 392 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
| 391 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
| 392 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
| 393 | 393 | <div> |
| 394 | - <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
| 395 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
| 396 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
| 394 | + <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
| 395 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
| 396 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
| 397 | 397 | </div> |
| 398 | 398 | <?php } ?> |
| 399 | 399 | |
| 400 | - <?php if ( 'gravityview' !== $download_info['slug'] ) { ?> |
|
| 401 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
| 402 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
| 403 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
| 400 | + <?php if ( 'gravityview' !== $download_info[ 'slug' ] ) { ?> |
|
| 401 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
| 402 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
| 403 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
| 404 | 404 | </a> |
| 405 | 405 | <?php } ?> |
| 406 | 406 | </div> |
| 407 | 407 | |
| 408 | 408 | <div class="addon-excerpt"><?php |
| 409 | 409 | |
| 410 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 410 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
| 411 | 411 | |
| 412 | 412 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
| 413 | 413 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | private function get_download_display_details( $download, $wp_plugins ) { |
| 451 | 451 | |
| 452 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
| 452 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
| 453 | 453 | 'thumbnail' => '', |
| 454 | 454 | 'title' => '', |
| 455 | 455 | 'textdomain' => '', |
@@ -461,9 +461,9 @@ discard block |
||
| 461 | 461 | 'installer_excerpt' => null, // May not be defined |
| 462 | 462 | ) ); |
| 463 | 463 | |
| 464 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
| 464 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
| 465 | 465 | |
| 466 | - $has_access = ! empty( $download['files'] ); |
|
| 466 | + $has_access = ! empty( $download[ 'files' ] ); |
|
| 467 | 467 | $spinner = true; |
| 468 | 468 | $href = $plugin_path = '#'; |
| 469 | 469 | $status = $item_class = $button_title = $button_class = ''; |
@@ -473,11 +473,11 @@ discard block |
||
| 473 | 473 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
| 474 | 474 | |
| 475 | 475 | // The license is not active - no matter what level, this should not work |
| 476 | - if( ! $is_active && empty( $base_price ) ) { |
|
| 476 | + if ( ! $is_active && empty( $base_price ) ) { |
|
| 477 | 477 | $spinner = false; |
| 478 | 478 | $status_label = ''; |
| 479 | 479 | $button_label = sprintf( __( 'Active %s License is Required.', 'gravityview' ), $required_license ); |
| 480 | - $href = $download_info['link']; |
|
| 480 | + $href = $download_info[ 'link' ]; |
|
| 481 | 481 | $button_class = 'button-primary'; |
| 482 | 482 | } |
| 483 | 483 | |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | $status_label = ''; |
| 488 | 488 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
| 489 | 489 | $button_class = 'button-primary button-large'; |
| 490 | - $href = $download_info['link']; |
|
| 490 | + $href = $download_info[ 'link' ]; |
|
| 491 | 491 | $item_class = 'featured'; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | $href = 'https://www.gravitykit.com/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 503 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
| 504 | 504 | $spinner = false; |
| 505 | 505 | $status = 'notinstalled'; |
| 506 | 506 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | $href = add_query_arg( |
| 516 | 516 | array( |
| 517 | 517 | 'action' => 'install-plugin', |
| 518 | - 'plugin' => $download_info['slug'], |
|
| 519 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
| 518 | + 'plugin' => $download_info[ 'slug' ], |
|
| 519 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
| 520 | 520 | ), |
| 521 | 521 | self_admin_url( 'update.php' ) |
| 522 | 522 | ); |
@@ -532,12 +532,12 @@ discard block |
||
| 532 | 532 | $status = 'inactive'; |
| 533 | 533 | $status_label = __( 'Inactive', 'gravityview' ); |
| 534 | 534 | $button_label = __( 'Activate', 'gravityview' ); |
| 535 | - $plugin_path = $wp_plugin['path']; |
|
| 535 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
| 536 | 536 | $button_class = 'button-secondary'; |
| 537 | 537 | } |
| 538 | 538 | // The plugin is installed and active |
| 539 | - elseif ( ! empty( $wp_plugin['path'] ) ) { |
|
| 540 | - $plugin_path = $wp_plugin['path']; |
|
| 539 | + elseif ( ! empty( $wp_plugin[ 'path' ] ) ) { |
|
| 540 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
| 541 | 541 | $status = 'active'; |
| 542 | 542 | $status_label = __( 'Active', 'gravityview' ); |
| 543 | 543 | $button_label = __( 'Deactivate', 'gravityview' ); |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | $href = add_query_arg( array( 'license_key' => $license_key ), $href ); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - $download_info['link'] = add_query_arg( array( 'license_key' => $license_key ), $download_info['link'] ); |
|
| 553 | + $download_info[ 'link' ] = add_query_arg( array( 'license_key' => $license_key ), $download_info[ 'link' ] ); |
|
| 554 | 554 | |
| 555 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
| 555 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -567,11 +567,11 @@ discard block |
||
| 567 | 567 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
| 568 | 568 | $base_price = \GFCommon::to_number( $base_price ); |
| 569 | 569 | |
| 570 | - unset( $download['pricing']['amount'] ); |
|
| 570 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
| 571 | 571 | |
| 572 | 572 | // Price options array, not single price |
| 573 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
| 574 | - $base_price = array_shift( $download['pricing'] ); |
|
| 573 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
| 574 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | return floatval( $base_price ); |
@@ -585,13 +585,13 @@ discard block |
||
| 585 | 585 | public function activate_download() { |
| 586 | 586 | $data = \GV\Utils::_POST( 'data', array() ); |
| 587 | 587 | |
| 588 | - if ( empty( $data['path'] ) ) { |
|
| 588 | + if ( empty( $data[ 'path' ] ) ) { |
|
| 589 | 589 | return; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $result = activate_plugin( $data['path'] ); |
|
| 592 | + $result = activate_plugin( $data[ 'path' ] ); |
|
| 593 | 593 | |
| 594 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
| 594 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
| 595 | 595 | wp_send_json_error( array( |
| 596 | 596 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
| 597 | 597 | ) ); |
@@ -608,13 +608,13 @@ discard block |
||
| 608 | 608 | public function deactivate_download() { |
| 609 | 609 | $data = \GV\Utils::_POST( 'data', array() ); |
| 610 | 610 | |
| 611 | - if ( empty( $data['path'] ) ) { |
|
| 611 | + if ( empty( $data[ 'path' ] ) ) { |
|
| 612 | 612 | return; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - deactivate_plugins( $data['path'] ); |
|
| 615 | + deactivate_plugins( $data[ 'path' ] ); |
|
| 616 | 616 | |
| 617 | - if( is_plugin_active( $data['path'] ) ) { |
|
| 617 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
| 618 | 618 | wp_send_json_error( array( |
| 619 | 619 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
| 620 | 620 | ) ); |
@@ -498,9 +498,7 @@ |
||
| 498 | 498 | $button_label = sprintf( __( 'Upgrade to %s for Access', 'gravityview' ), $required_license ); |
| 499 | 499 | $button_class = 'button-primary button-large'; |
| 500 | 500 | $href = 'https://www.gravitykit.com/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 501 | - } |
|
| 502 | - |
|
| 503 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 501 | + } elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 504 | 502 | $spinner = false; |
| 505 | 503 | $status = 'notinstalled'; |
| 506 | 504 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | 'GravityView_DataTables_Template' => array( |
| 60 | 60 | 'slug' => 'dt_placeholder', |
| 61 | 61 | 'label' => __( 'DataTables Table', 'gv-datatables', 'gravityview' ), |
| 62 | - 'description' => __('Display items in a dynamic table powered by DataTables.', 'gravityview'), |
|
| 63 | - 'logo' => plugins_url('assets/images/templates/logo-datatables.png', GRAVITYVIEW_FILE ), |
|
| 62 | + 'description' => __( 'Display items in a dynamic table powered by DataTables.', 'gravityview' ), |
|
| 63 | + 'logo' => plugins_url( 'assets/images/templates/logo-datatables.png', GRAVITYVIEW_FILE ), |
|
| 64 | 64 | 'buy_source' => 'https://www.gravitykit.com/pricing/?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=datatables', |
| 65 | 65 | 'preview' => 'https://try.gravityview.co/demo/view/datatables/?utm_source=plugin&utm_medium=try_demo&utm_campaign=view_type&utm_term=datatables', |
| 66 | 66 | 'license' => esc_html__( 'All Access', 'gravityview' ), |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $license_price_id = (int) \GV\Utils::get( $license, 'price_id', 0 ); |
|
| 106 | - $placeholder_price_id = (int) \GV\Utils::get( $placeholder, 'price_id' ); |
|
| 105 | + $license_price_id = (int)\GV\Utils::get( $license, 'price_id', 0 ); |
|
| 106 | + $placeholder_price_id = (int)\GV\Utils::get( $placeholder, 'price_id' ); |
|
| 107 | 107 | |
| 108 | - $placeholder['type'] = 'custom'; |
|
| 109 | - $placeholder['included'] = ( $license_price_id >= $placeholder_price_id ); |
|
| 108 | + $placeholder[ 'type' ] = 'custom'; |
|
| 109 | + $placeholder[ 'included' ] = ( $license_price_id >= $placeholder_price_id ); |
|
| 110 | 110 | |
| 111 | - new GravityView_Placeholder_Template( $placeholder['slug'], $placeholder ); |
|
| 111 | + new GravityView_Placeholder_Template( $placeholder[ 'slug' ], $placeholder ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | } catch ( Exception $exception ) { |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $this->plugin_file = $_plugin_file; |
| 52 | 52 | $this->name = plugin_basename( $_plugin_file ); |
| 53 | 53 | $this->slug = basename( $_plugin_file, '.php' ); |
| 54 | - $this->version = $_api_data['version']; |
|
| 55 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
| 56 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
|
| 54 | + $this->version = $_api_data[ 'version' ]; |
|
| 55 | + $this->wp_override = isset( $_api_data[ 'wp_override' ] ) ? (bool)$_api_data[ 'wp_override' ] : false; |
|
| 56 | + $this->beta = ! empty( $this->api_data[ 'beta' ] ) ? true : false; |
|
| 57 | 57 | $this->failed_request_cache_key = 'edd_sl_failed_http_' . md5( $this->api_url ); |
| 58 | 58 | |
| 59 | 59 | $edd_plugin_data[ $this->slug ] = $this->api_data; |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | $tested_parts = explode( '.', $version_info->tested ); |
| 186 | 186 | |
| 187 | 187 | // The current WordPress version is x.y.z, so update the tested version to match it. |
| 188 | - if ( isset( $current_version_parts[2] ) && $current_version_parts[0] === $tested_parts[0] && $current_version_parts[1] === $tested_parts[1] ) { |
|
| 189 | - $tested_parts[2] = $current_version_parts[2]; |
|
| 188 | + if ( isset( $current_version_parts[ 2 ] ) && $current_version_parts[ 0 ] === $tested_parts[ 0 ] && $current_version_parts[ 1 ] === $tested_parts[ 1 ] ) { |
|
| 189 | + $tested_parts[ 2 ] = $current_version_parts[ 2 ]; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | return implode( '.', $tested_parts ); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | printf( |
| 265 | 265 | /* translators: the plugin name. */ |
| 266 | 266 | esc_html__( 'There is a new version of %1$s available.', 'gravityview' ), |
| 267 | - esc_html( $plugin['Name'] ) |
|
| 267 | + esc_html( $plugin[ 'Name' ] ) |
|
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | if ( ! current_user_can( 'update_plugins' ) ) { |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | * @return array |
| 310 | 310 | */ |
| 311 | 311 | private function get_active_plugins() { |
| 312 | - $active_plugins = (array) get_option( 'active_plugins' ); |
|
| 313 | - $active_network_plugins = (array) get_site_option( 'active_sitewide_plugins' ); |
|
| 312 | + $active_plugins = (array)get_option( 'active_plugins' ); |
|
| 313 | + $active_network_plugins = (array)get_site_option( 'active_sitewide_plugins' ); |
|
| 314 | 314 | |
| 315 | 315 | return array_merge( $active_plugins, array_keys( $active_network_plugins ) ); |
| 316 | 316 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | public function http_request_args( $args, $url ) { |
| 429 | 429 | |
| 430 | 430 | if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
| 431 | - $args['sslverify'] = $this->verify_ssl(); |
|
| 431 | + $args[ 'sslverify' ] = $this->verify_ssl(); |
|
| 432 | 432 | } |
| 433 | 433 | return $args; |
| 434 | 434 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | private function api_request( $_action, $_data ) { |
| 449 | 449 | $data = array_merge( $this->api_data, $_data ); |
| 450 | 450 | |
| 451 | - if ( $data['slug'] !== $this->slug ) { |
|
| 451 | + if ( $data[ 'slug' ] !== $this->slug ) { |
|
| 452 | 452 | return; |
| 453 | 453 | } |
| 454 | 454 | |
@@ -512,15 +512,15 @@ discard block |
||
| 512 | 512 | */ |
| 513 | 513 | public function show_changelog() { |
| 514 | 514 | |
| 515 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) { |
|
| 515 | + if ( empty( $_REQUEST[ 'edd_sl_action' ] ) || 'view_plugin_changelog' !== $_REQUEST[ 'edd_sl_action' ] ) { |
|
| 516 | 516 | return; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
| 519 | + if ( empty( $_REQUEST[ 'plugin' ] ) ) { |
|
| 520 | 520 | return; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - if ( empty( $_REQUEST['slug'] ) || $this->slug !== $_REQUEST['slug'] ) { |
|
| 523 | + if ( empty( $_REQUEST[ 'slug' ] ) || $this->slug !== $_REQUEST[ 'slug' ] ) { |
|
| 524 | 524 | return; |
| 525 | 525 | } |
| 526 | 526 | |
@@ -531,8 +531,8 @@ discard block |
||
| 531 | 531 | $version_info = $this->get_repo_api_data(); |
| 532 | 532 | if ( isset( $version_info->sections ) ) { |
| 533 | 533 | $sections = $this->convert_object_to_array( $version_info->sections ); |
| 534 | - if ( ! empty( $sections['changelog'] ) ) { |
|
| 535 | - echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>'; |
|
| 534 | + if ( ! empty( $sections[ 'changelog' ] ) ) { |
|
| 535 | + echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections[ 'changelog' ] ) . '</div>'; |
|
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | private function get_version_from_remote() { |
| 548 | 548 | $api_params = array( |
| 549 | 549 | 'edd_action' => 'get_version', |
| 550 | - 'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '', |
|
| 551 | - 'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false, |
|
| 552 | - 'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false, |
|
| 553 | - 'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false, |
|
| 550 | + 'license' => ! empty( $this->api_data[ 'license' ] ) ? $this->api_data[ 'license' ] : '', |
|
| 551 | + 'item_name' => isset( $this->api_data[ 'item_name' ] ) ? $this->api_data[ 'item_name' ] : false, |
|
| 552 | + 'item_id' => isset( $this->api_data[ 'item_id' ] ) ? $this->api_data[ 'item_id' ] : false, |
|
| 553 | + 'version' => isset( $this->api_data[ 'version' ] ) ? $this->api_data[ 'version' ] : false, |
|
| 554 | 554 | 'slug' => $this->slug, |
| 555 | - 'author' => $this->api_data['author'], |
|
| 555 | + 'author' => $this->api_data[ 'author' ], |
|
| 556 | 556 | 'url' => home_url(), |
| 557 | 557 | 'beta' => $this->beta, |
| 558 | 558 | 'php_version' => phpversion(), |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | if ( ! empty( $request->sections ) ) { |
| 603 | 603 | foreach ( $request->sections as $key => $section ) { |
| 604 | - $request->$key = (array) $section; |
|
| 604 | + $request->$key = (array)$section; |
|
| 605 | 605 | } |
| 606 | 606 | } |
| 607 | 607 | |
@@ -623,17 +623,17 @@ discard block |
||
| 623 | 623 | $cache = get_option( $cache_key ); |
| 624 | 624 | |
| 625 | 625 | // Cache is expired |
| 626 | - if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
|
| 626 | + if ( empty( $cache[ 'timeout' ] ) || time() > $cache[ 'timeout' ] ) { |
|
| 627 | 627 | return false; |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. |
| 631 | - $cache['value'] = json_decode( $cache['value'] ); |
|
| 632 | - if ( ! empty( $cache['value']->icons ) ) { |
|
| 633 | - $cache['value']->icons = (array) $cache['value']->icons; |
|
| 631 | + $cache[ 'value' ] = json_decode( $cache[ 'value' ] ); |
|
| 632 | + if ( ! empty( $cache[ 'value' ]->icons ) ) { |
|
| 633 | + $cache[ 'value' ]->icons = (array)$cache[ 'value' ]->icons; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - return $cache['value']; |
|
| 636 | + return $cache[ 'value' ]; |
|
| 637 | 637 | |
| 638 | 638 | } |
| 639 | 639 | |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | update_option( $cache_key, $data, 'no' ); |
| 658 | 658 | |
| 659 | 659 | // Delete the duplicate option |
| 660 | - delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) ); |
|
| 660 | + delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ) ); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /** |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | * @return bool |
| 668 | 668 | */ |
| 669 | 669 | private function verify_ssl() { |
| 670 | - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
| 670 | + return (bool)apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | /** |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * @return string |
| 678 | 678 | */ |
| 679 | 679 | private function get_cache_key() { |
| 680 | - $string = $this->slug . $this->api_data['license'] . $this->beta; |
|
| 680 | + $string = $this->slug . $this->api_data[ 'license' ] . $this->beta; |
|
| 681 | 681 | |
| 682 | 682 | return 'edd_sl_' . md5( serialize( $string ) ); |
| 683 | 683 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $this->widget_description = __('Display a Gravity Forms form.', 'gravityview' ); |
|
| 28 | + $this->widget_description = __( 'Display a Gravity Forms form.', 'gravityview' ); |
|
| 29 | 29 | |
| 30 | 30 | $default_values = array( |
| 31 | 31 | 'header' => 1, |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | add_filter( 'gravityview/widget/hide_until_searched/allowlist', array( $this, 'add_to_allowlist' ) ); |
| 68 | 68 | |
| 69 | - parent::__construct( __( 'Gravity Forms', 'gravityview' ) , 'gravityforms', $default_values, $settings ); |
|
| 69 | + parent::__construct( __( 'Gravity Forms', 'gravityview' ), 'gravityforms', $default_values, $settings ); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | return $choices; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if( gravityview()->request->is_frontend() ) { |
|
| 89 | + if ( gravityview()->request->is_frontend() ) { |
|
| 90 | 90 | return $choices; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function add_to_allowlist( $allowlist ) { |
| 116 | 116 | |
| 117 | - $allowlist[] = 'gravityforms'; |
|
| 117 | + $allowlist[ ] = 'gravityforms'; |
|
| 118 | 118 | |
| 119 | 119 | return $allowlist; |
| 120 | 120 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param string $content |
| 125 | 125 | * @param string $context |
| 126 | 126 | */ |
| 127 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
| 127 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
| 128 | 128 | |
| 129 | 129 | if ( ! $this->pre_render_frontend() ) { |
| 130 | 130 | return; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @uses {@var $counter} |
| 124 | 124 | * @param Template_Context $context |
| 125 | 125 | */ |
| 126 | - add_action( 'gravityview/template/view/render', $add_anchor_id_filter = function ( $context ) use ( &$counter ) { |
|
| 126 | + add_action( 'gravityview/template/view/render', $add_anchor_id_filter = function( $context ) use ( &$counter ) { |
|
| 127 | 127 | /** @see \GV\View::set_anchor_id() */ |
| 128 | 128 | $context->view->set_anchor_id( $counter[ $context->view->ID ] ); |
| 129 | 129 | } ); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @uses {@var View $view} |
| 145 | 145 | */ |
| 146 | - add_filter( 'gravityview/widget/search/form/action', $add_search_action_filter = function ( $action ) use ( $view ) { |
|
| 146 | + add_filter( 'gravityview/widget/search/form/action', $add_search_action_filter = function( $action ) use ( $view ) { |
|
| 147 | 147 | return $action . '#' . $view->get_anchor_id(); |
| 148 | 148 | } ); |
| 149 | 149 | } |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | * This allows us to fake it till we make it. |
| 154 | 154 | */ |
| 155 | 155 | $parameters = $view->settings->as_atts(); |
| 156 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
| 156 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
| 157 | 157 | $has_multisort = true; |
| 158 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
| 159 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
| 160 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
| 158 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
| 159 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
| 160 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | 'entries' => $entries, |
| 173 | 173 | 'request' => $request, |
| 174 | 174 | ), empty( $parameters ) ? array() : array( |
| 175 | - 'paging' => $parameters['paging'], |
|
| 176 | - 'sorting' => $parameters['sorting'], |
|
| 175 | + 'paging' => $parameters[ 'paging' ], |
|
| 176 | + 'sorting' => $parameters[ 'sorting' ], |
|
| 177 | 177 | ), empty( $post ) ? array() : array( |
| 178 | 178 | 'post' => $post, |
| 179 | 179 | ) ) ); |