Completed
Pull Request — master (#716)
by Zack
09:51 queued 04:52
created
includes/fields/class-gravityview-field-checkbox.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 	var $name = 'checkbox';
11 11
 
12
-	var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains');
12
+	var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' );
13 13
 
14 14
 	var $_gf_field_class_name = 'GF_Field_Checkbox';
15 15
 
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 		$field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type );
40 40
 
41 41
 		// It's not the parent field; it's an input
42
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
42
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
43 43
 
44
-			if( $this->is_choice_value_enabled() ) {
44
+			if ( $this->is_choice_value_enabled() ) {
45 45
 
46 46
 				$desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gravityview' );
47 47
 				$default = 'value';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 				);
60 60
 			}
61 61
 
62
-			$field_options['choice_display'] = array(
62
+			$field_options[ 'choice_display' ] = array(
63 63
 				'type'    => 'radio',
64 64
 				'class'   => 'vertical',
65 65
 				'label'   => __( 'What should be displayed:', 'gravityview' ),
Please login to merge, or discard this patch.
includes/class-admin-views.php 1 patch
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -28,30 +28,30 @@  discard block
 block discarded – undo
28 28
 		add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 );
29 29
 
30 30
 		// Tooltips
31
-		add_filter( 'gform_tooltips', array( $this, 'tooltips') );
31
+		add_filter( 'gform_tooltips', array( $this, 'tooltips' ) );
32 32
 
33 33
 		// adding styles and scripts
34
-		add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 );
35
-		add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') );
36
-		add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') );
37
-		add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') );
38
-		add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') );
39
-
40
-		add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 );
41
-		add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 );
42
-		add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 );
43
-		add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') );
44
-		add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 );
34
+		add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles' ), 999 );
35
+		add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict' ) );
36
+		add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict' ) );
37
+		add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict' ) );
38
+		add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
39
+
40
+		add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas' ), 10, 4 );
41
+		add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas' ), 10, 3 );
42
+		add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields' ), 10, 2 );
43
+		add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets' ) );
44
+		add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas' ), 10, 5 );
45 45
 
46 46
 		// @todo check if this hook is needed..
47 47
 		//add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 );
48 48
 
49 49
 		// Add Connected Form column
50
-		add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) );
50
+		add_filter( 'manage_gravityview_posts_columns', array( $this, 'add_post_type_columns' ) );
51 51
 
52 52
 		add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 );
53 53
 
54
-		add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 );
54
+		add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content' ), 10, 2 );
55 55
 
56 56
 		add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) );
57 57
 
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	public function filter_pre_get_posts_by_gravityview_form_id( &$query ) {
67 67
 		global $pagenow;
68 68
 
69
-		if ( !is_admin() ) {
69
+		if ( ! is_admin() ) {
70 70
 			return;
71 71
 		}
72 72
 
73
-		if( 'edit.php' !== $pagenow || ! rgget( 'gravityview_form_id' ) || ! isset( $query->query_vars[ 'post_type' ] ) ) {
73
+		if ( 'edit.php' !== $pagenow || ! rgget( 'gravityview_form_id' ) || ! isset( $query->query_vars[ 'post_type' ] ) ) {
74 74
 			return;
75 75
 		}
76 76
 
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
 	function add_view_dropdown() {
88 88
 		$current_screen = get_current_screen();
89 89
 
90
-		if( 'gravityview' !== $current_screen->post_type ) {
90
+		if ( 'gravityview' !== $current_screen->post_type ) {
91 91
 			return;
92 92
 		}
93 93
 
94 94
 		$forms = gravityview_get_forms();
95 95
 		$current_form = rgget( 'gravityview_form_id' );
96 96
 		// If there are no forms to select, show no forms.
97
-		if( !empty( $forms ) ) { ?>
97
+		if ( ! empty( $forms ) ) { ?>
98 98
 			<select name="gravityview_form_id" id="gravityview_form_id">
99 99
 				<option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option>
100
-				<?php foreach( $forms as $form ) { ?>
101
-					<option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option>
100
+				<?php foreach ( $forms as $form ) { ?>
101
+					<option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option>
102 102
 				<?php } ?>
103 103
 			</select>
104 104
 		<?php }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) {
113 113
 		_deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' );
114
-		GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id );
114
+		GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name, $id );
115 115
 	}
116 116
 
117 117
 	/**
@@ -134,37 +134,37 @@  discard block
 block discarded – undo
134 134
 
135 135
 		$connected_views = gravityview_get_connected_views( $id );
136 136
 
137
-		if( empty( $connected_views ) ) {
137
+		if ( empty( $connected_views ) ) {
138 138
 			return $menu_items;
139 139
 		}
140 140
 
141 141
 		$sub_menu_items = array();
142 142
 		foreach ( (array)$connected_views as $view ) {
143 143
 
144
-			if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) {
144
+			if ( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) {
145 145
 				continue;
146 146
 			}
147 147
 
148
-			$label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title;
148
+			$label = empty( $view->post_title ) ? sprintf( __( 'No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title;
149 149
 
150
-			$sub_menu_items[] = array(
150
+			$sub_menu_items[ ] = array(
151 151
 				'label' => esc_attr( $label ),
152
-				'url' => admin_url( 'post.php?action=edit&post='.$view->ID ),
152
+				'url' => admin_url( 'post.php?action=edit&post=' . $view->ID ),
153 153
 			);
154 154
 		}
155 155
 
156 156
 		// If there were no items added, then let's create the parent menu
157
-		if( $sub_menu_items ) {
157
+		if ( $sub_menu_items ) {
158 158
 
159 159
 			// Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown
160
-			$sub_menu_items[] = array(
160
+			$sub_menu_items[ ] = array(
161 161
 				'url' => '#',
162 162
 				'label' => '',
163 163
 				'menu_class' => 'hidden',
164 164
 				'capabilities' => '',
165 165
 			);
166 166
 
167
-			$menu_items['gravityview'] = array(
167
+			$menu_items[ 'gravityview' ] = array(
168 168
 				'label'          => __( 'Connected Views', 'gravityview' ),
169 169
 				'icon'           => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>',
170 170
 				'title'          => __( 'GravityView Views using this form as a data source', 'gravityview' ),
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 		$add = array( 'captcha', 'page' );
195 195
 
196 196
 		// Don't allowing editing the following values:
197
-		if( $context === 'edit' ) {
198
-			$add[] = 'post_id';
197
+		if ( $context === 'edit' ) {
198
+			$add[ ] = 'post_id';
199 199
 		}
200 200
 
201 201
 		$return = array_merge( $array, $add );
@@ -218,32 +218,32 @@  discard block
 block discarded – undo
218 218
 		foreach ( $default_args as $key => $arg ) {
219 219
 
220 220
 			// If an arg has `tooltip` defined, but it's false, don't display a tooltip
221
-			if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; }
221
+			if ( isset( $arg[ 'tooltip' ] ) && empty( $arg[ 'tooltip' ] ) ) { continue; }
222 222
 
223 223
 			// By default, use `tooltip` if defined.
224
-			$tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip'];
224
+			$tooltip = empty( $arg[ 'tooltip' ] ) ? NULL : $arg[ 'tooltip' ];
225 225
 
226 226
 			// Otherwise, use the description as a tooltip.
227
-			if( empty( $tooltip ) && !empty( $arg['desc'] ) ) {
228
-				$tooltip = $arg['desc'];
227
+			if ( empty( $tooltip ) && ! empty( $arg[ 'desc' ] ) ) {
228
+				$tooltip = $arg[ 'desc' ];
229 229
 			}
230 230
 
231 231
 			// If there's no tooltip set, continue
232
-			if( empty( $tooltip ) ) {
232
+			if ( empty( $tooltip ) ) {
233 233
 				continue;
234 234
 			}
235 235
 
236 236
 			// Add the tooltip
237
-			$gv_tooltips[ 'gv_'.$key ] = array(
238
-				'title'	=> $arg['label'],
237
+			$gv_tooltips[ 'gv_' . $key ] = array(
238
+				'title'	=> $arg[ 'label' ],
239 239
 				'value'	=> $tooltip,
240 240
 			);
241 241
 
242 242
 		}
243 243
 
244
-		$gv_tooltips['gv_css_merge_tags'] = array(
245
-			'title' => __('CSS Merge Tags', 'gravityview'),
246
-			'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' )
244
+		$gv_tooltips[ 'gv_css_merge_tags' ] = array(
245
+			'title' => __( 'CSS Merge Tags', 'gravityview' ),
246
+			'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview' ), '<code>', '</code>' )
247 247
 		);
248 248
 
249 249
 		/**
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 
255 255
 		foreach ( $gv_tooltips as $key => $tooltip ) {
256 256
 
257
-			$title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>';
257
+			$title = empty( $tooltip[ 'title' ] ) ? '' : '<h6>' . esc_html( $tooltip[ 'title' ] ) . '</h6>';
258 258
 
259
-			$tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) );
259
+			$tooltips[ $key ] = $title . wpautop( esc_html( $tooltip[ 'value' ] ) );
260 260
 		}
261 261
 
262 262
 		return $tooltips;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return void
272 272
 	 */
273
-	public function add_custom_column_content( $column_name = NULL, $post_id )	{
273
+	public function add_custom_column_content( $column_name = NULL, $post_id ) {
274 274
 
275 275
 		$output = '';
276 276
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 				// Generate backup if label doesn't exist: `example_name` => `Example Name`
293 293
 				$template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) );
294 294
 
295
-				$output = $template ? $template['label'] : $template_id_pretty;
295
+				$output = $template ? $template[ 'label' ] : $template_id_pretty;
296 296
 
297 297
 				break;
298 298
 
@@ -333,44 +333,44 @@  discard block
 block discarded – undo
333 333
 	static public function get_connected_form_links( $form, $include_form_link = true ) {
334 334
 
335 335
 		// Either the form is empty or the form ID is 0, not yet set.
336
-		if( empty( $form ) ) {
336
+		if ( empty( $form ) ) {
337 337
 			return '';
338 338
 		}
339 339
 
340 340
 		// The $form is passed as the form ID
341
-		if( !is_array( $form ) ) {
341
+		if ( ! is_array( $form ) ) {
342 342
 			$form = gravityview_get_form( $form );
343 343
 		}
344 344
 
345
-		$form_id = $form['id'];
345
+		$form_id = $form[ 'id' ];
346 346
 		$links = array();
347 347
 
348
-		if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) {
348
+		if ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) {
349 349
 			$form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&amp;id=%d', $form_id ) );
350
-			$form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>';
351
-			$links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>';
350
+			$form_link = '<strong class="gv-form-title">' . gravityview_get_link( $form_url, $form[ 'title' ], 'class=row-title' ) . '</strong>';
351
+			$links[ ] = '<span>' . gravityview_get_link( $form_url, __( 'Edit Form', 'gravityview' ) ) . '</span>';
352 352
 		} else {
353
-			$form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>';
353
+			$form_link = '<strong class="gv-form-title">' . esc_html( $form[ 'title' ] ) . '</strong>';
354 354
 		}
355 355
 
356
-		if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) {
356
+		if ( GVCommon::has_cap( 'gravityforms_view_entries' ) ) {
357 357
 			$entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&amp;id=%d', $form_id ) );
358
-			$links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>';
358
+			$links[ ] = '<span>' . gravityview_get_link( $entries_url, __( 'Entries', 'gravityview' ) ) . '</span>';
359 359
 		}
360 360
 
361
-		if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) {
361
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) {
362 362
 			$settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&amp;view=settings&amp;id=%d', $form_id ) );
363
-			$links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>';
363
+			$links[ ] = '<span>' . gravityview_get_link( $settings_url, __( 'Settings', 'gravityview' ), 'title=' . __( 'Edit settings for this form', 'gravityview' ) ) . '</span>';
364 364
 		}
365 365
 
366
-		if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) {
366
+		if ( GVCommon::has_cap( array( "gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms" ) ) ) {
367 367
 			$preview_url = site_url( sprintf( '?gf_page=preview&amp;id=%d', $form_id ) );
368
-			$links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>';
368
+			$links[ ] = '<span>' . gravityview_get_link( $preview_url, __( 'Preview Form', 'gravityview' ), 'title=' . __( 'Preview this form', 'gravityview' ) ) . '</span>';
369 369
 		}
370 370
 
371 371
 		$output = '';
372 372
 
373
-		if( !empty( $include_form_link ) ) {
373
+		if ( ! empty( $include_form_link ) ) {
374 374
 			$output .= $form_link;
375 375
 		}
376 376
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		 */
383 383
 		$links = apply_filters( 'gravityview_connected_form_links', $links, $form );
384 384
 
385
-		$output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>';
385
+		$output .= '<div class="row-actions">' . implode( ' | ', $links ) . '</div>';
386 386
 
387 387
 		return $output;
388 388
 	}
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 		// Get the date column and save it for later to add back in.
397 397
 		// This adds it after the Data Source column.
398 398
 		// This way, we don't need to do array_slice, array_merge, etc.
399
-		$date = $columns['date'];
400
-		unset( $columns['date'] );
399
+		$date = $columns[ 'date' ];
400
+		unset( $columns[ 'date' ] );
401 401
 
402 402
 		$data_source_required_caps = array(
403 403
 			'gravityforms_edit_forms',
@@ -408,14 +408,14 @@  discard block
 block discarded – undo
408 408
 			'gravityforms_preview_forms',
409 409
 		);
410 410
 
411
-		if( GVCommon::has_cap( $data_source_required_caps ) ) {
412
-			$columns['gv_connected_form'] = __( 'Data Source', 'gravityview' );
411
+		if ( GVCommon::has_cap( $data_source_required_caps ) ) {
412
+			$columns[ 'gv_connected_form' ] = __( 'Data Source', 'gravityview' );
413 413
 		}
414 414
 
415
-		$columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' );
415
+		$columns[ 'gv_template' ] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' );
416 416
 
417 417
 		// Add the date back in.
418
-		$columns['date'] = $date;
418
+		$columns[ 'date' ] = $date;
419 419
 
420 420
 		return $columns;
421 421
 	}
@@ -429,12 +429,12 @@  discard block
 block discarded – undo
429 429
 	 */
430 430
 	function save_postdata( $post_id ) {
431 431
 
432
-		if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
432
+		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
433 433
 			return;
434 434
 		}
435 435
 
436 436
 		// validate post_type
437
-		if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) {
437
+		if ( ! isset( $_POST[ 'post_type' ] ) || 'gravityview' != $_POST[ 'post_type' ] ) {
438 438
 			return;
439 439
 		}
440 440
 
@@ -449,67 +449,67 @@  discard block
 block discarded – undo
449 449
 		$statii = array();
450 450
 
451 451
 		// check if this is a start fresh View
452
-		if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) {
452
+		if ( isset( $_POST[ 'gravityview_select_form_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_form_nonce' ], 'gravityview_select_form' ) ) {
453 453
 
454
-			$form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : '';
454
+			$form_id = ! empty( $_POST[ 'gravityview_form_id' ] ) ? $_POST[ 'gravityview_form_id' ] : '';
455 455
 			// save form id
456
-			$statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id );
456
+			$statii[ 'form_id' ] = update_post_meta( $post_id, '_gravityview_form_id', $form_id );
457 457
 
458 458
 		}
459 459
 
460
-		if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) {
460
+		if ( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii[ 'form_id' ] ) ) {
461 461
 			do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to create a new Form.', wp_get_current_user() );
462 462
 			return;
463 463
 		}
464 464
 
465 465
 		// Was this a start fresh?
466
-		if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) {
467
-			$statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 );
466
+		if ( ! empty( $_POST[ 'gravityview_form_id_start_fresh' ] ) ) {
467
+			$statii[ 'start_fresh' ] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 );
468 468
 		} else {
469
-			$statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' );
469
+			$statii[ 'start_fresh' ] = delete_post_meta( $post_id, '_gravityview_start_fresh' );
470 470
 		}
471 471
 
472 472
 		// Check if we have a template id
473
-		if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) {
473
+		if ( isset( $_POST[ 'gravityview_select_template_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_template_nonce' ], 'gravityview_select_template' ) ) {
474 474
 
475
-			$template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : '';
475
+			$template_id = ! empty( $_POST[ 'gravityview_directory_template' ] ) ? $_POST[ 'gravityview_directory_template' ] : '';
476 476
 
477 477
 			// now save template id
478
-			$statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id );
478
+			$statii[ 'directory_template' ] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id );
479 479
 		}
480 480
 
481 481
 
482 482
 		// save View Configuration metabox
483
-		if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) {
483
+		if ( isset( $_POST[ 'gravityview_view_configuration_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_view_configuration_nonce' ], 'gravityview_view_configuration' ) ) {
484 484
 
485 485
 			// template settings
486
-			if( empty( $_POST['template_settings'] ) ) {
487
-				$_POST['template_settings'] = array();
486
+			if ( empty( $_POST[ 'template_settings' ] ) ) {
487
+				$_POST[ 'template_settings' ] = array();
488 488
 			}
489
-			$statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] );
489
+			$statii[ 'template_settings' ] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST[ 'template_settings' ] );
490 490
 
491 491
 			$fields = array();
492 492
 
493 493
 			// Directory&single Visible Fields
494
-			if( !empty( $preset_fields ) ) {
494
+			if ( ! empty( $preset_fields ) ) {
495 495
 
496 496
 				$fields = $preset_fields;
497 497
 
498
-			} elseif( !empty( $_POST['fields'] ) ) {
498
+			} elseif ( ! empty( $_POST[ 'fields' ] ) ) {
499 499
 				$fields = _gravityview_process_posted_fields();
500 500
 			}
501 501
 
502
-			$statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields );
502
+			$statii[ 'directory_fields' ] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields );
503 503
 
504 504
 			// Directory Visible Widgets
505
-			if( empty( $_POST['widgets'] ) ) {
506
-				$_POST['widgets'] = array();
505
+			if ( empty( $_POST[ 'widgets' ] ) ) {
506
+				$_POST[ 'widgets' ] = array();
507 507
 			}
508
-			$statii['directory_widgets'] = update_post_meta( $post_id, '_gravityview_directory_widgets', $_POST['widgets'] );
508
+			$statii[ 'directory_widgets' ] = update_post_meta( $post_id, '_gravityview_directory_widgets', $_POST[ 'widgets' ] );
509 509
 
510 510
 		} // end save view configuration
511 511
 
512
-		do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) );
512
+		do_action( 'gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) );
513 513
 	}
514 514
 
515 515
 	/**
@@ -541,20 +541,20 @@  discard block
 block discarded – undo
541 541
 
542 542
 		$output = '';
543 543
 
544
-		if( !empty( $fields ) ) {
544
+		if ( ! empty( $fields ) ) {
545 545
 
546
-			foreach( $fields as $id => $details ) {
546
+			foreach ( $fields as $id => $details ) {
547 547
 
548
-				if( in_array( $details['type'], $blacklist_field_types ) ) {
548
+				if ( in_array( $details[ 'type' ], $blacklist_field_types ) ) {
549 549
 					continue;
550 550
 				}
551 551
 
552 552
 				// Edit mode only allows editing the parent fields, not single inputs.
553
-				if( $context === 'edit' && !empty( $details['parent'] ) ) {
553
+				if ( $context === 'edit' && ! empty( $details[ 'parent' ] ) ) {
554 554
 					continue;
555 555
 				}
556 556
 
557
-				$output .= new GravityView_Admin_View_Field( $details['label'], $id, $details );
557
+				$output .= new GravityView_Admin_View_Field( $details[ 'label' ], $id, $details );
558 558
 
559 559
 			} // End foreach
560 560
 		}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		echo $output;
563 563
 
564 564
 		// For the EDIT view we only want to allow the form fields.
565
-		if( $context === 'edit' ) {
565
+		if ( $context === 'edit' ) {
566 566
 			return;
567 567
 		}
568 568
 
@@ -586,16 +586,16 @@  discard block
 block discarded – undo
586 586
 		$additional_fields = apply_filters( 'gravityview_additional_fields', array(
587 587
 			array(
588 588
 				'label_text' => __( '+ Add All Fields', 'gravityview' ),
589
-				'desc' => __('Add all the available fields at once.', 'gravityview'),
589
+				'desc' => __( 'Add all the available fields at once.', 'gravityview' ),
590 590
 				'field_id' => 'all-fields',
591 591
 				'label_type' => 'field',
592 592
 				'input_type' => NULL,
593 593
 				'field_options' => NULL,
594 594
 				'settings_html'	=> NULL,
595 595
 			)
596
-		));
596
+		) );
597 597
 
598
-		if( !empty( $additional_fields )) {
598
+		if ( ! empty( $additional_fields ) ) {
599 599
 			foreach ( (array)$additional_fields as $item ) {
600 600
 
601 601
 				// Prevent items from not having index set
@@ -606,16 +606,16 @@  discard block
 block discarded – undo
606 606
 					'input_type' => NULL,
607 607
 					'field_options' => NULL,
608 608
 					'settings_html'	=> NULL,
609
-				));
609
+				) );
610 610
 
611 611
 				// Backward compat.
612
-				if( !empty( $item['field_options'] ) ) {
612
+				if ( ! empty( $item[ 'field_options' ] ) ) {
613 613
 					// Use settings_html from now on.
614
-					$item['settings_html'] = $item['field_options'];
614
+					$item[ 'settings_html' ] = $item[ 'field_options' ];
615 615
 				}
616 616
 
617 617
 				// Render a label for each of them
618
-				echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item );
618
+				echo new GravityView_Admin_View_Field( $item[ 'label_text' ], $item[ 'field_id' ], $item );
619 619
 
620 620
 			}
621 621
 		}
@@ -628,63 +628,63 @@  discard block
 block discarded – undo
628 628
 	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
629 629
 	 * @return array
630 630
 	 */
631
-	function get_entry_default_fields($form, $zone) {
631
+	function get_entry_default_fields( $form, $zone ) {
632 632
 
633 633
 		$entry_default_fields = array();
634 634
 
635
-		if( in_array( $zone, array( 'directory', 'single' ) ) ) {
635
+		if ( in_array( $zone, array( 'directory', 'single' ) ) ) {
636 636
 
637 637
 			$entry_default_fields = array(
638 638
 				'id' => array(
639
-					'label' => __('Entry ID', 'gravityview'),
639
+					'label' => __( 'Entry ID', 'gravityview' ),
640 640
 					'type' => 'id',
641
-					'desc'	=> __('The unique ID of the entry.', 'gravityview'),
641
+					'desc'	=> __( 'The unique ID of the entry.', 'gravityview' ),
642 642
 				),
643 643
 				'date_created' => array(
644
-					'label' => __('Entry Date', 'gravityview'),
645
-					'desc'	=> __('The date the entry was created.', 'gravityview'),
644
+					'label' => __( 'Entry Date', 'gravityview' ),
645
+					'desc'	=> __( 'The date the entry was created.', 'gravityview' ),
646 646
 					'type' => 'date_created',
647 647
 				),
648 648
 				'source_url' => array(
649
-					'label' => __('Source URL', 'gravityview'),
649
+					'label' => __( 'Source URL', 'gravityview' ),
650 650
 					'type' => 'source_url',
651
-					'desc'	=> __('The URL of the page where the form was submitted.', 'gravityview'),
651
+					'desc'	=> __( 'The URL of the page where the form was submitted.', 'gravityview' ),
652 652
 				),
653 653
 				'ip' => array(
654
-					'label' => __('User IP', 'gravityview'),
654
+					'label' => __( 'User IP', 'gravityview' ),
655 655
 					'type' => 'ip',
656
-					'desc'	=> __('The IP Address of the user who created the entry.', 'gravityview'),
656
+					'desc'	=> __( 'The IP Address of the user who created the entry.', 'gravityview' ),
657 657
 				),
658 658
 				'created_by' => array(
659
-					'label' => __('User', 'gravityview'),
659
+					'label' => __( 'User', 'gravityview' ),
660 660
 					'type' => 'created_by',
661
-					'desc'	=> __('Details of the logged-in user who created the entry (if any).', 'gravityview'),
661
+					'desc'	=> __( 'Details of the logged-in user who created the entry (if any).', 'gravityview' ),
662 662
 				),
663 663
 
664 664
 				/**
665 665
 				 * @since  1.2
666 666
 				 */
667 667
 				'custom'	=> array(
668
-					'label'	=> __('Custom Content', 'gravityview'),
668
+					'label'	=> __( 'Custom Content', 'gravityview' ),
669 669
 					'type'	=> 'custom',
670
-					'desc'	=> __('Insert custom text or HTML.', 'gravityview'),
670
+					'desc'	=> __( 'Insert custom text or HTML.', 'gravityview' ),
671 671
 				),
672 672
 
673 673
 				/**
674 674
 				 * @since 1.7.2
675 675
 				 */
676 676
 			    'other_entries' => array(
677
-				    'label'	=> __('Other Entries', 'gravityview'),
677
+				    'label'	=> __( 'Other Entries', 'gravityview' ),
678 678
 				    'type'	=> 'other_entries',
679
-				    'desc'	=> __('Display other entries created by the entry creator.', 'gravityview'),
679
+				    'desc'	=> __( 'Display other entries created by the entry creator.', 'gravityview' ),
680 680
 			    ),
681 681
 	        );
682 682
 
683
-			if( 'single' !== $zone) {
683
+			if ( 'single' !== $zone ) {
684 684
 
685
-				$entry_default_fields['entry_link'] = array(
686
-					'label' => __('Link to Entry', 'gravityview'),
687
-					'desc'	=> __('A dedicated link to the single entry with customizable text.', 'gravityview'),
685
+				$entry_default_fields[ 'entry_link' ] = array(
686
+					'label' => __( 'Link to Entry', 'gravityview' ),
687
+					'desc'	=> __( 'A dedicated link to the single entry with customizable text.', 'gravityview' ),
688 688
 					'type' => 'entry_link',
689 689
 				);
690 690
 			}
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 		 * @param  string|array $form form_ID or form object
699 699
 		 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
700 700
 		 */
701
-		return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone);
701
+		return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone );
702 702
 	}
703 703
 
704 704
 	/**
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	 */
710 710
 	function get_available_fields( $form = '', $zone = NULL ) {
711 711
 
712
-		if( empty( $form ) ) {
712
+		if ( empty( $form ) ) {
713 713
 			do_action( 'gravityview_log_error', '[get_available_fields] $form is empty' );
714 714
 			return array();
715 715
 		}
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 		$fields = gravityview_get_form_fields( $form, true );
719 719
 
720 720
 		// get meta fields ( only if form was already created )
721
-		if( !is_array( $form ) ) {
721
+		if ( ! is_array( $form ) ) {
722 722
 			$meta_fields = gravityview_get_entry_meta( $form );
723 723
 		} else {
724 724
 			$meta_fields = array();
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 
743 743
 		$widgets = $this->get_registered_widgets();
744 744
 
745
-		if( !empty( $widgets ) ) {
745
+		if ( ! empty( $widgets ) ) {
746 746
 
747
-			foreach( $widgets as $id => $details ) {
747
+			foreach ( $widgets as $id => $details ) {
748 748
 
749
-				echo new GravityView_Admin_View_Widget( $details['label'], $id, $details );
749
+				echo new GravityView_Admin_View_Widget( $details[ 'label' ], $id, $details );
750 750
 
751 751
 			}
752 752
 		}
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	function render_active_areas( $template_id, $type, $zone, $rows, $values ) {
781 781
 		global $post;
782 782
 
783
-		if( $type === 'widget' ) {
783
+		if ( $type === 'widget' ) {
784 784
 			$button_label = __( 'Add Widget', 'gravityview' );
785 785
 		} else {
786 786
 			$button_label = __( 'Add Field', 'gravityview' );
@@ -789,15 +789,15 @@  discard block
 block discarded – undo
789 789
 		$available_items = array();
790 790
 
791 791
 		// if saved values, get available fields to label everyone
792
-		if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) {
792
+		if ( ! empty( $values ) && ( ! empty( $post->ID ) || ! empty( $_POST[ 'template_id' ] ) ) ) {
793 793
 
794
-			if( !empty( $_POST['template_id'] ) ) {
795
-				$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
794
+			if ( ! empty( $_POST[ 'template_id' ] ) ) {
795
+				$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
796 796
 			} else {
797 797
 				$form = gravityview_get_form_id( $post->ID );
798 798
 			}
799 799
 
800
-			if( 'field' === $type ) {
800
+			if ( 'field' === $type ) {
801 801
 				$available_items = $this->get_available_fields( $form, $zone );
802 802
 			} else {
803 803
 				$available_items = $this->get_registered_widgets();
@@ -805,39 +805,39 @@  discard block
 block discarded – undo
805 805
 
806 806
 		}
807 807
 
808
-		foreach( $rows as $row ) :
809
-			foreach( $row as $col => $areas ) :
810
-				$column = ($col == '2-2') ? '1-2' : $col; ?>
808
+		foreach ( $rows as $row ) :
809
+			foreach ( $row as $col => $areas ) :
810
+				$column = ( $col == '2-2' ) ? '1-2' : $col; ?>
811 811
 
812 812
 				<div class="gv-grid-col-<?php echo esc_attr( $column ); ?>">
813 813
 
814
-					<?php foreach( $areas as $area ) : 	?>
814
+					<?php foreach ( $areas as $area ) : 	?>
815 815
 
816 816
 						<div class="gv-droppable-area">
817
-							<div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>">
817
+							<div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>">
818 818
 
819 819
 								<?php // render saved fields
820 820
 
821
-								if( !empty( $values[ $zone .'_'. $area['areaid'] ] ) ) {
821
+								if ( ! empty( $values[ $zone . '_' . $area[ 'areaid' ] ] ) ) {
822 822
 
823
-									foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) {
823
+									foreach ( $values[ $zone . '_' . $area[ 'areaid' ] ] as $uniqid => $field ) {
824 824
 
825 825
 										$input_type = NULL;
826
-										$original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ;
826
+										$original_item = isset( $available_items[ $field[ 'id' ] ] ) ? $available_items[ $field[ 'id' ] ] : false;
827 827
 
828
-										if( !$original_item ) {
828
+										if ( ! $original_item ) {
829 829
 
830
-											do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field ));
830
+											do_action( 'gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array( 'available_items' => $available_items, 'field' => $field ) );
831 831
 
832 832
 											$original_item = $field;
833 833
 										} else {
834 834
 
835
-											$input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL;
835
+											$input_type = isset( $original_item[ 'type' ] ) ? $original_item[ 'type' ] : NULL;
836 836
 
837 837
 										}
838 838
 
839 839
 										// Field options dialog box
840
-										$field_options = GravityView_Render_Settings::render_field_options( $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item );
840
+										$field_options = GravityView_Render_Settings::render_field_options( $type, $template_id, $field[ 'id' ], $original_item[ 'label' ], $zone . '_' . $area[ 'areaid' ], $input_type, $uniqid, $field, $zone, $original_item );
841 841
 
842 842
 										$item = array(
843 843
 											'input_type' => $input_type,
@@ -846,16 +846,16 @@  discard block
 block discarded – undo
846 846
 										);
847 847
 
848 848
 										// Merge the values with the current item to pass things like widget descriptions and original field names
849
-										if( $original_item ) {
849
+										if ( $original_item ) {
850 850
 											$item = wp_parse_args( $item, $original_item );
851 851
 										}
852 852
 
853
-										switch( $type ) {
853
+										switch ( $type ) {
854 854
 											case 'widget':
855
-												echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field );
855
+												echo new GravityView_Admin_View_Widget( $item[ 'label' ], $field[ 'id' ], $item, $field );
856 856
 												break;
857 857
 											default:
858
-												echo new GravityView_Admin_View_Field( $item['label'], $field['id'], $item, $field );
858
+												echo new GravityView_Admin_View_Field( $item[ 'label' ], $field[ 'id' ], $item, $field );
859 859
 										}
860 860
 
861 861
 
@@ -865,11 +865,11 @@  discard block
 block discarded – undo
865 865
 
866 866
 								} // End if zone is not empty ?>
867 867
 
868
-								<span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span>
868
+								<span class="drop-message"><?php echo sprintf( esc_attr__( '"+ %s" or drag existing %ss here.', 'gravityview' ), $button_label, $type ); ?></span>
869 869
 							</div>
870 870
 							<div class="gv-droppable-area-action">
871
-								<a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"><?php echo '+ '.esc_html( $button_label ); ?></a>
872
-								<p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> &ndash; <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p>
871
+								<a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"><?php echo '+ ' . esc_html( $button_label ); ?></a>
872
+								<p class="gv-droppable-area-title"><strong><?php echo esc_html( $area[ 'title' ] ); ?></strong><?php if ( ! empty( $area[ 'subtitle' ] ) ) { ?><span class="gv-droppable-area-subtitle"> &ndash; <?php echo esc_html( $area[ 'subtitle' ] ); ?></span><?php } ?></p>
873 873
 							</div>
874 874
 						</div>
875 875
 
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
892 892
 
893 893
 		$widgets = array();
894
-		if( !empty( $post_id ) ) {
894
+		if ( ! empty( $post_id ) ) {
895 895
 			$widgets = get_post_meta( $post_id, '_gravityview_directory_widgets', true );
896 896
 
897 897
 		}
@@ -922,19 +922,19 @@  discard block
 block discarded – undo
922 922
 	 */
923 923
 	function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) {
924 924
 
925
-		if( empty( $template_id ) ) {
925
+		if ( empty( $template_id ) ) {
926 926
 			do_action( 'gravityview_log_debug', '[render_directory_active_areas] $template_id is empty' );
927 927
 			return;
928 928
 		}
929 929
 
930 930
 		$template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context );
931 931
 
932
-		if( empty( $template_areas ) ) {
932
+		if ( empty( $template_areas ) ) {
933 933
 
934 934
 			do_action( 'gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id );
935 935
 			$output = '<div>';
936
-			$output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>';
937
-			$output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>';
936
+			$output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>' . $template_id . '</em>' ) . '</h2>';
937
+			$output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__( 'The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview' ) . '</p>';
938 938
 			$output .= '</div>';
939 939
 		} else {
940 940
 
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 
950 950
 		}
951 951
 
952
-		if( $echo ) {
952
+		if ( $echo ) {
953 953
 			echo $output;
954 954
 		}
955 955
 
@@ -969,25 +969,25 @@  discard block
 block discarded – undo
969 969
 		$is_widgets_page = ( $pagenow === 'widgets.php' );
970 970
 
971 971
 		// Add the GV font (with the Astronaut)
972
-		wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version );
972
+		wp_enqueue_style( 'gravityview_global', plugins_url( 'assets/css/admin-global.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
973 973
 
974
-		wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true );
974
+		wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
975 975
 
976 976
 		// Don't process any scripts below here if it's not a GravityView page.
977
-		if( !gravityview_is_admin_page($hook) && !$is_widgets_page ) { return; }
977
+		if ( ! gravityview_is_admin_page( $hook ) && ! $is_widgets_page ) { return; }
978 978
 
979 979
 		// Only enqueue the following on single pages
980
-		if( gravityview_is_admin_page($hook, 'single') || $is_widgets_page ) {
980
+		if ( gravityview_is_admin_page( $hook, 'single' ) || $is_widgets_page ) {
981 981
 
982 982
 			wp_enqueue_script( 'jquery-ui-datepicker' );
983
-			wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version );
983
+			wp_enqueue_style( 'gravityview_views_datepicker', plugins_url( 'assets/css/admin-datepicker.css', GRAVITYVIEW_FILE ), GravityView_Plugin::version );
984 984
 
985
-			$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
985
+			$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
986 986
 
987 987
 			//enqueue scripts
988 988
 			wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version );
989 989
 
990
-			wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
990
+			wp_localize_script( 'gravityview_views_scripts', 'gvGlobals', array(
991 991
 				'cookiepath' => COOKIEPATH,
992 992
 				'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
993 993
 				'label_viewname' => __( 'Enter View name here', 'gravityview' ),
@@ -1000,9 +1000,9 @@  discard block
 block discarded – undo
1000 1000
 				'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1001 1001
 				'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1002 1002
 				'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ),
1003
-			));
1003
+			) );
1004 1004
 
1005
-			wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version );
1005
+			wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version );
1006 1006
 
1007 1007
 			self::enqueue_gravity_forms_scripts();
1008 1008
 
@@ -1021,10 +1021,10 @@  discard block
 block discarded – undo
1021 1021
 		);
1022 1022
 
1023 1023
 		if ( wp_is_mobile() ) {
1024
-				    $scripts[] = 'jquery-touch-punch';
1024
+				    $scripts[ ] = 'jquery-touch-punch';
1025 1025
 		}
1026 1026
 
1027
-		foreach ($scripts as $script) {
1027
+		foreach ( $scripts as $script ) {
1028 1028
 			wp_enqueue_script( $script );
1029 1029
 		}
1030 1030
 	}
@@ -1033,11 +1033,11 @@  discard block
 block discarded – undo
1033 1033
 
1034 1034
 		$filter = current_filter();
1035 1035
 
1036
-		if( preg_match('/script/ism', $filter ) ) {
1036
+		if ( preg_match( '/script/ism', $filter ) ) {
1037 1037
 			$allow_scripts = array( 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker',
1038 1038
 			'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete' );
1039 1039
 			$registered = array_merge( $registered, $allow_scripts );
1040
-		} elseif( preg_match('/style/ism', $filter ) ) {
1040
+		} elseif ( preg_match( '/style/ism', $filter ) ) {
1041 1041
 			$allow_styles = array( 'dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker' );
1042 1042
 			$registered = array_merge( $registered, $allow_styles );
1043 1043
 		}
Please login to merge, or discard this patch.
includes/extensions/entry-notes/class-gravityview-field-notes.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -63,18 +63,18 @@  discard block
 block discarded – undo
63 63
 
64 64
 		add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) );
65 65
 
66
-		add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 );
67
-		add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') );
68
-		add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') );
66
+		add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 );
67
+		add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) );
68
+		add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) );
69 69
 
70
-		add_action( 'wp', array( $this, 'maybe_add_note'), 1000 );
71
-		add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') );
72
-		add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') );
70
+		add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 );
71
+		add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) );
72
+		add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) );
73 73
 
74 74
 		// add template path to check for field
75 75
 		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
76 76
 
77
-		add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
77
+		add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
78 78
 		add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) );
79 79
 		
80 80
 		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_entry_default_field' ), 10, 3 );
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function add_entry_default_field( $entry_default_fields, $form, $zone ) {
98 98
 
99
-		if( in_array( $zone, array( 'directory', 'single' ) ) ) {
100
-			$entry_default_fields['notes'] = array(
99
+		if ( in_array( $zone, array( 'directory', 'single' ) ) ) {
100
+			$entry_default_fields[ 'notes' ] = array(
101 101
 				'label' => __( 'Entry Notes', 'gravityview' ),
102 102
 				'type'  => 'notes',
103 103
 				'desc'  => __( 'Display, add, and delete notes for an entry.', 'gravityview' ),
@@ -130,23 +130,23 @@  discard block
 block discarded – undo
130 130
 	public function enqueue_scripts() {
131 131
 		global $wp_actions;
132 132
 
133
-		if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) {
133
+		if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) {
134 134
 			wp_enqueue_style( 'gravityview-notes' );
135 135
 			wp_enqueue_script( 'gravityview-notes' );
136 136
 		}
137 137
 
138
-		if( ! wp_script_is( 'gravityview-notes', 'done' ) ) {
138
+		if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) {
139 139
 
140 140
 			$strings = self::strings();
141 141
 
142 142
 			wp_localize_script( 'gravityview-notes', 'GVNotes', array(
143 143
 				'ajaxurl' => admin_url( 'admin-ajax.php' ),
144 144
 				'text' => array(
145
-					'processing' => $strings['processing'],
146
-					'delete_confirm' => $strings['delete-confirm'],
147
-					'note_added' => $strings['added-note'],
148
-					'error_invalid' => $strings['error-invalid'],
149
-					'error_empty_note' => $strings['error-empty-note'],
145
+					'processing' => $strings[ 'processing' ],
146
+					'delete_confirm' => $strings[ 'delete-confirm' ],
147
+					'note_added' => $strings[ 'added-note' ],
148
+					'error_invalid' => $strings[ 'error-invalid' ],
149
+					'error_empty_note' => $strings[ 'error-empty-note' ],
150 150
 				),
151 151
 			) );
152 152
 		}
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	function maybe_add_note() {
165 165
 
166
-		if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) {
166
+		if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) {
167 167
 			do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' );
168 168
 			return;
169 169
 		}
170 170
 
171
-		if( 'gv_note_add' === rgpost('action') ) {
171
+		if ( 'gv_note_add' === rgpost( 'action' ) ) {
172 172
 
173 173
 			$post = wp_unslash( $_POST );
174 174
 
175
-			if( $this->doing_ajax ) {
176
-				parse_str( $post['data'], $data );
175
+			if ( $this->doing_ajax ) {
176
+				parse_str( $post[ 'data' ], $data );
177 177
 			} else {
178 178
 				$data = $post;
179 179
 			}
180 180
 
181
-			$this->process_add_note( (array) $data );
181
+			$this->process_add_note( (array)$data );
182 182
 		}
183 183
 	}
184 184
 
@@ -205,23 +205,23 @@  discard block
 block discarded – undo
205 205
 		$error = false;
206 206
 		$success = false;
207 207
 
208
-		if( empty( $data['entry-slug'] ) ) {
208
+		if ( empty( $data[ 'entry-slug' ] ) ) {
209 209
 
210
-			$error = self::strings('error-invalid');
210
+			$error = self::strings( 'error-invalid' );
211 211
 			do_action( 'gravityview_log_error', __METHOD__ . ': The note is missing an Entry ID.' );
212 212
 
213 213
 		} else {
214 214
 
215
-			$valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] );
215
+			$valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] );
216 216
 			
217 217
 			$has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' );
218 218
 
219
-			if( ! $has_cap ) {
219
+			if ( ! $has_cap ) {
220 220
 				$error = self::strings( 'error-cap-add' );
221 221
 				do_action( 'gravityview_log_error', __METHOD__ . ': Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' );
222 222
 			} elseif ( $valid ) {
223 223
 
224
-				$entry = gravityview_get_entry( $data['entry-slug'], true, false );
224
+				$entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false );
225 225
 
226 226
 				$added = $this->add_note( $entry, $data );
227 227
 
@@ -239,22 +239,22 @@  discard block
 block discarded – undo
239 239
 					$this->maybe_send_entry_notes( $note, $entry, $data );
240 240
 
241 241
 					if ( $note ) {
242
-						$success = self::display_note( $note, ! empty( $data['show-delete'] ) );
243
-						do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact('note', 'data') );
242
+						$success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) );
243
+						do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact( 'note', 'data' ) );
244 244
 					} else {
245
-						$error = self::strings('error-add-note');
246
-						do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact('note', 'data') );
245
+						$error = self::strings( 'error-add-note' );
246
+						do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact( 'note', 'data' ) );
247 247
 					}
248 248
 				}
249 249
 			} else {
250
-				$error = self::strings('error-invalid');
250
+				$error = self::strings( 'error-invalid' );
251 251
 				do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed; the note was not created' );
252 252
 			}
253 253
 		}
254 254
 
255 255
 
256
-		if( $this->doing_ajax ) {
257
-			if( $success ) {
256
+		if ( $this->doing_ajax ) {
257
+			if ( $success ) {
258 258
 				wp_send_json_success( array( 'html' => $success ) );
259 259
 			} else {
260 260
 				$error = $error ? $error : self::strings( 'error-invalid' );
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 			return;
281 281
 		}
282 282
 
283
-		if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) {
283
+		if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) {
284 284
 
285 285
 			$post = wp_unslash( $_POST );
286 286
 			if ( $this->doing_ajax ) {
287
-				parse_str( $post['data'], $data );
287
+				parse_str( $post[ 'data' ], $data );
288 288
 			} else {
289 289
 				$data = $post;
290 290
 			}
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
 	 */
316 316
 	function process_delete_notes( $data ) {
317 317
 
318
-		$valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] );
318
+		$valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] );
319 319
 		$has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' );
320 320
 		$success = false;
321 321
 
322 322
 		if ( $valid && $has_cap ) {
323
-			GravityView_Entry_Notes::delete_notes( $data['note'] );
323
+			GravityView_Entry_Notes::delete_notes( $data[ 'note' ] );
324 324
 			$success = true;
325 325
 		}
326 326
 
327
-		if( $this->doing_ajax ) {
327
+		if ( $this->doing_ajax ) {
328 328
 
329
-			if( $success ) {
329
+			if ( $success ) {
330 330
 				wp_send_json_success();
331 331
 			} else {
332 332
 				if ( ! $valid ) {
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
 
360 360
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
361 361
 
362
-		unset( $field_options['show_as_link'] );
362
+		unset( $field_options[ 'show_as_link' ] );
363 363
 
364 364
 		$notes_options = array(
365 365
 			'notes' => array(
366 366
 				'type' => 'checkboxes',
367
-				'label' => __('Note Settings', 'gravityview'),
368
-				'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ),
367
+				'label' => __( 'Note Settings', 'gravityview' ),
368
+				'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ),
369 369
 				'options' => array(
370 370
 					'view' => array(
371 371
 						'label' => __( 'Display notes?', 'gravityview' ),
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 			'processing' => __( 'Processing&hellip;', 'gravityview' ),
418 418
 			'other-email' => __( 'Other email address', 'gravityview' ),
419 419
 			'email-label' => __( 'Email address', 'gravityview' ),
420
-			'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'),
420
+			'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ),
421 421
 			'subject-label' => __( 'Subject', 'gravityview' ),
422 422
 			'subject' => __( 'Email subject', 'gravityview' ),
423 423
 			'default-email-subject' => __( 'New entry note', 'gravityview' ),
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		 */
437 437
 		$strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' );
438 438
 
439
-		if( $key ) {
439
+		if ( $key ) {
440 440
 			return isset( $strings[ $key ] ) ? $strings[ $key ] : '';
441 441
 		}
442 442
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 	 */
456 456
 	static public function display_note( $note, $show_delete = false ) {
457 457
 
458
-		if( ! is_object( $note ) ) {
458
+		if ( ! is_object( $note ) ) {
459 459
 			return '';
460 460
 		}
461 461
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 		$note_row = ob_get_clean();
497 497
 
498 498
 		$replacements = array(
499
-			'{note_id}' => $note_content['note_id'],
499
+			'{note_id}' => $note_content[ 'note_id' ],
500 500
 			'{row_class}' => 'gv-note',
501 501
 			'{note_detail}' => $note_detail_html
502 502
 		);
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 
529 529
 		$user_data = get_userdata( $current_user->ID );
530 530
 
531
-		$note_content = trim( $data['gv-note-content'] );
531
+		$note_content = trim( $data[ 'gv-note-content' ] );
532 532
 
533
-		if( empty( $note_content ) ) {
533
+		if ( empty( $note_content ) ) {
534 534
 			return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) );
535 535
 		}
536 536
 
537
-		$return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' );
537
+		$return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' );
538 538
 
539 539
 		return $return;
540 540
 	}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 	 */
551 551
 	public static function get_add_note_part() {
552 552
 
553
-		if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) {
553
+		if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) {
554 554
 			do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").' );
555 555
 			return '';
556 556
 		}
@@ -563,19 +563,19 @@  discard block
 block discarded – undo
563 563
 
564 564
 		$visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' );
565 565
 		$entry = $gravityview_view->getCurrentEntry();
566
-		$entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
566
+		$entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry );
567 567
 		$nonce_field = wp_nonce_field( 'gv_note_add_' . $entry_slug, 'gv_note_add', false, false );
568 568
 
569 569
 		// Only generate the dropdown if the field settings allow it
570 570
 		$email_fields = '';
571
-		if( ! empty( $visibility_settings['email'] ) ) {
571
+		if ( ! empty( $visibility_settings[ 'email' ] ) ) {
572 572
 			$email_fields = self::get_note_email_fields( $entry_slug );
573 573
 		}
574 574
 
575 575
 		$add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html );
576 576
 		$add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html );
577
-		$add_note_html = str_replace( '{show_delete}', intval( $visibility_settings['delete'] ), $add_note_html );
578
-		$add_note_html   = str_replace( '{email_fields}', $email_fields, $add_note_html );
577
+		$add_note_html = str_replace( '{show_delete}', intval( $visibility_settings[ 'delete' ] ), $add_note_html );
578
+		$add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html );
579 579
 
580 580
 		return $add_note_html;
581 581
 	}
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
 		$note_emails = array();
600 600
 
601 601
 		foreach ( $email_fields as $email_field ) {
602
-			if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) {
603
-				$note_emails[] = $entry["{$email_field->id}"];
602
+			if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) {
603
+				$note_emails[ ] = $entry[ "{$email_field->id}" ];
604 604
 			}
605 605
 		}
606 606
 
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 		 */
613 613
 		$note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry );
614 614
 
615
-		return (array) $note_emails;
615
+		return (array)$note_emails;
616 616
 	}
617 617
 
618 618
 	/**
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	 */
629 629
 	private static function get_note_email_fields( $entry_slug = '' ) {
630 630
 
631
-		if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) {
631
+		if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) {
632 632
 			do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to email entry notes ("gravityview_email_entry_notes").' );
633 633
 			return '';
634 634
 		}
@@ -650,27 +650,27 @@  discard block
 block discarded – undo
650 650
 
651 651
 		if ( ! empty( $note_emails ) || $include_custom ) { ?>
652 652
 			<div class="gv-note-email-container">
653
-				<label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email'];  ?></label>
653
+				<label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label>
654 654
 				<select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>">
655
-					<option value=""><?php echo $strings['also-email'];  ?></option>
655
+					<option value=""><?php echo $strings[ 'also-email' ]; ?></option>
656 656
 					<?php foreach ( $note_emails as  $email ) {
657 657
 						?>
658 658
 						<option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option>
659 659
 					<?php }
660
-					if( $include_custom ) { ?>
661
-					<option value="custom"><?php echo self::strings('other-email'); ?></option>
660
+					if ( $include_custom ) { ?>
661
+					<option value="custom"><?php echo self::strings( 'other-email' ); ?></option>
662 662
 					<?php } ?>
663 663
 				</select>
664 664
 				<fieldset class="gv-note-to-container">
665
-					<?php if( $include_custom ) { ?>
665
+					<?php if ( $include_custom ) { ?>
666 666
 					<div class='gv-note-to-custom-container'>
667
-						<label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label>
668
-						<input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" />
667
+						<label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label>
668
+						<input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" />
669 669
 					</div>
670 670
 					<?php } ?>
671 671
 		            <div class='gv-note-subject-container'>
672
-		                <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label>
673
-		                <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" />
672
+		                <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label>
673
+		                <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" />
674 674
 		            </div>
675 675
 				</fieldset>
676 676
 			</div>
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	 */
694 694
 	private function maybe_send_entry_notes( $note = false, $entry, $data ) {
695 695
 
696
-		if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) {
696
+		if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) {
697 697
 			do_action( 'gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note );
698 698
 			return;
699 699
 		}
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 		do_action( 'gravityview_log_debug', __METHOD__ . ': $data', $data );
702 702
 
703 703
 		//emailing notes if configured
704
-		if ( ! empty( $data['gv-note-to'] ) ) {
704
+		if ( ! empty( $data[ 'gv-note-to' ] ) ) {
705 705
 
706 706
 			$default_data = array(
707 707
 				'gv-note-to' => '',
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 				'gv-note-content' => '',
711 711
 			);
712 712
 
713
-			$current_user  = wp_get_current_user();
713
+			$current_user = wp_get_current_user();
714 714
 			$email_data = wp_parse_args( $data, $default_data );
715 715
 
716
-			$from    = $current_user->user_email;
717
-			$to = $email_data['gv-note-to'];
716
+			$from = $current_user->user_email;
717
+			$to = $email_data[ 'gv-note-to' ];
718 718
 
719 719
 			/**
720 720
 			 * Documented in get_note_email_fields
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
 			 */
723 723
 			$include_custom = apply_filters( 'gravityview/field/notes/custom-email', true );
724 724
 
725
-			if( 'custom' === $to && $include_custom ) {
726
-				$to = $email_data['gv-note-to-custom'];
725
+			if ( 'custom' === $to && $include_custom ) {
726
+				$to = $email_data[ 'gv-note-to-custom' ];
727 727
 				do_action( 'gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to );
728 728
 			}
729 729
 
@@ -734,12 +734,12 @@  discard block
 block discarded – undo
734 734
 
735 735
 			$bcc = false;
736 736
 			$reply_to = $from;
737
-			$subject = trim( $email_data['gv-note-subject'] );
737
+			$subject = trim( $email_data[ 'gv-note-subject' ] );
738 738
 
739 739
 			// We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF
740 740
 			$subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject;
741
-			$message = $email_data['gv-note-content'];
742
-			$from_name     = $current_user->display_name;
741
+			$message = $email_data[ 'gv-note-content' ];
742
+			$from_name = $current_user->display_name;
743 743
 			$message_format = 'html';
744 744
 
745 745
 			/**
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 
755 755
 			GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false );
756 756
 
757
-			$form  = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array();
757
+			$form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array();
758 758
 
759 759
 			/**
760 760
 			 * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms
Please login to merge, or discard this patch.
includes/helper-functions.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 	// If there's an overriding CSS file in the current template folder, use it.
33 33
 	$template_css_path = trailingslashit( get_stylesheet_directory() ) . 'gravityview/css/' . $css_file;
34 34
 
35
-	if( file_exists( $template_css_path ) ) {
35
+	if ( file_exists( $template_css_path ) ) {
36 36
 		$path = trailingslashit( get_stylesheet_directory_uri() ) . 'gravityview/css/' . $css_file;
37
-		do_action( 'gravityview_log_debug', __FUNCTION__ . ': Stylesheet override ('. esc_attr( $css_file ) .')' );
37
+		do_action( 'gravityview_log_debug', __FUNCTION__ . ': Stylesheet override (' . esc_attr( $css_file ) . ')' );
38 38
 	} else {
39 39
 		// Default: use GravityView CSS file
40 40
 
41 41
 		// If no path is provided, assume default plugin templates CSS folder
42
-		if( '' === $dir_path ) {
42
+		if ( '' === $dir_path ) {
43 43
 			$dir_path = GRAVITYVIEW_DIR . 'templates/css/';
44 44
 		}
45 45
 		
46 46
 		// plugins_url() expects a path to a file, not directory. We append a file to be stripped.
47
-		$path = plugins_url( $css_file, trailingslashit( $dir_path )  . 'stripped-by-plugin_basename.php' );
47
+		$path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' );
48 48
 	}
49 49
 
50 50
 	return $path;
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 
83 83
 	$parsed_permalink = parse_url( get_permalink( $id ) );
84 84
 
85
-	$permalink_args =  isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false;
85
+	$permalink_args = isset( $parsed_permalink[ 'query' ] ) ? $parsed_permalink[ 'query' ] : false;
86 86
 
87
-	if( empty( $permalink_args ) ) {
87
+	if ( empty( $permalink_args ) ) {
88 88
 		return array();
89 89
 	}
90 90
 
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 function gv_selected( $value, $current, $echo = true, $type = 'selected' ) {
110 110
 
111 111
 	$output = '';
112
-	if( is_array( $current ) ) {
113
-		if( in_array( $value, $current ) ) {
112
+	if ( is_array( $current ) ) {
113
+		if ( in_array( $value, $current ) ) {
114 114
 			$output = __checked_selected_helper( true, true, false, $type );
115 115
 		}
116 116
 	} else {
117 117
 		$output = __checked_selected_helper( $value, $current, false, $type );
118 118
 	}
119 119
 
120
-	if( $echo ) {
120
+	if ( $echo ) {
121 121
 		echo $output;
122 122
 	}
123 123
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 }
126 126
 
127 127
 
128
-if( ! function_exists( 'gravityview_sanitize_html_class' ) ) {
128
+if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) {
129 129
 
130 130
 	/**
131 131
 	 * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function gravityview_strip_whitespace( $string ) {
173 173
 	$string = normalize_whitespace( $string );
174
-	return preg_replace('/[\r\n\t ]+/', ' ', $string );
174
+	return preg_replace( '/[\r\n\t ]+/', ' ', $string );
175 175
 }
176 176
 
177 177
 /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
  * @return string Included file contents
186 186
  */
187 187
 function gravityview_ob_include( $file_path, $object = NULL ) {
188
-	if( ! file_exists( $file_path ) ) {
188
+	if ( ! file_exists( $file_path ) ) {
189 189
 		do_action( 'gravityview_log_error', __FUNCTION__ . ': File path does not exist. ', $file_path );
190 190
 		return '';
191 191
 	}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 	$width = $height * 0.7586206897;
205 205
 
206
-	if( function_exists('is_rtl') && is_rtl() ) {
206
+	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
207 207
 		$style = 'margin:10px 10px 10px 0;';
208 208
 		$class = 'alignright';
209 209
 	} else {
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		$class = 'alignleft';
212 212
 	}
213 213
 
214
-	return '<img src="'.plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="'.$class.'" height="'.intval( $height ).'" width="'.round( $width, 2 ).'" alt="The GravityView Astronaut Says:" style="'.$style.'" />';
214
+	return '<img src="' . plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) . '" class="' . $class . '" height="' . intval( $height ) . '" width="' . round( $width, 2 ) . '" alt="The GravityView Astronaut Says:" style="' . $style . '" />';
215 215
 }
216 216
 
217 217
 /**
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 function gravityview_number_format( $number, $decimals = '' ) {
235 235
 	global $wp_locale;
236 236
 
237
-	if( '' === $decimals ) {
237
+	if ( '' === $decimals ) {
238 238
 
239
-		$decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.';
239
+		$decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.';
240 240
 
241 241
 		/**
242 242
 		 * Calculate the position of the decimal point in the number
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	$parts = parse_url( $value );
266 266
 
267 267
 	// No domain? Strange...show the original text.
268
-	if( empty( $parts['host'] ) ) {
268
+	if ( empty( $parts[ 'host' ] ) ) {
269 269
 		return $value;
270 270
 	}
271 271
 
@@ -278,16 +278,16 @@  discard block
 block discarded – undo
278 278
 	 * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n
279 279
 	 * If true: `http://example.com => example.com`
280 280
 	 */
281
-	if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) {
281
+	if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) {
282 282
 
283
-		if( isset( $parts['scheme'] ) ) {
284
-			$return .= $parts['scheme'];
283
+		if ( isset( $parts[ 'scheme' ] ) ) {
284
+			$return .= $parts[ 'scheme' ];
285 285
 		}
286 286
 
287 287
 	}
288 288
 
289 289
 	// The domain, which may contain a subdomain
290
-	$domain = $parts['host'];
290
+	$domain = $parts[ 'host' ];
291 291
 
292 292
 	/**
293 293
 	 * @filter `gravityview_anchor_text_stripwww` Strip www from the domain?
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 	 * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n
296 296
 	 * If true: `www.example.com => example.com`
297 297
 	 */
298
-	$strip_www = apply_filters('gravityview_anchor_text_stripwww', true );
298
+	$strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true );
299 299
 
300
-	if( $strip_www ) {
301
-		$domain = str_replace('www.', '', $domain );
300
+	if ( $strip_www ) {
301
+		$domain = str_replace( 'www.', '', $domain );
302 302
 	}
303 303
 
304 304
 	/**
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 	 * If true: `http://demo.example.com => example.com` \n
309 309
 	 * If false: `http://demo.example.com => demo.example.com`
310 310
 	 */
311
-	$strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true);
311
+	$strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true );
312 312
 
313
-	if( $strip_subdomains ) {
313
+	if ( $strip_subdomains ) {
314 314
 
315
-		$domain = _gravityview_strip_subdomain( $parts['host'] );
315
+		$domain = _gravityview_strip_subdomain( $parts[ 'host' ] );
316 316
 
317 317
 	}
318 318
 
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
 	 * If true: `http://example.com/sub/directory/page.html => example.com`  \n
327 327
 	 * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html`
328 328
 	 */
329
-	$root_only = apply_filters('gravityview_anchor_text_rootonly', true);
329
+	$root_only = apply_filters( 'gravityview_anchor_text_rootonly', true );
330 330
 
331
-	if( empty( $root_only ) ) {
331
+	if ( empty( $root_only ) ) {
332 332
 
333
-		if( isset( $parts['path'] ) ) {
334
-			$return .= $parts['path'];
333
+		if ( isset( $parts[ 'path' ] ) ) {
334
+			$return .= $parts[ 'path' ];
335 335
 		}
336 336
 	}
337 337
 
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 	 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n
342 342
 	 * If true: `http://example.com/?query=example => example.com`
343 343
 	 */
344
-	$strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true );
344
+	$strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true );
345 345
 
346
-	if( empty( $strip_query_string ) ) {
346
+	if ( empty( $strip_query_string ) ) {
347 347
 
348
-		if( isset( $parts['query'] ) ) {
349
-			$return .= '?'.$parts['query'];
348
+		if ( isset( $parts[ 'query' ] ) ) {
349
+			$return .= '?' . $parts[ 'query' ];
350 350
 		}
351 351
 
352 352
 	}
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
  */
364 364
 function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) {
365 365
 
366
-	if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
367
-		return $matches['domain'];
366
+	if ( preg_match( "/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
367
+		return $matches[ 'domain' ];
368 368
 	} else {
369 369
 		return $string_maybe_has_subdomain;
370 370
 	}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
  */
386 386
 function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true ) {
387 387
 
388
-	if(
388
+	if (
389 389
 		! isset( $value ) // If it's not set, it's empty!
390 390
 		|| false === $value
391 391
 		|| null === $value
@@ -396,20 +396,20 @@  discard block
 block discarded – undo
396 396
 		return true;
397 397
 	}
398 398
 
399
-	if( is_string( $value ) && $allow_string_booleans ) {
399
+	if ( is_string( $value ) && $allow_string_booleans ) {
400 400
 
401 401
 		$value = trim( $value );
402 402
 		$value = strtolower( $value );
403 403
 
404 404
 		if ( in_array( $value, array( 'yes', 'true' ), true ) ) {
405 405
 			$value = true;
406
-		} else if( in_array( $value, array( 'no', 'false' ), true ) ) {
406
+		} else if ( in_array( $value, array( 'no', 'false' ), true ) ) {
407 407
 			$value = false;
408 408
 		}
409 409
 	}
410 410
 
411 411
 	// If zero isn't empty, then if $value is a number and it's empty, it's zero. Thus, return false.
412
-	if( ! $zero_is_empty && is_numeric( $value ) && empty( $value ) ) {
412
+	if ( ! $zero_is_empty && is_numeric( $value ) && empty( $value ) ) {
413 413
 		return false;
414 414
 	}
415 415
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
 	// Use the original function, if exists.
434 434
 	// Requires WP 4.4+
435
-	if( function_exists( 'map_deep') ) {
435
+	if ( function_exists( 'map_deep' ) ) {
436 436
 		return map_deep( $value, $callback );
437 437
 	}
438 438
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
 	$exploded = explode( '.', "{$field_id}" );
499 499
 
500
-	return isset( $exploded[1] ) ? intval( $exploded[1] ) : false;
500
+	return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false;
501 501
 }
502 502
 
503 503
 /**
@@ -538,13 +538,13 @@  discard block
 block discarded – undo
538 538
 	 */
539 539
 	$args = apply_filters( 'gravityview_get_terms_choices_args', $args );
540 540
 
541
-	$terms = get_terms( $args['taxonomy'], $args );
541
+	$terms = get_terms( $args[ 'taxonomy' ], $args );
542 542
 
543 543
 	$choices = array();
544 544
 
545 545
 	if ( is_array( $terms ) ) {
546 546
 		foreach ( $terms as $term_id => $term_name ) {
547
-			$choices[] = array(
547
+			$choices[ ] = array(
548 548
 				'text'  => $term_name,
549 549
 				'value' => $term_id
550 550
 			);
@@ -568,21 +568,21 @@  discard block
 block discarded – undo
568 568
 function _gravityview_process_posted_fields() {
569 569
 	$fields = array();
570 570
 
571
-	if( !empty( $_POST['fields'] ) ) {
572
-		if ( ! is_array( $_POST['fields'] ) ) {
571
+	if ( ! empty( $_POST[ 'fields' ] ) ) {
572
+		if ( ! is_array( $_POST[ 'fields' ] ) ) {
573 573
 
574 574
 			// We are not using parse_str() due to max_input_vars limitation with large View configurations
575 575
 			$fields_holder = array();
576
-			GVCommon::gv_parse_str( $_POST['fields'], $fields_holder );
576
+			GVCommon::gv_parse_str( $_POST[ 'fields' ], $fields_holder );
577 577
 
578
-			if ( isset( $fields_holder['fields'] ) ) {
579
-				$fields = $fields_holder['fields'];
578
+			if ( isset( $fields_holder[ 'fields' ] ) ) {
579
+				$fields = $fields_holder[ 'fields' ];
580 580
 			} else {
581 581
 				do_action( 'gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder );
582 582
 			}
583 583
 
584 584
 		} else {
585
-			$fields = $_POST['fields'];
585
+			$fields = $_POST[ 'fields' ];
586 586
 		}
587 587
 	}
588 588
 
Please login to merge, or discard this patch.