Completed
Pull Request — develop (#1687)
by
unknown
16:12
created
includes/fields/class-gravityview-field-total.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total.
54 54
 	 */
55
-	public function add_to_blocklist( $blocklist = array(), $context = NULL  ){
55
+	public function add_to_blocklist( $blocklist = array(), $context = NULL ) {
56 56
 
57
-		if( empty( $context ) || $context !== 'edit' ) {
57
+		if ( empty( $context ) || $context !== 'edit' ) {
58 58
 			return $blocklist;
59 59
 		}
60 60
 
61
-		$blocklist[] = 'total';
61
+		$blocklist[ ] = 'total';
62 62
 
63 63
 		return $blocklist;
64 64
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	function edit_entry_recalculate_totals( $form = array(), $entry_id = 0, $Edit_Entry_Render = null ) {
78 78
 
79
-		$original_form = GFAPI::get_form( $form['id'] );
79
+		$original_form = GFAPI::get_form( $form[ 'id' ] );
80 80
 
81 81
 		$total_fields = GFCommon::get_fields_by_type( $original_form, 'total' );
82 82
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 
88 88
 			/** @type GF_Field_Total $total_field */
89 89
 			foreach ( $total_fields as $total_field ) {
90
-				$entry["{$total_field->id}"] = GFCommon::get_order_total( $original_form, $entry );
90
+				$entry[ "{$total_field->id}" ] = GFCommon::get_order_total( $original_form, $entry );
91 91
 			}
92 92
 
93 93
 			$return_entry = GFAPI::update_entry( $entry );
94 94
 
95
-			if( is_wp_error( $return_entry ) ) {
95
+			if ( is_wp_error( $return_entry ) ) {
96 96
 				gravityview()->log->error( 'Updating the entry total fields failed', array( 'data' => $return_entry ) );
97 97
 			} else {
98 98
 				gravityview()->log->debug( 'Updating the entry total fields succeeded' );
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	 *
53 53
 	 * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total.
54 54
 	 */
55
-	public function add_to_blocklist( $blocklist = array(), $context = NULL  ){
55
+	public function add_to_blocklist( $blocklist = array(), $context = NULL  ) {
56 56
 
57 57
 		if( empty( $context ) || $context !== 'edit' ) {
58 58
 			return $blocklist;
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-calculation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@
 block discarded – undo
49 49
 	public function blocklist_field_types( $field_types = array(), $context = '' ) {
50 50
 
51 51
 		// Allow Calculation field in Edit Entry
52
-		if( 'edit' !== $context ) {
53
-			$field_types[] = $this->name;
52
+		if ( 'edit' !== $context ) {
53
+			$field_types[ ] = $this->name;
54 54
 		}
55 55
 
56 56
 		return $field_types;
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
 
144 144
 		add_filter( 'gravityview/sortable/field_blocklist', array( $this, '_filter_sortable_fields' ), 1 );
145 145
 
146
-		if( $this->entry_meta_key ) {
146
+		if ( $this->entry_meta_key ) {
147 147
 			add_filter( 'gform_entry_meta', array( $this, 'add_entry_meta' ) );
148 148
 			add_filter( 'gravityview/common/sortable_fields', array( $this, 'add_sortable_field' ), 10, 2 );
149 149
 		}
150 150
 
151
-		if( $this->_custom_merge_tag ) {
151
+		if ( $this->_custom_merge_tag ) {
152 152
 			add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 );
153 153
 			add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 );
154 154
 		}
155 155
 
156
-		if( 'meta' === $this->group || '' !== $this->default_search_label ) {
156
+		if ( 'meta' === $this->group || '' !== $this->default_search_label ) {
157 157
 			add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 );
158 158
 		}
159 159
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		 * Auto-assign label from Gravity Forms label, if exists
162 162
 		 * @since 1.20
163 163
 		 */
164
-		if( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) {
164
+		if ( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) {
165 165
 			$this->label = ucfirst( GF_Fields::get( $this->name )->get_form_editor_field_title() );
166 166
 		}
167 167
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			'type'  => $this->name
208 208
 		);
209 209
 
210
-		$fields["{$this->entry_meta_key}"] = $added_field;
210
+		$fields[ "{$this->entry_meta_key}" ] = $added_field;
211 211
 
212 212
 		return $fields;
213 213
 	}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	function set_default_search_label( $label = '', $gf_field = null, $field = array() ) {
229 229
 
230
-		if( $this->name === $field['field'] && '' === $label ) {
230
+		if ( $this->name === $field[ 'field' ] && '' === $label ) {
231 231
 			$label = esc_html( $this->default_search_label );
232 232
 		}
233 233
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text.
250 250
 	 */
251
-	public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false  ) {
251
+	public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
252 252
 
253 253
 		// Is there is field merge tag? Strip whitespace off the ned, too.
254 254
 		preg_match_all( '/{' . preg_quote( $this->_custom_merge_tag ) . ':?(.*?)(?:\s)?}/ism', $text, $matches, PREG_SET_ORDER );
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
 	 */
282 282
 	public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
283 283
 
284
-		foreach( $matches as $match ) {
284
+		foreach ( $matches as $match ) {
285 285
 
286
-			$full_tag = $match[0];
286
+			$full_tag = $match[ 0 ];
287 287
 
288 288
 			// Strip the Merge Tags
289
-			$tag = str_replace( array( '{', '}'), '', $full_tag );
289
+			$tag = str_replace( array( '{', '}' ), '', $full_tag );
290 290
 
291 291
 			// Replace the value from the entry, if exists
292
-			if( isset( $entry[ $tag ] ) ) {
292
+			if ( isset( $entry[ $tag ] ) ) {
293 293
 
294 294
 				$value = $entry[ $tag ];
295 295
 
296
-				if( is_callable( array( $this, 'get_content') ) ) {
296
+				if ( is_callable( array( $this, 'get_content' ) ) ) {
297 297
 					$value = $this->get_content( $value );
298 298
 				}
299 299
 
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 */
367 367
 	public function _filter_sortable_fields( $not_sortable ) {
368 368
 
369
-		if( ! $this->is_sortable ) {
370
-			$not_sortable[] = $this->name;
369
+		if ( ! $this->is_sortable ) {
370
+			$not_sortable[ ] = $this->name;
371 371
 		}
372 372
 
373 373
 		return $not_sortable;
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 */
385 385
 	function add_entry_meta( $entry_meta ) {
386 386
 
387
-		if( ! isset( $entry_meta["{$this->entry_meta_key}"] ) ) {
387
+		if ( ! isset( $entry_meta[ "{$this->entry_meta_key}" ] ) ) {
388 388
 
389 389
 			$added_meta = array(
390 390
 				'label'             => $this->label,
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 			);
394 394
 
395 395
 			if ( $this->entry_meta_update_callback && is_callable( $this->entry_meta_update_callback ) ) {
396
-				$added_meta['update_entry_meta_callback'] = $this->entry_meta_update_callback;
396
+				$added_meta[ 'update_entry_meta_callback' ] = $this->entry_meta_update_callback;
397 397
 			}
398 398
 
399
-			$entry_meta["{$this->entry_meta_key}"] = $added_meta;
399
+			$entry_meta[ "{$this->entry_meta_key}" ] = $added_meta;
400 400
 
401 401
 		} else {
402
-			gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' =>  $entry_meta["{$this->entry_meta_key}"] ) );
402
+			gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' =>  $entry_meta[ "{$this->entry_meta_key}" ] ) );
403 403
 		}
404 404
 
405 405
 		return $entry_meta;
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 			'date_display' => array(
435 435
 				'type' => 'text',
436 436
 				'label' => __( 'Override Date Format', 'gravityview' ),
437
-				'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">', '</a>' ),
437
+				'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">', '</a>' ),
438 438
 				/**
439 439
 				 * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time)
440 440
 				 * @param[in,out] null|string $date_format Date Format (default: null)
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 
465 465
 		$options = $this->field_support_options();
466 466
 
467
-		if( isset( $options[ $key ] ) ) {
467
+		if ( isset( $options[ $key ] ) ) {
468 468
 			$field_options[ $key ] = $options[ $key ];
469 469
 		}
470 470
 
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
 		$connected_form = \GV\Utils::_POST( 'form_id' );
529 529
 
530 530
 		// Otherwise, get the Form ID from the Post page
531
-		if( empty( $connected_form ) ) {
531
+		if ( empty( $connected_form ) ) {
532 532
 			$connected_form = gravityview_get_form_id( get_the_ID() );
533 533
 		}
534 534
 
535
-		if( empty( $connected_form ) ) {
535
+		if ( empty( $connected_form ) ) {
536 536
 			gravityview()->log->error( 'Form not found for form ID "{form_id}"', array( 'form_id' => $connected_form ) );
537 537
 			return false;
538 538
 		}
Please login to merge, or discard this patch.
class-gravityview-plugin-hooks-gravity-forms-coupon.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		 */
54 54
 		$hide_coupon_fields = apply_filters( 'gravityview/edit_entry/hide-coupon-fields', $has_transaction_data );
55 55
 
56
-		return (bool) $hide_coupon_fields;
56
+		return (bool)$hide_coupon_fields;
57 57
 	}
58 58
 
59 59
 	/**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	public function edit_entry_field_blocklist( $blocklist = array(), $entry = array() ) {
79 79
 
80 80
 		if ( $this->should_hide_coupon_fields( $entry ) ) {
81
-			$blocklist[] = 'coupon';
81
+			$blocklist[ ] = 'coupon';
82 82
 		}
83 83
 
84 84
 		return $blocklist;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		// No coupons match the codes provided
117 117
 		$discounts = gf_coupons()->get_coupons_by_codes( $coupon_codes, $form );
118 118
 
119
-		if( ! $discounts ) {
119
+		if ( ! $discounts ) {
120 120
 			return $value;
121 121
 		}
122 122
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		 * @see GF_Field_Coupon::get_field_input
126 126
 		 */
127 127
 		$_POST = ! isset( $_POST ) ? array() : $_POST;
128
-		$_POST[ 'gf_coupons_' . $form['id'] ] = json_encode( (array) $discounts );
128
+		$_POST[ 'gf_coupons_' . $form[ 'id' ] ] = json_encode( (array)$discounts );
129 129
 		$_POST[ 'input_' . $field->id ] = implode( ',', $coupon_codes );
130 130
 
131 131
 		return $value;
Please login to merge, or discard this patch.
plugin-and-theme-hooks/class-gravityview-plugin-hooks-elegant-themes.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 		}
80 80
 
81 81
 		$sidebars_widgets = wp_get_sidebars_widgets();
82
-		if ( empty( $sidebars_widgets[ $matches[1] ] ) ) {
82
+		if ( empty( $sidebars_widgets[ $matches[ 1 ] ] ) ) {
83 83
 			return $shortcodes;
84 84
 		}
85 85
 
86
-		foreach ( $sidebars_widgets[ $matches[1] ] as $widgets ) {
86
+		foreach ( $sidebars_widgets[ $matches[ 1 ] ] as $widgets ) {
87 87
 			if (
88 88
 				/**
89 89
 				 * Blocklisted widgets.
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 				strpos( $widgets, 'gv_recent_entries' ) === 0
93 93
 			) {
94 94
 
95
-					$shortcodes []= 'et_pb_sidebar';
95
+					$shortcodes [ ] = 'et_pb_sidebar';
96 96
 					break;
97 97
 			}
98 98
 		}
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -18,84 +18,84 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 		$this->load_components( 'locking' );
44 44
 
45
-        $this->load_components( 'render' );
45
+		$this->load_components( 'render' );
46 46
 
47
-        // If GF User Registration Add-on exists
48
-        $this->load_components( 'user-registration' );
47
+		// If GF User Registration Add-on exists
48
+		$this->load_components( 'user-registration' );
49 49
 
50
-        $this->add_hooks();
50
+		$this->add_hooks();
51 51
 
52 52
 		// Process hooks for addons that may or may not be present
53 53
 		$this->addon_specific_hooks();
54 54
 	}
55 55
 
56 56
 
57
-    static function getInstance() {
57
+	static function getInstance() {
58 58
 
59
-        if( empty( self::$instance ) ) {
60
-            self::$instance = new GravityView_Edit_Entry;
61
-        }
59
+		if( empty( self::$instance ) ) {
60
+			self::$instance = new GravityView_Edit_Entry;
61
+		}
62 62
 
63
-        return self::$instance;
64
-    }
63
+		return self::$instance;
64
+	}
65 65
 
66 66
 
67
-    private function load_components( $component ) {
67
+	private function load_components( $component ) {
68 68
 
69
-        $dir = trailingslashit( self::$file );
69
+		$dir = trailingslashit( self::$file );
70 70
 
71
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
71
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
73 73
 
74
-        // Loads component and pass extension's instance so that component can
75
-        // talk each other.
76
-        require_once $filename;
77
-        $this->instances[ $component ] = new $classname( $this );
78
-        $this->instances[ $component ]->load();
74
+		// Loads component and pass extension's instance so that component can
75
+		// talk each other.
76
+		require_once $filename;
77
+		$this->instances[ $component ] = new $classname( $this );
78
+		$this->instances[ $component ]->load();
79 79
 
80
-    }
80
+	}
81 81
 
82
-    private function add_hooks() {
82
+	private function add_hooks() {
83 83
 
84
-        // Add front-end access to Gravity Forms delete file action
85
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
84
+		// Add front-end access to Gravity Forms delete file action
85
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
86 86
 
87
-        // Make sure this hook is run for non-admins
88
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
87
+		// Make sure this hook is run for non-admins
88
+		add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
89 89
 
90
-        add_filter( 'gravityview_blocklist_field_types', array( $this, 'modify_field_blocklist' ), 10, 2 );
90
+		add_filter( 'gravityview_blocklist_field_types', array( $this, 'modify_field_blocklist' ), 10, 2 );
91 91
 
92
-        // add template path to check for field
93
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
92
+		// add template path to check for field
93
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
94 94
 
95 95
 		add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 );
96 96
 
97 97
 		add_filter( 'gravityview/api/reserved_query_args', array( $this, 'add_reserved_arg' ) );
98
-    }
98
+	}
99 99
 
100 100
 	/**
101 101
 	 * Adds "edit" to the list of internal reserved query args
@@ -166,74 +166,74 @@  discard block
 block discarded – undo
166 166
 		return false;
167 167
 	}
168 168
 
169
-    /**
170
-     * Include this extension templates path
171
-     * @param array $file_paths List of template paths ordered
172
-     */
173
-    public function add_template_path( $file_paths ) {
174
-
175
-        // Index 100 is the default GravityView template path.
176
-        $file_paths[ 110 ] = self::$file;
177
-
178
-        return $file_paths;
179
-    }
180
-
181
-    /**
182
-     *
183
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
184
-     *
185
-     * @param $view_id int GravityView view id
186
-     * @param $form_id int Gravity Forms form id
187
-     * @param $entry_id int Gravity Forms entry id
188
-     * @return string
189
-     */
190
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
191
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
192
-    }
193
-
194
-
195
-    /**
196
-     * The edit entry link creates a secure link with a nonce
197
-     *
198
-     * It also mimics the URL structure Gravity Forms expects to have so that
199
-     * it formats the display of the edit form like it does in the backend, like
200
-     * "You can edit this post from the post page" fields, for example.
201
-     *
202
-     * @param $entry array Gravity Forms entry object
203
-     * @param $view_id int GravityView view id
204
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
205
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
206
-     * @return string
207
-     */
208
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
209
-
210
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
211
-
212
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
213
-
214
-        $url = add_query_arg( array(
215
-            'edit' => wp_create_nonce( $nonce_key )
216
-        ), $base );
217
-
218
-        if( $post_id ) {
219
-	        $url = add_query_arg( array( 'gvid' => $view_id ), $url );
220
-        }
221
-
222
-	    /**
223
-	     * Allow passing params to dynamically populate entry with values
224
-	     * @since 1.9.2
225
-	     */
226
-	    if( !empty( $field_values ) ) {
227
-
228
-		    if( is_array( $field_values ) ) {
229
-			    // If already an array, no parse_str() needed
230
-			    $params = $field_values;
231
-		    } else {
232
-			    parse_str( $field_values, $params );
233
-		    }
234
-
235
-		    $url = add_query_arg( $params, $url );
236
-	    }
169
+	/**
170
+	 * Include this extension templates path
171
+	 * @param array $file_paths List of template paths ordered
172
+	 */
173
+	public function add_template_path( $file_paths ) {
174
+
175
+		// Index 100 is the default GravityView template path.
176
+		$file_paths[ 110 ] = self::$file;
177
+
178
+		return $file_paths;
179
+	}
180
+
181
+	/**
182
+	 *
183
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
184
+	 *
185
+	 * @param $view_id int GravityView view id
186
+	 * @param $form_id int Gravity Forms form id
187
+	 * @param $entry_id int Gravity Forms entry id
188
+	 * @return string
189
+	 */
190
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
191
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
192
+	}
193
+
194
+
195
+	/**
196
+	 * The edit entry link creates a secure link with a nonce
197
+	 *
198
+	 * It also mimics the URL structure Gravity Forms expects to have so that
199
+	 * it formats the display of the edit form like it does in the backend, like
200
+	 * "You can edit this post from the post page" fields, for example.
201
+	 *
202
+	 * @param $entry array Gravity Forms entry object
203
+	 * @param $view_id int GravityView view id
204
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
205
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
206
+	 * @return string
207
+	 */
208
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
209
+
210
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
211
+
212
+		$base = gv_entry_link( $entry, $post_id ? : $view_id  );
213
+
214
+		$url = add_query_arg( array(
215
+			'edit' => wp_create_nonce( $nonce_key )
216
+		), $base );
217
+
218
+		if( $post_id ) {
219
+			$url = add_query_arg( array( 'gvid' => $view_id ), $url );
220
+		}
221
+
222
+		/**
223
+		 * Allow passing params to dynamically populate entry with values
224
+		 * @since 1.9.2
225
+		 */
226
+		if( !empty( $field_values ) ) {
227
+
228
+			if( is_array( $field_values ) ) {
229
+				// If already an array, no parse_str() needed
230
+				$params = $field_values;
231
+			} else {
232
+				parse_str( $field_values, $params );
233
+			}
234
+
235
+			$url = add_query_arg( $params, $url );
236
+		}
237 237
 
238 238
 		/**
239 239
 		 * @filter `gravityview/edit/link` Filter the edit URL link.
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		 * @param \GV\View $view The View.
243 243
 		 */
244 244
 		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id  ) );
245
-    }
245
+	}
246 246
 
247 247
 	/**
248 248
 	 * @depecated 2.14 Use {@see GravityView_Edit_Entry::modify_field_blocklist()}
@@ -333,19 +333,19 @@  discard block
 block discarded – undo
333 333
 	}
334 334
 
335 335
 
336
-    /**
337
-     * checks if user has permissions to edit a specific entry
338
-     *
339
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
340
-     *
341
-     * @param  array $entry Gravity Forms entry array
342
-     * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
343
-     * @return bool
344
-     */
345
-    public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
336
+	/**
337
+	 * checks if user has permissions to edit a specific entry
338
+	 *
339
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
340
+	 *
341
+	 * @param  array $entry Gravity Forms entry array
342
+	 * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
343
+	 * @return bool
344
+	 */
345
+	public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
346 346
 
347
-        // No permission by default
348
-        $user_can_edit = false;
347
+		// No permission by default
348
+		$user_can_edit = false;
349 349
 
350 350
 		// get user_edit setting
351 351
 		if ( empty( $view ) ) {
@@ -363,60 +363,60 @@  discard block
 block discarded – undo
363 363
 			$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
364 364
 		}
365 365
 
366
-        // If they can edit any entries (as defined in Gravity Forms)
367
-        // Or if they can edit other people's entries
368
-        // Then we're good.
369
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
366
+		// If they can edit any entries (as defined in Gravity Forms)
367
+		// Or if they can edit other people's entries
368
+		// Then we're good.
369
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
370 370
 
371
-            gravityview()->log->debug( 'User has ability to edit all entries.' );
371
+			gravityview()->log->debug( 'User has ability to edit all entries.' );
372 372
 
373
-            $user_can_edit = true;
373
+			$user_can_edit = true;
374 374
 
375
-        } else if( !isset( $entry['created_by'] ) ) {
375
+		} else if( !isset( $entry['created_by'] ) ) {
376 376
 
377
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
377
+			gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
378 378
 
379
-            $user_can_edit = false;
379
+			$user_can_edit = false;
380 380
 
381
-        } else {
381
+		} else {
382 382
 
383
-            $current_user = wp_get_current_user();
383
+			$current_user = wp_get_current_user();
384 384
 
385
-            // User edit is disabled
386
-            if( empty( $user_edit ) ) {
385
+			// User edit is disabled
386
+			if( empty( $user_edit ) ) {
387 387
 
388
-                gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
388
+				gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
389 389
 
390
-                $user_can_edit = false;
391
-            }
390
+				$user_can_edit = false;
391
+			}
392 392
 
393
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
394
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
393
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
394
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
395 395
 
396
-                gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
396
+				gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
397 397
 
398
-                $user_can_edit = true;
398
+				$user_can_edit = true;
399 399
 
400
-            } else if( ! is_user_logged_in() ) {
400
+			} else if( ! is_user_logged_in() ) {
401 401
 
402
-                gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
402
+				gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
403 403
 
404
-	            $user_can_edit = false; // Here just for clarity
405
-            }
404
+				$user_can_edit = false; // Here just for clarity
405
+			}
406 406
 
407
-        }
407
+		}
408 408
 
409
-        /**
410
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
411
-         * @since 1.15 Added `$entry` and `$view_id` parameters
412
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
413
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
414
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
415
-         */
416
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
409
+		/**
410
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
411
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
412
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
413
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
414
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
415
+		 */
416
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
417 417
 
418
-        return (bool) $user_can_edit;
419
-    }
418
+		return (bool) $user_can_edit;
419
+	}
420 420
 
421 421
 
422 422
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
39
+        if ( is_admin() ) {
40 40
             $this->load_components( 'admin' );
41 41
         }
42 42
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
     static function getInstance() {
58 58
 
59
-        if( empty( self::$instance ) ) {
59
+        if ( empty( self::$instance ) ) {
60 60
             self::$instance = new GravityView_Edit_Entry;
61 61
         }
62 62
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
     private function add_hooks() {
83 83
 
84 84
         // Add front-end access to Gravity Forms delete file action
85
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
85
+        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) );
86 86
 
87 87
         // Make sure this hook is run for non-admins
88
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
88
+        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) );
89 89
 
90 90
         add_filter( 'gravityview_blocklist_field_types', array( $this, 'modify_field_blocklist' ), 10, 2 );
91 91
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function add_reserved_arg( $args ) {
110 110
 
111
-		$args[] = 'edit';
111
+		$args[ ] = 'edit';
112 112
 
113 113
 		return $args;
114 114
 	}
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	private function addon_specific_hooks() {
121 121
 
122
-		if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
123
-			add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script'));
122
+		if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
123
+			add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) );
124 124
 		}
125 125
 
126 126
 	}
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
209 209
 
210
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
210
+        $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] );
211 211
 
212
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
212
+        $base = gv_entry_link( $entry, $post_id ?: $view_id );
213 213
 
214 214
         $url = add_query_arg( array(
215 215
             'edit' => wp_create_nonce( $nonce_key )
216 216
         ), $base );
217 217
 
218
-        if( $post_id ) {
218
+        if ( $post_id ) {
219 219
 	        $url = add_query_arg( array( 'gvid' => $view_id ), $url );
220 220
         }
221 221
 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	     * Allow passing params to dynamically populate entry with values
224 224
 	     * @since 1.9.2
225 225
 	     */
226
-	    if( !empty( $field_values ) ) {
226
+	    if ( ! empty( $field_values ) ) {
227 227
 
228
-		    if( is_array( $field_values ) ) {
228
+		    if ( is_array( $field_values ) ) {
229 229
 			    // If already an array, no parse_str() needed
230 230
 			    $params = $field_values;
231 231
 		    } else {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		 * @param array $entry The entry.
242 242
 		 * @param \GV\View $view The View.
243 243
 		 */
244
-		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id  ) );
244
+		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) );
245 245
     }
246 246
 
247 247
 	/**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	public function modify_field_blocklist( $fields = array(), $context = NULL ) {
271 271
 
272
-		if( empty( $context ) || $context !== 'edit' ) {
272
+		if ( empty( $context ) || $context !== 'edit' ) {
273 273
 			return $fields;
274 274
 		}
275 275
 
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
         // If they can edit any entries (as defined in Gravity Forms)
367 367
         // Or if they can edit other people's entries
368 368
         // Then we're good.
369
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
369
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) {
370 370
 
371 371
             gravityview()->log->debug( 'User has ability to edit all entries.' );
372 372
 
373 373
             $user_can_edit = true;
374 374
 
375
-        } else if( !isset( $entry['created_by'] ) ) {
375
+        } else if ( ! isset( $entry[ 'created_by' ] ) ) {
376 376
 
377
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
377
+            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' );
378 378
 
379 379
             $user_can_edit = false;
380 380
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             $current_user = wp_get_current_user();
384 384
 
385 385
             // User edit is disabled
386
-            if( empty( $user_edit ) ) {
386
+            if ( empty( $user_edit ) ) {
387 387
 
388 388
                 gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
389 389
 
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
             }
392 392
 
393 393
             // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
394
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
394
+            else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
395 395
 
396 396
                 gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
397 397
 
398 398
                 $user_can_edit = true;
399 399
 
400
-            } else if( ! is_user_logged_in() ) {
400
+            } else if ( ! is_user_logged_in() ) {
401 401
 
402 402
                 gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
403 403
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
          */
416 416
         $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
417 417
 
418
-        return (bool) $user_can_edit;
418
+        return (bool)$user_can_edit;
419 419
     }
420 420
 
421 421
 
Please login to merge, or discard this patch.
includes/class-cache.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		/**
85 85
 		 * @see RGFormsModel::update_lead_property() Trigger when any entry property changes
86 86
 		 */
87
-		foreach( $this->lead_db_columns as $column ) {
87
+		foreach ( $this->lead_db_columns as $column ) {
88 88
 			add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 );
89 89
 		}
90 90
 
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 			return;
116 116
 		}
117 117
 
118
-		gravityview()->log->debug( 'adding form {form_id} to blocklist because entry #{lead_id} was deleted', array( 'form_id' => $entry['form_id'], 'entry_id' => $lead_id, 'data' => array( 'value' => $property_value, 'previous' => $previous_value ) ) );
118
+		gravityview()->log->debug( 'adding form {form_id} to blocklist because entry #{lead_id} was deleted', array( 'form_id' => $entry[ 'form_id' ], 'entry_id' => $lead_id, 'data' => array( 'value' => $property_value, 'previous' => $previous_value ) ) );
119 119
 
120
-		$this->blocklist_add( $entry['form_id'] );
120
+		$this->blocklist_add( $entry[ 'form_id' ] );
121 121
 	}
122 122
 
123 123
 	/**
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function entry_updated( $form, $lead_id ) {
132 132
 
133
-		gravityview()->log->debug(' adding form {form_id} to blocklist because entry #{entry_id} was updated', array( 'form_id' => $form['id'], 'entry_id' => $lead_id ) );
133
+		gravityview()->log->debug( ' adding form {form_id} to blocklist because entry #{entry_id} was updated', array( 'form_id' => $form[ 'id' ], 'entry_id' => $lead_id ) );
134 134
 
135
-		$this->blocklist_add( $form['id'] );
135
+		$this->blocklist_add( $form[ 'id' ] );
136 136
 	}
137 137
 
138 138
 	/**
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function entry_created( $entry, $form ) {
149 149
 
150
-		gravityview()->log->debug( 'adding form {form_id} to blocklist because entry #{entry_id} was created', array( 'form_id' => $form['id'], 'entry_id' => $entry['id'] ) );
150
+		gravityview()->log->debug( 'adding form {form_id} to blocklist because entry #{entry_id} was created', array( 'form_id' => $form[ 'id' ], 'entry_id' => $entry[ 'id' ] ) );
151 151
 
152
-		$this->blocklist_add( $form['id'] );
152
+		$this->blocklist_add( $form[ 'id' ] );
153 153
 	}
154 154
 
155 155
 	/**
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 			return;
166 166
 		}
167 167
 
168
-		gravityview()->log->debug( 'adding form {form_id} to blocklist because entry #{entry_id} was added', array( 'form_id' => $form['id'], 'entry_id' => $entry['id'] ) );
168
+		gravityview()->log->debug( 'adding form {form_id} to blocklist because entry #{entry_id} was added', array( 'form_id' => $form[ 'id' ], 'entry_id' => $entry[ 'id' ] ) );
169 169
 
170
-		$this->blocklist_add( $form['id'] );
170
+		$this->blocklist_add( $form[ 'id' ] );
171 171
 	}
172 172
 
173 173
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 		// Normally just one form, but supports multiple forms
187 187
 		//
188 188
 		// Array of IDs 12, 5, 14 would result in `f:12-f:5-f:14`
189
-		$forms = 'f:' . implode( '-f:', (array) $form_ids );
189
+		$forms = 'f:' . implode( '-f:', (array)$form_ids );
190 190
 
191 191
 		// Prefix for transient keys
192 192
 		// Now the prefix would be: `gv-cache-f:12-f:5-f:14-`
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		$form_ids = is_array( $form_ids ) ? $form_ids : array( $form_ids );
237 237
 
238 238
 		// Add the passed form IDs
239
-		$blocklist = array_merge( (array) $blocklist, $form_ids );
239
+		$blocklist = array_merge( (array)$blocklist, $form_ids );
240 240
 
241 241
 		// Don't duplicate
242 242
 		$blocklist = array_unique( $blocklist );
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
 		$blocklist = get_option( self::BLOCKLIST_OPTION_NAME, array() );
281 281
 
282
-		$updated_list = array_diff( $blocklist, (array) $form_ids );
282
+		$updated_list = array_diff( $blocklist, (array)$form_ids );
283 283
 
284 284
 		gravityview()->log->debug( 'Removing form IDs from cache blocklist', array( 'data' => array(
285 285
 			'$form_ids'     => $form_ids,
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 			return false;
338 338
 		}
339 339
 
340
-		foreach ( (array) $form_ids as $form_id ) {
340
+		foreach ( (array)$form_ids as $form_id ) {
341 341
 
342 342
 			if ( in_array( $form_id, $blocklist ) ) {
343 343
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 			 * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache
412 412
 			 * @param int $time_in_seconds Default: `DAY_IN_SECONDS`
413 413
 			 */
414
-			$cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS );
414
+			$cache_time = (int)apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS );
415 415
 
416 416
 			gravityview()->log->debug( 'Setting cache with transient key {key} for {cache_time} seconds', array( 'key' => $this->key, 'cache_time' => $cache_time ) );
417 417
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 			return;
448 448
 		}
449 449
 
450
-		foreach ( (array) $form_ids as $form_id ) {
450
+		foreach ( (array)$form_ids as $form_id ) {
451 451
 
452 452
 			$key = '_transient_gv-cache-';
453 453
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	public function use_cache() {
559 559
 
560 560
 		// Exit early if debugging (unless running PHPUnit)
561
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! ( defined('DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) ) {
561
+		if ( defined( 'WP_DEBUG' ) && WP_DEBUG && ! ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) ) {
562 562
 			return apply_filters( 'gravityview_use_cache', false, $this );
563 563
 		}
564 564
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 
567 567
 		if ( GVCommon::has_cap( 'edit_gravityviews' ) ) {
568 568
 
569
-			if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) {
569
+			if ( isset( $_GET[ 'cache' ] ) || isset( $_GET[ 'nocache' ] ) ) {
570 570
 
571 571
 				gravityview()->log->debug( 'Not using cache: ?cache or ?nocache is in the URL' );
572 572
 
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 		 */
594 594
 		$use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this );
595 595
 
596
-		return (boolean) $use_cache;
596
+		return (boolean)$use_cache;
597 597
 	}
598 598
 
599 599
 }
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-fileupload.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -26,21 +26,21 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
28 28
 
29
-		unset( $field_options['search_filter'] );
29
+		unset( $field_options[ 'search_filter' ] );
30 30
 
31
-		if( 'edit' === $context ) {
31
+		if ( 'edit' === $context ) {
32 32
 			return $field_options;
33 33
 		}
34 34
 
35
-		$add_options['link_to_file'] = array(
35
+		$add_options[ 'link_to_file' ] = array(
36 36
 			'type' => 'checkbox',
37 37
 			'label' => __( 'Display as a Link:', 'gravityview' ),
38
-			'desc' => __('Display the uploaded files as links, rather than embedded content.', 'gravityview'),
38
+			'desc' => __( 'Display the uploaded files as links, rather than embedded content.', 'gravityview' ),
39 39
 			'value' => false,
40 40
 			'merge_tags' => false,
41 41
 		);
42 42
 
43
-		$add_options['image_width'] = array(
43
+		$add_options[ 'image_width' ] = array(
44 44
 			'type' => 'text',
45 45
 			'label' => __( 'Custom Width:', 'gravityview' ),
46 46
 			'desc' => __( 'Override the default image width (250).', 'gravityview' ),
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 			$base_id = null;
159 159
 
160 160
 			$is_single = gravityview_get_context() === 'single';
161
-			$lightbox = ! empty( $gravityview_view->atts['lightbox'] );
161
+			$lightbox = ! empty( $gravityview_view->atts[ 'lightbox' ] );
162 162
 			$field_compat = $gravityview_view->getCurrentField();
163 163
 		}
164 164
 
165 165
 		$output_arr = array();
166 166
 
167 167
 		// Get an array of file paths for the field.
168
-		$file_paths = \GV\Utils::get( $field , 'multipleFiles' ) ? json_decode( $value ) : array( $value );
168
+		$file_paths = \GV\Utils::get( $field, 'multipleFiles' ) ? json_decode( $value ) : array( $value );
169 169
 
170 170
 		// The $value JSON was probably truncated; let's check lead_detail_long.
171 171
 		if ( ! is_array( $file_paths ) ) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			$rendered = null;
186 186
 
187 187
 			// If the site is HTTPS, use HTTPS
188
-			if ( function_exists('set_url_scheme') ) {
188
+			if ( function_exists( 'set_url_scheme' ) ) {
189 189
 				$file_path = set_url_scheme( $file_path );
190 190
 			}
191 191
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			$file_path_info = pathinfo( $file_path );
197 197
 
198 198
 			// If pathinfo() gave us the extension of the file, run the switch statement using that.
199
-			$extension = empty( $file_path_info['extension'] ) ? NULL : strtolower( $file_path_info['extension'] );
199
+			$extension = empty( $file_path_info[ 'extension' ] ) ? NULL : strtolower( $file_path_info[ 'extension' ] );
200 200
 
201 201
 			/**
202 202
 			 * @filter `gravityview/fields/fileupload/extension` Modify the file extension before it's used in display logic
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			 */
207 207
 			$extension = apply_filters( 'gravityview/fields/fileupload/extension', $extension, $file_path );
208 208
 
209
-			$basename = $file_path_info['basename'];
209
+			$basename = $file_path_info[ 'basename' ];
210 210
 
211 211
 			// Get the secure download URL
212 212
 			$is_secure = false;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 					 */
247 247
 					$audio_settings = apply_filters( 'gravityview_audio_settings', array(
248 248
 						'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension
249
-						'class' => 'wp-audio-shortcode gv-audio gv-field-id-'.$field_settings['id']
249
+						'class' => 'wp-audio-shortcode gv-audio gv-field-id-' . $field_settings[ 'id' ]
250 250
 					), $context );
251 251
 
252 252
 					/**
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 					 */
276 276
 					$video_settings = apply_filters( 'gravityview_video_settings', array(
277 277
 						'src' => $insecure_file_path, // Needs to be insecure path so WP can parse extension
278
-						'class' => 'wp-video-shortcode gv-video gv-field-id-'.$field_settings['id']
278
+						'class' => 'wp-video-shortcode gv-video gv-field-id-' . $field_settings[ 'id' ]
279 279
 					), $context );
280 280
 
281 281
 					/**
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 					$file_path = add_query_arg( array( 'gv-iframe' => 'true' ), $file_path );
300 300
 				}
301 301
 
302
-				$field_settings['link_to_file'] = true;
302
+				$field_settings[ 'link_to_file' ] = true;
303 303
 
304 304
 			// Images
305 305
 			} else if ( in_array( $extension, array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ) ) ) {
306 306
 				$width = \GV\Utils::get( $field_settings, 'image_width', 250 );
307 307
 				$image_atts = array(
308 308
 					'src'   => $file_path,
309
-					'class' => 'gv-image gv-field-id-' . $field_settings['id'],
310
-					'alt'   => $field_settings['label'],
311
-					'width' => ( $is_single ? null : ( $width ? $width: 250 ) )
309
+					'class' => 'gv-image gv-field-id-' . $field_settings[ 'id' ],
310
+					'alt'   => $field_settings[ 'label' ],
311
+					'width' => ( $is_single ? null : ( $width ? $width : 250 ) )
312 312
 				);
313 313
 
314 314
 				if ( $is_secure ) {
315
-					$image_atts['validate_src'] = false;
315
+					$image_atts[ 'validate_src' ] = false;
316 316
 				}
317 317
 
318 318
 				/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
 				unset( $gv_entry );
335 335
 
336
-				if ( $lightbox && empty( $field_settings['show_as_link'] ) ) {
336
+				if ( $lightbox && empty( $field_settings[ 'show_as_link' ] ) ) {
337 337
 					$lightbox_link_atts = array(
338 338
 						'rel'   => sprintf( "%s-%s", $gv_class, $entry_slug ),
339 339
 						'class' => '',
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 				}
348 348
 
349 349
 				// Show as link should render the image regardless.
350
-				if ( ! empty( $field_settings['show_as_link'] ) ) {
350
+				if ( ! empty( $field_settings[ 'show_as_link' ] ) ) {
351 351
 					$text = $rendered;
352 352
 				}
353 353
 			}
354 354
 			// For all other non-media file types (ZIP, for example), always show as a link regardless of setting.
355 355
 			else {
356
-				$field_settings['link_to_file'] = true;
356
+				$field_settings[ 'link_to_file' ] = true;
357 357
 				$disable_lightbox = true;
358 358
 			}
359 359
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			$disable_wrapped_link = apply_filters( 'gravityview/fields/fileupload/disable_link', false, $field_compat, $context );
370 370
 
371 371
 			// Output textualized content where
372
-			if ( ! $disable_wrapped_link && ( ! empty( $field_settings['link_to_file'] ) || ! empty( $field_settings['show_as_link'] ) ) ) {
372
+			if ( ! $disable_wrapped_link && ( ! empty( $field_settings[ 'link_to_file' ] ) || ! empty( $field_settings[ 'show_as_link' ] ) ) ) {
373 373
 				/**
374 374
 				 * Modify the link text (defaults to the file name)
375 375
 				 *
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 				 */
383 383
 				$content = apply_filters( 'gravityview/fields/fileupload/link_content', $text, $field_compat, $context );
384 384
 
385
-				if ( empty( $field_settings['show_as_link'] ) ) {
385
+				if ( empty( $field_settings[ 'show_as_link' ] ) ) {
386 386
 					/**
387 387
 					 * @filter `gravityview/fields/fileupload/link_atts` Modify the link attributes for a file upload field
388 388
 					 * @since 2.0 Added $context
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				$content = empty( $rendered ) ? $text : $rendered;
404 404
 			}
405 405
 
406
-			$output_arr[] = array(
406
+			$output_arr[ ] = array(
407 407
 				'file_path' => $file_path,
408 408
 				'content' => $content
409 409
 			);
Please login to merge, or discard this patch.
class-gravityview-plugin-hooks-gravity-forms-dropbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	function filter_file_path( $string = '' ) {
46 46
 
47 47
 		$output = $string;
48
-		$output = str_replace('www.dropbox.com', 'dl.dropboxusercontent.com', $output );
48
+		$output = str_replace( 'www.dropbox.com', 'dl.dropboxusercontent.com', $output );
49 49
 		$output = str_replace( '?dl=0', '', $output );
50 50
 
51 51
 		return $output;
Please login to merge, or discard this patch.