Completed
Pull Request — develop (#1742)
by
unknown
18:03
created
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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&rsquo;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&rsquo;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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
includes/class-admin-installer.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.