Completed
Push — master ( babeed...92cdcd )
by Zack
11s
created
plugin-and-theme-hooks/class-gravityview-plugin-hooks-ultimate-member.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	function parse_um_profile_post_content( $args = array() ) {
44 44
 		global $ultimatemember;
45 45
 
46
-		if( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) {
46
+		if ( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) {
47 47
 			return;
48 48
 		}
49 49
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			return;
60 60
 		}
61 61
 
62
-		GravityView_View_Data::getInstance()->parse_post_content( $active_tab[0]->post_content );
62
+		GravityView_View_Data::getInstance()->parse_post_content( $active_tab[ 0 ]->post_content );
63 63
 
64 64
 		wp_reset_postdata();
65 65
 	}
Please login to merge, or discard this patch.
plugin-and-theme-hooks/abstract-gravityview-plugin-and-theme-hooks.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	private function maybe_add_hooks() {
92 92
 		$class_exists = $this->class_name && class_exists( $this->class_name );
93 93
 		$function_exists = $this->function_name && function_exists( $this->function_name );
94
-		$constant_defined = $this->constant_name && defined("{$this->constant_name}");
94
+		$constant_defined = $this->constant_name && defined( "{$this->constant_name}" );
95 95
 
96
-		if( $class_exists || $function_exists || $constant_defined ) {
96
+		if ( $class_exists || $function_exists || $constant_defined ) {
97 97
 			$this->add_hooks();
98 98
 		}
99 99
 	}
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 * @return void
105 105
 	 */
106 106
 	protected function add_hooks() {
107
-		if( $this->content_meta_keys ) {
107
+		if ( $this->content_meta_keys ) {
108 108
 			add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 );
109 109
 		}
110 110
 
111
-		if( $this->script_handles ) {
111
+		if ( $this->script_handles ) {
112 112
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) );
113 113
 		}
114 114
 
115
-		if( $this->style_handles ) {
115
+		if ( $this->style_handles ) {
116 116
 			add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) );
117 117
 		}
118 118
 
119
-		if( $this->post_type_support ) {
119
+		if ( $this->post_type_support ) {
120 120
 			add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 );
121 121
 		}
122 122
 	}
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-password.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -49,17 +49,17 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @return string If a custom field label isn't set, return the field label for the password field
51 51
 	 */
52
-	function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){
52
+	function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) {
53 53
 
54 54
 		// If using a custom label, no need to fetch the parent label
55
-		if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) {
55
+		if ( ! is_numeric( $field[ 'id' ] ) || ! empty( $field[ 'custom_label' ] ) ) {
56 56
 			return $label;
57 57
 		}
58 58
 
59
-		$field_object = GFFormsModel::get_field( $form, $field['id'] );
59
+		$field_object = GFFormsModel::get_field( $form, $field[ 'id' ] );
60 60
 
61
-		if( $field_object && 'password' === $field_object->type ) {
62
-			$label = $field['label'];
61
+		if ( $field_object && 'password' === $field_object->type ) {
62
+			$label = $field[ 'label' ];
63 63
 		}
64 64
 
65 65
 		return $label;
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 	function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) {
80 80
 
81 81
 		foreach ( $fields as $key => $field ) {
82
-			if( 'password' === $field['type'] ) {
82
+			if ( 'password' === $field[ 'type' ] ) {
83 83
 
84 84
 				// The Enter Password input
85
-				if( floor( $key ) === floatval( $key ) ) {
85
+				if ( floor( $key ) === floatval( $key ) ) {
86 86
 
87
-					if( ! empty( $field['parent'] ) ) {
88
-						$field['label']      = $field['parent']->label;
89
-						$field['adminOnly']  = $field['parent']->adminOnly;
90
-						$field['adminLabel'] = $field['parent']->adminLabel;
87
+					if ( ! empty( $field[ 'parent' ] ) ) {
88
+						$field[ 'label' ]      = $field[ 'parent' ]->label;
89
+						$field[ 'adminOnly' ]  = $field[ 'parent' ]->adminOnly;
90
+						$field[ 'adminLabel' ] = $field[ 'parent' ]->adminLabel;
91 91
 						// Don't show as a child input
92
-						unset( $field['parent'] );
92
+						unset( $field[ 'parent' ] );
93 93
 					}
94 94
 
95 95
 					$fields[ $key ] = $field;
Please login to merge, or discard this patch.
plugin-and-theme-hooks/class-gravityview-plugin-hooks-elegant-themes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 	 * Prevent Divi from adding their stuff to GV pages
35 35
 	 */
36 36
 	public function add_hooks_admin_init() {
37
-		if( GravityView_Admin::is_admin_page() ) {
37
+		if ( GravityView_Admin::is_admin_page() ) {
38 38
 			// Prevent Divi from adding import/export modal dialog
39 39
 			remove_action( 'admin_init', 'et_pb_register_builder_portabilities' );
40 40
 
Please login to merge, or discard this patch.
includes/class-oembed.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	static function getInstance() {
44 44
 
45
-		if( empty( self::$instance ) ) {
45
+		if ( empty( self::$instance ) ) {
46 46
 			self::$instance = new self;
47 47
 
48 48
 			self::$instance->initialize();
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		// Catch either
95 95
 		$match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})";
96 96
 
97
-		return '#'.$match_regex.'#i';
97
+		return '#' . $match_regex . '#i';
98 98
 	}
99 99
 
100 100
 	/**
@@ -113,18 +113,18 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$post_id = url_to_postid( $url );
115 115
 
116
-		if( empty( $post_id ) ) {
116
+		if ( empty( $post_id ) ) {
117 117
 
118 118
 			$args = array(
119 119
 				'post_status' => 'publish',
120 120
 				'name' => $slug,
121
-				'post_type' => array('any', 'gravityview'),
121
+				'post_type' => array( 'any', 'gravityview' ),
122 122
 			);
123 123
 
124 124
 			$posts = get_posts( $args );
125 125
 
126
-			if( !empty( $posts ) ) {
127
-				$post_id = $posts[0]->ID;
126
+			if ( ! empty( $posts ) ) {
127
+				$post_id = $posts[ 0 ]->ID;
128 128
 			}
129 129
 		}
130 130
 
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	public function render_handler( $matches, $attr, $url, $rawattr ) {
158 158
 
159 159
 		// If not using permalinks, re-assign values for matching groups
160
-		if( !empty( $matches['entry_slug2'] ) ) {
161
-			$matches['is_cpt'] = $matches['is_cpt2'];
162
-			$matches['slug'] = $matches['slug2'];
163
-			$matches['entry_slug'] = $matches['entry_slug2'];
164
-			unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] );
160
+		if ( ! empty( $matches[ 'entry_slug2' ] ) ) {
161
+			$matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ];
162
+			$matches[ 'slug' ] = $matches[ 'slug2' ];
163
+			$matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ];
164
+			unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] );
165 165
 		}
166 166
 
167 167
 		// No Entry was found
168
-		if( empty( $matches['entry_slug'] ) ) {
168
+		if ( empty( $matches[ 'entry_slug' ] ) ) {
169 169
 
170
-			do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches );
170
+			do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches );
171 171
 
172 172
 			return '';
173 173
 		}
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 		// Setup the data used
178 178
 		$this->set_vars( $matches, $attr, $url, $rawattr );
179 179
 
180
-		if( is_admin() && !$this->is_full_oembed_preview ) {
180
+		if ( is_admin() && ! $this->is_full_oembed_preview ) {
181 181
 			$return = $this->render_admin( $matches, $attr, $url, $rawattr );
182 182
 		} else {
183 183
 
184
-			if( $this->is_full_oembed_preview ) {
184
+			if ( $this->is_full_oembed_preview ) {
185 185
 				$return .= $this->generate_preview_notice();
186 186
 			}
187 187
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	private function generate_preview_notice() {
201 201
 		$floaty = GravityView_Admin::get_floaty();
202 202
 		$title = esc_html__( 'This will look better when it is embedded.', 'gravityview' );
203
-		$message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview');
204
-		return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>';
203
+		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' );
204
+		return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>';
205 205
 	}
206 206
 
207 207
 	/**
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	private function set_vars( $matches, $attr, $url, $rawattr ) {
216 216
 
217
-		$this->entry_id = $matches['entry_slug'];
217
+		$this->entry_id = $matches[ 'entry_slug' ];
218 218
 
219
-		$post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] );
219
+		$post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] );
220 220
 
221 221
 		// The URL didn't have the View Custom Post Type structure.
222
-		if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) {
222
+		if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) {
223 223
 
224
-			do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches );
224
+			do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches );
225 225
 
226 226
 			$this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id );
227 227
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		}
233 233
 
234 234
 		// The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that.
235
-		$this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) );
235
+		$this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) );
236 236
 	}
237 237
 
238 238
 	/**
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 		// Floaty the astronaut
251 251
 		$image = GravityView_Admin::get_floaty();
252 252
 
253
-		$embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id );
253
+		$embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id );
254 254
 
255
-		$embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id );
255
+		$embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id );
256 256
 
257 257
 		return '
258 258
 		<div class="loading-placeholder" style="background-color:#e6f0f5;">
259
-			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3>
259
+			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3>
260 260
 			<p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">
261
-				'.$embed_text.'
261
+				'.$embed_text . '
262 262
 			</p>
263 263
 			<br style="clear: both;">
264 264
 		</div>';
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	private function render_frontend( $matches, $attr, $url, $rawattr ) {
314 314
 
315 315
 		// If it's already been parsed, don't re-output it.
316
-		if( !empty( $this->output[ $this->entry_id ] ) ) {
316
+		if ( ! empty( $this->output[ $this->entry_id ] ) ) {
317 317
 			return $this->output[ $this->entry_id ];
318 318
 		}
319 319
 
320 320
 		$entry_output = $this->generate_entry_output();
321 321
 
322 322
 		// Wrap a container div around the output to allow for custom styling
323
-		$output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output );
323
+		$output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output );
324 324
 
325 325
 		/**
326 326
 		 * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		 *  @var string $url The original URL that was matched by the regex. \n
334 334
 		 *  @var array $rawattr The original unmodified attributes.
335 335
 		 */
336
-		$output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) );
336
+		$output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) );
337 337
 
338 338
 		unset( $entry_output );
339 339
 
Please login to merge, or discard this patch.
includes/class-admin-views.php 1 patch
Spacing   +172 added lines, -172 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,63 +449,63 @@  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
 
@@ -515,9 +515,9 @@  discard block
 block discarded – undo
515 515
 		 * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false.
516 516
 		 * @since 1.17.2
517 517
 		 */
518
-		do_action('gravityview_view_saved', $post_id, $statii );
518
+		do_action( 'gravityview_view_saved', $post_id, $statii );
519 519
 
520
-		do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) );
520
+		do_action( 'gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) );
521 521
 	}
522 522
 
523 523
 	/**
@@ -549,20 +549,20 @@  discard block
 block discarded – undo
549 549
 
550 550
 		$output = '';
551 551
 
552
-		if( !empty( $fields ) ) {
552
+		if ( ! empty( $fields ) ) {
553 553
 
554
-			foreach( $fields as $id => $details ) {
554
+			foreach ( $fields as $id => $details ) {
555 555
 
556
-				if( in_array( $details['type'], $blacklist_field_types ) ) {
556
+				if ( in_array( $details[ 'type' ], $blacklist_field_types ) ) {
557 557
 					continue;
558 558
 				}
559 559
 
560 560
 				// Edit mode only allows editing the parent fields, not single inputs.
561
-				if( $context === 'edit' && !empty( $details['parent'] ) ) {
561
+				if ( $context === 'edit' && ! empty( $details[ 'parent' ] ) ) {
562 562
 					continue;
563 563
 				}
564 564
 
565
-				$output .= new GravityView_Admin_View_Field( $details['label'], $id, $details );
565
+				$output .= new GravityView_Admin_View_Field( $details[ 'label' ], $id, $details );
566 566
 
567 567
 			} // End foreach
568 568
 		}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 		echo $output;
571 571
 
572 572
 		// For the EDIT view we only want to allow the form fields.
573
-		if( $context === 'edit' ) {
573
+		if ( $context === 'edit' ) {
574 574
 			return;
575 575
 		}
576 576
 
@@ -594,16 +594,16 @@  discard block
 block discarded – undo
594 594
 		$additional_fields = apply_filters( 'gravityview_additional_fields', array(
595 595
 			array(
596 596
 				'label_text' => __( '+ Add All Fields', 'gravityview' ),
597
-				'desc' => __('Add all the available fields at once.', 'gravityview'),
597
+				'desc' => __( 'Add all the available fields at once.', 'gravityview' ),
598 598
 				'field_id' => 'all-fields',
599 599
 				'label_type' => 'field',
600 600
 				'input_type' => NULL,
601 601
 				'field_options' => NULL,
602 602
 				'settings_html'	=> NULL,
603 603
 			)
604
-		));
604
+		) );
605 605
 
606
-		if( !empty( $additional_fields )) {
606
+		if ( ! empty( $additional_fields ) ) {
607 607
 			foreach ( (array)$additional_fields as $item ) {
608 608
 
609 609
 				// Prevent items from not having index set
@@ -614,16 +614,16 @@  discard block
 block discarded – undo
614 614
 					'input_type' => NULL,
615 615
 					'field_options' => NULL,
616 616
 					'settings_html'	=> NULL,
617
-				));
617
+				) );
618 618
 
619 619
 				// Backward compat.
620
-				if( !empty( $item['field_options'] ) ) {
620
+				if ( ! empty( $item[ 'field_options' ] ) ) {
621 621
 					// Use settings_html from now on.
622
-					$item['settings_html'] = $item['field_options'];
622
+					$item[ 'settings_html' ] = $item[ 'field_options' ];
623 623
 				}
624 624
 
625 625
 				// Render a label for each of them
626
-				echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item );
626
+				echo new GravityView_Admin_View_Field( $item[ 'label_text' ], $item[ 'field_id' ], $item );
627 627
 
628 628
 			}
629 629
 		}
@@ -636,63 +636,63 @@  discard block
 block discarded – undo
636 636
 	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
637 637
 	 * @return array
638 638
 	 */
639
-	function get_entry_default_fields($form, $zone) {
639
+	function get_entry_default_fields( $form, $zone ) {
640 640
 
641 641
 		$entry_default_fields = array();
642 642
 
643
-		if( in_array( $zone, array( 'directory', 'single' ) ) ) {
643
+		if ( in_array( $zone, array( 'directory', 'single' ) ) ) {
644 644
 
645 645
 			$entry_default_fields = array(
646 646
 				'id' => array(
647
-					'label' => __('Entry ID', 'gravityview'),
647
+					'label' => __( 'Entry ID', 'gravityview' ),
648 648
 					'type' => 'id',
649
-					'desc'	=> __('The unique ID of the entry.', 'gravityview'),
649
+					'desc'	=> __( 'The unique ID of the entry.', 'gravityview' ),
650 650
 				),
651 651
 				'date_created' => array(
652
-					'label' => __('Entry Date', 'gravityview'),
653
-					'desc'	=> __('The date the entry was created.', 'gravityview'),
652
+					'label' => __( 'Entry Date', 'gravityview' ),
653
+					'desc'	=> __( 'The date the entry was created.', 'gravityview' ),
654 654
 					'type' => 'date_created',
655 655
 				),
656 656
 				'source_url' => array(
657
-					'label' => __('Source URL', 'gravityview'),
657
+					'label' => __( 'Source URL', 'gravityview' ),
658 658
 					'type' => 'source_url',
659
-					'desc'	=> __('The URL of the page where the form was submitted.', 'gravityview'),
659
+					'desc'	=> __( 'The URL of the page where the form was submitted.', 'gravityview' ),
660 660
 				),
661 661
 				'ip' => array(
662
-					'label' => __('User IP', 'gravityview'),
662
+					'label' => __( 'User IP', 'gravityview' ),
663 663
 					'type' => 'ip',
664
-					'desc'	=> __('The IP Address of the user who created the entry.', 'gravityview'),
664
+					'desc'	=> __( 'The IP Address of the user who created the entry.', 'gravityview' ),
665 665
 				),
666 666
 				'created_by' => array(
667
-					'label' => __('User', 'gravityview'),
667
+					'label' => __( 'User', 'gravityview' ),
668 668
 					'type' => 'created_by',
669
-					'desc'	=> __('Details of the logged-in user who created the entry (if any).', 'gravityview'),
669
+					'desc'	=> __( 'Details of the logged-in user who created the entry (if any).', 'gravityview' ),
670 670
 				),
671 671
 
672 672
 				/**
673 673
 				 * @since  1.2
674 674
 				 */
675 675
 				'custom'	=> array(
676
-					'label'	=> __('Custom Content', 'gravityview'),
676
+					'label'	=> __( 'Custom Content', 'gravityview' ),
677 677
 					'type'	=> 'custom',
678
-					'desc'	=> __('Insert custom text or HTML.', 'gravityview'),
678
+					'desc'	=> __( 'Insert custom text or HTML.', 'gravityview' ),
679 679
 				),
680 680
 
681 681
 				/**
682 682
 				 * @since 1.7.2
683 683
 				 */
684 684
 			    'other_entries' => array(
685
-				    'label'	=> __('Other Entries', 'gravityview'),
685
+				    'label'	=> __( 'Other Entries', 'gravityview' ),
686 686
 				    'type'	=> 'other_entries',
687
-				    'desc'	=> __('Display other entries created by the entry creator.', 'gravityview'),
687
+				    'desc'	=> __( 'Display other entries created by the entry creator.', 'gravityview' ),
688 688
 			    ),
689 689
 	        );
690 690
 
691
-			if( 'single' !== $zone) {
691
+			if ( 'single' !== $zone ) {
692 692
 
693
-				$entry_default_fields['entry_link'] = array(
694
-					'label' => __('Link to Entry', 'gravityview'),
695
-					'desc'	=> __('A dedicated link to the single entry with customizable text.', 'gravityview'),
693
+				$entry_default_fields[ 'entry_link' ] = array(
694
+					'label' => __( 'Link to Entry', 'gravityview' ),
695
+					'desc'	=> __( 'A dedicated link to the single entry with customizable text.', 'gravityview' ),
696 696
 					'type' => 'entry_link',
697 697
 				);
698 698
 			}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		 * @param  string|array $form form_ID or form object
707 707
 		 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
708 708
 		 */
709
-		return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone);
709
+		return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone );
710 710
 	}
711 711
 
712 712
 	/**
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 	 */
718 718
 	function get_available_fields( $form = '', $zone = NULL ) {
719 719
 
720
-		if( empty( $form ) ) {
720
+		if ( empty( $form ) ) {
721 721
 			do_action( 'gravityview_log_error', '[get_available_fields] $form is empty' );
722 722
 			return array();
723 723
 		}
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		$fields = gravityview_get_form_fields( $form, true );
727 727
 
728 728
 		// get meta fields ( only if form was already created )
729
-		if( !is_array( $form ) ) {
729
+		if ( ! is_array( $form ) ) {
730 730
 			$meta_fields = gravityview_get_entry_meta( $form );
731 731
 		} else {
732 732
 			$meta_fields = array();
@@ -750,11 +750,11 @@  discard block
 block discarded – undo
750 750
 
751 751
 		$widgets = $this->get_registered_widgets();
752 752
 
753
-		if( !empty( $widgets ) ) {
753
+		if ( ! empty( $widgets ) ) {
754 754
 
755
-			foreach( $widgets as $id => $details ) {
755
+			foreach ( $widgets as $id => $details ) {
756 756
 
757
-				echo new GravityView_Admin_View_Widget( $details['label'], $id, $details );
757
+				echo new GravityView_Admin_View_Widget( $details[ 'label' ], $id, $details );
758 758
 
759 759
 			}
760 760
 		}
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	function render_active_areas( $template_id, $type, $zone, $rows, $values ) {
789 789
 		global $post;
790 790
 
791
-		if( $type === 'widget' ) {
791
+		if ( $type === 'widget' ) {
792 792
 			$button_label = __( 'Add Widget', 'gravityview' );
793 793
 		} else {
794 794
 			$button_label = __( 'Add Field', 'gravityview' );
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 		$available_items = array();
798 798
 
799 799
 		// if saved values, get available fields to label everyone
800
-		if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) {
800
+		if ( ! empty( $values ) && ( ! empty( $post->ID ) || ! empty( $_POST[ 'template_id' ] ) ) ) {
801 801
 
802
-			if( !empty( $_POST['template_id'] ) ) {
803
-				$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
802
+			if ( ! empty( $_POST[ 'template_id' ] ) ) {
803
+				$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
804 804
 			} else {
805 805
 				$form = gravityview_get_form_id( $post->ID );
806 806
 			}
807 807
 
808
-			if( 'field' === $type ) {
808
+			if ( 'field' === $type ) {
809 809
 				$available_items = $this->get_available_fields( $form, $zone );
810 810
 			} else {
811 811
 				$available_items = $this->get_registered_widgets();
@@ -813,39 +813,39 @@  discard block
 block discarded – undo
813 813
 
814 814
 		}
815 815
 
816
-		foreach( $rows as $row ) :
817
-			foreach( $row as $col => $areas ) :
818
-				$column = ($col == '2-2') ? '1-2' : $col; ?>
816
+		foreach ( $rows as $row ) :
817
+			foreach ( $row as $col => $areas ) :
818
+				$column = ( $col == '2-2' ) ? '1-2' : $col; ?>
819 819
 
820 820
 				<div class="gv-grid-col-<?php echo esc_attr( $column ); ?>">
821 821
 
822
-					<?php foreach( $areas as $area ) : 	?>
822
+					<?php foreach ( $areas as $area ) : 	?>
823 823
 
824 824
 						<div class="gv-droppable-area">
825
-							<div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>">
825
+							<div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>">
826 826
 
827 827
 								<?php // render saved fields
828 828
 
829
-								if( !empty( $values[ $zone .'_'. $area['areaid'] ] ) ) {
829
+								if ( ! empty( $values[ $zone . '_' . $area[ 'areaid' ] ] ) ) {
830 830
 
831
-									foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) {
831
+									foreach ( $values[ $zone . '_' . $area[ 'areaid' ] ] as $uniqid => $field ) {
832 832
 
833 833
 										$input_type = NULL;
834
-										$original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ;
834
+										$original_item = isset( $available_items[ $field[ 'id' ] ] ) ? $available_items[ $field[ 'id' ] ] : false;
835 835
 
836
-										if( !$original_item ) {
836
+										if ( ! $original_item ) {
837 837
 
838
-											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 ));
838
+											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 ) );
839 839
 
840 840
 											$original_item = $field;
841 841
 										} else {
842 842
 
843
-											$input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL;
843
+											$input_type = isset( $original_item[ 'type' ] ) ? $original_item[ 'type' ] : NULL;
844 844
 
845 845
 										}
846 846
 
847 847
 										// Field options dialog box
848
-										$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 );
848
+										$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 );
849 849
 
850 850
 										$item = array(
851 851
 											'input_type' => $input_type,
@@ -854,16 +854,16 @@  discard block
 block discarded – undo
854 854
 										);
855 855
 
856 856
 										// Merge the values with the current item to pass things like widget descriptions and original field names
857
-										if( $original_item ) {
857
+										if ( $original_item ) {
858 858
 											$item = wp_parse_args( $item, $original_item );
859 859
 										}
860 860
 
861
-										switch( $type ) {
861
+										switch ( $type ) {
862 862
 											case 'widget':
863
-												echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field );
863
+												echo new GravityView_Admin_View_Widget( $item[ 'label' ], $field[ 'id' ], $item, $field );
864 864
 												break;
865 865
 											default:
866
-												echo new GravityView_Admin_View_Field( $item['label'], $field['id'], $item, $field );
866
+												echo new GravityView_Admin_View_Field( $item[ 'label' ], $field[ 'id' ], $item, $field );
867 867
 										}
868 868
 
869 869
 
@@ -873,11 +873,11 @@  discard block
 block discarded – undo
873 873
 
874 874
 								} // End if zone is not empty ?>
875 875
 
876
-								<span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span>
876
+								<span class="drop-message"><?php echo sprintf( esc_attr__( '"+ %s" or drag existing %ss here.', 'gravityview' ), $button_label, $type ); ?></span>
877 877
 							</div>
878 878
 							<div class="gv-droppable-area-action">
879
-								<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>
880
-								<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>
879
+								<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>
880
+								<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>
881 881
 							</div>
882 882
 						</div>
883 883
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
900 900
 
901 901
 		$widgets = array();
902
-		if( !empty( $post_id ) ) {
902
+		if ( ! empty( $post_id ) ) {
903 903
 			$widgets = get_post_meta( $post_id, '_gravityview_directory_widgets', true );
904 904
 
905 905
 		}
@@ -930,19 +930,19 @@  discard block
 block discarded – undo
930 930
 	 */
931 931
 	function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) {
932 932
 
933
-		if( empty( $template_id ) ) {
933
+		if ( empty( $template_id ) ) {
934 934
 			do_action( 'gravityview_log_debug', '[render_directory_active_areas] $template_id is empty' );
935 935
 			return;
936 936
 		}
937 937
 
938 938
 		$template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context );
939 939
 
940
-		if( empty( $template_areas ) ) {
940
+		if ( empty( $template_areas ) ) {
941 941
 
942 942
 			do_action( 'gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id );
943 943
 			$output = '<div>';
944
-			$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>';
945
-			$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>';
944
+			$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>';
945
+			$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>';
946 946
 			$output .= '</div>';
947 947
 		} else {
948 948
 
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 
958 958
 		}
959 959
 
960
-		if( $echo ) {
960
+		if ( $echo ) {
961 961
 			echo $output;
962 962
 		}
963 963
 
@@ -977,25 +977,25 @@  discard block
 block discarded – undo
977 977
 		$is_widgets_page = ( $pagenow === 'widgets.php' );
978 978
 
979 979
 		// Add the GV font (with the Astronaut)
980
-		wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version );
980
+		wp_enqueue_style( 'gravityview_global', plugins_url( 'assets/css/admin-global.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
981 981
 
982
-		wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true );
982
+		wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
983 983
 
984 984
 		// Don't process any scripts below here if it's not a GravityView page.
985
-		if( !gravityview_is_admin_page($hook) && !$is_widgets_page ) { return; }
985
+		if ( ! gravityview_is_admin_page( $hook ) && ! $is_widgets_page ) { return; }
986 986
 
987 987
 		// Only enqueue the following on single pages
988
-		if( gravityview_is_admin_page($hook, 'single') || $is_widgets_page ) {
988
+		if ( gravityview_is_admin_page( $hook, 'single' ) || $is_widgets_page ) {
989 989
 
990 990
 			wp_enqueue_script( 'jquery-ui-datepicker' );
991
-			wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version );
991
+			wp_enqueue_style( 'gravityview_views_datepicker', plugins_url( 'assets/css/admin-datepicker.css', GRAVITYVIEW_FILE ), GravityView_Plugin::version );
992 992
 
993
-			$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
993
+			$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
994 994
 
995 995
 			//enqueue scripts
996 996
 			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 );
997 997
 
998
-			wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
998
+			wp_localize_script( 'gravityview_views_scripts', 'gvGlobals', array(
999 999
 				'cookiepath' => COOKIEPATH,
1000 1000
 				'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
1001 1001
 				'label_viewname' => __( 'Enter View name here', 'gravityview' ),
@@ -1008,9 +1008,9 @@  discard block
 block discarded – undo
1008 1008
 				'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1009 1009
 				'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1010 1010
 				'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' ),
1011
-			));
1011
+			) );
1012 1012
 
1013
-			wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version );
1013
+			wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version );
1014 1014
 
1015 1015
 			self::enqueue_gravity_forms_scripts();
1016 1016
 
@@ -1029,10 +1029,10 @@  discard block
 block discarded – undo
1029 1029
 		);
1030 1030
 
1031 1031
 		if ( wp_is_mobile() ) {
1032
-				    $scripts[] = 'jquery-touch-punch';
1032
+				    $scripts[ ] = 'jquery-touch-punch';
1033 1033
 		}
1034 1034
 
1035
-		foreach ($scripts as $script) {
1035
+		foreach ( $scripts as $script ) {
1036 1036
 			wp_enqueue_script( $script );
1037 1037
 		}
1038 1038
 	}
@@ -1041,11 +1041,11 @@  discard block
 block discarded – undo
1041 1041
 
1042 1042
 		$filter = current_filter();
1043 1043
 
1044
-		if( preg_match('/script/ism', $filter ) ) {
1044
+		if ( preg_match( '/script/ism', $filter ) ) {
1045 1045
 			$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',
1046 1046
 			'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete' );
1047 1047
 			$registered = array_merge( $registered, $allow_scripts );
1048
-		} elseif( preg_match('/style/ism', $filter ) ) {
1048
+		} elseif ( preg_match( '/style/ism', $filter ) ) {
1049 1049
 			$allow_styles = array( 'dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker' );
1050 1050
 			$registered = array_merge( $registered, $allow_styles );
1051 1051
 		}
Please login to merge, or discard this patch.
includes/class-admin-approve-entries.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -43,25 +43,25 @@  discard block
 block discarded – undo
43 43
 		/** gf_entries page - entries table screen */
44 44
 
45 45
 		// capture bulk actions
46
-		add_action( 'gform_loaded', array( $this, 'process_bulk_action') );
46
+		add_action( 'gform_loaded', array( $this, 'process_bulk_action' ) );
47 47
 
48 48
 		// add hidden field with approve status
49 49
 		add_action( 'gform_entries_first_column_actions', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 );
50 50
 
51 51
 		// process ajax approve entry requests
52
-		add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved'));
52
+		add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) );
53 53
 
54 54
 		// when using the User opt-in field, check on entry submission
55 55
 		add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 );
56 56
 
57 57
 		// in case entry is edited (on admin or frontend)
58
-		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2);
58
+		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 );
59 59
 
60 60
 
61 61
 		add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
62 62
 
63 63
 		// adding styles and scripts
64
-		add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') );
64
+		add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) );
65 65
 		// bypass Gravity Forms no-conflict mode
66 66
 		add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) );
67 67
 		add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) );
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		 * @param bool $show_filter_links True: show the "approved"/"disapproved" filter links. False: hide them.
91 91
 		 * @param array $form GF Form object of current form
92 92
 		 */
93
-		if( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) {
93
+		if ( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) {
94 94
 			return $filter_links;
95 95
 		}
96 96
 
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 		$approved_count = $disapproved_count = 0;
112 112
 
113 113
 		// Only count if necessary
114
-		if( $include_counts ) {
115
-			$approved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) );
116
-			$disapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) );
114
+		if ( $include_counts ) {
115
+			$approved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) );
116
+			$disapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) );
117 117
 		}
118 118
 
119
-		$filter_links[] = array(
119
+		$filter_links[ ] = array(
120 120
 			'id'            => 'gv_approved',
121 121
 			'field_filters' => $field_filters_approved,
122 122
 			'count'         => $approved_count,
123 123
 			'label'         => esc_html__( 'Approved', 'gravityview' ),
124 124
 		);
125 125
 
126
-		$filter_links[] = array(
126
+		$filter_links[ ] = array(
127 127
 			'id'            => 'gv_disapproved',
128 128
 			'field_filters' => $field_filters_disapproved,
129 129
 			'count'         => $disapproved_count,
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	function tooltips( $tooltips ) {
144 144
 
145
-		$tooltips['form_gravityview_fields'] = array(
146
-			'title' => __('GravityView Fields', 'gravityview'),
147
-			'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'),
145
+		$tooltips[ 'form_gravityview_fields' ] = array(
146
+			'title' => __( 'GravityView Fields', 'gravityview' ),
147
+			'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ),
148 148
 		);
149 149
 
150 150
 		return $tooltips;
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$gv_bulk_action = false;
257 257
 
258
-		if( version_compare( GFForms::$version, '2.0', '>=' ) ) {
259
-			$bulk_action = ( '-1' !== rgpost('action') ) ? rgpost('action') : rgpost('action2');
258
+		if ( version_compare( GFForms::$version, '2.0', '>=' ) ) {
259
+			$bulk_action = ( '-1' !== rgpost( 'action' ) ) ? rgpost( 'action' ) : rgpost( 'action2' );
260 260
 		} else {
261 261
 			// GF 1.9.x - Bulk action 2 is the bottom bulk action select form.
262
-			$bulk_action = rgpost('bulk_action') ? rgpost('bulk_action') : rgpost('bulk_action2');
262
+			$bulk_action = rgpost( 'bulk_action' ) ? rgpost( 'bulk_action' ) : rgpost( 'bulk_action2' );
263 263
 		}
264 264
 
265 265
 		// Check the $bulk_action value against GV actions, see if they're the same. I hate strpos().
266
-		if( ! empty( $bulk_action ) && preg_match( '/^('. implode( '|', $this->bulk_action_prefixes ) .')/ism', $bulk_action ) ) {
266
+		if ( ! empty( $bulk_action ) && preg_match( '/^(' . implode( '|', $this->bulk_action_prefixes ) . ')/ism', $bulk_action ) ) {
267 267
 			$gv_bulk_action = $bulk_action;
268 268
 		}
269 269
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		
289 289
 		// gforms_entry_list is the nonce that confirms we're on the right page
290 290
 		// gforms_update_note is sent when bulk editing entry notes. We don't want to process then.
291
-		if ( $bulk_action && rgpost('gforms_entry_list') && empty( $_POST['gforms_update_note'] ) ) {
291
+		if ( $bulk_action && rgpost( 'gforms_entry_list' ) && empty( $_POST[ 'gforms_update_note' ] ) ) {
292 292
 
293 293
 			check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' );
294 294
 
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 			}
307 307
 
308 308
 			// All entries are set to be updated, not just the visible ones
309
-			if ( ! empty( $_POST['all_entries'] ) ) {
309
+			if ( ! empty( $_POST[ 'all_entries' ] ) ) {
310 310
 
311 311
 				// Convert the current entry search into GF-formatted search criteria
312 312
 				$search = array(
313
-					'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0,
314
-					'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '',
315
-					'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains',
313
+					'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0,
314
+					'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '',
315
+					'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains',
316 316
 				);
317 317
 
318 318
 				$search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id );
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			} else {
324 324
 
325 325
 				// Changed from 'lead' to 'entry' in 2.0
326
-				$entries = isset( $_POST['lead'] ) ? $_POST['lead'] : $_POST['entry'];
326
+				$entries = isset( $_POST[ 'lead' ] ) ? $_POST[ 'lead' ] : $_POST[ 'entry' ];
327 327
 
328 328
 			}
329 329
 
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
 			$entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' );
336 336
 
337 337
 			switch ( $approved_status ) {
338
-				case $this->bulk_action_prefixes['approve']:
338
+				case $this->bulk_action_prefixes[ 'approve' ]:
339 339
 					self::update_bulk( $entries, 1, $form_id );
340 340
 					$this->bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count );
341 341
 					break;
342 342
 
343
-				case $this->bulk_action_prefixes['unapprove']:
343
+				case $this->bulk_action_prefixes[ 'unapprove' ]:
344 344
 					self::update_bulk( $entries, 0, $form_id );
345 345
 					$this->bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count );
346 346
 					break;
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	private static function update_bulk( $entries, $approved, $form_id ) {
366 366
 
367
-		if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) {
367
+		if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) {
368 368
 			do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries );
369 369
 			return false;
370 370
 		}
371 371
 
372
-		if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
372
+		if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
373 373
 			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' );
374 374
 			return false;
375 375
 		}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		// calculate approved field id once instead of looping through in the update_approved() method
380 380
 		$approved_column_id = self::get_approved_column( $form_id );
381 381
 
382
-		foreach( $entries as $entry_id ) {
382
+		foreach ( $entries as $entry_id ) {
383 383
 			self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id );
384 384
 		}
385 385
 	}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 	 * @param int $approvedcolumn (default: 0)
399 399
 	 * @return boolean True: It worked; False: it failed
400 400
 	 */
401
-	public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) {
401
+	public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) {
402 402
 
403
-		if( !class_exists( 'GFAPI' ) ) {
403
+		if ( ! class_exists( 'GFAPI' ) ) {
404 404
 			do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' );
405 405
 			return false;
406 406
 		}
407 407
 
408
-		if( empty( $approvedcolumn ) ) {
408
+		if ( empty( $approvedcolumn ) ) {
409 409
 			$approvedcolumn = self::get_approved_column( $form_id );
410 410
 		}
411 411
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 		self::update_approved_meta( $entry_id, $approved, $form_id );
425 425
 
426 426
 		// add note to entry
427
-		if( $result === true ) {
427
+		if ( $result === true ) {
428 428
 
429 429
 			$note = empty( $approved ) ? __( 'Disapproved the Entry for GravityView', 'gravityview' ) : __( 'Approved the Entry for GravityView', 'gravityview' );
430 430
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 			 */
436 436
 			$add_note = apply_filters( 'gravityview/approve_entries/add-note', true );
437 437
 
438
-			if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
438
+			if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
439 439
 				$current_user = wp_get_current_user();
440 440
 				GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note );
441 441
 			}
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 			 */
448 448
 			do_action( 'gravityview_clear_form_cache', $form_id );
449 449
 
450
-		} else if( is_wp_error( $result ) ) {
450
+		} else if ( is_wp_error( $result ) ) {
451 451
 
452 452
 			do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) );
453 453
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @param $form array Gravity Forms form object
469 469
 	 */
470 470
 	public function after_submission( $entry, $form ) {
471
-		$this->after_update_entry_update_approved_meta( $form , $entry['id'] );
471
+		$this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] );
472 472
 	}
473 473
 
474 474
 
@@ -484,18 +484,18 @@  discard block
 block discarded – undo
484 484
 	 */
485 485
 	public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) {
486 486
 
487
-		$approvedcolumn = self::get_approved_column( $form['id'] );
487
+		$approvedcolumn = self::get_approved_column( $form[ 'id' ] );
488 488
 
489 489
         /**
490 490
          * If the form doesn't contain the approve field, don't assume anything.
491 491
          */
492
-        if( empty( $approvedcolumn ) ) {
492
+        if ( empty( $approvedcolumn ) ) {
493 493
             return;
494 494
         }
495 495
 
496 496
 		$entry = GFAPI::get_entry( $entry_id );
497 497
 
498
-		self::update_approved_meta( $entry_id, $entry[ (string)$approvedcolumn ], $form['id'] );
498
+		self::update_approved_meta( $entry_id, $entry[ (string)$approvedcolumn ], $form[ 'id' ] );
499 499
 
500 500
 	}
501 501
 
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 		$is_approved = empty( $is_approved ) ? 0 : 'Approved';
521 521
 
522 522
 		// update entry meta
523
-		if( function_exists('gform_update_meta') ) {
523
+		if ( function_exists( 'gform_update_meta' ) ) {
524 524
 
525 525
 			gform_update_meta( $entry_id, 'is_approved', $is_approved, $form_id );
526 526
 
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 			 */
533 533
 			do_action( 'gravityview/approve_entries/updated', $entry_id, $is_approved );
534 534
 
535
-			if( empty( $is_approved ) ) {
535
+			if ( empty( $is_approved ) ) {
536 536
 
537 537
 				/**
538 538
 				 * @action `gravityview/approve_entries/disapproved` Triggered when an entry is rejected
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 
555 555
 		} else {
556 556
 
557
-			do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' );
557
+			do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' );
558 558
 
559 559
 		}
560 560
 	}
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	public function ajax_update_approved() {
568 568
 
569
-		if( empty( $_POST['entry_id'] ) || empty( $_POST['form_id'] ) ) {
569
+		if ( empty( $_POST[ 'entry_id' ] ) || empty( $_POST[ 'form_id' ] ) ) {
570 570
 
571 571
 			do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST );
572 572
 
573 573
 			$result = false;
574 574
 		}
575 575
 
576
-		else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) {
576
+		else if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxgfentries' ) ) {
577 577
 
578 578
 			do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST );
579 579
 
580 580
 			$result = false;
581 581
 		}
582 582
 
583
-		else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) {
583
+		else if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST[ 'entry_id' ] ) ) {
584 584
 
585 585
 			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' );
586 586
 
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 
590 590
 		else {
591 591
 
592
-			$result = self::update_approved( $_POST['entry_id'], $_POST['approved'], $_POST['form_id'] );
592
+			$result = self::update_approved( $_POST[ 'entry_id' ], $_POST[ 'approved' ], $_POST[ 'form_id' ] );
593 593
 
594
-			if( is_wp_error( $result ) ) {
594
+			if ( is_wp_error( $result ) ) {
595 595
 				/** @var WP_Error $result */
596
-				do_action( 'gravityview_log_error', __METHOD__ .' Error updating approval: ' . $result->get_error_message() );
596
+				do_action( 'gravityview_log_error', __METHOD__ . ' Error updating approval: ' . $result->get_error_message() );
597 597
 				$result = false;
598 598
 			}
599 599
 
@@ -613,29 +613,29 @@  discard block
 block discarded – undo
613 613
 	 */
614 614
 	static public function get_approved_column( $form ) {
615 615
 
616
-        if( empty( $form ) ) {
616
+        if ( empty( $form ) ) {
617 617
             return null;
618 618
         }
619 619
 
620
-        if( !is_array( $form ) ) {
620
+        if ( ! is_array( $form ) ) {
621 621
             $form = GVCommon::get_form( $form );
622 622
         }
623 623
 
624
-		foreach( $form['fields'] as $key => $field ) {
624
+		foreach ( $form[ 'fields' ] as $key => $field ) {
625 625
 
626
-            $field = (array) $field;
626
+            $field = (array)$field;
627 627
 
628
-			if( !empty( $field['gravityview_approved'] ) ) {
629
-				if( !empty($field['inputs'][0]['id']) ) {
630
-					return $field['inputs'][0]['id'];
628
+			if ( ! empty( $field[ 'gravityview_approved' ] ) ) {
629
+				if ( ! empty( $field[ 'inputs' ][ 0 ][ 'id' ] ) ) {
630
+					return $field[ 'inputs' ][ 0 ][ 'id' ];
631 631
 				}
632 632
 			}
633 633
 
634 634
             // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work..
635
-            if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) {
636
-                foreach ( $field['inputs'] as $key2 => $input ) {
637
-                    if ( strtolower( $input['label'] ) == 'approved' ) {
638
-                        return $input['id'];
635
+            if ( 'checkbox' == $field[ 'type' ] && isset( $field[ 'inputs' ] ) && is_array( $field[ 'inputs' ] ) ) {
636
+                foreach ( $field[ 'inputs' ] as $key2 => $input ) {
637
+                    if ( strtolower( $input[ 'label' ] ) == 'approved' ) {
638
+                        return $input[ 'id' ];
639 639
                     }
640 640
                 }
641 641
             }
@@ -657,18 +657,18 @@  discard block
 block discarded – undo
657 657
 	 *
658 658
 	 * @return void
659 659
 	 */
660
-	static public function add_entry_approved_hidden_input(  $form_id, $field_id, $value, $entry, $query_string ) {
660
+	static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) {
661 661
 
662
-		if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) {
662
+		if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) {
663 663
 			return;
664 664
 		}
665 665
 
666
-		if( empty( $entry['id'] ) ) {
666
+		if ( empty( $entry[ 'id' ] ) ) {
667 667
 			return;
668 668
 		}
669 669
 
670
-		if( gform_get_meta( $entry['id'], 'is_approved' ) ) {
671
-			echo '<input type="hidden" class="entry_approved" id="entry_approved_'. $entry['id'] .'" value="true" />';
670
+		if ( gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) {
671
+			echo '<input type="hidden" class="entry_approved" id="entry_approved_' . $entry[ 'id' ] . '" value="true" />';
672 672
 		}
673 673
 	}
674 674
 
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 	 */
682 682
 	private function get_form_id() {
683 683
 
684
-		$form_id = GFForms::get('id');
684
+		$form_id = GFForms::get( 'id' );
685 685
 
686 686
 		// If there are no forms identified, use the first form. That's how GF does it.
687
-		if( empty( $form_id ) && class_exists('RGFormsModel') ) {
687
+		if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) {
688 688
 			$form_id = $this->get_first_form_id();
689 689
 		}
690 690
 
@@ -704,14 +704,14 @@  discard block
 block discarded – undo
704 704
 
705 705
 		$forms = RGFormsModel::get_forms( null, 'title' );
706 706
 
707
-		if( ! isset( $forms[0] ) ) {
707
+		if ( ! isset( $forms[ 0 ] ) ) {
708 708
 			do_action( 'gravityview_log_error', __METHOD__ . ': No forms were found' );
709 709
 			return 0;
710 710
 		}
711 711
 
712
-		$first_form = $forms[0];
712
+		$first_form = $forms[ 0 ];
713 713
 
714
-		$form_id = is_object( $forms[0] ) ? $first_form->id : $first_form['id'];
714
+		$form_id = is_object( $forms[ 0 ] ) ? $first_form->id : $first_form[ 'id' ];
715 715
 
716 716
 		return intval( $form_id );
717 717
 	}
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 
720 720
 	function add_scripts_and_styles( $hook ) {
721 721
 
722
-		if( ! class_exists( 'RGForms' ) ) {
722
+		if ( ! class_exists( 'RGForms' ) ) {
723 723
 
724 724
 			do_action( 'gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.' );
725 725
 
@@ -728,34 +728,34 @@  discard block
 block discarded – undo
728 728
 
729 729
 		// enqueue styles & scripts gf_entries
730 730
 		// But only if we're on the main Entries page, not on reports pages
731
-		if( GFForms::get_page() !== 'entry_list' ) {
731
+		if ( GFForms::get_page() !== 'entry_list' ) {
732 732
 			return;
733 733
 		}
734 734
 
735 735
 		$form_id = $this->get_form_id();
736 736
 
737 737
 		// Things are broken; no forms were found
738
-		if( empty( $form_id ) ) {
738
+		if ( empty( $form_id ) ) {
739 739
 			return;
740 740
 		}
741 741
 
742
-		wp_enqueue_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version );
742
+		wp_enqueue_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
743 743
 
744
-		$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
744
+		$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
745 745
 
746
-		wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version );
746
+		wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version );
747 747
 
748 748
 		wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array(
749
-			'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries'),
749
+			'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries' ),
750 750
 			'form_id' => $form_id,
751 751
 			'show_column' => (int)$this->show_approve_entry_column( $form_id ),
752 752
 			'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ),
753 753
 			'bulk_actions' => $this->get_bulk_actions( $form_id ),
754 754
 			'bulk_message' => $this->bulk_update_message,
755
-			'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'),
756
-			'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'),
757
-			'column_title' => __( 'Show entry in directory view?', 'gravityview'),
758
-			'column_link' => esc_url( add_query_arg( array('sort' => self::get_approved_column( $form_id ) ) ) ),
755
+			'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview' ),
756
+			'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview' ),
757
+			'column_title' => __( 'Show entry in directory view?', 'gravityview' ),
758
+			'column_link' => esc_url( add_query_arg( array( 'sort' => self::get_approved_column( $form_id ) ) ) ),
759 759
 		) );
760 760
 
761 761
 	}
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
 			'GravityView' => array(
776 776
 				array(
777 777
 					'label' => __( 'Approve', 'gravityview' ),
778
-					'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['approve'], $form_id ),
778
+					'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'approve' ], $form_id ),
779 779
 				),
780 780
 				array(
781 781
 					'label' => __( 'Disapprove', 'gravityview' ),
782
-					'value' => sprintf( '%s-%d', $this->bulk_action_prefixes['unapprove'], $form_id ),
782
+					'value' => sprintf( '%s-%d', $this->bulk_action_prefixes[ 'unapprove' ], $form_id ),
783 783
 				),
784 784
 			),
785 785
 		);
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
 		// Sanitize the values, just to be sure.
797 797
 		foreach ( $bulk_actions as $key => $group ) {
798 798
 			foreach ( $group as $i => $action ) {
799
-				$bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] );
800
-				$bulk_actions[ $key ][ $i ]['value'] = esc_attr( $bulk_actions[ $key ][ $i ]['value'] );
799
+				$bulk_actions[ $key ][ $i ][ 'label' ] = esc_html( $bulk_actions[ $key ][ $i ][ 'label' ] );
800
+				$bulk_actions[ $key ][ $i ][ 'value' ] = esc_attr( $bulk_actions[ $key ][ $i ][ 'value' ] );
801 801
 			}
802 802
 		}
803 803
 
@@ -822,13 +822,13 @@  discard block
 block discarded – undo
822 822
 		 * @since 1.7.2
823 823
 		 * @param boolean $hide_if_no_connections
824 824
 		 */
825
-		$hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false );
825
+		$hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false );
826 826
 
827
-		if( $hide_if_no_connections ) {
827
+		if ( $hide_if_no_connections ) {
828 828
 
829 829
 			$connected_views = gravityview_get_connected_views( $form_id );
830 830
 
831
-			if( empty( $connected_views ) ) {
831
+			if ( empty( $connected_views ) ) {
832 832
 				$show_approve_column = false;
833 833
 			}
834 834
 		}
@@ -838,18 +838,18 @@  discard block
 block discarded – undo
838 838
 		 * @param boolean $show_approve_column Whether the column will be shown
839 839
 		 * @param int $form_id The ID of the Gravity Forms form for which entries are being shown
840 840
 		 */
841
-		$show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id );
841
+		$show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id );
842 842
 
843 843
 		return $show_approve_column;
844 844
 	}
845 845
 
846 846
 	function register_gform_noconflict_script( $scripts ) {
847
-		$scripts[] = 'gravityview_gf_entries_scripts';
847
+		$scripts[ ] = 'gravityview_gf_entries_scripts';
848 848
 		return $scripts;
849 849
 	}
850 850
 
851 851
 	function register_gform_noconflict_style( $styles ) {
852
-		$styles[] = 'gravityview_entries_list';
852
+		$styles[ ] = 'gravityview_entries_list';
853 853
 		return $styles;
854 854
 	}
855 855
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-render.php 2 patches
Indentation   +1648 added lines, -1648 removed lines patch added patch discarded remove patch
@@ -10,21 +10,21 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Render {
18 18
 
19
-    /**
20
-     * @var GravityView_Edit_Entry
21
-     */
22
-    protected $loader;
19
+	/**
20
+	 * @var GravityView_Edit_Entry
21
+	 */
22
+	protected $loader;
23 23
 
24 24
 	/**
25 25
 	 * @var string String used to generate unique nonce for the entry/form/view combination. Allows access to edit page.
26 26
 	 */
27
-    static $nonce_key;
27
+	static $nonce_key;
28 28
 
29 29
 	/**
30 30
 	 * @since 1.9
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	private static $supports_product_fields = false;
46 46
 
47
-    /**
48
-     * Gravity Forms entry array
49
-     *
50
-     * @var array
51
-     */
52
-    var $entry;
47
+	/**
48
+	 * Gravity Forms entry array
49
+	 *
50
+	 * @var array
51
+	 */
52
+	var $entry;
53 53
 
54 54
 	/**
55 55
 	 * Gravity Forms entry array (it won't get changed during this class lifecycle)
@@ -58,135 +58,135 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	private static $original_entry = array();
60 60
 
61
-    /**
62
-     * Gravity Forms form array (GravityView modifies the content through this class lifecycle)
63
-     *
64
-     * @var array
65
-     */
66
-    var $form;
67
-
68
-    /**
69
-     * Gravity Forms form array (it won't get changed during this class lifecycle)
70
-     * @since 1.16.2.1
71
-     * @var array
72
-     */
73
-    private static $original_form;
74
-
75
-    /**
76
-     * Gravity Forms form array after the form validation process
77
-     * @since 1.13
78
-     * @var array
79
-     */
80
-    var $form_after_validation = null;
81
-
82
-    /**
83
-     * Hold an array of GF field objects that have calculation rules
84
-     * @var array
85
-     */
86
-    var $fields_with_calculation = array();
87
-
88
-    /**
89
-     * Hold an array of GF field objects with type 'total'
90
-     * @var array
91
-     */
92
-    var $total_fields = array();
93
-
94
-    /**
95
-     * Gravity Forms form id
96
-     *
97
-     * @var int
98
-     */
99
-    var $form_id;
100
-
101
-    /**
102
-     * ID of the current view
103
-     *
104
-     * @var int
105
-     */
106
-    var $view_id;
107
-
108
-    /**
109
-     * Updated entry is valid (GF Validation object)
110
-     *
111
-     * @var array
112
-     */
113
-    var $is_valid = NULL;
114
-
115
-    function __construct( GravityView_Edit_Entry $loader ) {
116
-        $this->loader = $loader;
117
-    }
118
-
119
-    function load() {
120
-
121
-        /** @define "GRAVITYVIEW_DIR" "../../../" */
122
-        include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
123
-
124
-        // Don't display an embedded form when editing an entry
125
-        add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
126
-        add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
127
-
128
-        // Stop Gravity Forms processing what is ours!
129
-        add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
130
-
131
-        add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
132
-
133
-        add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
134
-
135
-        // Disable conditional logic if needed (since 1.9)
136
-        add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 );
137
-
138
-        // Make sure GF doesn't validate max files (since 1.9)
139
-        add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
140
-
141
-        // Add fields expected by GFFormDisplay::validate()
142
-        add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
143
-
144
-    }
145
-
146
-    /**
147
-     * Don't show any forms embedded on a page when GravityView is in Edit Entry mode
148
-     *
149
-     * Adds a `__return_empty_string` filter on the Gravity Forms shortcode on the `wp_head` action
150
-     * And then removes it on the `wp_footer` action
151
-     *
152
-     * @since 1.16.1
153
-     *
154
-     * @return void
155
-     */
156
-    function prevent_render_form() {
157
-        if( $this->is_edit_entry() ) {
158
-            if( 'wp_head' === current_filter() ) {
159
-                add_filter( 'gform_shortcode_form', '__return_empty_string' );
160
-            } else {
161
-                remove_filter( 'gform_shortcode_form', '__return_empty_string' );
162
-            }
163
-        }
164
-    }
165
-
166
-    /**
167
-     * Because we're mimicking being a front-end Gravity Forms form while using a Gravity Forms
168
-     * backend form, we need to prevent them from saving twice.
169
-     * @return void
170
-     */
171
-    function prevent_maybe_process_form() {
172
-
173
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
174
-
175
-        if( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
176
-            remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
177
-        }
178
-    }
179
-
180
-    /**
181
-     * Is the current page an Edit Entry page?
182
-     * @return boolean
183
-     */
184
-    public function is_edit_entry() {
185
-
186
-        $gf_page = function_exists('rgpost') && ( 'entry' === rgget( 'view' ) && isset( $_GET['edit'] ) || rgpost( 'action' ) === 'update' );
187
-
188
-        return $gf_page;
189
-    }
61
+	/**
62
+	 * Gravity Forms form array (GravityView modifies the content through this class lifecycle)
63
+	 *
64
+	 * @var array
65
+	 */
66
+	var $form;
67
+
68
+	/**
69
+	 * Gravity Forms form array (it won't get changed during this class lifecycle)
70
+	 * @since 1.16.2.1
71
+	 * @var array
72
+	 */
73
+	private static $original_form;
74
+
75
+	/**
76
+	 * Gravity Forms form array after the form validation process
77
+	 * @since 1.13
78
+	 * @var array
79
+	 */
80
+	var $form_after_validation = null;
81
+
82
+	/**
83
+	 * Hold an array of GF field objects that have calculation rules
84
+	 * @var array
85
+	 */
86
+	var $fields_with_calculation = array();
87
+
88
+	/**
89
+	 * Hold an array of GF field objects with type 'total'
90
+	 * @var array
91
+	 */
92
+	var $total_fields = array();
93
+
94
+	/**
95
+	 * Gravity Forms form id
96
+	 *
97
+	 * @var int
98
+	 */
99
+	var $form_id;
100
+
101
+	/**
102
+	 * ID of the current view
103
+	 *
104
+	 * @var int
105
+	 */
106
+	var $view_id;
107
+
108
+	/**
109
+	 * Updated entry is valid (GF Validation object)
110
+	 *
111
+	 * @var array
112
+	 */
113
+	var $is_valid = NULL;
114
+
115
+	function __construct( GravityView_Edit_Entry $loader ) {
116
+		$this->loader = $loader;
117
+	}
118
+
119
+	function load() {
120
+
121
+		/** @define "GRAVITYVIEW_DIR" "../../../" */
122
+		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
123
+
124
+		// Don't display an embedded form when editing an entry
125
+		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
126
+		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
127
+
128
+		// Stop Gravity Forms processing what is ours!
129
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
130
+
131
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
132
+
133
+		add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
134
+
135
+		// Disable conditional logic if needed (since 1.9)
136
+		add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 );
137
+
138
+		// Make sure GF doesn't validate max files (since 1.9)
139
+		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
140
+
141
+		// Add fields expected by GFFormDisplay::validate()
142
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
143
+
144
+	}
145
+
146
+	/**
147
+	 * Don't show any forms embedded on a page when GravityView is in Edit Entry mode
148
+	 *
149
+	 * Adds a `__return_empty_string` filter on the Gravity Forms shortcode on the `wp_head` action
150
+	 * And then removes it on the `wp_footer` action
151
+	 *
152
+	 * @since 1.16.1
153
+	 *
154
+	 * @return void
155
+	 */
156
+	function prevent_render_form() {
157
+		if( $this->is_edit_entry() ) {
158
+			if( 'wp_head' === current_filter() ) {
159
+				add_filter( 'gform_shortcode_form', '__return_empty_string' );
160
+			} else {
161
+				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
162
+			}
163
+		}
164
+	}
165
+
166
+	/**
167
+	 * Because we're mimicking being a front-end Gravity Forms form while using a Gravity Forms
168
+	 * backend form, we need to prevent them from saving twice.
169
+	 * @return void
170
+	 */
171
+	function prevent_maybe_process_form() {
172
+
173
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
174
+
175
+		if( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
176
+			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
177
+		}
178
+	}
179
+
180
+	/**
181
+	 * Is the current page an Edit Entry page?
182
+	 * @return boolean
183
+	 */
184
+	public function is_edit_entry() {
185
+
186
+		$gf_page = function_exists('rgpost') && ( 'entry' === rgget( 'view' ) && isset( $_GET['edit'] ) || rgpost( 'action' ) === 'update' );
187
+
188
+		return $gf_page;
189
+	}
190 190
 
191 191
 	/**
192 192
 	 * Is the current page an Edit Entry page?
@@ -197,578 +197,578 @@  discard block
 block discarded – undo
197 197
 		return !empty( $_POST[ self::$nonce_field ] );
198 198
 	}
199 199
 
200
-    /**
201
-     * When Edit entry view is requested setup the vars
202
-     */
203
-    function setup_vars() {
204
-        $gravityview_view = GravityView_View::getInstance();
200
+	/**
201
+	 * When Edit entry view is requested setup the vars
202
+	 */
203
+	function setup_vars() {
204
+		$gravityview_view = GravityView_View::getInstance();
205
+
205 206
 
207
+		$entries = $gravityview_view->getEntries();
208
+		self::$original_entry = $entries[0];
209
+		$this->entry = $entries[0];
206 210
 
207
-        $entries = $gravityview_view->getEntries();
208
-	    self::$original_entry = $entries[0];
209
-	    $this->entry = $entries[0];
211
+		self::$original_form = $gravityview_view->getForm();
212
+		$this->form = $gravityview_view->getForm();
213
+		$this->form_id = $gravityview_view->getFormId();
214
+		$this->view_id = $gravityview_view->getViewId();
210 215
 
211
-        self::$original_form = $gravityview_view->getForm();
212
-        $this->form = $gravityview_view->getForm();
213
-        $this->form_id = $gravityview_view->getFormId();
214
-        $this->view_id = $gravityview_view->getViewId();
216
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
217
+	}
215 218
 
216
-        self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
217
-    }
218 219
 
220
+	/**
221
+	 * Load required files and trigger edit flow
222
+	 *
223
+	 * Run when the is_edit_entry returns true.
224
+	 *
225
+	 * @param GravityView_View_Data $gv_data GravityView Data object
226
+	 * @return void
227
+	 */
228
+	function init( $gv_data ) {
219 229
 
220
-    /**
221
-     * Load required files and trigger edit flow
222
-     *
223
-     * Run when the is_edit_entry returns true.
224
-     *
225
-     * @param GravityView_View_Data $gv_data GravityView Data object
226
-     * @return void
227
-     */
228
-    function init( $gv_data ) {
230
+		require_once( GFCommon::get_base_path() . '/form_display.php' );
231
+		require_once( GFCommon::get_base_path() . '/entry_detail.php' );
229 232
 
230
-        require_once( GFCommon::get_base_path() . '/form_display.php' );
231
-        require_once( GFCommon::get_base_path() . '/entry_detail.php' );
233
+		$this->setup_vars();
232 234
 
233
-        $this->setup_vars();
235
+		// Multiple Views embedded, don't proceed if nonce fails
236
+		if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) {
237
+			return;
238
+		}
234 239
 
235
-        // Multiple Views embedded, don't proceed if nonce fails
236
-        if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) {
237
-            return;
238
-        }
240
+		// Sorry, you're not allowed here.
241
+		if( false === $this->user_can_edit_entry( true ) ) {
242
+			return;
243
+		}
239 244
 
240
-        // Sorry, you're not allowed here.
241
-        if( false === $this->user_can_edit_entry( true ) ) {
242
-            return;
243
-        }
245
+		$this->print_scripts();
244 246
 
245
-        $this->print_scripts();
247
+		$this->process_save();
246 248
 
247
-        $this->process_save();
249
+		$this->edit_entry_form();
248 250
 
249
-        $this->edit_entry_form();
251
+	}
250 252
 
251
-    }
252 253
 
254
+	/**
255
+	 * Force Gravity Forms to output scripts as if it were in the admin
256
+	 * @return void
257
+	 */
258
+	function print_scripts() {
259
+		$gravityview_view = GravityView_View::getInstance();
253 260
 
254
-    /**
255
-     * Force Gravity Forms to output scripts as if it were in the admin
256
-     * @return void
257
-     */
258
-    function print_scripts() {
259
-        $gravityview_view = GravityView_View::getInstance();
261
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
260 262
 
261
-        wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
263
+		GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
262 264
 
263
-        GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
265
+		// Sack is required for images
266
+		wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );
267
+	}
264 268
 
265
-        // Sack is required for images
266
-        wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );
267
-    }
268 269
 
270
+	/**
271
+	 * Process edit entry form save
272
+	 */
273
+	function process_save() {
269 274
 
270
-    /**
271
-     * Process edit entry form save
272
-     */
273
-    function process_save() {
275
+		if( empty( $_POST ) ) {
276
+			return;
277
+		}
274 278
 
275
-        if( empty( $_POST ) ) {
276
-            return;
277
-        }
279
+		// Make sure the entry, view, and form IDs are all correct
280
+		$valid = $this->verify_nonce();
278 281
 
279
-        // Make sure the entry, view, and form IDs are all correct
280
-        $valid = $this->verify_nonce();
282
+		if( !$valid ) {
283
+			do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
284
+			return;
285
+		}
281 286
 
282
-        if( !$valid ) {
283
-            do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
284
-            return;
285
-        }
287
+		if( $this->entry['id'] !== $_POST['lid'] ) {
288
+			do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
289
+			return;
290
+		}
286 291
 
287
-        if( $this->entry['id'] !== $_POST['lid'] ) {
288
-            do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
289
-            return;
290
-        }
292
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
291 293
 
292
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
294
+		$this->process_save_process_files( $this->form_id );
293 295
 
294
-        $this->process_save_process_files( $this->form_id );
296
+		$this->validate();
295 297
 
296
-        $this->validate();
298
+		if( $this->is_valid ) {
297 299
 
298
-        if( $this->is_valid ) {
300
+			do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
299 301
 
300
-            do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
302
+			/**
303
+			 * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields
304
+			 */
305
+			$form = $this->form_prepare_for_save();
301 306
 
302
-            /**
303
-             * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields
304
-             */
305
-            $form = $this->form_prepare_for_save();
307
+			/**
308
+			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
309
+			 */
310
+			unset( $_GET['page'] );
306 311
 
307
-            /**
308
-             * @hack to avoid the capability validation of the method save_lead for GF 1.9+
309
-             */
310
-            unset( $_GET['page'] );
312
+			GFFormsModel::save_lead( $form, $this->entry );
311 313
 
312
-            GFFormsModel::save_lead( $form, $this->entry );
314
+			// If there's a post associated with the entry, process post fields
315
+			if( !empty( $this->entry['post_id'] ) ) {
316
+				$this->maybe_update_post_fields( $form );
317
+			}
313 318
 
314
-            // If there's a post associated with the entry, process post fields
315
-            if( !empty( $this->entry['post_id'] ) ) {
316
-                $this->maybe_update_post_fields( $form );
317
-            }
319
+			// Process calculation fields
320
+			$this->update_calculation_fields();
318 321
 
319
-            // Process calculation fields
320
-            $this->update_calculation_fields();
322
+			// Perform actions normally performed after updating a lead
323
+			$this->after_update();
321 324
 
322
-            // Perform actions normally performed after updating a lead
323
-            $this->after_update();
325
+			/**
326
+			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
327
+			 * @param array $form Gravity Forms form array
328
+			 * @param string $entry_id Numeric ID of the entry that was updated
329
+			 */
330
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );
331
+		}
324 332
 
325
-            /**
326
-             * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
327
-             * @param array $form Gravity Forms form array
328
-             * @param string $entry_id Numeric ID of the entry that was updated
329
-             */
330
-            do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );
331
-        }
333
+	} // process_save
332 334
 
333
-    } // process_save
334 335
 
336
+	/**
337
+	 * Have GF handle file uploads
338
+	 *
339
+	 * Copy of code from GFFormDisplay::process_form()
340
+	 *
341
+	 * @param int $form_id
342
+	 */
343
+	function process_save_process_files( $form_id ) {
335 344
 
336
-    /**
337
-     * Have GF handle file uploads
338
-     *
339
-     * Copy of code from GFFormDisplay::process_form()
340
-     *
341
-     * @param int $form_id
342
-     */
343
-    function process_save_process_files( $form_id ) {
345
+		//Loading files that have been uploaded to temp folder
346
+		$files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) );
347
+		if ( ! is_array( $files ) ) {
348
+			$files = array();
349
+		}
344 350
 
345
-        //Loading files that have been uploaded to temp folder
346
-        $files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) );
347
-        if ( ! is_array( $files ) ) {
348
-            $files = array();
349
-        }
351
+		RGFormsModel::$uploaded_files[ $form_id ] = $files;
352
+	}
350 353
 
351
-        RGFormsModel::$uploaded_files[ $form_id ] = $files;
352
-    }
353
-
354
-    /**
355
-     * Remove max_files validation (done on gravityforms.js) to avoid conflicts with GravityView
356
-     * Late validation done on self::custom_validation
357
-     *
358
-     * @param $plupload_init array Plupload settings
359
-     * @param $form_id
360
-     * @param $instance
361
-     * @return mixed
362
-     */
363
-    public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
364
-        if( ! $this->is_edit_entry() ) {
365
-            return $plupload_init;
366
-        }
367
-
368
-        $plupload_init['gf_vars']['max_files'] = 0;
369
-
370
-        return $plupload_init;
371
-    }
372
-
373
-
374
-    /**
375
-     * Unset adminOnly and convert field input key to string
376
-     * @return array $form
377
-     */
378
-    private function form_prepare_for_save() {
379
-
380
-        $form = $this->form;
381
-
382
-        foreach( $form['fields'] as $k => &$field ) {
383
-
384
-            // Remove the fields with calculation formulas before save to avoid conflicts with GF logic
385
-            // @since 1.16.3
386
-            if( $field->has_calculation() ) {
387
-                unset( $form['fields'][ $k ] );
388
-            }
389
-
390
-            $field->adminOnly = false;
391
-
392
-            if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
393
-                foreach( $field->inputs as $key => $input ) {
394
-                    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
395
-                }
396
-            }
397
-        }
398
-
399
-        return $form;
400
-    }
401
-
402
-    private function update_calculation_fields() {
403
-
404
-        $form = self::$original_form;
405
-        $update = false;
406
-
407
-        // get the most up to date entry values
408
-        $entry = GFAPI::get_entry( $this->entry['id'] );
409
-
410
-        if( !empty( $this->fields_with_calculation ) ) {
411
-            $update = true;
412
-            foreach ( $this->fields_with_calculation as $calc_field ) {
413
-                $inputs = $calc_field->get_entry_inputs();
414
-                if ( is_array( $inputs ) ) {
415
-                    foreach ( $inputs as $input ) {
416
-                        $input_name = 'input_' . str_replace( '.', '_', $input['id'] );
417
-                        $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
418
-                    }
419
-                } else {
420
-                    $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
421
-                    $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
422
-                }
423
-            }
424
-
425
-        }
426
-
427
-        //saving total field as the last field of the form.
428
-        if ( ! empty( $this->total_fields ) ) {
429
-            $update = true;
430
-            foreach ( $this->total_fields as $total_field ) {
431
-                $input_name = 'input_' . str_replace( '.', '_', $total_field->id);
432
-                $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry );
433
-            }
434
-        }
435
-
436
-        if( $update ) {
437
-
438
-            $return_entry = GFAPI::update_entry( $entry );
439
-
440
-            if( is_wp_error( $return_entry ) ) {
441
-                do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry );
442
-            } else {
443
-                do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' );
444
-            }
445
-        }
446
-    }
447
-
448
-    /**
449
-     * Handle updating the Post Image field
450
-     *
451
-     * Sets a new Featured Image if configured in Gravity Forms; otherwise uploads/updates media
452
-     *
453
-     * @since 1.17
454
-     *
455
-     * @uses GFFormsModel::media_handle_upload
456
-     * @uses set_post_thumbnail
457
-     * 
458
-     * @param array $form GF Form array
459
-     * @param GF_Field $field GF Field
460
-     * @param string $field_id Numeric ID of the field
461
-     * @param string $value
462
-     * @param array $entry GF Entry currently being edited
463
-     * @param int $post_id ID of the Post being edited
464
-     *
465
-     * @return mixed|string
466
-     */
467
-    private function update_post_image( $form, $field, $field_id, $value, $entry, $post_id ) {
468
-
469
-        $input_name = 'input_' . $field_id;
470
-
471
-        if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
472
-
473
-            // We have a new image
474
-
475
-            $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
476
-
477
-            $ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
478
-            $img_url = rgar( $ary, 0 );
479
-
480
-            $img_title       = count( $ary ) > 1 ? $ary[1] : '';
481
-            $img_caption     = count( $ary ) > 2 ? $ary[2] : '';
482
-            $img_description = count( $ary ) > 3 ? $ary[3] : '';
483
-
484
-            $image_meta = array(
485
-                'post_excerpt' => $img_caption,
486
-                'post_content' => $img_description,
487
-            );
488
-
489
-            //adding title only if it is not empty. It will default to the file name if it is not in the array
490
-            if ( ! empty( $img_title ) ) {
491
-                $image_meta['post_title'] = $img_title;
492
-            }
493
-
494
-            /**
495
-             * todo: As soon as \GFFormsModel::media_handle_upload becomes a public method, move this call to \GFFormsModel::media_handle_upload and remove the hack from this class.
496
-             * Note: the method became public in GF 1.9.17.7, but we don't require that version yet.
497
-             */
498
-            require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';
499
-            $media_id = GravityView_GFFormsModel::media_handle_upload( $img_url, $post_id, $image_meta );
500
-
501
-            // is this field set as featured image?
502
-            if ( $media_id && $field->postFeaturedImage ) {
503
-                set_post_thumbnail( $post_id, $media_id );
504
-            }
505
-
506
-        } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) {
507
-
508
-            // Same image although the image title, caption or description might have changed
509
-
510
-            $ary = array();
511
-            if( ! empty( $entry[ $field_id ] ) ) {
512
-                $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] );
513
-            }
514
-            $img_url = rgar( $ary, 0 );
515
-
516
-            // is this really the same image or something went wrong ?
517
-            if( $img_url === $_POST[ $input_name ] ) {
518
-
519
-                $img_title       = rgar( $value, $field_id .'.1' );
520
-                $img_caption     = rgar( $value, $field_id .'.4' );
521
-                $img_description = rgar( $value, $field_id .'.7' );
522
-
523
-                $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : '';
524
-
525
-                if ( $field->postFeaturedImage ) {
526
-
527
-                    $image_meta = array(
528
-                        'ID' => get_post_thumbnail_id( $post_id ),
529
-                        'post_title' => $img_title,
530
-                        'post_excerpt' => $img_caption,
531
-                        'post_content' => $img_description,
532
-                    );
533
-
534
-                    // update image title, caption or description
535
-                    wp_update_post( $image_meta );
536
-                }
537
-            }
538
-
539
-        } else {
540
-
541
-            // if we get here, image was removed or not set.
542
-            $value = '';
543
-
544
-            if ( $field->postFeaturedImage ) {
545
-                delete_post_thumbnail( $post_id );
546
-            }
547
-        }
548
-
549
-        return $value;
550
-    }
551
-
552
-    /**
553
-     * Loop through the fields being edited and if they include Post fields, update the Entry's post object
554
-     *
555
-     * @param array $form Gravity Forms form
556
-     *
557
-     * @return void
558
-     */
559
-    private function maybe_update_post_fields( $form ) {
560
-
561
-        $post_id = $this->entry['post_id'];
562
-
563
-        // Security check
564
-        if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
565
-            do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );
566
-            return;
567
-        }
354
+	/**
355
+	 * Remove max_files validation (done on gravityforms.js) to avoid conflicts with GravityView
356
+	 * Late validation done on self::custom_validation
357
+	 *
358
+	 * @param $plupload_init array Plupload settings
359
+	 * @param $form_id
360
+	 * @param $instance
361
+	 * @return mixed
362
+	 */
363
+	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
364
+		if( ! $this->is_edit_entry() ) {
365
+			return $plupload_init;
366
+		}
568 367
 
569
-        $update_entry = false;
368
+		$plupload_init['gf_vars']['max_files'] = 0;
570 369
 
571
-        $updated_post = $original_post = get_post( $post_id );
370
+		return $plupload_init;
371
+	}
572 372
 
573
-        foreach ( $this->entry as $field_id => $value ) {
574
-
575
-            $field = RGFormsModel::get_field( $form, $field_id );
576
-
577
-            if( ! $field ) {
578
-                continue;
579
-            }
580
-
581
-            if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
582
-
583
-                // Get the value of the field, including $_POSTed value
584
-                $value = RGFormsModel::get_field_value( $field );
585
-
586
-                // Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
587
-                $entry_tmp = $this->entry;
588
-                $entry_tmp["{$field_id}"] = $value;
589
-
590
-                switch( $field->type ) {
591
-
592
-                    case 'post_title':
593
-                        $post_title = $value;
594
-                        if( rgar( $form, 'postTitleTemplateEnabled' ) ) {
595
-                            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
596
-                        }
597
-                        $updated_post->post_title = $post_title;
598
-                        $updated_post->post_name  = $post_title;
599
-                        unset( $post_title );
600
-                        break;
601
-
602
-                    case 'post_content':
603
-                        $post_content = $value;
604
-                        if( rgar( $form, 'postContentTemplateEnabled' ) ) {
605
-                            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
606
-                        }
607
-                        $updated_post->post_content = $post_content;
608
-                        unset( $post_content );
609
-                        break;
610
-                    case 'post_excerpt':
611
-                        $updated_post->post_excerpt = $value;
612
-                        break;
613
-                    case 'post_tags':
614
-                        wp_set_post_tags( $post_id, $value, false );
615
-                        break;
616
-                    case 'post_category':
617
-                        break;
618
-                    case 'post_custom_field':
619
-                        if( ! empty( $field->customFieldTemplateEnabled ) ) {
620
-                            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
621
-                        }
622
-
623
-                        $input_type = RGFormsModel::get_input_type( $field );
624
-
625
-                        // Only certain custom field types are supported
626
-                        switch( $input_type ) {
627
-                            case 'fileupload':
628
-                            case 'list':
629
-                            case 'multiselect':
630
-                                if( ! is_string( $value ) ) {
631
-                                    $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value );
632
-                                }
633
-                            // break; left intentionally out
634
-                            default:
635
-                                update_post_meta( $post_id, $field->postCustomFieldName, $value );
636
-                        }
637
-
638
-                        break;
639
-
640
-                    case 'post_image':
641
-                        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
642
-                        break;
643
-
644
-                }
645
-
646
-                // update entry after
647
-                $this->entry["{$field_id}"] = $value;
648
-
649
-                $update_entry = true;
650
-
651
-                unset( $entry_tmp );
652
-            }
653
-
654
-        }
655
-
656
-        if( $update_entry ) {
657
-
658
-            $return_entry = GFAPI::update_entry( $this->entry );
659
-
660
-            if( is_wp_error( $return_entry ) ) {
661
-               do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) );
662
-            } else {
663
-                do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );
664
-            }
665
-
666
-        }
667
-
668
-        $return_post = wp_update_post( $updated_post, true );
669
-
670
-        if( is_wp_error( $return_post ) ) {
671
-            $return_post->add_data( $updated_post, '$updated_post' );
672
-            do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) );
673
-        } else {
674
-            do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post );
675
-        }
676
-    }
677
-
678
-    /**
679
-     * Convert a field content template into prepared output
680
-     *
681
-     * @uses GravityView_GFFormsModel::get_post_field_images()
682
-     *
683
-     * @since 1.17
684
-     *
685
-     * @param string $template The content template for the field
686
-     * @param array $form Gravity Forms form
687
-     * @param bool $do_shortcode Whether to process shortcode inside content. In GF, only run on Custom Field and Post Content fields
688
-     *
689
-     * @return mixed|string|void
690
-     */
691
-    function fill_post_template( $template, $form, $entry, $do_shortcode = false ) {
692
-
693
-        require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';
694
-
695
-        $post_images = GravityView_GFFormsModel::get_post_field_images( $form, $entry );
696
-
697
-        //replacing post image variables
698
-        $output = GFCommon::replace_variables_post_image( $template, $post_images, $entry );
699
-
700
-        //replacing all other variables
701
-        $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
702
-
703
-        // replace conditional shortcodes
704
-        if( $do_shortcode ) {
705
-            $output = do_shortcode( $output );
706
-        }
707
-
708
-        return $output;
709
-    }
710
-
711
-
712
-    /**
713
-     * Perform actions normally performed after updating a lead
714
-     *
715
-     * @since 1.8
716
-     *
717
-     * @see GFEntryDetail::lead_detail_page()
718
-     *
719
-     * @return void
720
-     */
721
-    function after_update() {
722 373
 
723
-        do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
724
-        do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] );
374
+	/**
375
+	 * Unset adminOnly and convert field input key to string
376
+	 * @return array $form
377
+	 */
378
+	private function form_prepare_for_save() {
725 379
 
726
-        // Re-define the entry now that we've updated it.
727
-        $entry = RGFormsModel::get_lead( $this->entry['id'] );
380
+		$form = $this->form;
728 381
 
729
-        $entry = GFFormsModel::set_entry_meta( $entry, $this->form );
382
+		foreach( $form['fields'] as $k => &$field ) {
730 383
 
731
-        // We need to clear the cache because Gravity Forms caches the field values, which
732
-        // we have just updated.
733
-        foreach ($this->form['fields'] as $key => $field) {
734
-            GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
735
-        }
384
+			// Remove the fields with calculation formulas before save to avoid conflicts with GF logic
385
+			// @since 1.16.3
386
+			if( $field->has_calculation() ) {
387
+				unset( $form['fields'][ $k ] );
388
+			}
736 389
 
737
-        $this->entry = $entry;
738
-    }
390
+			$field->adminOnly = false;
739 391
 
392
+			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
393
+				foreach( $field->inputs as $key => $input ) {
394
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
395
+				}
396
+			}
397
+		}
740 398
 
741
-    /**
742
-     * Display the Edit Entry form
743
-     *
744
-     * @return [type] [description]
745
-     */
746
-    public function edit_entry_form() {
399
+		return $form;
400
+	}
401
+
402
+	private function update_calculation_fields() {
403
+
404
+		$form = self::$original_form;
405
+		$update = false;
406
+
407
+		// get the most up to date entry values
408
+		$entry = GFAPI::get_entry( $this->entry['id'] );
409
+
410
+		if( !empty( $this->fields_with_calculation ) ) {
411
+			$update = true;
412
+			foreach ( $this->fields_with_calculation as $calc_field ) {
413
+				$inputs = $calc_field->get_entry_inputs();
414
+				if ( is_array( $inputs ) ) {
415
+					foreach ( $inputs as $input ) {
416
+						$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
417
+						$entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
418
+					}
419
+				} else {
420
+					$input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
421
+					$entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
422
+				}
423
+			}
747 424
 
748
-        ?>
425
+		}
426
+
427
+		//saving total field as the last field of the form.
428
+		if ( ! empty( $this->total_fields ) ) {
429
+			$update = true;
430
+			foreach ( $this->total_fields as $total_field ) {
431
+				$input_name = 'input_' . str_replace( '.', '_', $total_field->id);
432
+				$entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry );
433
+			}
434
+		}
435
+
436
+		if( $update ) {
437
+
438
+			$return_entry = GFAPI::update_entry( $entry );
439
+
440
+			if( is_wp_error( $return_entry ) ) {
441
+				do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry );
442
+			} else {
443
+				do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' );
444
+			}
445
+		}
446
+	}
447
+
448
+	/**
449
+	 * Handle updating the Post Image field
450
+	 *
451
+	 * Sets a new Featured Image if configured in Gravity Forms; otherwise uploads/updates media
452
+	 *
453
+	 * @since 1.17
454
+	 *
455
+	 * @uses GFFormsModel::media_handle_upload
456
+	 * @uses set_post_thumbnail
457
+	 * 
458
+	 * @param array $form GF Form array
459
+	 * @param GF_Field $field GF Field
460
+	 * @param string $field_id Numeric ID of the field
461
+	 * @param string $value
462
+	 * @param array $entry GF Entry currently being edited
463
+	 * @param int $post_id ID of the Post being edited
464
+	 *
465
+	 * @return mixed|string
466
+	 */
467
+	private function update_post_image( $form, $field, $field_id, $value, $entry, $post_id ) {
468
+
469
+		$input_name = 'input_' . $field_id;
470
+
471
+		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
472
+
473
+			// We have a new image
474
+
475
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
476
+
477
+			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
478
+			$img_url = rgar( $ary, 0 );
479
+
480
+			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
481
+			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
482
+			$img_description = count( $ary ) > 3 ? $ary[3] : '';
483
+
484
+			$image_meta = array(
485
+				'post_excerpt' => $img_caption,
486
+				'post_content' => $img_description,
487
+			);
488
+
489
+			//adding title only if it is not empty. It will default to the file name if it is not in the array
490
+			if ( ! empty( $img_title ) ) {
491
+				$image_meta['post_title'] = $img_title;
492
+			}
493
+
494
+			/**
495
+			 * todo: As soon as \GFFormsModel::media_handle_upload becomes a public method, move this call to \GFFormsModel::media_handle_upload and remove the hack from this class.
496
+			 * Note: the method became public in GF 1.9.17.7, but we don't require that version yet.
497
+			 */
498
+			require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';
499
+			$media_id = GravityView_GFFormsModel::media_handle_upload( $img_url, $post_id, $image_meta );
500
+
501
+			// is this field set as featured image?
502
+			if ( $media_id && $field->postFeaturedImage ) {
503
+				set_post_thumbnail( $post_id, $media_id );
504
+			}
505
+
506
+		} elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) {
507
+
508
+			// Same image although the image title, caption or description might have changed
509
+
510
+			$ary = array();
511
+			if( ! empty( $entry[ $field_id ] ) ) {
512
+				$ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] );
513
+			}
514
+			$img_url = rgar( $ary, 0 );
515
+
516
+			// is this really the same image or something went wrong ?
517
+			if( $img_url === $_POST[ $input_name ] ) {
518
+
519
+				$img_title       = rgar( $value, $field_id .'.1' );
520
+				$img_caption     = rgar( $value, $field_id .'.4' );
521
+				$img_description = rgar( $value, $field_id .'.7' );
522
+
523
+				$value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : '';
524
+
525
+				if ( $field->postFeaturedImage ) {
526
+
527
+					$image_meta = array(
528
+						'ID' => get_post_thumbnail_id( $post_id ),
529
+						'post_title' => $img_title,
530
+						'post_excerpt' => $img_caption,
531
+						'post_content' => $img_description,
532
+					);
533
+
534
+					// update image title, caption or description
535
+					wp_update_post( $image_meta );
536
+				}
537
+			}
538
+
539
+		} else {
540
+
541
+			// if we get here, image was removed or not set.
542
+			$value = '';
543
+
544
+			if ( $field->postFeaturedImage ) {
545
+				delete_post_thumbnail( $post_id );
546
+			}
547
+		}
548
+
549
+		return $value;
550
+	}
551
+
552
+	/**
553
+	 * Loop through the fields being edited and if they include Post fields, update the Entry's post object
554
+	 *
555
+	 * @param array $form Gravity Forms form
556
+	 *
557
+	 * @return void
558
+	 */
559
+	private function maybe_update_post_fields( $form ) {
560
+
561
+		$post_id = $this->entry['post_id'];
562
+
563
+		// Security check
564
+		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
565
+			do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );
566
+			return;
567
+		}
568
+
569
+		$update_entry = false;
570
+
571
+		$updated_post = $original_post = get_post( $post_id );
572
+
573
+		foreach ( $this->entry as $field_id => $value ) {
574
+
575
+			$field = RGFormsModel::get_field( $form, $field_id );
576
+
577
+			if( ! $field ) {
578
+				continue;
579
+			}
580
+
581
+			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
582
+
583
+				// Get the value of the field, including $_POSTed value
584
+				$value = RGFormsModel::get_field_value( $field );
585
+
586
+				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
587
+				$entry_tmp = $this->entry;
588
+				$entry_tmp["{$field_id}"] = $value;
589
+
590
+				switch( $field->type ) {
591
+
592
+					case 'post_title':
593
+						$post_title = $value;
594
+						if( rgar( $form, 'postTitleTemplateEnabled' ) ) {
595
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
596
+						}
597
+						$updated_post->post_title = $post_title;
598
+						$updated_post->post_name  = $post_title;
599
+						unset( $post_title );
600
+						break;
601
+
602
+					case 'post_content':
603
+						$post_content = $value;
604
+						if( rgar( $form, 'postContentTemplateEnabled' ) ) {
605
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
606
+						}
607
+						$updated_post->post_content = $post_content;
608
+						unset( $post_content );
609
+						break;
610
+					case 'post_excerpt':
611
+						$updated_post->post_excerpt = $value;
612
+						break;
613
+					case 'post_tags':
614
+						wp_set_post_tags( $post_id, $value, false );
615
+						break;
616
+					case 'post_category':
617
+						break;
618
+					case 'post_custom_field':
619
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
620
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
621
+						}
622
+
623
+						$input_type = RGFormsModel::get_input_type( $field );
624
+
625
+						// Only certain custom field types are supported
626
+						switch( $input_type ) {
627
+							case 'fileupload':
628
+							case 'list':
629
+							case 'multiselect':
630
+								if( ! is_string( $value ) ) {
631
+									$value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value );
632
+								}
633
+							// break; left intentionally out
634
+							default:
635
+								update_post_meta( $post_id, $field->postCustomFieldName, $value );
636
+						}
637
+
638
+						break;
639
+
640
+					case 'post_image':
641
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
642
+						break;
643
+
644
+				}
645
+
646
+				// update entry after
647
+				$this->entry["{$field_id}"] = $value;
648
+
649
+				$update_entry = true;
650
+
651
+				unset( $entry_tmp );
652
+			}
653
+
654
+		}
655
+
656
+		if( $update_entry ) {
657
+
658
+			$return_entry = GFAPI::update_entry( $this->entry );
659
+
660
+			if( is_wp_error( $return_entry ) ) {
661
+			   do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) );
662
+			} else {
663
+				do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );
664
+			}
665
+
666
+		}
667
+
668
+		$return_post = wp_update_post( $updated_post, true );
669
+
670
+		if( is_wp_error( $return_post ) ) {
671
+			$return_post->add_data( $updated_post, '$updated_post' );
672
+			do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) );
673
+		} else {
674
+			do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post );
675
+		}
676
+	}
677
+
678
+	/**
679
+	 * Convert a field content template into prepared output
680
+	 *
681
+	 * @uses GravityView_GFFormsModel::get_post_field_images()
682
+	 *
683
+	 * @since 1.17
684
+	 *
685
+	 * @param string $template The content template for the field
686
+	 * @param array $form Gravity Forms form
687
+	 * @param bool $do_shortcode Whether to process shortcode inside content. In GF, only run on Custom Field and Post Content fields
688
+	 *
689
+	 * @return mixed|string|void
690
+	 */
691
+	function fill_post_template( $template, $form, $entry, $do_shortcode = false ) {
692
+
693
+		require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';
694
+
695
+		$post_images = GravityView_GFFormsModel::get_post_field_images( $form, $entry );
696
+
697
+		//replacing post image variables
698
+		$output = GFCommon::replace_variables_post_image( $template, $post_images, $entry );
699
+
700
+		//replacing all other variables
701
+		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
702
+
703
+		// replace conditional shortcodes
704
+		if( $do_shortcode ) {
705
+			$output = do_shortcode( $output );
706
+		}
707
+
708
+		return $output;
709
+	}
710
+
711
+
712
+	/**
713
+	 * Perform actions normally performed after updating a lead
714
+	 *
715
+	 * @since 1.8
716
+	 *
717
+	 * @see GFEntryDetail::lead_detail_page()
718
+	 *
719
+	 * @return void
720
+	 */
721
+	function after_update() {
722
+
723
+		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
724
+		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] );
725
+
726
+		// Re-define the entry now that we've updated it.
727
+		$entry = RGFormsModel::get_lead( $this->entry['id'] );
728
+
729
+		$entry = GFFormsModel::set_entry_meta( $entry, $this->form );
730
+
731
+		// We need to clear the cache because Gravity Forms caches the field values, which
732
+		// we have just updated.
733
+		foreach ($this->form['fields'] as $key => $field) {
734
+			GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
735
+		}
736
+
737
+		$this->entry = $entry;
738
+	}
739
+
740
+
741
+	/**
742
+	 * Display the Edit Entry form
743
+	 *
744
+	 * @return [type] [description]
745
+	 */
746
+	public function edit_entry_form() {
747
+
748
+		?>
749 749
 
750 750
         <div class="gv-edit-entry-wrapper"><?php
751 751
 
752
-            $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
752
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
753 753
 
754
-            /**
755
-             * Fixes weird wpautop() issue
756
-             * @see https://github.com/katzwebservices/GravityView/issues/451
757
-             */
758
-            echo gravityview_strip_whitespace( $javascript );
754
+			/**
755
+			 * Fixes weird wpautop() issue
756
+			 * @see https://github.com/katzwebservices/GravityView/issues/451
757
+			 */
758
+			echo gravityview_strip_whitespace( $javascript );
759 759
 
760
-            ?><h2 class="gv-edit-entry-title">
760
+			?><h2 class="gv-edit-entry-title">
761 761
                 <span><?php
762 762
 
763
-                    /**
764
-                     * @filter `gravityview_edit_entry_title` Modify the edit entry title
765
-                     * @param string $edit_entry_title Modify the "Edit Entry" title
766
-                     * @param GravityView_Edit_Entry_Render $this This object
767
-                     */
768
-                    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
763
+					/**
764
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
765
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
766
+					 * @param GravityView_Edit_Entry_Render $this This object
767
+					 */
768
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
769 769
 
770
-                    echo esc_attr( $edit_entry_title );
771
-            ?></span>
770
+					echo esc_attr( $edit_entry_title );
771
+			?></span>
772 772
             </h2>
773 773
 
774 774
             <?php $this->maybe_print_message(); ?>
@@ -779,1144 +779,1144 @@  discard block
 block discarded – undo
779 779
 
780 780
                 <?php
781 781
 
782
-                wp_nonce_field( self::$nonce_key, self::$nonce_key );
782
+				wp_nonce_field( self::$nonce_key, self::$nonce_key );
783 783
 
784
-                wp_nonce_field( self::$nonce_field, self::$nonce_field, false );
784
+				wp_nonce_field( self::$nonce_field, self::$nonce_field, false );
785 785
 
786
-                // Print the actual form HTML
787
-                $this->render_edit_form();
786
+				// Print the actual form HTML
787
+				$this->render_edit_form();
788 788
 
789
-                ?>
789
+				?>
790 790
             </form>
791 791
 
792 792
         </div>
793 793
 
794 794
     <?php
795
-    }
796
-
797
-    /**
798
-     * Display success or error message if the form has been submitted
799
-     *
800
-     * @uses GVCommon::generate_notice
801
-     *
802
-     * @since 1.16.2.2
803
-     *
804
-     * @return void
805
-     */
806
-    private function maybe_print_message() {
807
-
808
-        if( rgpost('action') === 'update' ) {
809
-
810
-            $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );
811
-
812
-            if( ! $this->is_valid ){
813
-
814
-                // Keeping this compatible with Gravity Forms.
815
-                $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
816
-                $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
817
-
818
-                echo GVCommon::generate_notice( $message , 'gv-error' );
819
-
820
-            } else {
821
-                $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' );
822
-
823
-                /**
824
-                 * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)
825
-                 * @since 1.5.4
826
-                 * @param string $entry_updated_message Existing message
827
-                 * @param int $view_id View ID
828
-                 * @param array $entry Gravity Forms entry array
829
-                 * @param string $back_link URL to return to the original entry. @since 1.6
830
-                 */
831
-                $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
832
-
833
-                echo GVCommon::generate_notice( $message );
834
-            }
835
-
836
-        }
837
-    }
838
-
839
-    /**
840
-     * Display the Edit Entry form in the original Gravity Forms format
841
-     *
842
-     * @since 1.9
843
-     *
844
-     * @return void
845
-     */
846
-    private function render_edit_form() {
847
-
848
-        /**
849
-         * @action `gravityview/edit-entry/render/before` Before rendering the Edit Entry form
850
-         * @since 1.17
851
-         * @param GravityView_Edit_Entry_Render $this
852
-         */
853
-        do_action( 'gravityview/edit-entry/render/before', $this );
854
-
855
-        add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
856
-        add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
857
-        add_filter( 'gform_disable_view_counter', '__return_true' );
858
-
859
-        add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
860
-        add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
861
-
862
-        add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10, 3 );
863
-
864
-        // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
865
-        unset( $_GET['page'] );
866
-
867
-        // TODO: Verify multiple-page forms
868
-        // TODO: Product fields are not editable
869
-
870
-        $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
871
-
872
-        remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10 );
873
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
874
-        remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
875
-        remove_filter( 'gform_disable_view_counter', '__return_true' );
876
-        remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
877
-        remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 );
878
-
879
-        echo $html;
880
-
881
-        /**
882
-         * @action `gravityview/edit-entry/render/after` After rendering the Edit Entry form
883
-         * @since 1.17
884
-         * @param GravityView_Edit_Entry_Render $this
885
-         */
886
-        do_action( 'gravityview/edit-entry/render/after', $this );
887
-    }
888
-
889
-    /**
890
-     * Survey fields inject their output using `gform_field_input` filter, but in Edit Entry, the values were empty.
891
-     * We filter the values here because it was the easiest access point: tell the survey field the correct value, GF outputs it.
892
-     *
893
-     * @TODO: REMOVE; now added in class-gravityview-plugin-hooks-gravity-forms-survey.php
894
-     * 
895
-     * @since 1.16.4
896
-     *
897
-     * @param string $value Existing value
898
-     * @param GF_Field $field
899
-     * @param string $name Field custom parameter name, normally blank.
900
-     *
901
-     * @return mixed
902
-     */
903
-    function fix_survey_fields_value( $value, $field, $name ) {
795
+	}
796
+
797
+	/**
798
+	 * Display success or error message if the form has been submitted
799
+	 *
800
+	 * @uses GVCommon::generate_notice
801
+	 *
802
+	 * @since 1.16.2.2
803
+	 *
804
+	 * @return void
805
+	 */
806
+	private function maybe_print_message() {
807
+
808
+		if( rgpost('action') === 'update' ) {
809
+
810
+			$back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );
811
+
812
+			if( ! $this->is_valid ){
813
+
814
+				// Keeping this compatible with Gravity Forms.
815
+				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
816
+				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
817
+
818
+				echo GVCommon::generate_notice( $message , 'gv-error' );
819
+
820
+			} else {
821
+				$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' );
822
+
823
+				/**
824
+				 * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)
825
+				 * @since 1.5.4
826
+				 * @param string $entry_updated_message Existing message
827
+				 * @param int $view_id View ID
828
+				 * @param array $entry Gravity Forms entry array
829
+				 * @param string $back_link URL to return to the original entry. @since 1.6
830
+				 */
831
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
832
+
833
+				echo GVCommon::generate_notice( $message );
834
+			}
835
+
836
+		}
837
+	}
838
+
839
+	/**
840
+	 * Display the Edit Entry form in the original Gravity Forms format
841
+	 *
842
+	 * @since 1.9
843
+	 *
844
+	 * @return void
845
+	 */
846
+	private function render_edit_form() {
847
+
848
+		/**
849
+		 * @action `gravityview/edit-entry/render/before` Before rendering the Edit Entry form
850
+		 * @since 1.17
851
+		 * @param GravityView_Edit_Entry_Render $this
852
+		 */
853
+		do_action( 'gravityview/edit-entry/render/before', $this );
854
+
855
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
856
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
857
+		add_filter( 'gform_disable_view_counter', '__return_true' );
858
+
859
+		add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
860
+		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
861
+
862
+		add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10, 3 );
863
+
864
+		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
865
+		unset( $_GET['page'] );
866
+
867
+		// TODO: Verify multiple-page forms
868
+		// TODO: Product fields are not editable
869
+
870
+		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
871
+
872
+		remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10 );
873
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
874
+		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
875
+		remove_filter( 'gform_disable_view_counter', '__return_true' );
876
+		remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
877
+		remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 );
878
+
879
+		echo $html;
880
+
881
+		/**
882
+		 * @action `gravityview/edit-entry/render/after` After rendering the Edit Entry form
883
+		 * @since 1.17
884
+		 * @param GravityView_Edit_Entry_Render $this
885
+		 */
886
+		do_action( 'gravityview/edit-entry/render/after', $this );
887
+	}
888
+
889
+	/**
890
+	 * Survey fields inject their output using `gform_field_input` filter, but in Edit Entry, the values were empty.
891
+	 * We filter the values here because it was the easiest access point: tell the survey field the correct value, GF outputs it.
892
+	 *
893
+	 * @TODO: REMOVE; now added in class-gravityview-plugin-hooks-gravity-forms-survey.php
894
+	 * 
895
+	 * @since 1.16.4
896
+	 *
897
+	 * @param string $value Existing value
898
+	 * @param GF_Field $field
899
+	 * @param string $name Field custom parameter name, normally blank.
900
+	 *
901
+	 * @return mixed
902
+	 */
903
+	function fix_survey_fields_value( $value, $field, $name ) {
904 904
         
905
-        if( 'survey' === $field->type ) {
906
-
907
-	        // We need to run through each survey row until we find a match for expected values
908
-	        foreach ( $this->entry as $field_id => $field_value ) {
909
-
910
-		        if ( floor( $field_id ) !== floor( $field->id ) ) {
911
-			        continue;
912
-		        }
913
-
914
-		        if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) {
915
-			        list( $row_val, $col_val ) = explode( ':', $field_value, 2 );
916
-
917
-		            // If the $name matches the $row_val, we are processing the correct row
918
-			        if( $row_val === $name ) {
919
-				        $value = $field_value;
920
-				        break;
921
-			        }
922
-		        } else {
923
-			        // When not processing multiple rows, the value is the $entry[ $field_id ] value.
924
-			        $value = $field_value;
925
-				    break;
926
-		        }
905
+		if( 'survey' === $field->type ) {
906
+
907
+			// We need to run through each survey row until we find a match for expected values
908
+			foreach ( $this->entry as $field_id => $field_value ) {
909
+
910
+				if ( floor( $field_id ) !== floor( $field->id ) ) {
911
+					continue;
912
+				}
913
+
914
+				if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) {
915
+					list( $row_val, $col_val ) = explode( ':', $field_value, 2 );
916
+
917
+					// If the $name matches the $row_val, we are processing the correct row
918
+					if( $row_val === $name ) {
919
+						$value = $field_value;
920
+						break;
921
+					}
922
+				} else {
923
+					// When not processing multiple rows, the value is the $entry[ $field_id ] value.
924
+					$value = $field_value;
925
+					break;
926
+				}
927 927
 			}
928
-        }
929
-
930
-        return $value;
931
-    }
932
-
933
-    /**
934
-     * Display the Update/Cancel/Delete buttons for the Edit Entry form
935
-     * @since 1.8
936
-     * @return string
937
-     */
938
-    public function render_form_buttons() {
939
-        return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
940
-    }
941
-
942
-
943
-    /**
944
-     * Modify the form fields that are shown when using GFFormDisplay::get_form()
945
-     *
946
-     * By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.
947
-     *
948
-     * @param array $form
949
-     * @param boolean $ajax Whether in AJAX mode
950
-     * @param array|string $field_values Passed parameters to the form
951
-     *
952
-     * @since 1.9
953
-     *
954
-     * @return array Modified form array
955
-     */
956
-    public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
957
-
958
-        // In case we have validated the form, use it to inject the validation results into the form render
959
-        if( isset( $this->form_after_validation ) ) {
960
-            $form = $this->form_after_validation;
961
-        } else {
962
-            $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
963
-        }
964
-
965
-        $form = $this->filter_conditional_logic( $form );
966
-
967
-        // for now we don't support Save and Continue feature.
968
-        if( ! self::$supports_save_and_continue ) {
969
-	        unset( $form['save'] );
970
-        }
971
-
972
-        return $form;
973
-    }
974
-
975
-    /**
976
-     * When displaying a field, check if it's a Post Field, and if so, make sure the post exists and current user has edit rights.
977
-     *
978
-     * @since 1.16.2.2
979
-     *
980
-     * @param string $field_content Always empty. Returning not-empty overrides the input.
981
-     * @param GF_Field $field
982
-     * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
983
-     * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
984
-     * @param int $form_id Form ID
985
-     *
986
-     * @return string If error, the error message. If no error, blank string (modify_edit_field_input() runs next)
987
-     */
988
-    function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
989
-
990
-        if( GFCommon::is_post_field( $field ) ) {
991
-
992
-            $message = null;
993
-
994
-            // First, make sure they have the capability to edit the post.
995
-            if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
996
-
997
-                /**
998
-                 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
999
-                 * @param string $message The existing "You don't have permission..." text
1000
-                 */
1001
-                $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1002
-
1003
-            } elseif( null === get_post( $this->entry['post_id'] ) ) {
1004
-                /**
1005
-                 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1006
-                 * @param string $message The existing "This field is not editable; the post no longer exists." text
1007
-                 */
1008
-                $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1009
-            }
1010
-
1011
-            if( $message ) {
1012
-                $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1013
-            }
1014
-        }
1015
-
1016
-        return $field_content;
1017
-    }
1018
-
1019
-    /**
1020
-     *
1021
-     * Fill-in the saved values into the form inputs
1022
-     *
1023
-     * @param string $field_content Always empty. Returning not-empty overrides the input.
1024
-     * @param GF_Field $field
1025
-     * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
1026
-     * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
1027
-     * @param int $form_id Form ID
1028
-     *
1029
-     * @return mixed
1030
-     */
1031
-    function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1032
-
1033
-        $gv_field = GravityView_Fields::get_associated_field( $field );
1034
-
1035
-        // If the form has been submitted, then we don't need to pre-fill the values,
1036
-        // Except for fileupload type and when a field input is overridden- run always!!
1037
-        if(
1038
-            ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1039
-            && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1040
-            || ! empty( $field_content )
1041
-            || in_array( $field->type, array( 'honeypot' ) )
1042
-            || GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable
1043
-        ) {
1044
-	        return $field_content;
1045
-        }
1046
-
1047
-        // Turn on Admin-style display for file upload fields only
1048
-        if( 'fileupload' === $field->type ) {
1049
-            $_GET['page'] = 'gf_entries';
1050
-        }
1051
-
1052
-        // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
1053
-        $field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
1054
-
1055
-        // add categories as choices for Post Category field
1056
-        if ( 'post_category' === $field->type ) {
1057
-            $field = GFCommon::add_categories_as_choices( $field, $value );
1058
-        }
1059
-
1060
-        $field_value = $this->get_field_value( $field );
1061
-
1062
-        /**
1063
-         * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1064
-         * @since 1.11
1065
-         * @param mixed $field_value field value used to populate the input
1066
-         * @param object $field Gravity Forms field object ( Class GF_Field )
1067
-         */
1068
-        $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field );
1069
-
1070
-        /**
1071
-         * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1072
-         * @since 1.17
1073
-         * @param mixed $field_value field value used to populate the input
1074
-         * @param GF_Field $field Gravity Forms field object
1075
-         */
1076
-        $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field );
1077
-
1078
-	    // Prevent any PHP warnings, like undefined index
1079
-	    ob_start();
1080
-
1081
-        if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1082
-            /** @var GF_Field $gv_field */
1083
-            $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1084
-        } else {
1085
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1086
-        }
1087
-
1088
-
1089
-	    // If there was output, it's an error
1090
-	    $warnings = ob_get_clean();
1091
-
1092
-	    if( !empty( $warnings ) ) {
1093
-		    do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );
1094
-	    }
1095
-
1096
-        /**
1097
-         * Unset hack $_GET['page'] = 'gf_entries'
1098
-         * We need the fileupload html field to render with the proper id
1099
-         *  ( <li id="field_80_16" ... > )
1100
-         */
1101
-        unset( $_GET['page'] );
1102
-
1103
-        return $return;
1104
-    }
1105
-
1106
-    /**
1107
-     * Modify the value for the current field input
1108
-     *
1109
-     * @param GF_Field $field
1110
-     *
1111
-     * @return array|mixed|string|void
1112
-     */
1113
-    private function get_field_value( $field ) {
1114
-
1115
-        /**
1116
-         * @filter `gravityview/edit_entry/pre_populate/override` Allow the pre-populated value to override saved value in Edit Entry form. By default, pre-populate mechanism only kicks on empty fields.
1117
-         * @param boolean True: override saved values; False: don't override (default)
1118
-         * @param $field GF_Field object Gravity Forms field object
1119
-         * @since 1.13
1120
-         */
1121
-        $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1122
-
1123
-        // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1124
-        if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1125
-
1126
-            $field_value = array();
1127
-
1128
-            // only accept pre-populated values if the field doesn't have any choice selected.
1129
-            $allow_pre_populated = $field->allowsPrepopulate;
1130
-
1131
-            foreach ( (array)$field->inputs as $input ) {
1132
-
1133
-                $input_id = strval( $input['id'] );
928
+		}
929
+
930
+		return $value;
931
+	}
932
+
933
+	/**
934
+	 * Display the Update/Cancel/Delete buttons for the Edit Entry form
935
+	 * @since 1.8
936
+	 * @return string
937
+	 */
938
+	public function render_form_buttons() {
939
+		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
940
+	}
941
+
942
+
943
+	/**
944
+	 * Modify the form fields that are shown when using GFFormDisplay::get_form()
945
+	 *
946
+	 * By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.
947
+	 *
948
+	 * @param array $form
949
+	 * @param boolean $ajax Whether in AJAX mode
950
+	 * @param array|string $field_values Passed parameters to the form
951
+	 *
952
+	 * @since 1.9
953
+	 *
954
+	 * @return array Modified form array
955
+	 */
956
+	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
957
+
958
+		// In case we have validated the form, use it to inject the validation results into the form render
959
+		if( isset( $this->form_after_validation ) ) {
960
+			$form = $this->form_after_validation;
961
+		} else {
962
+			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
963
+		}
964
+
965
+		$form = $this->filter_conditional_logic( $form );
966
+
967
+		// for now we don't support Save and Continue feature.
968
+		if( ! self::$supports_save_and_continue ) {
969
+			unset( $form['save'] );
970
+		}
971
+
972
+		return $form;
973
+	}
974
+
975
+	/**
976
+	 * When displaying a field, check if it's a Post Field, and if so, make sure the post exists and current user has edit rights.
977
+	 *
978
+	 * @since 1.16.2.2
979
+	 *
980
+	 * @param string $field_content Always empty. Returning not-empty overrides the input.
981
+	 * @param GF_Field $field
982
+	 * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
983
+	 * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
984
+	 * @param int $form_id Form ID
985
+	 *
986
+	 * @return string If error, the error message. If no error, blank string (modify_edit_field_input() runs next)
987
+	 */
988
+	function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
989
+
990
+		if( GFCommon::is_post_field( $field ) ) {
991
+
992
+			$message = null;
993
+
994
+			// First, make sure they have the capability to edit the post.
995
+			if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
996
+
997
+				/**
998
+				 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
999
+				 * @param string $message The existing "You don't have permission..." text
1000
+				 */
1001
+				$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1002
+
1003
+			} elseif( null === get_post( $this->entry['post_id'] ) ) {
1004
+				/**
1005
+				 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1006
+				 * @param string $message The existing "This field is not editable; the post no longer exists." text
1007
+				 */
1008
+				$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1009
+			}
1010
+
1011
+			if( $message ) {
1012
+				$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1013
+			}
1014
+		}
1015
+
1016
+		return $field_content;
1017
+	}
1018
+
1019
+	/**
1020
+	 *
1021
+	 * Fill-in the saved values into the form inputs
1022
+	 *
1023
+	 * @param string $field_content Always empty. Returning not-empty overrides the input.
1024
+	 * @param GF_Field $field
1025
+	 * @param string|array $value If array, it's a field with multiple inputs. If string, single input.
1026
+	 * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.
1027
+	 * @param int $form_id Form ID
1028
+	 *
1029
+	 * @return mixed
1030
+	 */
1031
+	function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1032
+
1033
+		$gv_field = GravityView_Fields::get_associated_field( $field );
1034
+
1035
+		// If the form has been submitted, then we don't need to pre-fill the values,
1036
+		// Except for fileupload type and when a field input is overridden- run always!!
1037
+		if(
1038
+			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1039
+			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1040
+			|| ! empty( $field_content )
1041
+			|| in_array( $field->type, array( 'honeypot' ) )
1042
+			|| GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable
1043
+		) {
1044
+			return $field_content;
1045
+		}
1046
+
1047
+		// Turn on Admin-style display for file upload fields only
1048
+		if( 'fileupload' === $field->type ) {
1049
+			$_GET['page'] = 'gf_entries';
1050
+		}
1051
+
1052
+		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
1053
+		$field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */
1054
+
1055
+		// add categories as choices for Post Category field
1056
+		if ( 'post_category' === $field->type ) {
1057
+			$field = GFCommon::add_categories_as_choices( $field, $value );
1058
+		}
1059
+
1060
+		$field_value = $this->get_field_value( $field );
1061
+
1062
+		/**
1063
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1064
+		 * @since 1.11
1065
+		 * @param mixed $field_value field value used to populate the input
1066
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1067
+		 */
1068
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field );
1069
+
1070
+		/**
1071
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1072
+		 * @since 1.17
1073
+		 * @param mixed $field_value field value used to populate the input
1074
+		 * @param GF_Field $field Gravity Forms field object
1075
+		 */
1076
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field );
1077
+
1078
+		// Prevent any PHP warnings, like undefined index
1079
+		ob_start();
1080
+
1081
+		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1082
+			/** @var GF_Field $gv_field */
1083
+			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1084
+		} else {
1085
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1086
+		}
1087
+
1088
+
1089
+		// If there was output, it's an error
1090
+		$warnings = ob_get_clean();
1091
+
1092
+		if( !empty( $warnings ) ) {
1093
+			do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );
1094
+		}
1095
+
1096
+		/**
1097
+		 * Unset hack $_GET['page'] = 'gf_entries'
1098
+		 * We need the fileupload html field to render with the proper id
1099
+		 *  ( <li id="field_80_16" ... > )
1100
+		 */
1101
+		unset( $_GET['page'] );
1102
+
1103
+		return $return;
1104
+	}
1105
+
1106
+	/**
1107
+	 * Modify the value for the current field input
1108
+	 *
1109
+	 * @param GF_Field $field
1110
+	 *
1111
+	 * @return array|mixed|string|void
1112
+	 */
1113
+	private function get_field_value( $field ) {
1114
+
1115
+		/**
1116
+		 * @filter `gravityview/edit_entry/pre_populate/override` Allow the pre-populated value to override saved value in Edit Entry form. By default, pre-populate mechanism only kicks on empty fields.
1117
+		 * @param boolean True: override saved values; False: don't override (default)
1118
+		 * @param $field GF_Field object Gravity Forms field object
1119
+		 * @since 1.13
1120
+		 */
1121
+		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1122
+
1123
+		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1124
+		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1125
+
1126
+			$field_value = array();
1127
+
1128
+			// only accept pre-populated values if the field doesn't have any choice selected.
1129
+			$allow_pre_populated = $field->allowsPrepopulate;
1130
+
1131
+			foreach ( (array)$field->inputs as $input ) {
1132
+
1133
+				$input_id = strval( $input['id'] );
1134 1134
                 
1135
-                if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1136
-                    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1137
-                    $allow_pre_populated = false;
1138
-                }
1135
+				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1136
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1137
+					$allow_pre_populated = false;
1138
+				}
1139 1139
 
1140
-            }
1140
+			}
1141 1141
 
1142
-            $pre_value = $field->get_value_submission( array(), false );
1142
+			$pre_value = $field->get_value_submission( array(), false );
1143 1143
 
1144
-            $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1144
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1145 1145
 
1146
-        } else {
1146
+		} else {
1147 1147
 
1148
-            $id = intval( $field->id );
1148
+			$id = intval( $field->id );
1149 1149
 
1150
-            // get pre-populated value if exists
1151
-            $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : '';
1150
+			// get pre-populated value if exists
1151
+			$pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : '';
1152 1152
 
1153
-            // saved field entry value (if empty, fallback to the pre-populated value, if exists)
1154
-            // or pre-populated value if not empty and set to override saved value
1155
-            $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;
1153
+			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1154
+			// or pre-populated value if not empty and set to override saved value
1155
+			$field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;
1156 1156
 
1157
-            // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1158
-            if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1159
-                $categories = array();
1160
-                foreach ( explode( ',', $field_value ) as $cat_string ) {
1161
-                    $categories[] = GFCommon::format_post_category( $cat_string, true );
1162
-                }
1163
-                $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1164
-            }
1157
+			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1158
+			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1159
+				$categories = array();
1160
+				foreach ( explode( ',', $field_value ) as $cat_string ) {
1161
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1162
+				}
1163
+				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1164
+			}
1165 1165
 
1166
-        }
1166
+		}
1167 1167
 
1168
-        // if value is empty get the default value if defined
1169
-        $field_value = $field->get_value_default_if_empty( $field_value );
1168
+		// if value is empty get the default value if defined
1169
+		$field_value = $field->get_value_default_if_empty( $field_value );
1170 1170
 
1171
-        return $field_value;
1172
-    }
1171
+		return $field_value;
1172
+	}
1173 1173
 
1174 1174
 
1175
-    // ---- Entry validation
1175
+	// ---- Entry validation
1176 1176
 
1177
-    /**
1178
-     * Add field keys that Gravity Forms expects.
1179
-     *
1180
-     * @see GFFormDisplay::validate()
1181
-     * @param  array $form GF Form
1182
-     * @return array       Modified GF Form
1183
-     */
1184
-    function gform_pre_validation( $form ) {
1177
+	/**
1178
+	 * Add field keys that Gravity Forms expects.
1179
+	 *
1180
+	 * @see GFFormDisplay::validate()
1181
+	 * @param  array $form GF Form
1182
+	 * @return array       Modified GF Form
1183
+	 */
1184
+	function gform_pre_validation( $form ) {
1185 1185
 
1186
-        if( ! $this->verify_nonce() ) {
1187
-            return $form;
1188
-        }
1186
+		if( ! $this->verify_nonce() ) {
1187
+			return $form;
1188
+		}
1189 1189
 
1190
-        // Fix PHP warning regarding undefined index.
1191
-        foreach ( $form['fields'] as &$field) {
1190
+		// Fix PHP warning regarding undefined index.
1191
+		foreach ( $form['fields'] as &$field) {
1192 1192
 
1193
-            // This is because we're doing admin form pretending to be front-end, so Gravity Forms
1194
-            // expects certain field array items to be set.
1195
-            foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1196
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1197
-            }
1193
+			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1194
+			// expects certain field array items to be set.
1195
+			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1196
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1197
+			}
1198 1198
 
1199
-            // unset emailConfirmEnabled for email type fields
1200
-           /* if( 'email' === $field['type'] && !empty( $field['emailConfirmEnabled'] ) ) {
1199
+			// unset emailConfirmEnabled for email type fields
1200
+		   /* if( 'email' === $field['type'] && !empty( $field['emailConfirmEnabled'] ) ) {
1201 1201
                 $field['emailConfirmEnabled'] = '';
1202 1202
             }*/
1203 1203
 
1204
-            switch( RGFormsModel::get_input_type( $field ) ) {
1204
+			switch( RGFormsModel::get_input_type( $field ) ) {
1205
+
1206
+				/**
1207
+				 * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
1208
+				 *
1209
+				 * What we have to do is set the value so that it doesn't get overwritten as empty on save and appears immediately in the Edit Entry screen again.
1210
+				 *
1211
+				 * @hack
1212
+				 */
1213
+				case 'fileupload':
1214
+
1215
+					// Set the previous value
1216
+					$entry = $this->get_entry();
1217
+
1218
+					$input_name = 'input_'.$field->id;
1219
+					$form_id = $form['id'];
1220
+
1221
+					$value = NULL;
1205 1222
 
1206
-                /**
1207
-                 * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
1208
-                 *
1209
-                 * What we have to do is set the value so that it doesn't get overwritten as empty on save and appears immediately in the Edit Entry screen again.
1210
-                 *
1211
-                 * @hack
1212
-                 */
1213
-                case 'fileupload':
1214
-
1215
-                    // Set the previous value
1216
-                    $entry = $this->get_entry();
1217
-
1218
-                    $input_name = 'input_'.$field->id;
1219
-                    $form_id = $form['id'];
1220
-
1221
-                    $value = NULL;
1222
-
1223
-                    // Use the previous entry value as the default.
1224
-                    if( isset( $entry[ $field->id ] ) ) {
1225
-                        $value = $entry[ $field->id ];
1226
-                    }
1223
+					// Use the previous entry value as the default.
1224
+					if( isset( $entry[ $field->id ] ) ) {
1225
+						$value = $entry[ $field->id ];
1226
+					}
1227 1227
 
1228
-                    // If this is a single upload file
1229
-                    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1230
-                        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1231
-                        $value = $file_path['url'];
1228
+					// If this is a single upload file
1229
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1230
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1231
+						$value = $file_path['url'];
1232 1232
 
1233
-                    } else {
1234
-
1235
-                        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1236
-                        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1237
-                        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1238
-
1239
-                    }
1240
-
1241
-                    if( rgar($field, "multipleFiles") ) {
1242
-
1243
-                        // If there are fresh uploads, process and merge them.
1244
-                        // Otherwise, use the passed values, which should be json-encoded array of URLs
1245
-                        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1246
-                            $value = empty( $value ) ? '[]' : $value;
1247
-                            $value = stripslashes_deep( $value );
1248
-                            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1249
-                        }
1233
+					} else {
1250 1234
 
1251
-                    } else {
1235
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1236
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1237
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1252 1238
 
1253
-                        // A file already exists when editing an entry
1254
-                        // We set this to solve issue when file upload fields are required.
1255
-                        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1239
+					}
1256 1240
 
1257
-                    }
1241
+					if( rgar($field, "multipleFiles") ) {
1258 1242
 
1259
-                    $this->entry[ $input_name ] = $value;
1260
-                    $_POST[ $input_name ] = $value;
1243
+						// If there are fresh uploads, process and merge them.
1244
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1245
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1246
+							$value = empty( $value ) ? '[]' : $value;
1247
+							$value = stripslashes_deep( $value );
1248
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1249
+						}
1261 1250
 
1262
-                    break;
1251
+					} else {
1263 1252
 
1264
-                case 'number':
1265
-                    // Fix "undefined index" issue at line 1286 in form_display.php
1266
-                    if( !isset( $_POST['input_'.$field->id ] ) ) {
1267
-                        $_POST['input_'.$field->id ] = NULL;
1268
-                    }
1269
-                    break;
1270
-                case 'captcha':
1271
-                    // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php
1272
-                    $_POST['recaptcha_challenge_field'] = NULL;
1273
-                    $_POST['recaptcha_response_field'] = NULL;
1274
-                    break;
1275
-            }
1253
+						// A file already exists when editing an entry
1254
+						// We set this to solve issue when file upload fields are required.
1255
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1276 1256
 
1277
-        }
1257
+					}
1278 1258
 
1279
-        return $form;
1280
-    }
1259
+					$this->entry[ $input_name ] = $value;
1260
+					$_POST[ $input_name ] = $value;
1281 1261
 
1262
+					break;
1282 1263
 
1283
-    /**
1284
-     * Process validation for a edit entry submission
1285
-     *
1286
-     * Sets the `is_valid` object var
1287
-     *
1288
-     * @return void
1289
-     */
1290
-    function validate() {
1264
+				case 'number':
1265
+					// Fix "undefined index" issue at line 1286 in form_display.php
1266
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1267
+						$_POST['input_'.$field->id ] = NULL;
1268
+					}
1269
+					break;
1270
+				case 'captcha':
1271
+					// Fix issue with recaptcha_check_answer() on line 1458 in form_display.php
1272
+					$_POST['recaptcha_challenge_field'] = NULL;
1273
+					$_POST['recaptcha_response_field'] = NULL;
1274
+					break;
1275
+			}
1276
+
1277
+		}
1278
+
1279
+		return $form;
1280
+	}
1291 1281
 
1292
-        /**
1293
-         * If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry
1294
-         * GF User Registration Add-on version > 3.x has a different class name
1295
-         * @since 1.16.2
1296
-         */
1297
-        if ( class_exists( 'GF_User_Registration' ) ) {
1298
-            remove_filter( 'gform_validation', array( GF_User_Registration::get_instance(), 'validate' ) );
1299
-        } else  if ( class_exists( 'GFUser' ) ) {
1300
-            remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) );
1301
-        }
1302 1282
 
1283
+	/**
1284
+	 * Process validation for a edit entry submission
1285
+	 *
1286
+	 * Sets the `is_valid` object var
1287
+	 *
1288
+	 * @return void
1289
+	 */
1290
+	function validate() {
1303 1291
 
1304
-        /**
1305
-         * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.
1306
-         * You can enter whatever you want!
1307
-         * We try validating, and customize the results using `self::custom_validation()`
1308
-         */
1309
-        add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1292
+		/**
1293
+		 * If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry
1294
+		 * GF User Registration Add-on version > 3.x has a different class name
1295
+		 * @since 1.16.2
1296
+		 */
1297
+		if ( class_exists( 'GF_User_Registration' ) ) {
1298
+			remove_filter( 'gform_validation', array( GF_User_Registration::get_instance(), 'validate' ) );
1299
+		} else  if ( class_exists( 'GFUser' ) ) {
1300
+			remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) );
1301
+		}
1310 1302
 
1311
-        // Needed by the validate funtion
1312
-        $failed_validation_page = NULL;
1313
-        $field_values = RGForms::post( 'gform_field_values' );
1314 1303
 
1315
-        // Prevent entry limit from running when editing an entry, also
1316
-        // prevent form scheduling from preventing editing
1317
-        unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1304
+		/**
1305
+		 * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.
1306
+		 * You can enter whatever you want!
1307
+		 * We try validating, and customize the results using `self::custom_validation()`
1308
+		 */
1309
+		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1318 1310
 
1319
-        // Hide fields depending on Edit Entry settings
1320
-        $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1311
+		// Needed by the validate funtion
1312
+		$failed_validation_page = NULL;
1313
+		$field_values = RGForms::post( 'gform_field_values' );
1321 1314
 
1322
-        $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1315
+		// Prevent entry limit from running when editing an entry, also
1316
+		// prevent form scheduling from preventing editing
1317
+		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1323 1318
 
1324
-        remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1325
-    }
1319
+		// Hide fields depending on Edit Entry settings
1320
+		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1326 1321
 
1322
+		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1327 1323
 
1328
-    /**
1329
-     * Make validation work for Edit Entry
1330
-     *
1331
-     * Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end
1332
-     * form pretending to be a back-end form), validate() doesn't know we _can't_ edit post
1333
-     * fields. This goes through all the fields and if they're an invalid post field, we
1334
-     * set them as valid. If there are still issues, we'll return false.
1335
-     *
1336
-     * @param  [type] $validation_results [description]
1337
-     * @return [type]                     [description]
1338
-     */
1339
-    function custom_validation( $validation_results ) {
1324
+		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1325
+	}
1326
+
1327
+
1328
+	/**
1329
+	 * Make validation work for Edit Entry
1330
+	 *
1331
+	 * Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end
1332
+	 * form pretending to be a back-end form), validate() doesn't know we _can't_ edit post
1333
+	 * fields. This goes through all the fields and if they're an invalid post field, we
1334
+	 * set them as valid. If there are still issues, we'll return false.
1335
+	 *
1336
+	 * @param  [type] $validation_results [description]
1337
+	 * @return [type]                     [description]
1338
+	 */
1339
+	function custom_validation( $validation_results ) {
1340 1340
 
1341
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1341
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1342 1342
 
1343
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1343
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1344 1344
 
1345
-        $gv_valid = true;
1345
+		$gv_valid = true;
1346 1346
 
1347
-        foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1347
+		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1348 1348
 
1349
-            $value = RGFormsModel::get_field_value( $field );
1350
-            $field_type = RGFormsModel::get_input_type( $field );
1349
+			$value = RGFormsModel::get_field_value( $field );
1350
+			$field_type = RGFormsModel::get_input_type( $field );
1351 1351
 
1352
-            // Validate always
1353
-            switch ( $field_type ) {
1352
+			// Validate always
1353
+			switch ( $field_type ) {
1354 1354
 
1355 1355
 
1356
-                case 'fileupload' :
1357
-                case 'post_image':
1356
+				case 'fileupload' :
1357
+				case 'post_image':
1358 1358
 
1359
-                    // in case nothing is uploaded but there are already files saved
1360
-                    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1361
-                        $field->failed_validation = false;
1362
-                        unset( $field->validation_message );
1363
-                    }
1359
+					// in case nothing is uploaded but there are already files saved
1360
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1361
+						$field->failed_validation = false;
1362
+						unset( $field->validation_message );
1363
+					}
1364 1364
 
1365
-                    // validate if multi file upload reached max number of files [maxFiles] => 2
1366
-                    if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) {
1365
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1366
+					if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) {
1367 1367
 
1368
-                        $input_name = 'input_' . $field->id;
1369
-                        //uploaded
1370
-                        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1368
+						$input_name = 'input_' . $field->id;
1369
+						//uploaded
1370
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1371 1371
 
1372
-                        //existent
1373
-                        $entry = $this->get_entry();
1374
-                        $value = NULL;
1375
-                        if( isset( $entry[ $field->id ] ) ) {
1376
-                            $value = json_decode( $entry[ $field->id ], true );
1377
-                        }
1372
+						//existent
1373
+						$entry = $this->get_entry();
1374
+						$value = NULL;
1375
+						if( isset( $entry[ $field->id ] ) ) {
1376
+							$value = json_decode( $entry[ $field->id ], true );
1377
+						}
1378 1378
 
1379
-                        // count uploaded files and existent entry files
1380
-                        $count_files = count( $file_names ) + count( $value );
1379
+						// count uploaded files and existent entry files
1380
+						$count_files = count( $file_names ) + count( $value );
1381 1381
 
1382
-                        if( $count_files > $field->maxFiles ) {
1383
-                            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1384
-                            $field->failed_validation = 1;
1385
-                            $gv_valid = false;
1382
+						if( $count_files > $field->maxFiles ) {
1383
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1384
+							$field->failed_validation = 1;
1385
+							$gv_valid = false;
1386 1386
 
1387
-                            // in case of error make sure the newest upload files are removed from the upload input
1388
-                            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1389
-                        }
1387
+							// in case of error make sure the newest upload files are removed from the upload input
1388
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1389
+						}
1390 1390
 
1391
-                    }
1391
+					}
1392 1392
 
1393 1393
 
1394
-                    break;
1394
+					break;
1395 1395
 
1396
-            }
1396
+			}
1397 1397
 
1398
-            // This field has failed validation.
1399
-            if( !empty( $field->failed_validation ) ) {
1398
+			// This field has failed validation.
1399
+			if( !empty( $field->failed_validation ) ) {
1400 1400
 
1401
-                do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );
1401
+				do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );
1402 1402
 
1403
-                switch ( $field_type ) {
1403
+				switch ( $field_type ) {
1404 1404
 
1405
-                    // Captchas don't need to be re-entered.
1406
-                    case 'captcha':
1405
+					// Captchas don't need to be re-entered.
1406
+					case 'captcha':
1407 1407
 
1408
-                        // Post Image fields aren't editable, so we un-fail them.
1409
-                    case 'post_image':
1410
-                        $field->failed_validation = false;
1411
-                        unset( $field->validation_message );
1412
-                        break;
1408
+						// Post Image fields aren't editable, so we un-fail them.
1409
+					case 'post_image':
1410
+						$field->failed_validation = false;
1411
+						unset( $field->validation_message );
1412
+						break;
1413 1413
 
1414
-                }
1414
+				}
1415 1415
 
1416
-                // You can't continue inside a switch, so we do it after.
1417
-                if( empty( $field->failed_validation ) ) {
1418
-                    continue;
1419
-                }
1416
+				// You can't continue inside a switch, so we do it after.
1417
+				if( empty( $field->failed_validation ) ) {
1418
+					continue;
1419
+				}
1420 1420
 
1421
-                // checks if the No Duplicates option is not validating entry against itself, since
1422
-                // we're editing a stored entry, it would also assume it's a duplicate.
1423
-                if( !empty( $field->noDuplicates ) ) {
1421
+				// checks if the No Duplicates option is not validating entry against itself, since
1422
+				// we're editing a stored entry, it would also assume it's a duplicate.
1423
+				if( !empty( $field->noDuplicates ) ) {
1424 1424
 
1425
-                    $entry = $this->get_entry();
1425
+					$entry = $this->get_entry();
1426 1426
 
1427
-                    // If the value of the entry is the same as the stored value
1428
-                    // Then we can assume it's not a duplicate, it's the same.
1429
-                    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1430
-                        //if value submitted was not changed, then don't validate
1431
-                        $field->failed_validation = false;
1427
+					// If the value of the entry is the same as the stored value
1428
+					// Then we can assume it's not a duplicate, it's the same.
1429
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1430
+						//if value submitted was not changed, then don't validate
1431
+						$field->failed_validation = false;
1432 1432
 
1433
-                        unset( $field->validation_message );
1433
+						unset( $field->validation_message );
1434 1434
 
1435
-                        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1435
+						do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1436 1436
 
1437
-                        continue;
1438
-                    }
1439
-                }
1437
+						continue;
1438
+					}
1439
+				}
1440 1440
 
1441
-                // if here then probably we are facing the validation 'At least one field must be filled out'
1442
-                if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1443
-                    unset( $field->validation_message );
1444
-	                $field->validation_message = false;
1445
-                    continue;
1446
-                }
1441
+				// if here then probably we are facing the validation 'At least one field must be filled out'
1442
+				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1443
+					unset( $field->validation_message );
1444
+					$field->validation_message = false;
1445
+					continue;
1446
+				}
1447 1447
 
1448
-                $gv_valid = false;
1448
+				$gv_valid = false;
1449 1449
 
1450
-            }
1450
+			}
1451 1451
 
1452
-        }
1452
+		}
1453 1453
 
1454
-        $validation_results['is_valid'] = $gv_valid;
1454
+		$validation_results['is_valid'] = $gv_valid;
1455 1455
 
1456
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1456
+		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1457 1457
 
1458
-        // We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1459
-        $this->form_after_validation = $validation_results['form'];
1458
+		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1459
+		$this->form_after_validation = $validation_results['form'];
1460 1460
 
1461
-        return $validation_results;
1462
-    }
1461
+		return $validation_results;
1462
+	}
1463 1463
 
1464 1464
 
1465
-    /**
1466
-     * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!
1467
-     * Get the current entry and set it if it's not yet set.
1468
-     * @return array Gravity Forms entry array
1469
-     */
1470
-    public function get_entry() {
1465
+	/**
1466
+	 * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!
1467
+	 * Get the current entry and set it if it's not yet set.
1468
+	 * @return array Gravity Forms entry array
1469
+	 */
1470
+	public function get_entry() {
1471 1471
 
1472
-        if( empty( $this->entry ) ) {
1473
-            // Get the database value of the entry that's being edited
1474
-            $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1475
-        }
1472
+		if( empty( $this->entry ) ) {
1473
+			// Get the database value of the entry that's being edited
1474
+			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1475
+		}
1476 1476
 
1477
-        return $this->entry;
1478
-    }
1477
+		return $this->entry;
1478
+	}
1479 1479
 
1480 1480
 
1481 1481
 
1482
-    // --- Filters
1482
+	// --- Filters
1483 1483
 
1484
-    /**
1485
-     * Get the Edit Entry fields as configured in the View
1486
-     *
1487
-     * @since 1.8
1488
-     *
1489
-     * @param int $view_id
1490
-     *
1491
-     * @return array Array of fields that are configured in the Edit tab in the Admin
1492
-     */
1493
-    private function get_configured_edit_fields( $form, $view_id ) {
1484
+	/**
1485
+	 * Get the Edit Entry fields as configured in the View
1486
+	 *
1487
+	 * @since 1.8
1488
+	 *
1489
+	 * @param int $view_id
1490
+	 *
1491
+	 * @return array Array of fields that are configured in the Edit tab in the Admin
1492
+	 */
1493
+	private function get_configured_edit_fields( $form, $view_id ) {
1494 1494
 
1495
-        // Get all fields for form
1496
-        $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );
1495
+		// Get all fields for form
1496
+		$properties = GravityView_View_Data::getInstance()->get_fields( $view_id );
1497 1497
 
1498
-        // If edit tab not yet configured, show all fields
1499
-        $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1498
+		// If edit tab not yet configured, show all fields
1499
+		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1500 1500
 
1501
-        // Show hidden fields as text fields
1502
-        $form = $this->fix_survey_fields( $form );
1501
+		// Show hidden fields as text fields
1502
+		$form = $this->fix_survey_fields( $form );
1503 1503
 
1504
-        // Hide fields depending on admin settings
1505
-        $fields = $this->filter_fields( $form['fields'], $edit_fields );
1504
+		// Hide fields depending on admin settings
1505
+		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1506 1506
 
1507
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1508
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1507
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1508
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1509 1509
 
1510
-        /**
1511
-         * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
1512
-         * @since 1.17
1513
-         * @param GF_Field[] $fields Gravity Forms form fields
1514
-         * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration
1515
-         * @param array $form GF Form array (`fields` key modified to have only fields configured to show in Edit Entry)
1516
-         * @param int $view_id View ID
1517
-         */
1518
-        $fields = apply_filters( 'gravityview/edit_entry/form_fields', $fields, $edit_fields, $form, $view_id );
1510
+		/**
1511
+		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
1512
+		 * @since 1.17
1513
+		 * @param GF_Field[] $fields Gravity Forms form fields
1514
+		 * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration
1515
+		 * @param array $form GF Form array (`fields` key modified to have only fields configured to show in Edit Entry)
1516
+		 * @param int $view_id View ID
1517
+		 */
1518
+		$fields = apply_filters( 'gravityview/edit_entry/form_fields', $fields, $edit_fields, $form, $view_id );
1519 1519
 
1520
-        return $fields;
1521
-    }
1520
+		return $fields;
1521
+	}
1522 1522
 
1523
-    /**
1524
-     * Make sure Survey fields accept pre-populating values; otherwise existing values won't be filled-in
1525
-     *
1526
-     * @since 1.16.4
1527
-     *
1528
-     * @param array $form
1529
-     *
1530
-     * @return array Form, with all fields set to `allowsPrepopulate => true`
1531
-     */
1532
-    private function fix_survey_fields( $form ) {
1523
+	/**
1524
+	 * Make sure Survey fields accept pre-populating values; otherwise existing values won't be filled-in
1525
+	 *
1526
+	 * @since 1.16.4
1527
+	 *
1528
+	 * @param array $form
1529
+	 *
1530
+	 * @return array Form, with all fields set to `allowsPrepopulate => true`
1531
+	 */
1532
+	private function fix_survey_fields( $form ) {
1533 1533
 
1534
-        /** @var GF_Field $field */
1535
-        foreach( $form['fields'] as &$field ) {
1536
-            $field->allowsPrepopulate = true;
1537
-        }
1534
+		/** @var GF_Field $field */
1535
+		foreach( $form['fields'] as &$field ) {
1536
+			$field->allowsPrepopulate = true;
1537
+		}
1538 1538
 
1539
-        return $form;
1540
-    }
1539
+		return $form;
1540
+	}
1541 1541
     
1542 1542
 
1543
-    /**
1544
-     * Filter area fields based on specified conditions
1545
-     *  - This filter removes the fields that have calculation configured
1546
-     *
1547
-     * @uses GravityView_Edit_Entry::user_can_edit_field() Check caps
1548
-     * @access private
1549
-     * @param GF_Field[] $fields
1550
-     * @param array $configured_fields
1551
-     * @since  1.5
1552
-     * @return array $fields
1553
-     */
1554
-    private function filter_fields( $fields, $configured_fields ) {
1555
-
1556
-        if( empty( $fields ) || !is_array( $fields ) ) {
1557
-            return $fields;
1558
-        }
1559
-
1560
-        $edit_fields = array();
1561
-
1562
-        $field_type_blacklist = array(
1563
-            'page',
1564
-        );
1565
-
1566
-	    /**
1567
-	     * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable.
1568
-	     * @since 1.9.1
1569
-         * @param boolean $hide_product_fields Whether to hide product fields in the editor.  Default: false
1570
-	     */
1571
-	    $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );
1572
-
1573
-	    if( $hide_product_fields ) {
1574
-		    $field_type_blacklist[] = 'option';
1575
-		    $field_type_blacklist[] = 'quantity';
1576
-            $field_type_blacklist[] = 'product';
1577
-            $field_type_blacklist[] = 'total';
1578
-            $field_type_blacklist[] = 'shipping';
1579
-            $field_type_blacklist[] = 'calculation';
1580
-	    }
1581
-
1582
-        // First, remove blacklist or calculation fields
1583
-        foreach ( $fields as $key => $field ) {
1584
-
1585
-            // Remove the fields that have calculation properties and keep them to be used later
1586
-            // @since 1.16.2
1587
-            if( $field->has_calculation() ) {
1588
-                $this->fields_with_calculation[] = $field;
1589
-                // don't remove the calculation fields on form render.
1590
-            }
1591
-
1592
-            // process total field after all fields have been saved
1593
-            if ( $field->type == 'total' ) {
1594
-                $this->total_fields[] = $field;
1595
-                unset( $fields[ $key ] );
1596
-            }
1597
-
1598
-            if( in_array( $field->type, $field_type_blacklist ) ) {
1599
-                unset( $fields[ $key ] );
1600
-            }
1601
-        }
1602
-
1603
-        // The Edit tab has not been configured, so we return all fields by default.
1604
-        if( empty( $configured_fields ) ) {
1605
-            return $fields;
1606
-        }
1607
-
1608
-        // The edit tab has been configured, so we loop through to configured settings
1609
-        foreach ( $configured_fields as $configured_field ) {
1610
-
1611
-	        /** @var GF_Field $field */
1612
-	        foreach ( $fields as $field ) {
1613
-
1614
-                if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1615
-                    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1616
-                    break;
1617
-                }
1618
-
1619
-            }
1620
-
1621
-        }
1622
-
1623
-        return $edit_fields;
1624
-
1625
-    }
1626
-
1627
-    /**
1628
-     * Override GF Form field properties with the ones defined on the View
1629
-     * @param  GF_Field $field GF Form field object
1630
-     * @param  array $setting  GV field options
1631
-     * @since  1.5
1632
-     * @return array
1633
-     */
1634
-    private function merge_field_properties( $field, $field_setting ) {
1635
-
1636
-        $return_field = $field;
1637
-
1638
-        if( empty( $field_setting['show_label'] ) ) {
1639
-            $return_field->label = '';
1640
-        } elseif ( !empty( $field_setting['custom_label'] ) ) {
1641
-            $return_field->label = $field_setting['custom_label'];
1642
-        }
1643
-
1644
-        if( !empty( $field_setting['custom_class'] ) ) {
1645
-            $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1646
-        }
1647
-
1648
-        /**
1649
-         * Normalize page numbers - avoid conflicts with page validation
1650
-         * @since 1.6
1651
-         */
1652
-        $return_field->pageNumber = 1;
1653
-
1654
-        return $return_field;
1655
-
1656
-    }
1657
-
1658
-    /**
1659
-     * Remove fields that shouldn't be visible based on the Gravity Forms adminOnly field property
1660
-     *
1661
-     * @since 1.9.1
1662
-     *
1663
-     * @param array|GF_Field[] $fields Gravity Forms form fields
1664
-     * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration
1665
-     * @param array $form GF Form array
1666
-     * @param int $view_id View ID
1667
-     *
1668
-     * @return array Possibly modified form array
1669
-     */
1670
-    function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1671
-
1672
-	    /**
1673
-         * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true
1674
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1675
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1676
-	     * @since 1.9.1
1677
-	     * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1678
-	     * @param array $form GF Form array
1679
-	     * @param int $view_id View ID
1680
-	     */
1681
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1682
-
1683
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1684
-            foreach( $fields as $k => $field ) {
1685
-                if( $field->adminOnly ) {
1686
-                    unset( $fields[ $k ] );
1687
-                }
1688
-            }
1689
-            return $fields;
1690
-        }
1691
-
1692
-	    foreach( $fields as &$field ) {
1693
-		    $field->adminOnly = false;
1694
-        }
1695
-
1696
-        return $fields;
1697
-    }
1698
-
1699
-    // --- Conditional Logic
1700
-
1701
-    /**
1702
-     * Remove the conditional logic rules from the form button and the form fields, if needed.
1703
-     *
1704
-     * @since 1.9
1705
-     *
1706
-     * @param array $form Gravity Forms form
1707
-     * @return array Modified form, if not using Conditional Logic
1708
-     */
1709
-    function filter_conditional_logic( $form ) {
1710
-
1711
-        /**
1712
-         * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
1713
-         * @since 1.9
1714
-         * @param bool $use_conditional_logic True: Gravity Forms will show/hide fields just like in the original form; False: conditional logic will be disabled and fields will be shown based on configuration. Default: true
1715
-         * @param array $form Gravity Forms form
1716
-         */
1717
-        $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1718
-
1719
-        if( $use_conditional_logic ) {
1720
-            return $form;
1721
-        }
1722
-
1723
-        foreach( $form['fields'] as &$field ) {
1724
-            /* @var GF_Field $field */
1725
-            $field->conditionalLogic = null;
1726
-        }
1727
-
1728
-        unset( $form['button']['conditionalLogic'] );
1729
-
1730
-        return $form;
1731
-
1732
-    }
1733
-
1734
-    /**
1735
-     * Disable the Gravity Forms conditional logic script and features on the Edit Entry screen
1736
-     *
1737
-     * @since 1.9
1738
-     *
1739
-     * @param $has_conditional_logic
1740
-     * @param $form
1741
-     * @return mixed|void
1742
-     */
1743
-    function manage_conditional_logic( $has_conditional_logic, $form ) {
1744
-
1745
-        if( ! $this->is_edit_entry() ) {
1746
-            return $has_conditional_logic;
1747
-        }
1748
-
1749
-        return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1750
-    }
1751
-
1752
-
1753
-    // --- User checks and nonces
1754
-
1755
-    /**
1756
-     * Check if the user can edit the entry
1757
-     *
1758
-     * - Is the nonce valid?
1759
-     * - Does the user have the right caps for the entry
1760
-     * - Is the entry in the trash?
1761
-     *
1762
-     * @todo Move to GVCommon
1763
-     *
1764
-     * @param  boolean $echo Show error messages in the form?
1765
-     * @return boolean        True: can edit form. False: nope.
1766
-     */
1767
-    function user_can_edit_entry( $echo = false ) {
1768
-
1769
-        $error = NULL;
1770
-
1771
-        /**
1772
-         *  1. Permalinks are turned off
1773
-         *  2. There are two entries embedded using oEmbed
1774
-         *  3. One of the entries has just been saved
1775
-         */
1776
-        if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1777
-
1778
-            $error = true;
1779
-
1780
-        }
1781
-
1782
-        if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1783
-
1784
-            $error = true;
1785
-
1786
-        } elseif( ! $this->verify_nonce() ) {
1787
-
1788
-            /**
1789
-             * If the Entry is embedded, there may be two entries on the same page.
1790
-             * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1791
-             */
1792
-            if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1793
-                $error = true;
1794
-            } else {
1795
-                $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1796
-            }
1543
+	/**
1544
+	 * Filter area fields based on specified conditions
1545
+	 *  - This filter removes the fields that have calculation configured
1546
+	 *
1547
+	 * @uses GravityView_Edit_Entry::user_can_edit_field() Check caps
1548
+	 * @access private
1549
+	 * @param GF_Field[] $fields
1550
+	 * @param array $configured_fields
1551
+	 * @since  1.5
1552
+	 * @return array $fields
1553
+	 */
1554
+	private function filter_fields( $fields, $configured_fields ) {
1555
+
1556
+		if( empty( $fields ) || !is_array( $fields ) ) {
1557
+			return $fields;
1558
+		}
1559
+
1560
+		$edit_fields = array();
1561
+
1562
+		$field_type_blacklist = array(
1563
+			'page',
1564
+		);
1565
+
1566
+		/**
1567
+		 * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable.
1568
+		 * @since 1.9.1
1569
+		 * @param boolean $hide_product_fields Whether to hide product fields in the editor.  Default: false
1570
+		 */
1571
+		$hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );
1572
+
1573
+		if( $hide_product_fields ) {
1574
+			$field_type_blacklist[] = 'option';
1575
+			$field_type_blacklist[] = 'quantity';
1576
+			$field_type_blacklist[] = 'product';
1577
+			$field_type_blacklist[] = 'total';
1578
+			$field_type_blacklist[] = 'shipping';
1579
+			$field_type_blacklist[] = 'calculation';
1580
+		}
1581
+
1582
+		// First, remove blacklist or calculation fields
1583
+		foreach ( $fields as $key => $field ) {
1584
+
1585
+			// Remove the fields that have calculation properties and keep them to be used later
1586
+			// @since 1.16.2
1587
+			if( $field->has_calculation() ) {
1588
+				$this->fields_with_calculation[] = $field;
1589
+				// don't remove the calculation fields on form render.
1590
+			}
1591
+
1592
+			// process total field after all fields have been saved
1593
+			if ( $field->type == 'total' ) {
1594
+				$this->total_fields[] = $field;
1595
+				unset( $fields[ $key ] );
1596
+			}
1597
+
1598
+			if( in_array( $field->type, $field_type_blacklist ) ) {
1599
+				unset( $fields[ $key ] );
1600
+			}
1601
+		}
1602
+
1603
+		// The Edit tab has not been configured, so we return all fields by default.
1604
+		if( empty( $configured_fields ) ) {
1605
+			return $fields;
1606
+		}
1607
+
1608
+		// The edit tab has been configured, so we loop through to configured settings
1609
+		foreach ( $configured_fields as $configured_field ) {
1610
+
1611
+			/** @var GF_Field $field */
1612
+			foreach ( $fields as $field ) {
1613
+
1614
+				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1615
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1616
+					break;
1617
+				}
1797 1618
 
1798
-        }
1799
-
1800
-        if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1801
-            $error = __( 'You do not have permission to edit this entry.', 'gravityview');
1802
-        }
1803
-
1804
-        if( $this->entry['status'] === 'trash' ) {
1805
-            $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1806
-        }
1619
+			}
1807 1620
 
1808
-        // No errors; everything's fine here!
1809
-        if( empty( $error ) ) {
1810
-            return true;
1811
-        }
1621
+		}
1812 1622
 
1813
-        if( $echo && $error !== true ) {
1623
+		return $edit_fields;
1814 1624
 
1815
-	        $error = esc_html( $error );
1625
+	}
1816 1626
 
1817
-	        /**
1818
-	         * @since 1.9
1819
-	         */
1820
-	        if ( ! empty( $this->entry ) ) {
1821
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1822
-	        }
1627
+	/**
1628
+	 * Override GF Form field properties with the ones defined on the View
1629
+	 * @param  GF_Field $field GF Form field object
1630
+	 * @param  array $setting  GV field options
1631
+	 * @since  1.5
1632
+	 * @return array
1633
+	 */
1634
+	private function merge_field_properties( $field, $field_setting ) {
1823 1635
 
1824
-            echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1825
-        }
1636
+		$return_field = $field;
1826 1637
 
1827
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1638
+		if( empty( $field_setting['show_label'] ) ) {
1639
+			$return_field->label = '';
1640
+		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1641
+			$return_field->label = $field_setting['custom_label'];
1642
+		}
1828 1643
 
1829
-        return false;
1830
-    }
1644
+		if( !empty( $field_setting['custom_class'] ) ) {
1645
+			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1646
+		}
1831 1647
 
1648
+		/**
1649
+		 * Normalize page numbers - avoid conflicts with page validation
1650
+		 * @since 1.6
1651
+		 */
1652
+		$return_field->pageNumber = 1;
1832 1653
 
1833
-    /**
1834
-     * Check whether a field is editable by the current user, and optionally display an error message
1835
-     * @uses  GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities
1836
-     * @param  array  $field Field or field settings array
1837
-     * @param  boolean $echo  Whether to show error message telling user they aren't allowed
1838
-     * @return boolean         True: user can edit the current field; False: nope, they can't.
1839
-     */
1840
-    private function user_can_edit_field( $field, $echo = false ) {
1841
-
1842
-        $error = NULL;
1654
+		return $return_field;
1843 1655
 
1844
-        if( ! $this->check_user_cap_edit_field( $field ) ) {
1845
-            $error = __( 'You do not have permission to edit this field.', 'gravityview');
1846
-        }
1656
+	}
1847 1657
 
1848
-        // No errors; everything's fine here!
1849
-        if( empty( $error ) ) {
1850
-            return true;
1851
-        }
1658
+	/**
1659
+	 * Remove fields that shouldn't be visible based on the Gravity Forms adminOnly field property
1660
+	 *
1661
+	 * @since 1.9.1
1662
+	 *
1663
+	 * @param array|GF_Field[] $fields Gravity Forms form fields
1664
+	 * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration
1665
+	 * @param array $form GF Form array
1666
+	 * @param int $view_id View ID
1667
+	 *
1668
+	 * @return array Possibly modified form array
1669
+	 */
1670
+	function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1671
+
1672
+		/**
1673
+		 * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true
1674
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1675
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1676
+		 * @since 1.9.1
1677
+		 * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1678
+		 * @param array $form GF Form array
1679
+		 * @param int $view_id View ID
1680
+		 */
1681
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1682
+
1683
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1684
+			foreach( $fields as $k => $field ) {
1685
+				if( $field->adminOnly ) {
1686
+					unset( $fields[ $k ] );
1687
+				}
1688
+			}
1689
+			return $fields;
1690
+		}
1852 1691
 
1853
-        if( $echo ) {
1854
-            echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
1855
-        }
1856
-
1857
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1692
+		foreach( $fields as &$field ) {
1693
+			$field->adminOnly = false;
1694
+		}
1858 1695
 
1859
-        return false;
1696
+		return $fields;
1697
+	}
1860 1698
 
1861
-    }
1699
+	// --- Conditional Logic
1862 1700
 
1701
+	/**
1702
+	 * Remove the conditional logic rules from the form button and the form fields, if needed.
1703
+	 *
1704
+	 * @since 1.9
1705
+	 *
1706
+	 * @param array $form Gravity Forms form
1707
+	 * @return array Modified form, if not using Conditional Logic
1708
+	 */
1709
+	function filter_conditional_logic( $form ) {
1863 1710
 
1864
-    /**
1865
-     * checks if user has permissions to edit a specific field
1866
-     *
1867
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!
1868
-     *
1869
-     * @param  [type] $field [description]
1870
-     * @return bool
1871
-     */
1872
-    private function check_user_cap_edit_field( $field ) {
1711
+		/**
1712
+		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
1713
+		 * @since 1.9
1714
+		 * @param bool $use_conditional_logic True: Gravity Forms will show/hide fields just like in the original form; False: conditional logic will be disabled and fields will be shown based on configuration. Default: true
1715
+		 * @param array $form Gravity Forms form
1716
+		 */
1717
+		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1873 1718
 
1874
-        // If they can edit any entries (as defined in Gravity Forms), we're good.
1875
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1876
-            return true;
1877
-        }
1719
+		if( $use_conditional_logic ) {
1720
+			return $form;
1721
+		}
1878 1722
 
1879
-        $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
1723
+		foreach( $form['fields'] as &$field ) {
1724
+			/* @var GF_Field $field */
1725
+			$field->conditionalLogic = null;
1726
+		}
1880 1727
 
1881
-        // If the field has custom editing capaibilities set, check those
1882
-        if( $field_cap ) {
1883
-            return GVCommon::has_cap( $field['allow_edit_cap'] );
1884
-        }
1885
-
1886
-        return false;
1887
-    }
1728
+		unset( $form['button']['conditionalLogic'] );
1888 1729
 
1730
+		return $form;
1889 1731
 
1890
-    /**
1891
-     * Is the current nonce valid for editing the entry?
1892
-     * @return boolean
1893
-     */
1894
-    public function verify_nonce() {
1732
+	}
1733
+
1734
+	/**
1735
+	 * Disable the Gravity Forms conditional logic script and features on the Edit Entry screen
1736
+	 *
1737
+	 * @since 1.9
1738
+	 *
1739
+	 * @param $has_conditional_logic
1740
+	 * @param $form
1741
+	 * @return mixed|void
1742
+	 */
1743
+	function manage_conditional_logic( $has_conditional_logic, $form ) {
1895 1744
 
1896
-        // Verify form submitted for editing single
1897
-        if( $this->is_edit_entry_submission() ) {
1898
-            $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
1899
-        }
1745
+		if( ! $this->is_edit_entry() ) {
1746
+			return $has_conditional_logic;
1747
+		}
1900 1748
 
1901
-        // Verify
1902
-        else if( ! $this->is_edit_entry() ) {
1903
-            $valid = false;
1904
-        }
1749
+		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1750
+	}
1751
+
1752
+
1753
+	// --- User checks and nonces
1754
+
1755
+	/**
1756
+	 * Check if the user can edit the entry
1757
+	 *
1758
+	 * - Is the nonce valid?
1759
+	 * - Does the user have the right caps for the entry
1760
+	 * - Is the entry in the trash?
1761
+	 *
1762
+	 * @todo Move to GVCommon
1763
+	 *
1764
+	 * @param  boolean $echo Show error messages in the form?
1765
+	 * @return boolean        True: can edit form. False: nope.
1766
+	 */
1767
+	function user_can_edit_entry( $echo = false ) {
1905 1768
 
1906
-        else {
1907
-            $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1908
-        }
1769
+		$error = NULL;
1909 1770
 
1910
-        /**
1911
-         * @filter `gravityview/edit_entry/verify_nonce` Override Edit Entry nonce validation. Return true to declare nonce valid.
1912
-         * @since 1.13
1913
-         * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated
1914
-         * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry
1915
-         */
1916
-        $valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field );
1771
+		/**
1772
+		 *  1. Permalinks are turned off
1773
+		 *  2. There are two entries embedded using oEmbed
1774
+		 *  3. One of the entries has just been saved
1775
+		 */
1776
+		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1917 1777
 
1918
-        return $valid;
1919
-    }
1778
+			$error = true;
1779
+
1780
+		}
1781
+
1782
+		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1783
+
1784
+			$error = true;
1785
+
1786
+		} elseif( ! $this->verify_nonce() ) {
1787
+
1788
+			/**
1789
+			 * If the Entry is embedded, there may be two entries on the same page.
1790
+			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1791
+			 */
1792
+			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1793
+				$error = true;
1794
+			} else {
1795
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1796
+			}
1797
+
1798
+		}
1799
+
1800
+		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1801
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
1802
+		}
1803
+
1804
+		if( $this->entry['status'] === 'trash' ) {
1805
+			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1806
+		}
1807
+
1808
+		// No errors; everything's fine here!
1809
+		if( empty( $error ) ) {
1810
+			return true;
1811
+		}
1812
+
1813
+		if( $echo && $error !== true ) {
1814
+
1815
+			$error = esc_html( $error );
1816
+
1817
+			/**
1818
+			 * @since 1.9
1819
+			 */
1820
+			if ( ! empty( $this->entry ) ) {
1821
+				$error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1822
+			}
1823
+
1824
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1825
+		}
1826
+
1827
+		do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1828
+
1829
+		return false;
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * Check whether a field is editable by the current user, and optionally display an error message
1835
+	 * @uses  GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities
1836
+	 * @param  array  $field Field or field settings array
1837
+	 * @param  boolean $echo  Whether to show error message telling user they aren't allowed
1838
+	 * @return boolean         True: user can edit the current field; False: nope, they can't.
1839
+	 */
1840
+	private function user_can_edit_field( $field, $echo = false ) {
1841
+
1842
+		$error = NULL;
1843
+
1844
+		if( ! $this->check_user_cap_edit_field( $field ) ) {
1845
+			$error = __( 'You do not have permission to edit this field.', 'gravityview');
1846
+		}
1847
+
1848
+		// No errors; everything's fine here!
1849
+		if( empty( $error ) ) {
1850
+			return true;
1851
+		}
1852
+
1853
+		if( $echo ) {
1854
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
1855
+		}
1856
+
1857
+		do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1858
+
1859
+		return false;
1860
+
1861
+	}
1862
+
1863
+
1864
+	/**
1865
+	 * checks if user has permissions to edit a specific field
1866
+	 *
1867
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!
1868
+	 *
1869
+	 * @param  [type] $field [description]
1870
+	 * @return bool
1871
+	 */
1872
+	private function check_user_cap_edit_field( $field ) {
1873
+
1874
+		// If they can edit any entries (as defined in Gravity Forms), we're good.
1875
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1876
+			return true;
1877
+		}
1878
+
1879
+		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
1880
+
1881
+		// If the field has custom editing capaibilities set, check those
1882
+		if( $field_cap ) {
1883
+			return GVCommon::has_cap( $field['allow_edit_cap'] );
1884
+		}
1885
+
1886
+		return false;
1887
+	}
1888
+
1889
+
1890
+	/**
1891
+	 * Is the current nonce valid for editing the entry?
1892
+	 * @return boolean
1893
+	 */
1894
+	public function verify_nonce() {
1895
+
1896
+		// Verify form submitted for editing single
1897
+		if( $this->is_edit_entry_submission() ) {
1898
+			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
1899
+		}
1900
+
1901
+		// Verify
1902
+		else if( ! $this->is_edit_entry() ) {
1903
+			$valid = false;
1904
+		}
1905
+
1906
+		else {
1907
+			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1908
+		}
1909
+
1910
+		/**
1911
+		 * @filter `gravityview/edit_entry/verify_nonce` Override Edit Entry nonce validation. Return true to declare nonce valid.
1912
+		 * @since 1.13
1913
+		 * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated
1914
+		 * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry
1915
+		 */
1916
+		$valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field );
1917
+
1918
+		return $valid;
1919
+	}
1920 1920
 
1921 1921
 
1922 1922
 
Please login to merge, or discard this patch.
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
     function load() {
120 120
 
121 121
         /** @define "GRAVITYVIEW_DIR" "../../../" */
122
-        include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
122
+        include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
123 123
 
124 124
         // Don't display an embedded form when editing an entry
125 125
         add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
126 126
         add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
127 127
 
128 128
         // Stop Gravity Forms processing what is ours!
129
-        add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
129
+        add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
130 130
 
131
-        add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
131
+        add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
132 132
 
133 133
         add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
134 134
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
140 140
 
141 141
         // Add fields expected by GFFormDisplay::validate()
142
-        add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
142
+        add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
143 143
 
144 144
     }
145 145
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      * @return void
155 155
      */
156 156
     function prevent_render_form() {
157
-        if( $this->is_edit_entry() ) {
158
-            if( 'wp_head' === current_filter() ) {
157
+        if ( $this->is_edit_entry() ) {
158
+            if ( 'wp_head' === current_filter() ) {
159 159
                 add_filter( 'gform_shortcode_form', '__return_empty_string' );
160 160
             } else {
161 161
                 remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
      */
171 171
     function prevent_maybe_process_form() {
172 172
 
173
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
173
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
174 174
 
175
-        if( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
176
-            remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
175
+        if ( $this->is_edit_entry_submission() && $this->verify_nonce() ) {
176
+            remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
177 177
         }
178 178
     }
179 179
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function is_edit_entry() {
185 185
 
186
-        $gf_page = function_exists('rgpost') && ( 'entry' === rgget( 'view' ) && isset( $_GET['edit'] ) || rgpost( 'action' ) === 'update' );
186
+        $gf_page = function_exists( 'rgpost' ) && ( 'entry' === rgget( 'view' ) && isset( $_GET[ 'edit' ] ) || rgpost( 'action' ) === 'update' );
187 187
 
188 188
         return $gf_page;
189 189
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @return boolean
195 195
 	 */
196 196
 	public function is_edit_entry_submission() {
197
-		return !empty( $_POST[ self::$nonce_field ] );
197
+		return ! empty( $_POST[ self::$nonce_field ] );
198 198
 	}
199 199
 
200 200
     /**
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 
206 206
 
207 207
         $entries = $gravityview_view->getEntries();
208
-	    self::$original_entry = $entries[0];
209
-	    $this->entry = $entries[0];
208
+	    self::$original_entry = $entries[ 0 ];
209
+	    $this->entry = $entries[ 0 ];
210 210
 
211 211
         self::$original_form = $gravityview_view->getForm();
212 212
         $this->form = $gravityview_view->getForm();
213 213
         $this->form_id = $gravityview_view->getFormId();
214 214
         $this->view_id = $gravityview_view->getViewId();
215 215
 
216
-        self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
216
+        self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
217 217
     }
218 218
 
219 219
 
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
         $this->setup_vars();
234 234
 
235 235
         // Multiple Views embedded, don't proceed if nonce fails
236
-        if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) {
236
+        if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) {
237 237
             return;
238 238
         }
239 239
 
240 240
         // Sorry, you're not allowed here.
241
-        if( false === $this->user_can_edit_entry( true ) ) {
241
+        if ( false === $this->user_can_edit_entry( true ) ) {
242 242
             return;
243 243
         }
244 244
 
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
     function print_scripts() {
259 259
         $gravityview_view = GravityView_View::getInstance();
260 260
 
261
-        wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
261
+        wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
262 262
 
263
-        GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
263
+        GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
264 264
 
265 265
         // Sack is required for images
266 266
         wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );
@@ -272,32 +272,32 @@  discard block
 block discarded – undo
272 272
      */
273 273
     function process_save() {
274 274
 
275
-        if( empty( $_POST ) ) {
275
+        if ( empty( $_POST ) ) {
276 276
             return;
277 277
         }
278 278
 
279 279
         // Make sure the entry, view, and form IDs are all correct
280 280
         $valid = $this->verify_nonce();
281 281
 
282
-        if( !$valid ) {
283
-            do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
282
+        if ( ! $valid ) {
283
+            do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );
284 284
             return;
285 285
         }
286 286
 
287
-        if( $this->entry['id'] !== $_POST['lid'] ) {
288
-            do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
287
+        if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
288
+            do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );
289 289
             return;
290 290
         }
291 291
 
292
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
292
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
293 293
 
294 294
         $this->process_save_process_files( $this->form_id );
295 295
 
296 296
         $this->validate();
297 297
 
298
-        if( $this->is_valid ) {
298
+        if ( $this->is_valid ) {
299 299
 
300
-            do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
300
+            do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' );
301 301
 
302 302
             /**
303 303
              * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields
@@ -307,12 +307,12 @@  discard block
 block discarded – undo
307 307
             /**
308 308
              * @hack to avoid the capability validation of the method save_lead for GF 1.9+
309 309
              */
310
-            unset( $_GET['page'] );
310
+            unset( $_GET[ 'page' ] );
311 311
 
312 312
             GFFormsModel::save_lead( $form, $this->entry );
313 313
 
314 314
             // If there's a post associated with the entry, process post fields
315
-            if( !empty( $this->entry['post_id'] ) ) {
315
+            if ( ! empty( $this->entry[ 'post_id' ] ) ) {
316 316
                 $this->maybe_update_post_fields( $form );
317 317
             }
318 318
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
              * @param array $form Gravity Forms form array
328 328
              * @param string $entry_id Numeric ID of the entry that was updated
329 329
              */
330
-            do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );
330
+            do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] );
331 331
         }
332 332
 
333 333
     } // process_save
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
      * @return mixed
362 362
      */
363 363
     public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
364
-        if( ! $this->is_edit_entry() ) {
364
+        if ( ! $this->is_edit_entry() ) {
365 365
             return $plupload_init;
366 366
         }
367 367
 
368
-        $plupload_init['gf_vars']['max_files'] = 0;
368
+        $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
369 369
 
370 370
         return $plupload_init;
371 371
     }
@@ -379,19 +379,19 @@  discard block
 block discarded – undo
379 379
 
380 380
         $form = $this->form;
381 381
 
382
-        foreach( $form['fields'] as $k => &$field ) {
382
+        foreach ( $form[ 'fields' ] as $k => &$field ) {
383 383
 
384 384
             // Remove the fields with calculation formulas before save to avoid conflicts with GF logic
385 385
             // @since 1.16.3
386
-            if( $field->has_calculation() ) {
387
-                unset( $form['fields'][ $k ] );
386
+            if ( $field->has_calculation() ) {
387
+                unset( $form[ 'fields' ][ $k ] );
388 388
             }
389 389
 
390 390
             $field->adminOnly = false;
391 391
 
392
-            if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
393
-                foreach( $field->inputs as $key => $input ) {
394
-                    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
392
+            if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
393
+                foreach ( $field->inputs as $key => $input ) {
394
+                    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
395 395
                 }
396 396
             }
397 397
         }
@@ -405,20 +405,20 @@  discard block
 block discarded – undo
405 405
         $update = false;
406 406
 
407 407
         // get the most up to date entry values
408
-        $entry = GFAPI::get_entry( $this->entry['id'] );
408
+        $entry = GFAPI::get_entry( $this->entry[ 'id' ] );
409 409
 
410
-        if( !empty( $this->fields_with_calculation ) ) {
410
+        if ( ! empty( $this->fields_with_calculation ) ) {
411 411
             $update = true;
412 412
             foreach ( $this->fields_with_calculation as $calc_field ) {
413 413
                 $inputs = $calc_field->get_entry_inputs();
414 414
                 if ( is_array( $inputs ) ) {
415 415
                     foreach ( $inputs as $input ) {
416
-                        $input_name = 'input_' . str_replace( '.', '_', $input['id'] );
417
-                        $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
416
+                        $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
417
+                        $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry );
418 418
                     }
419 419
                 } else {
420
-                    $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
421
-                    $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
420
+                    $input_name = 'input_' . str_replace( '.', '_', $calc_field->id );
421
+                    $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry );
422 422
                 }
423 423
             }
424 424
 
@@ -428,16 +428,16 @@  discard block
 block discarded – undo
428 428
         if ( ! empty( $this->total_fields ) ) {
429 429
             $update = true;
430 430
             foreach ( $this->total_fields as $total_field ) {
431
-                $input_name = 'input_' . str_replace( '.', '_', $total_field->id);
432
-                $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry );
431
+                $input_name = 'input_' . str_replace( '.', '_', $total_field->id );
432
+                $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry[ 'id' ], $entry );
433 433
             }
434 434
         }
435 435
 
436
-        if( $update ) {
436
+        if ( $update ) {
437 437
 
438 438
             $return_entry = GFAPI::update_entry( $entry );
439 439
 
440
-            if( is_wp_error( $return_entry ) ) {
440
+            if ( is_wp_error( $return_entry ) ) {
441 441
                 do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry );
442 442
             } else {
443 443
                 do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' );
@@ -468,18 +468,18 @@  discard block
 block discarded – undo
468 468
 
469 469
         $input_name = 'input_' . $field_id;
470 470
 
471
-        if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
471
+        if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
472 472
 
473 473
             // We have a new image
474 474
 
475
-            $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
475
+            $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
476 476
 
477 477
             $ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
478 478
             $img_url = rgar( $ary, 0 );
479 479
 
480
-            $img_title       = count( $ary ) > 1 ? $ary[1] : '';
481
-            $img_caption     = count( $ary ) > 2 ? $ary[2] : '';
482
-            $img_description = count( $ary ) > 3 ? $ary[3] : '';
480
+            $img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
481
+            $img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
482
+            $img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
483 483
 
484 484
             $image_meta = array(
485 485
                 'post_excerpt' => $img_caption,
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 
489 489
             //adding title only if it is not empty. It will default to the file name if it is not in the array
490 490
             if ( ! empty( $img_title ) ) {
491
-                $image_meta['post_title'] = $img_title;
491
+                $image_meta[ 'post_title' ] = $img_title;
492 492
             }
493 493
 
494 494
             /**
@@ -503,22 +503,22 @@  discard block
 block discarded – undo
503 503
                 set_post_thumbnail( $post_id, $media_id );
504 504
             }
505 505
 
506
-        } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) {
506
+        } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) {
507 507
 
508 508
             // Same image although the image title, caption or description might have changed
509 509
 
510 510
             $ary = array();
511
-            if( ! empty( $entry[ $field_id ] ) ) {
511
+            if ( ! empty( $entry[ $field_id ] ) ) {
512 512
                 $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] );
513 513
             }
514 514
             $img_url = rgar( $ary, 0 );
515 515
 
516 516
             // is this really the same image or something went wrong ?
517
-            if( $img_url === $_POST[ $input_name ] ) {
517
+            if ( $img_url === $_POST[ $input_name ] ) {
518 518
 
519
-                $img_title       = rgar( $value, $field_id .'.1' );
520
-                $img_caption     = rgar( $value, $field_id .'.4' );
521
-                $img_description = rgar( $value, $field_id .'.7' );
519
+                $img_title       = rgar( $value, $field_id . '.1' );
520
+                $img_caption     = rgar( $value, $field_id . '.4' );
521
+                $img_description = rgar( $value, $field_id . '.7' );
522 522
 
523 523
                 $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : '';
524 524
 
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
      */
559 559
     private function maybe_update_post_fields( $form ) {
560 560
 
561
-        $post_id = $this->entry['post_id'];
561
+        $post_id = $this->entry[ 'post_id' ];
562 562
 
563 563
         // Security check
564
-        if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
565
-            do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );
564
+        if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
565
+            do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id );
566 566
             return;
567 567
         }
568 568
 
@@ -574,25 +574,25 @@  discard block
 block discarded – undo
574 574
 
575 575
             $field = RGFormsModel::get_field( $form, $field_id );
576 576
 
577
-            if( ! $field ) {
577
+            if ( ! $field ) {
578 578
                 continue;
579 579
             }
580 580
 
581
-            if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
581
+            if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
582 582
 
583 583
                 // Get the value of the field, including $_POSTed value
584 584
                 $value = RGFormsModel::get_field_value( $field );
585 585
 
586 586
                 // Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
587 587
                 $entry_tmp = $this->entry;
588
-                $entry_tmp["{$field_id}"] = $value;
588
+                $entry_tmp[ "{$field_id}" ] = $value;
589 589
 
590
-                switch( $field->type ) {
590
+                switch ( $field->type ) {
591 591
 
592 592
                     case 'post_title':
593 593
                         $post_title = $value;
594
-                        if( rgar( $form, 'postTitleTemplateEnabled' ) ) {
595
-                            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
594
+                        if ( rgar( $form, 'postTitleTemplateEnabled' ) ) {
595
+                            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
596 596
                         }
597 597
                         $updated_post->post_title = $post_title;
598 598
                         $updated_post->post_name  = $post_title;
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 
602 602
                     case 'post_content':
603 603
                         $post_content = $value;
604
-                        if( rgar( $form, 'postContentTemplateEnabled' ) ) {
605
-                            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
604
+                        if ( rgar( $form, 'postContentTemplateEnabled' ) ) {
605
+                            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
606 606
                         }
607 607
                         $updated_post->post_content = $post_content;
608 608
                         unset( $post_content );
@@ -616,19 +616,19 @@  discard block
 block discarded – undo
616 616
                     case 'post_category':
617 617
                         break;
618 618
                     case 'post_custom_field':
619
-                        if( ! empty( $field->customFieldTemplateEnabled ) ) {
619
+                        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
620 620
                             $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
621 621
                         }
622 622
 
623 623
                         $input_type = RGFormsModel::get_input_type( $field );
624 624
 
625 625
                         // Only certain custom field types are supported
626
-                        switch( $input_type ) {
626
+                        switch ( $input_type ) {
627 627
                             case 'fileupload':
628 628
                             case 'list':
629 629
                             case 'multiselect':
630
-                                if( ! is_string( $value ) ) {
631
-                                    $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value );
630
+                                if ( ! is_string( $value ) ) {
631
+                                    $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value );
632 632
                                 }
633 633
                             // break; left intentionally out
634 634
                             default:
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
                 }
645 645
 
646 646
                 // update entry after
647
-                $this->entry["{$field_id}"] = $value;
647
+                $this->entry[ "{$field_id}" ] = $value;
648 648
 
649 649
                 $update_entry = true;
650 650
 
@@ -653,25 +653,25 @@  discard block
 block discarded – undo
653 653
 
654 654
         }
655 655
 
656
-        if( $update_entry ) {
656
+        if ( $update_entry ) {
657 657
 
658 658
             $return_entry = GFAPI::update_entry( $this->entry );
659 659
 
660
-            if( is_wp_error( $return_entry ) ) {
660
+            if ( is_wp_error( $return_entry ) ) {
661 661
                do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) );
662 662
             } else {
663
-                do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );
663
+                do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' );
664 664
             }
665 665
 
666 666
         }
667 667
 
668 668
         $return_post = wp_update_post( $updated_post, true );
669 669
 
670
-        if( is_wp_error( $return_post ) ) {
670
+        if ( is_wp_error( $return_post ) ) {
671 671
             $return_post->add_data( $updated_post, '$updated_post' );
672 672
             do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) );
673 673
         } else {
674
-            do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post );
674
+            do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post );
675 675
         }
676 676
     }
677 677
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
         $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
702 702
 
703 703
         // replace conditional shortcodes
704
-        if( $do_shortcode ) {
704
+        if ( $do_shortcode ) {
705 705
             $output = do_shortcode( $output );
706 706
         }
707 707
 
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
      */
721 721
     function after_update() {
722 722
 
723
-        do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
724
-        do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] );
723
+        do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
724
+        do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] );
725 725
 
726 726
         // Re-define the entry now that we've updated it.
727
-        $entry = RGFormsModel::get_lead( $this->entry['id'] );
727
+        $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
728 728
 
729 729
         $entry = GFFormsModel::set_entry_meta( $entry, $this->form );
730 730
 
731 731
         // We need to clear the cache because Gravity Forms caches the field values, which
732 732
         // we have just updated.
733
-        foreach ($this->form['fields'] as $key => $field) {
734
-            GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
733
+        foreach ( $this->form[ 'fields' ] as $key => $field ) {
734
+            GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
735 735
         }
736 736
 
737 737
         $this->entry = $entry;
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 
750 750
         <div class="gv-edit-entry-wrapper"><?php
751 751
 
752
-            $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
752
+            $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
753 753
 
754 754
             /**
755 755
              * Fixes weird wpautop() issue
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
                      * @param string $edit_entry_title Modify the "Edit Entry" title
766 766
                      * @param GravityView_Edit_Entry_Render $this This object
767 767
                      */
768
-                    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
768
+                    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
769 769
 
770 770
                     echo esc_attr( $edit_entry_title );
771 771
             ?></span>
@@ -805,20 +805,20 @@  discard block
 block discarded – undo
805 805
      */
806 806
     private function maybe_print_message() {
807 807
 
808
-        if( rgpost('action') === 'update' ) {
808
+        if ( rgpost( 'action' ) === 'update' ) {
809 809
 
810 810
             $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );
811 811
 
812
-            if( ! $this->is_valid ){
812
+            if ( ! $this->is_valid ) {
813 813
 
814 814
                 // Keeping this compatible with Gravity Forms.
815
-                $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
816
-                $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
815
+                $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
816
+                $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
817 817
 
818
-                echo GVCommon::generate_notice( $message , 'gv-error' );
818
+                echo GVCommon::generate_notice( $message, 'gv-error' );
819 819
 
820 820
             } else {
821
-                $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' );
821
+                $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' );
822 822
 
823 823
                 /**
824 824
                  * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
                  * @param array $entry Gravity Forms entry array
829 829
                  * @param string $back_link URL to return to the original entry. @since 1.6
830 830
                  */
831
-                $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
831
+                $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
832 832
 
833 833
                 echo GVCommon::generate_notice( $message );
834 834
             }
@@ -852,24 +852,24 @@  discard block
 block discarded – undo
852 852
          */
853 853
         do_action( 'gravityview/edit-entry/render/before', $this );
854 854
 
855
-        add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
856
-        add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
855
+        add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
856
+        add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
857 857
         add_filter( 'gform_disable_view_counter', '__return_true' );
858 858
 
859 859
         add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
860 860
         add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
861 861
 
862
-        add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10, 3 );
862
+        add_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value' ), 10, 3 );
863 863
 
864 864
         // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
865
-        unset( $_GET['page'] );
865
+        unset( $_GET[ 'page' ] );
866 866
 
867 867
         // TODO: Verify multiple-page forms
868 868
         // TODO: Product fields are not editable
869 869
 
870
-        $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
870
+        $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
871 871
 
872
-        remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value'), 10 );
872
+        remove_filter( 'gform_field_value', array( $this, 'fix_survey_fields_value' ), 10 );
873 873
 	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
874 874
         remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
875 875
         remove_filter( 'gform_disable_view_counter', '__return_true' );
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
      */
903 903
     function fix_survey_fields_value( $value, $field, $name ) {
904 904
         
905
-        if( 'survey' === $field->type ) {
905
+        if ( 'survey' === $field->type ) {
906 906
 
907 907
 	        // We need to run through each survey row until we find a match for expected values
908 908
 	        foreach ( $this->entry as $field_id => $field_value ) {
@@ -911,11 +911,11 @@  discard block
 block discarded – undo
911 911
 			        continue;
912 912
 		        }
913 913
 
914
-		        if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) {
914
+		        if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) {
915 915
 			        list( $row_val, $col_val ) = explode( ':', $field_value, 2 );
916 916
 
917 917
 		            // If the $name matches the $row_val, we are processing the correct row
918
-			        if( $row_val === $name ) {
918
+			        if ( $row_val === $name ) {
919 919
 				        $value = $field_value;
920 920
 				        break;
921 921
 			        }
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
      * @return string
937 937
      */
938 938
     public function render_form_buttons() {
939
-        return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
939
+        return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
940 940
     }
941 941
 
942 942
 
@@ -956,17 +956,17 @@  discard block
 block discarded – undo
956 956
     public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
957 957
 
958 958
         // In case we have validated the form, use it to inject the validation results into the form render
959
-        if( isset( $this->form_after_validation ) ) {
959
+        if ( isset( $this->form_after_validation ) ) {
960 960
             $form = $this->form_after_validation;
961 961
         } else {
962
-            $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
962
+            $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
963 963
         }
964 964
 
965 965
         $form = $this->filter_conditional_logic( $form );
966 966
 
967 967
         // for now we don't support Save and Continue feature.
968
-        if( ! self::$supports_save_and_continue ) {
969
-	        unset( $form['save'] );
968
+        if ( ! self::$supports_save_and_continue ) {
969
+	        unset( $form[ 'save' ] );
970 970
         }
971 971
 
972 972
         return $form;
@@ -987,29 +987,29 @@  discard block
 block discarded – undo
987 987
      */
988 988
     function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
989 989
 
990
-        if( GFCommon::is_post_field( $field ) ) {
990
+        if ( GFCommon::is_post_field( $field ) ) {
991 991
 
992 992
             $message = null;
993 993
 
994 994
             // First, make sure they have the capability to edit the post.
995
-            if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
995
+            if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
996 996
 
997 997
                 /**
998 998
                  * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
999 999
                  * @param string $message The existing "You don't have permission..." text
1000 1000
                  */
1001
-                $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1001
+                $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1002 1002
 
1003
-            } elseif( null === get_post( $this->entry['post_id'] ) ) {
1003
+            } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1004 1004
                 /**
1005 1005
                  * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1006 1006
                  * @param string $message The existing "This field is not editable; the post no longer exists." text
1007 1007
                  */
1008
-                $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1008
+                $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1009 1009
             }
1010 1010
 
1011
-            if( $message ) {
1012
-                $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1011
+            if ( $message ) {
1012
+                $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1013 1013
             }
1014 1014
         }
1015 1015
 
@@ -1034,8 +1034,8 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
         // If the form has been submitted, then we don't need to pre-fill the values,
1036 1036
         // Except for fileupload type and when a field input is overridden- run always!!
1037
-        if(
1038
-            ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1037
+        if (
1038
+            ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1039 1039
             && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1040 1040
             || ! empty( $field_content )
1041 1041
             || in_array( $field->type, array( 'honeypot' ) )
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
         }
1046 1046
 
1047 1047
         // Turn on Admin-style display for file upload fields only
1048
-        if( 'fileupload' === $field->type ) {
1049
-            $_GET['page'] = 'gf_entries';
1048
+        if ( 'fileupload' === $field->type ) {
1049
+            $_GET[ 'page' ] = 'gf_entries';
1050 1050
         }
1051 1051
 
1052 1052
         // SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
          * @param mixed $field_value field value used to populate the input
1074 1074
          * @param GF_Field $field Gravity Forms field object
1075 1075
          */
1076
-        $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field );
1076
+        $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field );
1077 1077
 
1078 1078
 	    // Prevent any PHP warnings, like undefined index
1079 1079
 	    ob_start();
1080 1080
 
1081
-        if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1081
+        if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1082 1082
             /** @var GF_Field $gv_field */
1083 1083
             $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1084 1084
         } else {
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 	    // If there was output, it's an error
1090 1090
 	    $warnings = ob_get_clean();
1091 1091
 
1092
-	    if( !empty( $warnings ) ) {
1092
+	    if ( ! empty( $warnings ) ) {
1093 1093
 		    do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );
1094 1094
 	    }
1095 1095
 
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
          * We need the fileupload html field to render with the proper id
1099 1099
          *  ( <li id="field_80_16" ... > )
1100 1100
          */
1101
-        unset( $_GET['page'] );
1101
+        unset( $_GET[ 'page' ] );
1102 1102
 
1103 1103
         return $return;
1104 1104
     }
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
         $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1122 1122
 
1123 1123
         // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1124
-        if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1124
+        if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1125 1125
 
1126 1126
             $field_value = array();
1127 1127
 
@@ -1130,10 +1130,10 @@  discard block
 block discarded – undo
1130 1130
 
1131 1131
             foreach ( (array)$field->inputs as $input ) {
1132 1132
 
1133
-                $input_id = strval( $input['id'] );
1133
+                $input_id = strval( $input[ 'id' ] );
1134 1134
                 
1135 1135
                 if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1136
-                    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1136
+                    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1137 1137
                     $allow_pre_populated = false;
1138 1138
                 }
1139 1139
 
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
             $pre_value = $field->get_value_submission( array(), false );
1143 1143
 
1144
-            $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1144
+            $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1145 1145
 
1146 1146
         } else {
1147 1147
 
@@ -1152,13 +1152,13 @@  discard block
 block discarded – undo
1152 1152
 
1153 1153
             // saved field entry value (if empty, fallback to the pre-populated value, if exists)
1154 1154
             // or pre-populated value if not empty and set to override saved value
1155
-            $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;
1155
+            $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;
1156 1156
 
1157 1157
             // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1158
-            if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1158
+            if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1159 1159
                 $categories = array();
1160 1160
                 foreach ( explode( ',', $field_value ) as $cat_string ) {
1161
-                    $categories[] = GFCommon::format_post_category( $cat_string, true );
1161
+                    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1162 1162
                 }
1163 1163
                 $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1164 1164
             }
@@ -1183,12 +1183,12 @@  discard block
 block discarded – undo
1183 1183
      */
1184 1184
     function gform_pre_validation( $form ) {
1185 1185
 
1186
-        if( ! $this->verify_nonce() ) {
1186
+        if ( ! $this->verify_nonce() ) {
1187 1187
             return $form;
1188 1188
         }
1189 1189
 
1190 1190
         // Fix PHP warning regarding undefined index.
1191
-        foreach ( $form['fields'] as &$field) {
1191
+        foreach ( $form[ 'fields' ] as &$field ) {
1192 1192
 
1193 1193
             // This is because we're doing admin form pretending to be front-end, so Gravity Forms
1194 1194
             // expects certain field array items to be set.
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
                 $field['emailConfirmEnabled'] = '';
1202 1202
             }*/
1203 1203
 
1204
-            switch( RGFormsModel::get_input_type( $field ) ) {
1204
+            switch ( RGFormsModel::get_input_type( $field ) ) {
1205 1205
 
1206 1206
                 /**
1207 1207
                  * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
@@ -1215,37 +1215,37 @@  discard block
 block discarded – undo
1215 1215
                     // Set the previous value
1216 1216
                     $entry = $this->get_entry();
1217 1217
 
1218
-                    $input_name = 'input_'.$field->id;
1219
-                    $form_id = $form['id'];
1218
+                    $input_name = 'input_' . $field->id;
1219
+                    $form_id = $form[ 'id' ];
1220 1220
 
1221 1221
                     $value = NULL;
1222 1222
 
1223 1223
                     // Use the previous entry value as the default.
1224
-                    if( isset( $entry[ $field->id ] ) ) {
1224
+                    if ( isset( $entry[ $field->id ] ) ) {
1225 1225
                         $value = $entry[ $field->id ];
1226 1226
                     }
1227 1227
 
1228 1228
                     // If this is a single upload file
1229
-                    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1230
-                        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1231
-                        $value = $file_path['url'];
1229
+                    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1230
+                        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1231
+                        $value = $file_path[ 'url' ];
1232 1232
 
1233 1233
                     } else {
1234 1234
 
1235 1235
                         // Fix PHP warning on line 1498 of form_display.php for post_image fields
1236 1236
                         // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1237
-                        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1237
+                        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1238 1238
 
1239 1239
                     }
1240 1240
 
1241
-                    if( rgar($field, "multipleFiles") ) {
1241
+                    if ( rgar( $field, "multipleFiles" ) ) {
1242 1242
 
1243 1243
                         // If there are fresh uploads, process and merge them.
1244 1244
                         // Otherwise, use the passed values, which should be json-encoded array of URLs
1245
-                        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1245
+                        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1246 1246
                             $value = empty( $value ) ? '[]' : $value;
1247 1247
                             $value = stripslashes_deep( $value );
1248
-                            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1248
+                            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1249 1249
                         }
1250 1250
 
1251 1251
                     } else {
@@ -1263,14 +1263,14 @@  discard block
 block discarded – undo
1263 1263
 
1264 1264
                 case 'number':
1265 1265
                     // Fix "undefined index" issue at line 1286 in form_display.php
1266
-                    if( !isset( $_POST['input_'.$field->id ] ) ) {
1267
-                        $_POST['input_'.$field->id ] = NULL;
1266
+                    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1267
+                        $_POST[ 'input_' . $field->id ] = NULL;
1268 1268
                     }
1269 1269
                     break;
1270 1270
                 case 'captcha':
1271 1271
                     // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php
1272
-                    $_POST['recaptcha_challenge_field'] = NULL;
1273
-                    $_POST['recaptcha_response_field'] = NULL;
1272
+                    $_POST[ 'recaptcha_challenge_field' ] = NULL;
1273
+                    $_POST[ 'recaptcha_response_field' ] = NULL;
1274 1274
                     break;
1275 1275
             }
1276 1276
 
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
          * You can enter whatever you want!
1307 1307
          * We try validating, and customize the results using `self::custom_validation()`
1308 1308
          */
1309
-        add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1309
+        add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1310 1310
 
1311 1311
         // Needed by the validate funtion
1312 1312
         $failed_validation_page = NULL;
@@ -1314,14 +1314,14 @@  discard block
 block discarded – undo
1314 1314
 
1315 1315
         // Prevent entry limit from running when editing an entry, also
1316 1316
         // prevent form scheduling from preventing editing
1317
-        unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1317
+        unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1318 1318
 
1319 1319
         // Hide fields depending on Edit Entry settings
1320
-        $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1320
+        $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1321 1321
 
1322 1322
         $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1323 1323
 
1324
-        remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1324
+        remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1325 1325
     }
1326 1326
 
1327 1327
 
@@ -1338,13 +1338,13 @@  discard block
 block discarded – undo
1338 1338
      */
1339 1339
     function custom_validation( $validation_results ) {
1340 1340
 
1341
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1341
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );
1342 1342
 
1343
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1343
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );
1344 1344
 
1345 1345
         $gv_valid = true;
1346 1346
 
1347
-        foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1347
+        foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1348 1348
 
1349 1349
             $value = RGFormsModel::get_field_value( $field );
1350 1350
             $field_type = RGFormsModel::get_input_type( $field );
@@ -1357,35 +1357,35 @@  discard block
 block discarded – undo
1357 1357
                 case 'post_image':
1358 1358
 
1359 1359
                     // in case nothing is uploaded but there are already files saved
1360
-                    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1360
+                    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1361 1361
                         $field->failed_validation = false;
1362 1362
                         unset( $field->validation_message );
1363 1363
                     }
1364 1364
 
1365 1365
                     // validate if multi file upload reached max number of files [maxFiles] => 2
1366
-                    if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) {
1366
+                    if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) {
1367 1367
 
1368 1368
                         $input_name = 'input_' . $field->id;
1369 1369
                         //uploaded
1370
-                        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1370
+                        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1371 1371
 
1372 1372
                         //existent
1373 1373
                         $entry = $this->get_entry();
1374 1374
                         $value = NULL;
1375
-                        if( isset( $entry[ $field->id ] ) ) {
1375
+                        if ( isset( $entry[ $field->id ] ) ) {
1376 1376
                             $value = json_decode( $entry[ $field->id ], true );
1377 1377
                         }
1378 1378
 
1379 1379
                         // count uploaded files and existent entry files
1380 1380
                         $count_files = count( $file_names ) + count( $value );
1381 1381
 
1382
-                        if( $count_files > $field->maxFiles ) {
1382
+                        if ( $count_files > $field->maxFiles ) {
1383 1383
                             $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1384 1384
                             $field->failed_validation = 1;
1385 1385
                             $gv_valid = false;
1386 1386
 
1387 1387
                             // in case of error make sure the newest upload files are removed from the upload input
1388
-                            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1388
+                            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1389 1389
                         }
1390 1390
 
1391 1391
                     }
@@ -1396,7 +1396,7 @@  discard block
 block discarded – undo
1396 1396
             }
1397 1397
 
1398 1398
             // This field has failed validation.
1399
-            if( !empty( $field->failed_validation ) ) {
1399
+            if ( ! empty( $field->failed_validation ) ) {
1400 1400
 
1401 1401
                 do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );
1402 1402
 
@@ -1414,32 +1414,32 @@  discard block
 block discarded – undo
1414 1414
                 }
1415 1415
 
1416 1416
                 // You can't continue inside a switch, so we do it after.
1417
-                if( empty( $field->failed_validation ) ) {
1417
+                if ( empty( $field->failed_validation ) ) {
1418 1418
                     continue;
1419 1419
                 }
1420 1420
 
1421 1421
                 // checks if the No Duplicates option is not validating entry against itself, since
1422 1422
                 // we're editing a stored entry, it would also assume it's a duplicate.
1423
-                if( !empty( $field->noDuplicates ) ) {
1423
+                if ( ! empty( $field->noDuplicates ) ) {
1424 1424
 
1425 1425
                     $entry = $this->get_entry();
1426 1426
 
1427 1427
                     // If the value of the entry is the same as the stored value
1428 1428
                     // Then we can assume it's not a duplicate, it's the same.
1429
-                    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1429
+                    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1430 1430
                         //if value submitted was not changed, then don't validate
1431 1431
                         $field->failed_validation = false;
1432 1432
 
1433 1433
                         unset( $field->validation_message );
1434 1434
 
1435
-                        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1435
+                        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );
1436 1436
 
1437 1437
                         continue;
1438 1438
                     }
1439 1439
                 }
1440 1440
 
1441 1441
                 // if here then probably we are facing the validation 'At least one field must be filled out'
1442
-                if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1442
+                if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1443 1443
                     unset( $field->validation_message );
1444 1444
 	                $field->validation_message = false;
1445 1445
                     continue;
@@ -1451,12 +1451,12 @@  discard block
 block discarded – undo
1451 1451
 
1452 1452
         }
1453 1453
 
1454
-        $validation_results['is_valid'] = $gv_valid;
1454
+        $validation_results[ 'is_valid' ] = $gv_valid;
1455 1455
 
1456
-        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1456
+        do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );
1457 1457
 
1458 1458
         // We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1459
-        $this->form_after_validation = $validation_results['form'];
1459
+        $this->form_after_validation = $validation_results[ 'form' ];
1460 1460
 
1461 1461
         return $validation_results;
1462 1462
     }
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
      */
1470 1470
     public function get_entry() {
1471 1471
 
1472
-        if( empty( $this->entry ) ) {
1472
+        if ( empty( $this->entry ) ) {
1473 1473
             // Get the database value of the entry that's being edited
1474 1474
             $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1475 1475
         }
@@ -1496,13 +1496,13 @@  discard block
 block discarded – undo
1496 1496
         $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );
1497 1497
 
1498 1498
         // If edit tab not yet configured, show all fields
1499
-        $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1499
+        $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1500 1500
 
1501 1501
         // Show hidden fields as text fields
1502 1502
         $form = $this->fix_survey_fields( $form );
1503 1503
 
1504 1504
         // Hide fields depending on admin settings
1505
-        $fields = $this->filter_fields( $form['fields'], $edit_fields );
1505
+        $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1506 1506
 
1507 1507
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1508 1508
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
     private function fix_survey_fields( $form ) {
1533 1533
 
1534 1534
         /** @var GF_Field $field */
1535
-        foreach( $form['fields'] as &$field ) {
1535
+        foreach ( $form[ 'fields' ] as &$field ) {
1536 1536
             $field->allowsPrepopulate = true;
1537 1537
         }
1538 1538
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
      */
1554 1554
     private function filter_fields( $fields, $configured_fields ) {
1555 1555
 
1556
-        if( empty( $fields ) || !is_array( $fields ) ) {
1556
+        if ( empty( $fields ) || ! is_array( $fields ) ) {
1557 1557
             return $fields;
1558 1558
         }
1559 1559
 
@@ -1570,13 +1570,13 @@  discard block
 block discarded – undo
1570 1570
 	     */
1571 1571
 	    $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );
1572 1572
 
1573
-	    if( $hide_product_fields ) {
1574
-		    $field_type_blacklist[] = 'option';
1575
-		    $field_type_blacklist[] = 'quantity';
1576
-            $field_type_blacklist[] = 'product';
1577
-            $field_type_blacklist[] = 'total';
1578
-            $field_type_blacklist[] = 'shipping';
1579
-            $field_type_blacklist[] = 'calculation';
1573
+	    if ( $hide_product_fields ) {
1574
+		    $field_type_blacklist[ ] = 'option';
1575
+		    $field_type_blacklist[ ] = 'quantity';
1576
+            $field_type_blacklist[ ] = 'product';
1577
+            $field_type_blacklist[ ] = 'total';
1578
+            $field_type_blacklist[ ] = 'shipping';
1579
+            $field_type_blacklist[ ] = 'calculation';
1580 1580
 	    }
1581 1581
 
1582 1582
         // First, remove blacklist or calculation fields
@@ -1584,24 +1584,24 @@  discard block
 block discarded – undo
1584 1584
 
1585 1585
             // Remove the fields that have calculation properties and keep them to be used later
1586 1586
             // @since 1.16.2
1587
-            if( $field->has_calculation() ) {
1588
-                $this->fields_with_calculation[] = $field;
1587
+            if ( $field->has_calculation() ) {
1588
+                $this->fields_with_calculation[ ] = $field;
1589 1589
                 // don't remove the calculation fields on form render.
1590 1590
             }
1591 1591
 
1592 1592
             // process total field after all fields have been saved
1593 1593
             if ( $field->type == 'total' ) {
1594
-                $this->total_fields[] = $field;
1594
+                $this->total_fields[ ] = $field;
1595 1595
                 unset( $fields[ $key ] );
1596 1596
             }
1597 1597
 
1598
-            if( in_array( $field->type, $field_type_blacklist ) ) {
1598
+            if ( in_array( $field->type, $field_type_blacklist ) ) {
1599 1599
                 unset( $fields[ $key ] );
1600 1600
             }
1601 1601
         }
1602 1602
 
1603 1603
         // The Edit tab has not been configured, so we return all fields by default.
1604
-        if( empty( $configured_fields ) ) {
1604
+        if ( empty( $configured_fields ) ) {
1605 1605
             return $fields;
1606 1606
         }
1607 1607
 
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
 	        /** @var GF_Field $field */
1612 1612
 	        foreach ( $fields as $field ) {
1613 1613
 
1614
-                if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1615
-                    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1614
+                if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1615
+                    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1616 1616
                     break;
1617 1617
                 }
1618 1618
 
@@ -1635,14 +1635,14 @@  discard block
 block discarded – undo
1635 1635
 
1636 1636
         $return_field = $field;
1637 1637
 
1638
-        if( empty( $field_setting['show_label'] ) ) {
1638
+        if ( empty( $field_setting[ 'show_label' ] ) ) {
1639 1639
             $return_field->label = '';
1640
-        } elseif ( !empty( $field_setting['custom_label'] ) ) {
1641
-            $return_field->label = $field_setting['custom_label'];
1640
+        } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1641
+            $return_field->label = $field_setting[ 'custom_label' ];
1642 1642
         }
1643 1643
 
1644
-        if( !empty( $field_setting['custom_class'] ) ) {
1645
-            $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1644
+        if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1645
+            $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1646 1646
         }
1647 1647
 
1648 1648
         /**
@@ -1680,16 +1680,16 @@  discard block
 block discarded – undo
1680 1680
 	     */
1681 1681
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1682 1682
 
1683
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1684
-            foreach( $fields as $k => $field ) {
1685
-                if( $field->adminOnly ) {
1683
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1684
+            foreach ( $fields as $k => $field ) {
1685
+                if ( $field->adminOnly ) {
1686 1686
                     unset( $fields[ $k ] );
1687 1687
                 }
1688 1688
             }
1689 1689
             return $fields;
1690 1690
         }
1691 1691
 
1692
-	    foreach( $fields as &$field ) {
1692
+	    foreach ( $fields as &$field ) {
1693 1693
 		    $field->adminOnly = false;
1694 1694
         }
1695 1695
 
@@ -1716,16 +1716,16 @@  discard block
 block discarded – undo
1716 1716
          */
1717 1717
         $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1718 1718
 
1719
-        if( $use_conditional_logic ) {
1719
+        if ( $use_conditional_logic ) {
1720 1720
             return $form;
1721 1721
         }
1722 1722
 
1723
-        foreach( $form['fields'] as &$field ) {
1723
+        foreach ( $form[ 'fields' ] as &$field ) {
1724 1724
             /* @var GF_Field $field */
1725 1725
             $field->conditionalLogic = null;
1726 1726
         }
1727 1727
 
1728
-        unset( $form['button']['conditionalLogic'] );
1728
+        unset( $form[ 'button' ][ 'conditionalLogic' ] );
1729 1729
 
1730 1730
         return $form;
1731 1731
 
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
      */
1743 1743
     function manage_conditional_logic( $has_conditional_logic, $form ) {
1744 1744
 
1745
-        if( ! $this->is_edit_entry() ) {
1745
+        if ( ! $this->is_edit_entry() ) {
1746 1746
             return $has_conditional_logic;
1747 1747
         }
1748 1748
 
@@ -1773,44 +1773,44 @@  discard block
 block discarded – undo
1773 1773
          *  2. There are two entries embedded using oEmbed
1774 1774
          *  3. One of the entries has just been saved
1775 1775
          */
1776
-        if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1776
+        if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
1777 1777
 
1778 1778
             $error = true;
1779 1779
 
1780 1780
         }
1781 1781
 
1782
-        if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1782
+        if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
1783 1783
 
1784 1784
             $error = true;
1785 1785
 
1786
-        } elseif( ! $this->verify_nonce() ) {
1786
+        } elseif ( ! $this->verify_nonce() ) {
1787 1787
 
1788 1788
             /**
1789 1789
              * If the Entry is embedded, there may be two entries on the same page.
1790 1790
              * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1791 1791
              */
1792
-            if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1792
+            if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1793 1793
                 $error = true;
1794 1794
             } else {
1795
-                $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1795
+                $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
1796 1796
             }
1797 1797
 
1798 1798
         }
1799 1799
 
1800
-        if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1801
-            $error = __( 'You do not have permission to edit this entry.', 'gravityview');
1800
+        if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1801
+            $error = __( 'You do not have permission to edit this entry.', 'gravityview' );
1802 1802
         }
1803 1803
 
1804
-        if( $this->entry['status'] === 'trash' ) {
1805
-            $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1804
+        if ( $this->entry[ 'status' ] === 'trash' ) {
1805
+            $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
1806 1806
         }
1807 1807
 
1808 1808
         // No errors; everything's fine here!
1809
-        if( empty( $error ) ) {
1809
+        if ( empty( $error ) ) {
1810 1810
             return true;
1811 1811
         }
1812 1812
 
1813
-        if( $echo && $error !== true ) {
1813
+        if ( $echo && $error !== true ) {
1814 1814
 
1815 1815
 	        $error = esc_html( $error );
1816 1816
 
@@ -1818,13 +1818,13 @@  discard block
 block discarded – undo
1818 1818
 	         * @since 1.9
1819 1819
 	         */
1820 1820
 	        if ( ! empty( $this->entry ) ) {
1821
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1821
+		        $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1822 1822
 	        }
1823 1823
 
1824
-            echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1824
+            echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
1825 1825
         }
1826 1826
 
1827
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1827
+        do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );
1828 1828
 
1829 1829
         return false;
1830 1830
     }
@@ -1841,20 +1841,20 @@  discard block
 block discarded – undo
1841 1841
 
1842 1842
         $error = NULL;
1843 1843
 
1844
-        if( ! $this->check_user_cap_edit_field( $field ) ) {
1845
-            $error = __( 'You do not have permission to edit this field.', 'gravityview');
1844
+        if ( ! $this->check_user_cap_edit_field( $field ) ) {
1845
+            $error = __( 'You do not have permission to edit this field.', 'gravityview' );
1846 1846
         }
1847 1847
 
1848 1848
         // No errors; everything's fine here!
1849
-        if( empty( $error ) ) {
1849
+        if ( empty( $error ) ) {
1850 1850
             return true;
1851 1851
         }
1852 1852
 
1853
-        if( $echo ) {
1854
-            echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
1853
+        if ( $echo ) {
1854
+            echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
1855 1855
         }
1856 1856
 
1857
-        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1857
+        do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );
1858 1858
 
1859 1859
         return false;
1860 1860
 
@@ -1872,15 +1872,15 @@  discard block
 block discarded – undo
1872 1872
     private function check_user_cap_edit_field( $field ) {
1873 1873
 
1874 1874
         // If they can edit any entries (as defined in Gravity Forms), we're good.
1875
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1875
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
1876 1876
             return true;
1877 1877
         }
1878 1878
 
1879
-        $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
1879
+        $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
1880 1880
 
1881 1881
         // If the field has custom editing capaibilities set, check those
1882
-        if( $field_cap ) {
1883
-            return GVCommon::has_cap( $field['allow_edit_cap'] );
1882
+        if ( $field_cap ) {
1883
+            return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
1884 1884
         }
1885 1885
 
1886 1886
         return false;
@@ -1894,17 +1894,17 @@  discard block
 block discarded – undo
1894 1894
     public function verify_nonce() {
1895 1895
 
1896 1896
         // Verify form submitted for editing single
1897
-        if( $this->is_edit_entry_submission() ) {
1897
+        if ( $this->is_edit_entry_submission() ) {
1898 1898
             $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
1899 1899
         }
1900 1900
 
1901 1901
         // Verify
1902
-        else if( ! $this->is_edit_entry() ) {
1902
+        else if ( ! $this->is_edit_entry() ) {
1903 1903
             $valid = false;
1904 1904
         }
1905 1905
 
1906 1906
         else {
1907
-            $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
1907
+            $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
1908 1908
         }
1909 1909
 
1910 1910
         /**
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/search-field-select.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 $search_field = $gravityview_view->search_field;
11 11
 
12 12
 // Make sure that there are choices to display
13
-if( empty( $search_field['choices'] ) ) {
14
-	do_action('gravityview_log_debug', 'search-field-select.php - No choices for field' );
13
+if ( empty( $search_field[ 'choices' ] ) ) {
14
+	do_action( 'gravityview_log_debug', 'search-field-select.php - No choices for field' );
15 15
 	return;
16 16
 }
17 17
 
@@ -21,19 +21,19 @@  discard block
 block discarded – undo
21 21
  * @param string $default_option Default: `&mdash;` (—)
22 22
  * @param string $field_type Field type: "select" or "multiselect"
23 23
  */
24
-$default_option = apply_filters('gravityview/extension/search/select_default', '&mdash;', 'select' );
24
+$default_option = apply_filters( 'gravityview/extension/search/select_default', '&mdash;', 'select' );
25 25
 
26 26
 ?>
27 27
 <div class="gv-search-box gv-search-field-select">
28
-	<?php if( ! gv_empty( $search_field['label'], false ) ) { ?>
29
-		<label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label>
28
+	<?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?>
29
+		<label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label>
30 30
 	<?php } ?>
31 31
 	<p>
32
-		<select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>">
33
-			<option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option>
32
+		<select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>">
33
+			<option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option>
34 34
 			<?php
35
-			foreach( $search_field['choices'] as $choice ) : ?>
36
-				<option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>
35
+			foreach ( $search_field[ 'choices' ] as $choice ) : ?>
36
+				<option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field[ 'value' ] ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option>
37 37
 			<?php endforeach; ?>
38 38
 		</select>
39 39
 	</p>
Please login to merge, or discard this patch.