@@ -17,11 +17,11 @@ discard block  | 
                                                    ||
| 17 | 17 | */  | 
                                                        
| 18 | 18 |  	private function __construct( $passed_post = NULL ) { | 
                                                        
| 19 | 19 | |
| 20 | -		if( !empty( $passed_post ) ) { | 
                                                        |
| 20 | +		if ( ! empty( $passed_post ) ) { | 
                                                        |
| 21 | 21 | |
| 22 | 22 | $id_or_id_array = $this->maybe_get_view_id( $passed_post );  | 
                                                        
| 23 | 23 | |
| 24 | -			if( !empty( $id_or_id_array ) ) { | 
                                                        |
| 24 | +			if ( ! empty( $id_or_id_array ) ) { | 
                                                        |
| 25 | 25 | $this->add_view( $id_or_id_array );  | 
                                                        
| 26 | 26 | }  | 
                                                        
| 27 | 27 | }  | 
                                                        
@@ -56,33 +56,33 @@ discard block  | 
                                                    ||
| 56 | 56 | |
| 57 | 57 | $ids = array();  | 
                                                        
| 58 | 58 | |
| 59 | -		if( ! empty( $passed_post ) ) { | 
                                                        |
| 59 | +		if ( ! empty( $passed_post ) ) { | 
                                                        |
| 60 | 60 | |
| 61 | -			if( is_numeric( $passed_post ) ) { | 
                                                        |
| 61 | +			if ( is_numeric( $passed_post ) ) { | 
                                                        |
| 62 | 62 | $passed_post = get_post( $passed_post );  | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | 64 | |
| 65 | 65 | // Convert WP_Posts into WP_Posts[] array  | 
                                                        
| 66 | -			if( $passed_post instanceof WP_Post ) { | 
                                                        |
| 66 | +			if ( $passed_post instanceof WP_Post ) { | 
                                                        |
| 67 | 67 | $passed_post = array( $passed_post );  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
| 70 | -			if( is_array( $passed_post ) ) { | 
                                                        |
| 70 | +			if ( is_array( $passed_post ) ) { | 
                                                        |
| 71 | 71 | |
| 72 | -				foreach ( $passed_post as &$post) { | 
                                                        |
| 73 | -					if( ( get_post_type( $post ) === 'gravityview' ) ) { | 
                                                        |
| 74 | - $ids[] = $post->ID;  | 
                                                        |
| 75 | -					} else{ | 
                                                        |
| 72 | +				foreach ( $passed_post as &$post ) { | 
                                                        |
| 73 | +					if ( ( get_post_type( $post ) === 'gravityview' ) ) { | 
                                                        |
| 74 | + $ids[ ] = $post->ID;  | 
                                                        |
| 75 | +					} else { | 
                                                        |
| 76 | 76 | // Parse the Post Content  | 
                                                        
| 77 | 77 | $id = $this->parse_post_content( $post->post_content );  | 
                                                        
| 78 | -						if( $id ) { | 
                                                        |
| 79 | - $ids = array_merge( $ids, (array) $id );  | 
                                                        |
| 78 | +						if ( $id ) { | 
                                                        |
| 79 | + $ids = array_merge( $ids, (array)$id );  | 
                                                        |
| 80 | 80 | }  | 
                                                        
| 81 | 81 | |
| 82 | 82 | // Parse the Post Meta  | 
                                                        
| 83 | 83 | $id = $this->parse_post_meta( $post->ID );  | 
                                                        
| 84 | -						if( $id ) { | 
                                                        |
| 85 | - $ids = array_merge( $ids, (array) $id );  | 
                                                        |
| 84 | +						if ( $id ) { | 
                                                        |
| 85 | + $ids = array_merge( $ids, (array)$id );  | 
                                                        |
| 86 | 86 | }  | 
                                                        
| 87 | 87 | }  | 
                                                        
| 88 | 88 | |
@@ -93,24 +93,24 @@ discard block  | 
                                                    ||
| 93 | 93 |  				if ( is_string( $passed_post ) ) { | 
                                                        
| 94 | 94 | |
| 95 | 95 | $id = $this->parse_post_content( $passed_post );  | 
                                                        
| 96 | -					if( $id ) { | 
                                                        |
| 97 | - $ids = array_merge( $ids, (array) $id );  | 
                                                        |
| 96 | +					if ( $id ) { | 
                                                        |
| 97 | + $ids = array_merge( $ids, (array)$id );  | 
                                                        |
| 98 | 98 | }  | 
                                                        
| 99 | 99 | |
| 100 | 100 |  				} else { | 
                                                        
| 101 | 101 | $id = $this->get_id_from_atts( $passed_post );  | 
                                                        
| 102 | - $ids[] = intval( $id );  | 
                                                        |
| 102 | + $ids[ ] = intval( $id );  | 
                                                        |
| 103 | 103 | }  | 
                                                        
| 104 | 104 | }  | 
                                                        
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
| 107 | -		if( empty($ids) ) { | 
                                                        |
| 107 | +		if ( empty( $ids ) ) { | 
                                                        |
| 108 | 108 | return NULL;  | 
                                                        
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | // If it's just one ID, return that.  | 
                                                        
| 112 | 112 | // Otherwise, return array of IDs  | 
                                                        
| 113 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;  | 
                                                        |
| 113 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids;  | 
                                                        |
| 114 | 114 | }  | 
                                                        
| 115 | 115 | |
| 116 | 116 | /**  | 
                                                        
@@ -118,7 +118,7 @@ discard block  | 
                                                    ||
| 118 | 118 | */  | 
                                                        
| 119 | 119 |  	public static function getInstance( $passed_post = NULL ) { | 
                                                        
| 120 | 120 | |
| 121 | -		if( empty( self::$instance ) ) { | 
                                                        |
| 121 | +		if ( empty( self::$instance ) ) { | 
                                                        |
| 122 | 122 | self::$instance = new GravityView_View_Data( $passed_post );  | 
                                                        
| 123 | 123 | }  | 
                                                        
| 124 | 124 | |
@@ -131,19 +131,19 @@ discard block  | 
                                                    ||
| 131 | 131 | |
| 132 | 132 |  	function get_view( $view_id, $atts = NULL ) { | 
                                                        
| 133 | 133 | |
| 134 | -		if( ! is_numeric( $view_id) ) { | 
                                                        |
| 135 | -			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); | 
                                                        |
| 134 | +		if ( ! is_numeric( $view_id ) ) { | 
                                                        |
| 135 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id ) );  | 
                                                        |
| 136 | 136 | return false;  | 
                                                        
| 137 | 137 | }  | 
                                                        
| 138 | 138 | |
| 139 | 139 | // Backup: the view hasn't been fetched yet. Doing it now.  | 
                                                        
| 140 | 140 |  		if ( ! isset( $this->views[ $view_id ] ) ) { | 
                                                        
| 141 | -			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); | 
                                                        |
| 141 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] View #%s not set yet.', $view_id ) );  | 
                                                        |
| 142 | 142 | return $this->add_view( $view_id, $atts );  | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | 144 | |
| 145 | 145 |  		if ( empty( $this->views[ $view_id ] ) ) { | 
                                                        
| 146 | -			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); | 
                                                        |
| 146 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id ) );  | 
                                                        |
| 147 | 147 | return false;  | 
                                                        
| 148 | 148 | }  | 
                                                        
| 149 | 149 | |
@@ -174,8 +174,8 @@ discard block  | 
                                                    ||
| 174 | 174 |  	function add_view( $view_id, $atts = NULL ) { | 
                                                        
| 175 | 175 | |
| 176 | 176 | // Handle array of IDs  | 
                                                        
| 177 | -		if( is_array( $view_id ) ) { | 
                                                        |
| 178 | -			foreach( $view_id as $id ) { | 
                                                        |
| 177 | +		if ( is_array( $view_id ) ) { | 
                                                        |
| 178 | +			foreach ( $view_id as $id ) { | 
                                                        |
| 179 | 179 | |
| 180 | 180 | $this->add_view( $id, $atts );  | 
                                                        
| 181 | 181 | }  | 
                                                        
@@ -184,21 +184,21 @@ discard block  | 
                                                    ||
| 184 | 184 | }  | 
                                                        
| 185 | 185 | |
| 186 | 186 | // The view has been set already; returning stored view.  | 
                                                        
| 187 | -		if ( !empty( $this->views[ $view_id ] ) ) { | 
                                                        |
| 188 | -			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); | 
                                                        |
| 187 | +		if ( ! empty( $this->views[ $view_id ] ) ) { | 
                                                        |
| 188 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id ) );  | 
                                                        |
| 189 | 189 | return $this->views[ $view_id ];  | 
                                                        
| 190 | 190 | }  | 
                                                        
| 191 | 191 | |
| 192 | -		if( ! $this->view_exists( $view_id ) ) { | 
                                                        |
| 193 | -			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); | 
                                                        |
| 192 | +		if ( ! $this->view_exists( $view_id ) ) { | 
                                                        |
| 193 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id ) );  | 
                                                        |
| 194 | 194 | return false;  | 
                                                        
| 195 | 195 | }  | 
                                                        
| 196 | 196 | |
| 197 | 197 | $form_id = gravityview_get_form_id( $view_id );  | 
                                                        
| 198 | 198 | |
| 199 | -		if( empty( $form_id ) ) { | 
                                                        |
| 199 | +		if ( empty( $form_id ) ) { | 
                                                        |
| 200 | 200 | |
| 201 | -			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); | 
                                                        |
| 201 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id ) );  | 
                                                        |
| 202 | 202 | |
| 203 | 203 | return false;  | 
                                                        
| 204 | 204 | }  | 
                                                        
@@ -206,21 +206,21 @@ discard block  | 
                                                    ||
| 206 | 206 | // Get the settings for the View ID  | 
                                                        
| 207 | 207 | $view_settings = gravityview_get_template_settings( $view_id );  | 
                                                        
| 208 | 208 | |
| 209 | -		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); | 
                                                        |
| 209 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id ), $view_settings );  | 
                                                        |
| 210 | 210 | |
| 211 | 211 | // Merge the view settings with the defaults  | 
                                                        
| 212 | 212 | $view_defaults = wp_parse_args( $view_settings, self::get_default_args() );  | 
                                                        
| 213 | 213 | |
| 214 | -		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); | 
                                                        |
| 214 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults );  | 
                                                        |
| 215 | 215 | |
| 216 | -		if( ! empty( $atts ) && is_array( $atts ) ) { | 
                                                        |
| 216 | +		if ( ! empty( $atts ) && is_array( $atts ) ) { | 
                                                        |
| 217 | 217 | |
| 218 | -			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts ); | 
                                                        |
| 218 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts );  | 
                                                        |
| 219 | 219 | |
| 220 | 220 | // Get the settings from the shortcode and merge them with defaults.  | 
                                                        
| 221 | 221 | $atts = shortcode_atts( $view_defaults, $atts );  | 
                                                        
| 222 | 222 | |
| 223 | -			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts ); | 
                                                        |
| 223 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts );  | 
                                                        |
| 224 | 224 | |
| 225 | 225 |  		} else { | 
                                                        
| 226 | 226 | |
@@ -229,7 +229,7 @@ discard block  | 
                                                    ||
| 229 | 229 | |
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | - unset( $atts['id'], $view_defaults, $view_settings );  | 
                                                        |
| 232 | + unset( $atts[ 'id' ], $view_defaults, $view_settings );  | 
                                                        |
| 233 | 233 | |
| 234 | 234 | $data = array(  | 
                                                        
| 235 | 235 | 'id' => $view_id,  | 
                                                        
@@ -242,7 +242,7 @@ discard block  | 
                                                    ||
| 242 | 242 | 'form' => gravityview_get_form( $form_id ),  | 
                                                        
| 243 | 243 | );  | 
                                                        
| 244 | 244 | |
| 245 | -		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); | 
                                                        |
| 245 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] View #%s being added.', $view_id ), $data );  | 
                                                        |
| 246 | 246 | |
| 247 | 247 | $this->views[ $view_id ] = $data;  | 
                                                        
| 248 | 248 | |
@@ -277,15 +277,15 @@ discard block  | 
                                                    ||
| 277 | 277 | */  | 
                                                        
| 278 | 278 |  	private function filter_fields( $dir_fields ) { | 
                                                        
| 279 | 279 | |
| 280 | -		if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { | 
                                                        |
| 280 | +		if ( empty( $dir_fields ) || ! is_array( $dir_fields ) ) { | 
                                                        |
| 281 | 281 | return $dir_fields;  | 
                                                        
| 282 | 282 | }  | 
                                                        
| 283 | 283 | |
| 284 | -		foreach( $dir_fields as $area => $fields ) { | 
                                                        |
| 284 | +		foreach ( $dir_fields as $area => $fields ) { | 
                                                        |
| 285 | 285 | |
| 286 | -			foreach( (array)$fields as $uniqid => $properties ) { | 
                                                        |
| 286 | +			foreach ( (array)$fields as $uniqid => $properties ) { | 
                                                        |
| 287 | 287 | |
| 288 | -				if( $this->hide_field_check_conditions( $properties ) ) { | 
                                                        |
| 288 | +				if ( $this->hide_field_check_conditions( $properties ) ) { | 
                                                        |
| 289 | 289 | unset( $dir_fields[ $area ][ $uniqid ] );  | 
                                                        
| 290 | 290 | }  | 
                                                        
| 291 | 291 | |
@@ -307,7 +307,7 @@ discard block  | 
                                                    ||
| 307 | 307 |  	private function hide_field_check_conditions( $properties ) { | 
                                                        
| 308 | 308 | |
| 309 | 309 | // logged-in visibility  | 
                                                        
| 310 | -		if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { | 
                                                        |
| 310 | +		if ( ! empty( $properties[ 'only_loggedin' ] ) && ! GVCommon::has_cap( $properties[ 'only_loggedin_cap' ] ) ) { | 
                                                        |
| 311 | 311 | return true;  | 
                                                        
| 312 | 312 | }  | 
                                                        
| 313 | 313 | |
@@ -321,14 +321,14 @@ discard block  | 
                                                    ||
| 321 | 321 | // Get the settings from the shortcode and merge them with defaults.  | 
                                                        
| 322 | 322 | $atts = wp_parse_args( $atts, self::get_default_args() );  | 
                                                        
| 323 | 323 | |
| 324 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL;  | 
                                                        |
| 324 | + $view_id = ! empty( $atts[ 'view_id' ] ) ? (int)$atts[ 'view_id' ] : NULL;  | 
                                                        |
| 325 | 325 | |
| 326 | -		if( empty( $view_id ) && !empty( $atts['id'] ) ) { | 
                                                        |
| 327 | - $view_id = (int)$atts['id'];  | 
                                                        |
| 326 | +		if ( empty( $view_id ) && ! empty( $atts[ 'id' ] ) ) { | 
                                                        |
| 327 | + $view_id = (int)$atts[ 'id' ];  | 
                                                        |
| 328 | 328 | }  | 
                                                        
| 329 | 329 | |
| 330 | -		if( empty( $view_id ) ) { | 
                                                        |
| 331 | -			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); | 
                                                        |
| 330 | +		if ( empty( $view_id ) ) { | 
                                                        |
| 331 | + do_action( 'gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts );  | 
                                                        |
| 332 | 332 | return;  | 
                                                        
| 333 | 333 | }  | 
                                                        
| 334 | 334 | |
@@ -350,46 +350,46 @@ discard block  | 
                                                    ||
| 350 | 350 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin  | 
                                                        
| 351 | 351 | * @since 1.6  | 
                                                        
| 352 | 352 | */  | 
                                                        
| 353 | -		if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { | 
                                                        |
| 353 | +		if ( ! shortcode_exists( 'gravityview' ) && class_exists( 'GravityView_Shortcode' ) ) { | 
                                                        |
| 354 | 354 | new GravityView_Shortcode;  | 
                                                        
| 355 | 355 | }  | 
                                                        
| 356 | 356 | |
| 357 | 357 | $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' );  | 
                                                        
| 358 | 358 | |
| 359 | -		if( empty( $shortcodes ) ) { | 
                                                        |
| 359 | +		if ( empty( $shortcodes ) ) { | 
                                                        |
| 360 | 360 | return NULL;  | 
                                                        
| 361 | 361 | }  | 
                                                        
| 362 | 362 | |
| 363 | -		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); | 
                                                        |
| 363 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes );  | 
                                                        |
| 364 | 364 | |
| 365 | 365 | $ids = array();  | 
                                                        
| 366 | 366 | |
| 367 | -		foreach ($shortcodes as $key => $shortcode) { | 
                                                        |
| 367 | +		foreach ( $shortcodes as $key => $shortcode ) { | 
                                                        |
| 368 | 368 | |
| 369 | - $shortcode[3] = htmlspecialchars_decode( $shortcode[3], ENT_QUOTES );  | 
                                                        |
| 369 | + $shortcode[ 3 ] = htmlspecialchars_decode( $shortcode[ 3 ], ENT_QUOTES );  | 
                                                        |
| 370 | 370 | |
| 371 | - $args = shortcode_parse_atts( $shortcode[3] );  | 
                                                        |
| 371 | + $args = shortcode_parse_atts( $shortcode[ 3 ] );  | 
                                                        |
| 372 | 372 | |
| 373 | -			if( empty( $args['id'] ) ) { | 
                                                        |
| 374 | -				do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); | 
                                                        |
| 373 | +			if ( empty( $args[ 'id' ] ) ) { | 
                                                        |
| 374 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode );  | 
                                                        |
| 375 | 375 | continue;  | 
                                                        
| 376 | 376 | }  | 
                                                        
| 377 | 377 | |
| 378 | -			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); | 
                                                        |
| 378 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args[ 'id' ] ), $args );  | 
                                                        |
| 379 | 379 | |
| 380 | 380 | // Store the View to the object for later fetching.  | 
                                                        
| 381 | - $this->add_view( $args['id'], $args );  | 
                                                        |
| 381 | + $this->add_view( $args[ 'id' ], $args );  | 
                                                        |
| 382 | 382 | |
| 383 | - $ids[] = $args['id'];  | 
                                                        |
| 383 | + $ids[ ] = $args[ 'id' ];  | 
                                                        |
| 384 | 384 | }  | 
                                                        
| 385 | 385 | |
| 386 | -		if( empty($ids) ) { | 
                                                        |
| 386 | +		if ( empty( $ids ) ) { | 
                                                        |
| 387 | 387 | return NULL;  | 
                                                        
| 388 | 388 | }  | 
                                                        
| 389 | 389 | |
| 390 | 390 | // If it's just one ID, return that.  | 
                                                        
| 391 | 391 | // Otherwise, return array of IDs  | 
                                                        
| 392 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;  | 
                                                        |
| 392 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids;  | 
                                                        |
| 393 | 393 | |
| 394 | 394 | }  | 
                                                        
| 395 | 395 | |
@@ -410,7 +410,7 @@ discard block  | 
                                                    ||
| 410 | 410 | */  | 
                                                        
| 411 | 411 | $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id );  | 
                                                        
| 412 | 412 | |
| 413 | -		if( empty( $meta_keys ) ) { | 
                                                        |
| 413 | +		if ( empty( $meta_keys ) ) { | 
                                                        |
| 414 | 414 | return NULL;  | 
                                                        
| 415 | 415 | }  | 
                                                        
| 416 | 416 | |
@@ -418,16 +418,16 @@ discard block  | 
                                                    ||
| 418 | 418 | |
| 419 | 419 | $meta_content = '';  | 
                                                        
| 420 | 420 | |
| 421 | -		foreach( $meta_keys as $key ) { | 
                                                        |
| 422 | - $meta = get_post_meta( $post_id, $key , true );  | 
                                                        |
| 423 | -			if( ! is_string( $meta ) ) { | 
                                                        |
| 421 | +		foreach ( $meta_keys as $key ) { | 
                                                        |
| 422 | + $meta = get_post_meta( $post_id, $key, true );  | 
                                                        |
| 423 | +			if ( ! is_string( $meta ) ) { | 
                                                        |
| 424 | 424 | continue;  | 
                                                        
| 425 | 425 | }  | 
                                                        
| 426 | 426 | $meta_content .= $meta . ' ';  | 
                                                        
| 427 | 427 | }  | 
                                                        
| 428 | 428 | |
| 429 | -		if( empty( $meta_content ) ) { | 
                                                        |
| 430 | -			do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); | 
                                                        |
| 429 | +		if ( empty( $meta_content ) ) { | 
                                                        |
| 430 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys );  | 
                                                        |
| 431 | 431 | return NULL;  | 
                                                        
| 432 | 432 | }  | 
                                                        
| 433 | 433 | |
@@ -454,16 +454,16 @@ discard block  | 
                                                    ||
| 454 | 454 | $message = NULL;  | 
                                                        
| 455 | 455 | |
| 456 | 456 | // Not invalid if not set!  | 
                                                        
| 457 | -		if( empty( $post_id ) || empty( $view_id ) ) { | 
                                                        |
| 457 | +		if ( empty( $post_id ) || empty( $view_id ) ) { | 
                                                        |
| 458 | 458 | |
| 459 | -			if( $empty_is_valid ) { | 
                                                        |
| 459 | +			if ( $empty_is_valid ) { | 
                                                        |
| 460 | 460 | return true;  | 
                                                        
| 461 | 461 | }  | 
                                                        
| 462 | 462 | |
| 463 | 463 | $message = esc_html__( 'The ID is required.', 'gravityview' );  | 
                                                        
| 464 | 464 | }  | 
                                                        
| 465 | 465 | |
| 466 | -		if( ! $message ) { | 
                                                        |
| 466 | +		if ( ! $message ) { | 
                                                        |
| 467 | 467 | $status = get_post_status( $post_id );  | 
                                                        
| 468 | 468 | |
| 469 | 469 | // Nothing exists with that post ID.  | 
                                                        
@@ -475,7 +475,7 @@ discard block  | 
                                                    ||
| 475 | 475 | }  | 
                                                        
| 476 | 476 | }  | 
                                                        
| 477 | 477 | |
| 478 | -		if( ! $message ) { | 
                                                        |
| 478 | +		if ( ! $message ) { | 
                                                        |
| 479 | 479 | |
| 480 | 480 | // Nothing exists with that post ID.  | 
                                                        
| 481 | 481 |  			if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { | 
                                                        
@@ -484,25 +484,25 @@ discard block  | 
                                                    ||
| 484 | 484 | |
| 485 | 485 | }  | 
                                                        
| 486 | 486 | |
| 487 | -		if( ! $message ) { | 
                                                        |
| 487 | +		if ( ! $message ) { | 
                                                        |
| 488 | 488 | $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id );  | 
                                                        
| 489 | 489 | |
| 490 | 490 | // The post or page specified does not contain the shortcode.  | 
                                                        
| 491 | -			if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { | 
                                                        |
| 491 | +			if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) { | 
                                                        |
| 492 | 492 | $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' );  | 
                                                        
| 493 | 493 | }  | 
                                                        
| 494 | 494 | }  | 
                                                        
| 495 | 495 | |
| 496 | -		if( ! $message ) { | 
                                                        |
| 496 | +		if ( ! $message ) { | 
                                                        |
| 497 | 497 | |
| 498 | 498 | // It's a View  | 
                                                        
| 499 | -			if( 'gravityview' === get_post_type( $post_id ) ) { | 
                                                        |
| 500 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );;  | 
                                                        |
| 499 | +			if ( 'gravityview' === get_post_type( $post_id ) ) { | 
                                                        |
| 500 | + $message = esc_html__( 'The ID is already a View.', 'gravityview' ); ;  | 
                                                        |
| 501 | 501 | }  | 
                                                        
| 502 | 502 | |
| 503 | 503 | }  | 
                                                        
| 504 | 504 | |
| 505 | -		if( $message ) { | 
                                                        |
| 505 | +		if ( $message ) { | 
                                                        |
| 506 | 506 | return new WP_Error( 'invalid_embed_id', $message );  | 
                                                        
| 507 | 507 | }  | 
                                                        
| 508 | 508 | |
@@ -519,7 +519,7 @@ discard block  | 
                                                    ||
| 519 | 519 | |
| 520 | 520 | $args = self::get_default_args( $with_details );  | 
                                                        
| 521 | 521 | |
| 522 | -		if( !isset( $args[ $key ] ) ) { return NULL; } | 
                                                        |
| 522 | +		if ( ! isset( $args[ $key ] ) ) { return NULL; } | 
                                                        |
| 523 | 523 | |
| 524 | 524 | return $args[ $key ];  | 
                                                        
| 525 | 525 | }  | 
                                                        
@@ -548,7 +548,7 @@ discard block  | 
                                                    ||
| 548 | 548 | */  | 
                                                        
| 549 | 549 | $default_settings = apply_filters( 'gravityview_default_args', array(  | 
                                                        
| 550 | 550 | 'id' => array(  | 
                                                        
| 551 | -				'label' => __('View ID', 'gravityview'), | 
                                                        |
| 551 | + 'label' => __( 'View ID', 'gravityview' ),  | 
                                                        |
| 552 | 552 | 'type' => 'number',  | 
                                                        
| 553 | 553 | 'group' => 'default',  | 
                                                        
| 554 | 554 | 'value' => NULL,  | 
                                                        
@@ -556,7 +556,7 @@ discard block  | 
                                                    ||
| 556 | 556 | 'show_in_shortcode' => false,  | 
                                                        
| 557 | 557 | ),  | 
                                                        
| 558 | 558 | 'page_size' => array(  | 
                                                        
| 559 | -				'label' 	=> __('Number of entries per page', 'gravityview'), | 
                                                        |
| 559 | + 'label' => __( 'Number of entries per page', 'gravityview' ),  | 
                                                        |
| 560 | 560 | 'type' => 'number',  | 
                                                        
| 561 | 561 | 'class' => 'small-text',  | 
                                                        
| 562 | 562 | 'group' => 'default',  | 
                                                        
@@ -580,8 +580,8 @@ discard block  | 
                                                    ||
| 580 | 580 | ),  | 
                                                        
| 581 | 581 | 'admin_show_all_statuses' => array(  | 
                                                        
| 582 | 582 | 'label' => __( 'Show all entries to administrators', 'gravityview' ),  | 
                                                        
| 583 | -				'desc'	=> __('Administrators will be able to see entries with any approval status.', 'gravityview'), | 
                                                        |
| 584 | -				'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), | 
                                                        |
| 583 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ),  | 
                                                        |
| 584 | + 'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ),  | 
                                                        |
| 585 | 585 | 'requires' => 'show_only_approved',  | 
                                                        
| 586 | 586 | 'type' => 'checkbox',  | 
                                                        
| 587 | 587 | 'group' => 'default',  | 
                                                        
@@ -606,40 +606,40 @@ discard block  | 
                                                    ||
| 606 | 606 | 'user_edit' => array(  | 
                                                        
| 607 | 607 | 'label' => __( 'Allow User Edit', 'gravityview' ),  | 
                                                        
| 608 | 608 | 'group' => 'default',  | 
                                                        
| 609 | -				'desc'	=> __('Allow logged-in users to edit entries they created.', 'gravityview'), | 
                                                        |
| 609 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ),  | 
                                                        |
| 610 | 610 | 'value' => 0,  | 
                                                        
| 611 | -				'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), | 
                                                        |
| 611 | + 'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ),  | 
                                                        |
| 612 | 612 | 'type' => 'checkbox',  | 
                                                        
| 613 | 613 | 'show_in_shortcode' => true,  | 
                                                        
| 614 | 614 | ),  | 
                                                        
| 615 | 615 | 'user_delete' => array(  | 
                                                        
| 616 | 616 | 'label' => __( 'Allow User Delete', 'gravityview' ),  | 
                                                        
| 617 | 617 | 'group' => 'default',  | 
                                                        
| 618 | -				'desc'	=> __('Allow logged-in users to delete entries they created.', 'gravityview'), | 
                                                        |
| 618 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ),  | 
                                                        |
| 619 | 619 | 'value' => 0,  | 
                                                        
| 620 | -				'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), | 
                                                        |
| 620 | + 'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ),  | 
                                                        |
| 621 | 621 | 'type' => 'checkbox',  | 
                                                        
| 622 | 622 | 'show_in_shortcode' => true,  | 
                                                        
| 623 | 623 | ),  | 
                                                        
| 624 | 624 | 'sort_field' => array(  | 
                                                        
| 625 | -				'label'	=> __('Sort by field', 'gravityview'), | 
                                                        |
| 625 | + 'label' => __( 'Sort by field', 'gravityview' ),  | 
                                                        |
| 626 | 626 | 'type' => 'select',  | 
                                                        
| 627 | 627 | 'value' => '',  | 
                                                        
| 628 | 628 | 'group' => 'sort',  | 
                                                        
| 629 | 629 | 'options' => array(  | 
                                                        
| 630 | - '' => __( 'Default', 'gravityview'),  | 
                                                        |
| 631 | - 'date_created' => __( 'Date Created', 'gravityview'),  | 
                                                        |
| 630 | + '' => __( 'Default', 'gravityview' ),  | 
                                                        |
| 631 | + 'date_created' => __( 'Date Created', 'gravityview' ),  | 
                                                        |
| 632 | 632 | ),  | 
                                                        
| 633 | 633 | 'show_in_shortcode' => true,  | 
                                                        
| 634 | 634 | ),  | 
                                                        
| 635 | 635 | 'sort_direction' => array(  | 
                                                        
| 636 | -				'label' 	=> __('Sort direction', 'gravityview'), | 
                                                        |
| 636 | + 'label' => __( 'Sort direction', 'gravityview' ),  | 
                                                        |
| 637 | 637 | 'type' => 'select',  | 
                                                        
| 638 | 638 | 'value' => 'ASC',  | 
                                                        
| 639 | 639 | 'group' => 'sort',  | 
                                                        
| 640 | 640 | 'options' => array(  | 
                                                        
| 641 | -					'ASC' => __('ASC', 'gravityview'), | 
                                                        |
| 642 | -					'DESC' => __('DESC', 'gravityview'), | 
                                                        |
| 641 | + 'ASC' => __( 'ASC', 'gravityview' ),  | 
                                                        |
| 642 | + 'DESC' => __( 'DESC', 'gravityview' ),  | 
                                                        |
| 643 | 643 |  					//'RAND' => __('Random', 'gravityview'), | 
                                                        
| 644 | 644 | ),  | 
                                                        
| 645 | 645 | 'show_in_shortcode' => true,  | 
                                                        
@@ -655,69 +655,69 @@ discard block  | 
                                                    ||
| 655 | 655 | 'show_in_template' => array( 'default_table' ),  | 
                                                        
| 656 | 656 | ),  | 
                                                        
| 657 | 657 | 'start_date' => array(  | 
                                                        
| 658 | -				'label' 	=> __('Filter by Start Date', 'gravityview'), | 
                                                        |
| 658 | + 'label' => __( 'Filter by Start Date', 'gravityview' ),  | 
                                                        |
| 659 | 659 | 'class' => 'gv-datepicker',  | 
                                                        
| 660 | -				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), | 
                                                        |
| 660 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),  | 
                                                        |
| 661 | 661 | 'type' => 'text',  | 
                                                        
| 662 | 662 | 'value' => '',  | 
                                                        
| 663 | 663 | 'group' => 'filter',  | 
                                                        
| 664 | 664 | 'show_in_shortcode' => true,  | 
                                                        
| 665 | 665 | ),  | 
                                                        
| 666 | 666 | 'end_date' => array(  | 
                                                        
| 667 | -				'label' 	=> __('Filter by End Date', 'gravityview'), | 
                                                        |
| 667 | + 'label' => __( 'Filter by End Date', 'gravityview' ),  | 
                                                        |
| 668 | 668 | 'class' => 'gv-datepicker',  | 
                                                        
| 669 | -				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), | 
                                                        |
| 669 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),  | 
                                                        |
| 670 | 670 | 'type' => 'text',  | 
                                                        
| 671 | 671 | 'value' => '',  | 
                                                        
| 672 | 672 | 'group' => 'filter',  | 
                                                        
| 673 | 673 | 'show_in_shortcode' => true,  | 
                                                        
| 674 | 674 | ),  | 
                                                        
| 675 | 675 | 'class' => array(  | 
                                                        
| 676 | -				'label' 	=> __('CSS Class', 'gravityview'), | 
                                                        |
| 677 | -				'desc'	=> __('CSS class to add to the wrapping HTML container.', 'gravityview'), | 
                                                        |
| 676 | + 'label' => __( 'CSS Class', 'gravityview' ),  | 
                                                        |
| 677 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ),  | 
                                                        |
| 678 | 678 | 'group' => 'default',  | 
                                                        
| 679 | 679 | 'type' => 'text',  | 
                                                        
| 680 | 680 | 'value' => '',  | 
                                                        
| 681 | 681 | 'show_in_shortcode' => false,  | 
                                                        
| 682 | 682 | ),  | 
                                                        
| 683 | 683 | 'search_value' => array(  | 
                                                        
| 684 | -				'label' 	=> __('Search Value', 'gravityview'), | 
                                                        |
| 685 | -				'desc'	=> __('Define a default search value for the View', 'gravityview'), | 
                                                        |
| 684 | + 'label' => __( 'Search Value', 'gravityview' ),  | 
                                                        |
| 685 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ),  | 
                                                        |
| 686 | 686 | 'type' => 'text',  | 
                                                        
| 687 | 687 | 'value' => '',  | 
                                                        
| 688 | 688 | 'group' => 'filter',  | 
                                                        
| 689 | 689 | 'show_in_shortcode' => false,  | 
                                                        
| 690 | 690 | ),  | 
                                                        
| 691 | 691 | 'search_field' => array(  | 
                                                        
| 692 | -				'label' 	=> __('Search Field', 'gravityview'), | 
                                                        |
| 693 | -				'desc'	=> __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), | 
                                                        |
| 692 | + 'label' => __( 'Search Field', 'gravityview' ),  | 
                                                        |
| 693 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ),  | 
                                                        |
| 694 | 694 | 'type' => 'number',  | 
                                                        
| 695 | 695 | 'value' => '',  | 
                                                        
| 696 | 696 | 'group' => 'filter',  | 
                                                        
| 697 | 697 | 'show_in_shortcode' => false,  | 
                                                        
| 698 | 698 | ),  | 
                                                        
| 699 | 699 | 'single_title' => array(  | 
                                                        
| 700 | -				'label'	=> __('Single Entry Title', 'gravityview'), | 
                                                        |
| 700 | + 'label' => __( 'Single Entry Title', 'gravityview' ),  | 
                                                        |
| 701 | 701 | 'type' => 'text',  | 
                                                        
| 702 | -				'desc'	=> __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), | 
                                                        |
| 702 | + 'desc' => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ),  | 
                                                        |
| 703 | 703 | 'group' => 'default',  | 
                                                        
| 704 | 704 | 'value' => '',  | 
                                                        
| 705 | 705 | 'show_in_shortcode' => false,  | 
                                                        
| 706 | 706 | 'full_width' => true,  | 
                                                        
| 707 | 707 | ),  | 
                                                        
| 708 | 708 | 'back_link_label' => array(  | 
                                                        
| 709 | -				'label'	=> __('Back Link Label', 'gravityview'), | 
                                                        |
| 709 | + 'label' => __( 'Back Link Label', 'gravityview' ),  | 
                                                        |
| 710 | 710 | 'group' => 'default',  | 
                                                        
| 711 | -				'desc'	=> __('The text of the link that returns to the multiple entries view.', 'gravityview'), | 
                                                        |
| 711 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ),  | 
                                                        |
| 712 | 712 | 'type' => 'text',  | 
                                                        
| 713 | 713 | 'value' => '',  | 
                                                        
| 714 | 714 | 'show_in_shortcode' => false,  | 
                                                        
| 715 | 715 | 'full_width' => true,  | 
                                                        
| 716 | 716 | ),  | 
                                                        
| 717 | 717 | 'embed_only' => array(  | 
                                                        
| 718 | -				'label'	=> __('Prevent Direct Access', 'gravityview'), | 
                                                        |
| 718 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ),  | 
                                                        |
| 719 | 719 | 'group' => 'default',  | 
                                                        
| 720 | -				'desc'	=> __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), | 
                                                        |
| 720 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ),  | 
                                                        |
| 721 | 721 | 'type' => 'checkbox',  | 
                                                        
| 722 | 722 | 'value' => '',  | 
                                                        
| 723 | 723 | 'show_in_shortcode' => false,  | 
                                                        
@@ -728,15 +728,15 @@ discard block  | 
                                                    ||
| 728 | 728 | 'value' => '',  | 
                                                        
| 729 | 729 | 'show_in_shortcode' => false,  | 
                                                        
| 730 | 730 | ),  | 
                                                        
| 731 | - ));  | 
                                                        |
| 731 | + ) );  | 
                                                        |
| 732 | 732 | |
| 733 | 733 | // By default, we only want the key => value pairing, not the whole array.  | 
                                                        
| 734 | -		if( empty( $with_details ) ) { | 
                                                        |
| 734 | +		if ( empty( $with_details ) ) { | 
                                                        |
| 735 | 735 | |
| 736 | 736 | $defaults = array();  | 
                                                        
| 737 | 737 | |
| 738 | -			foreach( $default_settings as $key => $value ) { | 
                                                        |
| 739 | - $defaults[ $key ] = $value['value'];  | 
                                                        |
| 738 | +			foreach ( $default_settings as $key => $value ) { | 
                                                        |
| 739 | + $defaults[ $key ] = $value[ 'value' ];  | 
                                                        |
| 740 | 740 | }  | 
                                                        
| 741 | 741 | |
| 742 | 742 | return $defaults;  | 
                                                        
@@ -745,12 +745,12 @@ discard block  | 
                                                    ||
| 745 | 745 | // But sometimes, we want all the details.  | 
                                                        
| 746 | 746 |  		else { | 
                                                        
| 747 | 747 | |
| 748 | -			foreach ($default_settings as $key => $value) { | 
                                                        |
| 748 | +			foreach ( $default_settings as $key => $value ) { | 
                                                        |
| 749 | 749 | |
| 750 | 750 | // If the $group argument is set for the method,  | 
                                                        
| 751 | 751 | // ignore any settings that aren't in that group.  | 
                                                        
| 752 | -				if( !empty( $group ) && is_string( $group ) ) { | 
                                                        |
| 753 | -					if( empty( $value['group'] ) || $value['group'] !== $group ) { | 
                                                        |
| 752 | +				if ( ! empty( $group ) && is_string( $group ) ) { | 
                                                        |
| 753 | +					if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { | 
                                                        |
| 754 | 754 | unset( $default_settings[ $key ] );  | 
                                                        
| 755 | 755 | }  | 
                                                        
| 756 | 756 | }  | 
                                                        
@@ -42,12 +42,12 @@ discard block  | 
                                                    ||
| 42 | 42 | |
| 43 | 43 | add_action( 'wp', array( $this, 'process_delete' ), 10000 );  | 
                                                        
| 44 | 44 | |
| 45 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 );  | 
                                                        |
| 45 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );  | 
                                                        |
| 46 | 46 | |
| 47 | 47 | add_action( 'gravityview_before', array( $this, 'display_message' ) );  | 
                                                        
| 48 | 48 | |
| 49 | 49 | // For the Delete Entry Link, you don't want visible to all users.  | 
                                                        
| 50 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 );  | 
                                                        |
| 50 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );  | 
                                                        |
| 51 | 51 | |
| 52 | 52 | // Modify the field options based on the name of the field type  | 
                                                        
| 53 | 53 | add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 );  | 
                                                        
@@ -55,10 +55,10 @@ discard block  | 
                                                    ||
| 55 | 55 | // add template path to check for field  | 
                                                        
| 56 | 56 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );  | 
                                                        
| 57 | 57 | |
| 58 | - add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 );  | 
                                                        |
| 58 | + add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 3 );  | 
                                                        |
| 59 | 59 | |
| 60 | - add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );  | 
                                                        |
| 61 | - add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );  | 
                                                        |
| 60 | + add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );  | 
                                                        |
| 61 | + add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );  | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | 64 | /**  | 
                                                        
@@ -69,7 +69,7 @@ discard block  | 
                                                    ||
| 69 | 69 | */  | 
                                                        
| 70 | 70 |  	static function getInstance() { | 
                                                        
| 71 | 71 | |
| 72 | -		if( empty( self::$instance ) ) { | 
                                                        |
| 72 | +		if ( empty( self::$instance ) ) { | 
                                                        |
| 73 | 73 | self::$instance = new self;  | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
@@ -105,20 +105,20 @@ discard block  | 
                                                    ||
| 105 | 105 |  	function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { | 
                                                        
| 106 | 106 | |
| 107 | 107 | // Always a link, never a filter  | 
                                                        
| 108 | - unset( $field_options['show_as_link'], $field_options['search_filter'] );  | 
                                                        |
| 108 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );  | 
                                                        |
| 109 | 109 | |
| 110 | 110 | // Delete Entry link should only appear to visitors capable of editing entries  | 
                                                        
| 111 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );  | 
                                                        |
| 111 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );  | 
                                                        |
| 112 | 112 | |
| 113 | - $add_option['delete_link'] = array(  | 
                                                        |
| 113 | + $add_option[ 'delete_link' ] = array(  | 
                                                        |
| 114 | 114 | 'type' => 'text',  | 
                                                        
| 115 | 115 | 'label' => __( 'Delete Link Text', 'gravityview' ),  | 
                                                        
| 116 | 116 | 'desc' => NULL,  | 
                                                        
| 117 | -			'value' => __('Delete Entry', 'gravityview'), | 
                                                        |
| 117 | + 'value' => __( 'Delete Entry', 'gravityview' ),  | 
                                                        |
| 118 | 118 | 'merge_tags' => true,  | 
                                                        
| 119 | 119 | );  | 
                                                        
| 120 | 120 | |
| 121 | - $field_options['allow_edit_cap'] = array(  | 
                                                        |
| 121 | + $field_options[ 'allow_edit_cap' ] = array(  | 
                                                        |
| 122 | 122 | 'type' => 'select',  | 
                                                        
| 123 | 123 | 'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ),  | 
                                                        
| 124 | 124 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),  | 
                                                        
@@ -142,8 +142,8 @@ discard block  | 
                                                    ||
| 142 | 142 | */  | 
                                                        
| 143 | 143 |  	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { | 
                                                        
| 144 | 144 | |
| 145 | -		if( 'edit' !== $zone ) { | 
                                                        |
| 146 | - $entry_default_fields['delete_link'] = array(  | 
                                                        |
| 145 | +		if ( 'edit' !== $zone ) { | 
                                                        |
| 146 | + $entry_default_fields[ 'delete_link' ] = array(  | 
                                                        |
| 147 | 147 | 'label' => __( 'Delete Entry', 'gravityview' ),  | 
                                                        
| 148 | 148 | 'type' => 'delete_link',  | 
                                                        
| 149 | 149 | 'desc' => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ),  | 
                                                        
@@ -160,7 +160,7 @@ discard block  | 
                                                    ||
| 160 | 160 | */  | 
                                                        
| 161 | 161 |  	function add_available_field( $available_fields = array() ) { | 
                                                        
| 162 | 162 | |
| 163 | - $available_fields['delete_link'] = array(  | 
                                                        |
| 163 | + $available_fields[ 'delete_link' ] = array(  | 
                                                        |
| 164 | 164 | 'label_text' => __( 'Delete Entry', 'gravityview' ),  | 
                                                        
| 165 | 165 | 'field_id' => 'delete_link',  | 
                                                        
| 166 | 166 | 'label_type' => 'field',  | 
                                                        
@@ -188,12 +188,12 @@ discard block  | 
                                                    ||
| 188 | 188 | $caps = $visibility_caps;  | 
                                                        
| 189 | 189 | |
| 190 | 190 | // If we're configuring fields in the edit context, we want a limited selection  | 
                                                        
| 191 | -		if( $field_id === 'delete_link' ) { | 
                                                        |
| 191 | +		if ( $field_id === 'delete_link' ) { | 
                                                        |
| 192 | 192 | |
| 193 | 193 | // Remove other built-in caps.  | 
                                                        
| 194 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );  | 
                                                        |
| 194 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );  | 
                                                        |
| 195 | 195 | |
| 196 | -			$caps['read'] = _x('Entry Creator', 'User capability', 'gravityview'); | 
                                                        |
| 196 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );  | 
                                                        |
| 197 | 197 | }  | 
                                                        
| 198 | 198 | |
| 199 | 199 | return $caps;  | 
                                                        
@@ -206,7 +206,7 @@ discard block  | 
                                                    ||
| 206 | 206 | * @param [type] $entry [description]  | 
                                                        
| 207 | 207 | */  | 
                                                        
| 208 | 208 |  	function set_entry( $entry = null ) { | 
                                                        
| 209 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry;  | 
                                                        |
| 209 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry;  | 
                                                        |
| 210 | 210 | }  | 
                                                        
| 211 | 211 | |
| 212 | 212 | /**  | 
                                                        
@@ -236,13 +236,13 @@ discard block  | 
                                                    ||
| 236 | 236 | |
| 237 | 237 | $base = GravityView_API::directory_link( $post_id, true );  | 
                                                        
| 238 | 238 | |
| 239 | -		if( empty( $base ) ) { | 
                                                        |
| 240 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );  | 
                                                        |
| 239 | +		if ( empty( $base ) ) { | 
                                                        |
| 240 | + do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: ' . $post_id );  | 
                                                        |
| 241 | 241 | return NULL;  | 
                                                        
| 242 | 242 | }  | 
                                                        
| 243 | 243 | |
| 244 | 244 | // Use the slug instead of the ID for consistent security  | 
                                                        
| 245 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );  | 
                                                        |
| 245 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry );  | 
                                                        |
| 246 | 246 | |
| 247 | 247 | $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;  | 
                                                        
| 248 | 248 | |
@@ -253,7 +253,7 @@ discard block  | 
                                                    ||
| 253 | 253 | 'view_id' => $view_id,  | 
                                                        
| 254 | 254 | ), $base );  | 
                                                        
| 255 | 255 | |
| 256 | - $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );  | 
                                                        |
| 256 | + $url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' );  | 
                                                        |
| 257 | 257 | |
| 258 | 258 | return $url;  | 
                                                        
| 259 | 259 | }  | 
                                                        
@@ -270,7 +270,7 @@ discard block  | 
                                                    ||
| 270 | 270 |  	function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) { | 
                                                        
| 271 | 271 | |
| 272 | 272 | // Only show the link to those who are allowed to see it.  | 
                                                        
| 273 | -		if( !self::check_user_cap_delete_entry( $entry ) ) { | 
                                                        |
| 273 | +		if ( ! self::check_user_cap_delete_entry( $entry ) ) { | 
                                                        |
| 274 | 274 | return;  | 
                                                        
| 275 | 275 | }  | 
                                                        
| 276 | 276 | |
@@ -281,7 +281,7 @@ discard block  | 
                                                    ||
| 281 | 281 | $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true );  | 
                                                        
| 282 | 282 | |
| 283 | 283 | // If the button is hidden by the filter, don't show.  | 
                                                        
| 284 | -		if( !$show_delete_button ) { | 
                                                        |
| 284 | +		if ( ! $show_delete_button ) { | 
                                                        |
| 285 | 285 | return;  | 
                                                        
| 286 | 286 | }  | 
                                                        
| 287 | 287 | |
@@ -311,27 +311,27 @@ discard block  | 
                                                    ||
| 311 | 311 |  	function process_delete() { | 
                                                        
| 312 | 312 | |
| 313 | 313 | // If the form is submitted  | 
                                                        
| 314 | -		if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) { | 
                                                        |
| 314 | +		if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) { | 
                                                        |
| 315 | 315 | |
| 316 | 316 | // Make sure it's a GravityView request  | 
                                                        
| 317 | - $valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) );  | 
                                                        |
| 317 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) );  | 
                                                        |
| 318 | 318 | |
| 319 | -			if( ! $valid_nonce_key ) { | 
                                                        |
| 320 | -				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' ); | 
                                                        |
| 319 | +			if ( ! $valid_nonce_key ) { | 
                                                        |
| 320 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' );  | 
                                                        |
| 321 | 321 | return;  | 
                                                        
| 322 | 322 | }  | 
                                                        
| 323 | 323 | |
| 324 | 324 | // Get the entry slug  | 
                                                        
| 325 | - $entry_slug = esc_attr( $_GET['entry_id'] );  | 
                                                        |
| 325 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] );  | 
                                                        |
| 326 | 326 | |
| 327 | 327 | // See if there's an entry there  | 
                                                        
| 328 | 328 | $entry = gravityview_get_entry( $entry_slug );  | 
                                                        
| 329 | 329 | |
| 330 | -			if( $entry ) { | 
                                                        |
| 330 | +			if ( $entry ) { | 
                                                        |
| 331 | 331 | |
| 332 | 332 | $has_permission = $this->user_can_delete_entry( $entry );  | 
                                                        
| 333 | 333 | |
| 334 | -				if( is_wp_error( $has_permission ) ) { | 
                                                        |
| 334 | +				if ( is_wp_error( $has_permission ) ) { | 
                                                        |
| 335 | 335 | |
| 336 | 336 | $messages = array(  | 
                                                        
| 337 | 337 | 'message' => urlencode( $has_permission->get_error_message() ),  | 
                                                        
@@ -343,7 +343,7 @@ discard block  | 
                                                    ||
| 343 | 343 | // Delete the entry  | 
                                                        
| 344 | 344 | $delete_response = $this->delete_or_trash_entry( $entry );  | 
                                                        
| 345 | 345 | |
| 346 | -					if( is_wp_error( $delete_response ) ) { | 
                                                        |
| 346 | +					if ( is_wp_error( $delete_response ) ) { | 
                                                        |
| 347 | 347 | |
| 348 | 348 | $messages = array(  | 
                                                        
| 349 | 349 | 'message' => urlencode( $delete_response->get_error_message() ),  | 
                                                        
@@ -362,10 +362,10 @@ discard block  | 
                                                    ||
| 362 | 362 | |
| 363 | 363 |  			} else { | 
                                                        
| 364 | 364 | |
| 365 | -				do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug ); | 
                                                        |
| 365 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug ' . $entry_slug );  | 
                                                        |
| 366 | 366 | |
| 367 | 367 | $messages = array(  | 
                                                        
| 368 | -					'message' => urlencode( __('The entry does not exist.', 'gravityview') ), | 
                                                        |
| 368 | + 'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ),  | 
                                                        |
| 369 | 369 | 'status' => 'error',  | 
                                                        
| 370 | 370 | );  | 
                                                        
| 371 | 371 | }  | 
                                                        
@@ -405,18 +405,18 @@ discard block  | 
                                                    ||
| 405 | 405 | */  | 
                                                        
| 406 | 406 |  	private function delete_or_trash_entry( $entry ) { | 
                                                        
| 407 | 407 | |
| 408 | - $entry_id = $entry['id'];  | 
                                                        |
| 408 | + $entry_id = $entry[ 'id' ];  | 
                                                        |
| 409 | 409 | |
| 410 | 410 | $mode = $this->get_delete_mode();  | 
                                                        
| 411 | 411 | |
| 412 | -		if( 'delete' === $mode ) { | 
                                                        |
| 412 | +		if ( 'delete' === $mode ) { | 
                                                        |
| 413 | 413 | |
| 414 | 414 | do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id );  | 
                                                        
| 415 | 415 | |
| 416 | 416 | // Delete the entry  | 
                                                        
| 417 | 417 | $delete_response = GFAPI::delete_entry( $entry_id );  | 
                                                        
| 418 | 418 | |
| 419 | -			if( ! is_wp_error( $delete_response ) ) { | 
                                                        |
| 419 | +			if ( ! is_wp_error( $delete_response ) ) { | 
                                                        |
| 420 | 420 | $delete_response = 'deleted';  | 
                                                        
| 421 | 421 | |
| 422 | 422 | /**  | 
                                                        
@@ -437,8 +437,8 @@ discard block  | 
                                                    ||
| 437 | 437 | $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' );  | 
                                                        
| 438 | 438 | new GravityView_Cache;  | 
                                                        
| 439 | 439 | |
| 440 | -			if( ! $trashed ) { | 
                                                        |
| 441 | -				$delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) ); | 
                                                        |
| 440 | +			if ( ! $trashed ) { | 
                                                        |
| 441 | + $delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) );  | 
                                                        |
| 442 | 442 |  			} else { | 
                                                        
| 443 | 443 | |
| 444 | 444 | /**  | 
                                                        
@@ -469,7 +469,7 @@ discard block  | 
                                                    ||
| 469 | 469 |  	public function process_connected_posts( $entry_id = 0, $entry = array() ) { | 
                                                        
| 470 | 470 | |
| 471 | 471 | // The entry had no connected post  | 
                                                        
| 472 | -		if( empty( $entry['post_id'] ) ) { | 
                                                        |
| 472 | +		if ( empty( $entry[ 'post_id' ] ) ) { | 
                                                        |
| 473 | 473 | return;  | 
                                                        
| 474 | 474 | }  | 
                                                        
| 475 | 475 | |
@@ -480,22 +480,22 @@ discard block  | 
                                                    ||
| 480 | 480 | */  | 
                                                        
| 481 | 481 | $delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true );  | 
                                                        
| 482 | 482 | |
| 483 | -		if( false === $delete_post ) { | 
                                                        |
| 483 | +		if ( false === $delete_post ) { | 
                                                        |
| 484 | 484 | return;  | 
                                                        
| 485 | 485 | }  | 
                                                        
| 486 | 486 | |
| 487 | 487 | $action = current_action();  | 
                                                        
| 488 | 488 | |
| 489 | -		if( 'gravityview/delete-entry/deleted' === $action ) { | 
                                                        |
| 490 | - $result = wp_delete_post( $entry['post_id'], true );  | 
                                                        |
| 489 | +		if ( 'gravityview/delete-entry/deleted' === $action ) { | 
                                                        |
| 490 | + $result = wp_delete_post( $entry[ 'post_id' ], true );  | 
                                                        |
| 491 | 491 |  		} else { | 
                                                        
| 492 | - $result = wp_trash_post( $entry['post_id'] );  | 
                                                        |
| 492 | + $result = wp_trash_post( $entry[ 'post_id' ] );  | 
                                                        |
| 493 | 493 | }  | 
                                                        
| 494 | 494 | |
| 495 | -		if( false === $result ) { | 
                                                        |
| 496 | - do_action( 'gravityview_log_error', __METHOD__ . ' (called by '.$action.'): Error processing the Post connected to the entry.', $entry );  | 
                                                        |
| 495 | +		if ( false === $result ) { | 
                                                        |
| 496 | + do_action( 'gravityview_log_error', __METHOD__ . ' (called by ' . $action . '): Error processing the Post connected to the entry.', $entry );  | 
                                                        |
| 497 | 497 |  		} else { | 
                                                        
| 498 | - do_action( 'gravityview_log_debug', __METHOD__ . ' (called by '.$action.'): Successfully processed Post connected to the entry.', $entry );  | 
                                                        |
| 498 | + do_action( 'gravityview_log_debug', __METHOD__ . ' (called by ' . $action . '): Successfully processed Post connected to the entry.', $entry );  | 
                                                        |
| 499 | 499 | }  | 
                                                        
| 500 | 500 | }  | 
                                                        
| 501 | 501 | |
@@ -508,13 +508,13 @@ discard block  | 
                                                    ||
| 508 | 508 |  	public function verify_nonce() { | 
                                                        
| 509 | 509 | |
| 510 | 510 | // No delete entry request was made  | 
                                                        
| 511 | -		if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { | 
                                                        |
| 511 | +		if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) { | 
                                                        |
| 512 | 512 | return false;  | 
                                                        
| 513 | 513 | }  | 
                                                        
| 514 | 514 | |
| 515 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] );  | 
                                                        |
| 515 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] );  | 
                                                        |
| 516 | 516 | |
| 517 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key );  | 
                                                        |
| 517 | + $valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key );  | 
                                                        |
| 518 | 518 | |
| 519 | 519 | /**  | 
                                                        
| 520 | 520 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid.  | 
                                                        
@@ -536,7 +536,7 @@ discard block  | 
                                                    ||
| 536 | 536 | */  | 
                                                        
| 537 | 537 |  	public static function get_confirm_dialog() { | 
                                                        
| 538 | 538 | |
| 539 | -		$confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview'); | 
                                                        |
| 539 | + $confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' );  | 
                                                        |
| 540 | 540 | |
| 541 | 541 | /**  | 
                                                        
| 542 | 542 | * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text  | 
                                                        
@@ -544,7 +544,7 @@ discard block  | 
                                                    ||
| 544 | 544 | */  | 
                                                        
| 545 | 545 | $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm );  | 
                                                        
| 546 | 546 | |
| 547 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');';  | 
                                                        |
| 547 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');';  | 
                                                        |
| 548 | 548 | }  | 
                                                        
| 549 | 549 | |
| 550 | 550 | /**  | 
                                                        
@@ -562,16 +562,16 @@ discard block  | 
                                                    ||
| 562 | 562 | |
| 563 | 563 | $error = NULL;  | 
                                                        
| 564 | 564 | |
| 565 | -		if( ! $this->verify_nonce() ) { | 
                                                        |
| 566 | - $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview');  | 
                                                        |
| 565 | +		if ( ! $this->verify_nonce() ) { | 
                                                        |
| 566 | + $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' );  | 
                                                        |
| 567 | 567 | }  | 
                                                        
| 568 | 568 | |
| 569 | -		if( ! self::check_user_cap_delete_entry( $entry ) ) { | 
                                                        |
| 570 | - $error = __( 'You do not have permission to delete this entry.', 'gravityview');  | 
                                                        |
| 569 | +		if ( ! self::check_user_cap_delete_entry( $entry ) ) { | 
                                                        |
| 570 | + $error = __( 'You do not have permission to delete this entry.', 'gravityview' );  | 
                                                        |
| 571 | 571 | }  | 
                                                        
| 572 | 572 | |
| 573 | -		if( $entry['status'] === 'trash' ) { | 
                                                        |
| 574 | -			if( 'trash' === $this->get_delete_mode() ) { | 
                                                        |
| 573 | +		if ( $entry[ 'status' ] === 'trash' ) { | 
                                                        |
| 574 | +			if ( 'trash' === $this->get_delete_mode() ) { | 
                                                        |
| 575 | 575 | $error = __( 'The entry is already in the trash.', 'gravityview' );  | 
                                                        
| 576 | 576 |  			} else { | 
                                                        
| 577 | 577 | $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' );  | 
                                                        
@@ -579,11 +579,11 @@ discard block  | 
                                                    ||
| 579 | 579 | }  | 
                                                        
| 580 | 580 | |
| 581 | 581 | // No errors; everything's fine here!  | 
                                                        
| 582 | -		if( empty( $error ) ) { | 
                                                        |
| 582 | +		if ( empty( $error ) ) { | 
                                                        |
| 583 | 583 | return true;  | 
                                                        
| 584 | 584 | }  | 
                                                        
| 585 | 585 | |
| 586 | -		do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error ); | 
                                                        |
| 586 | + do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );  | 
                                                        |
| 587 | 587 | |
| 588 | 588 | return new WP_Error( 'gravityview-delete-entry-permissions', $error );  | 
                                                        
| 589 | 589 | }  | 
                                                        
@@ -605,32 +605,32 @@ discard block  | 
                                                    ||
| 605 | 605 | |
| 606 | 606 | $current_user = wp_get_current_user();  | 
                                                        
| 607 | 607 | |
| 608 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL;  | 
                                                        |
| 608 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL;  | 
                                                        |
| 609 | 609 | |
| 610 | 610 | // Or if they can delete any entries (as defined in Gravity Forms), we're good.  | 
                                                        
| 611 | -		if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { | 
                                                        |
| 611 | +		if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { | 
                                                        |
| 612 | 612 | |
| 613 | -			do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); | 
                                                        |
| 613 | + do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );  | 
                                                        |
| 614 | 614 | |
| 615 | 615 | return true;  | 
                                                        
| 616 | 616 | }  | 
                                                        
| 617 | 617 | |
| 618 | 618 | |
| 619 | 619 | // If field options are passed, check if current user can view the link  | 
                                                        
| 620 | -		if( !empty( $field ) ) { | 
                                                        |
| 620 | +		if ( ! empty( $field ) ) { | 
                                                        |
| 621 | 621 | |
| 622 | 622 | // If capability is not defined, something is not right!  | 
                                                        
| 623 | -			if( empty( $field['allow_edit_cap'] ) ) { | 
                                                        |
| 623 | +			if ( empty( $field[ 'allow_edit_cap' ] ) ) { | 
                                                        |
| 624 | 624 | |
| 625 | 625 | do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field );  | 
                                                        
| 626 | 626 | |
| 627 | 627 | return false;  | 
                                                        
| 628 | 628 | }  | 
                                                        
| 629 | 629 | |
| 630 | -			if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { | 
                                                        |
| 630 | +			if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) { | 
                                                        |
| 631 | 631 | |
| 632 | 632 | // Do not return true if cap is read, as we need to check if the current user created the entry  | 
                                                        
| 633 | -				if( $field['allow_edit_cap'] !== 'read' ) { | 
                                                        |
| 633 | +				if ( $field[ 'allow_edit_cap' ] !== 'read' ) { | 
                                                        |
| 634 | 634 | return true;  | 
                                                        
| 635 | 635 | }  | 
                                                        
| 636 | 636 | |
@@ -643,9 +643,9 @@ discard block  | 
                                                    ||
| 643 | 643 | |
| 644 | 644 | }  | 
                                                        
| 645 | 645 | |
| 646 | -		if( !isset( $entry['created_by'] ) ) { | 
                                                        |
| 646 | +		if ( ! isset( $entry[ 'created_by' ] ) ) { | 
                                                        |
| 647 | 647 | |
| 648 | -			do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.'); | 
                                                        |
| 648 | + do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.' );  | 
                                                        |
| 649 | 649 | |
| 650 | 650 | return false;  | 
                                                        
| 651 | 651 | }  | 
                                                        
@@ -653,24 +653,24 @@ discard block  | 
                                                    ||
| 653 | 653 | $view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id;  | 
                                                        
| 654 | 654 | |
| 655 | 655 | // Only checks user_delete view option if view is already set  | 
                                                        
| 656 | -		if( $view_id ) { | 
                                                        |
| 656 | +		if ( $view_id ) { | 
                                                        |
| 657 | 657 | |
| 658 | 658 | $current_view = gravityview_get_current_view_data( $view_id );  | 
                                                        
| 659 | 659 | |
| 660 | - $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false;  | 
                                                        |
| 660 | + $user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false;  | 
                                                        |
| 661 | 661 | |
| 662 | -			if( empty( $user_delete ) ) { | 
                                                        |
| 662 | +			if ( empty( $user_delete ) ) { | 
                                                        |
| 663 | 663 | |
| 664 | -				do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' ); | 
                                                        |
| 664 | + do_action( 'gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );  | 
                                                        |
| 665 | 665 | |
| 666 | 666 | return false;  | 
                                                        
| 667 | 667 | }  | 
                                                        
| 668 | 668 | }  | 
                                                        
| 669 | 669 | |
| 670 | 670 | // If the logged-in user is the same as the user who created the entry, we're good.  | 
                                                        
| 671 | -		if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { | 
                                                        |
| 671 | +		if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { | 
                                                        |
| 672 | 672 | |
| 673 | -			do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) ); | 
                                                        |
| 673 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );  | 
                                                        |
| 674 | 674 | |
| 675 | 675 | return true;  | 
                                                        
| 676 | 676 | }  | 
                                                        
@@ -693,31 +693,31 @@ discard block  | 
                                                    ||
| 693 | 693 | */  | 
                                                        
| 694 | 694 |  	public function display_message( $current_view_id = 0 ) { | 
                                                        
| 695 | 695 | |
| 696 | -		if( empty( $_GET['status'] ) || ! self::verify_nonce() ) { | 
                                                        |
| 696 | +		if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { | 
                                                        |
| 697 | 697 | return;  | 
                                                        
| 698 | 698 | }  | 
                                                        
| 699 | 699 | |
| 700 | 700 | // Entry wasn't deleted from current View  | 
                                                        
| 701 | -		if( intval( $_GET['gvid'] ) !== intval( $current_view_id ) ) { | 
                                                        |
| 701 | +		if ( intval( $_GET[ 'gvid' ] ) !== intval( $current_view_id ) ) { | 
                                                        |
| 702 | 702 | return;  | 
                                                        
| 703 | 703 | }  | 
                                                        
| 704 | 704 | |
| 705 | - $status = esc_attr( $_GET['status'] );  | 
                                                        |
| 706 | -		$message_from_url = rgget('message'); | 
                                                        |
| 705 | + $status = esc_attr( $_GET[ 'status' ] );  | 
                                                        |
| 706 | + $message_from_url = rgget( 'message' );  | 
                                                        |
| 707 | 707 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) );  | 
                                                        
| 708 | 708 | $class = '';  | 
                                                        
| 709 | 709 | |
| 710 | 710 |  		switch ( $status ) { | 
                                                        
| 711 | 711 | case 'error':  | 
                                                        
| 712 | 712 | $class = ' gv-error error';  | 
                                                        
| 713 | -				$error_message = __('There was an error deleting the entry: %s', 'gravityview'); | 
                                                        |
| 713 | + $error_message = __( 'There was an error deleting the entry: %s', 'gravityview' );  | 
                                                        |
| 714 | 714 | $message = sprintf( $error_message, $message_from_url );  | 
                                                        
| 715 | 715 | break;  | 
                                                        
| 716 | 716 | case 'trashed':  | 
                                                        
| 717 | -				$message = __('The entry was successfully moved to the trash.', 'gravityview'); | 
                                                        |
| 717 | + $message = __( 'The entry was successfully moved to the trash.', 'gravityview' );  | 
                                                        |
| 718 | 718 | break;  | 
                                                        
| 719 | 719 | default:  | 
                                                        
| 720 | -				$message = __('The entry was successfully deleted.', 'gravityview'); | 
                                                        |
| 720 | + $message = __( 'The entry was successfully deleted.', 'gravityview' );  | 
                                                        |
| 721 | 721 | break;  | 
                                                        
| 722 | 722 | }  | 
                                                        
| 723 | 723 | |
@@ -731,7 +731,7 @@ discard block  | 
                                                    ||
| 731 | 731 | $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url );  | 
                                                        
| 732 | 732 | |
| 733 | 733 | // DISPLAY ERROR/SUCCESS MESSAGE  | 
                                                        
| 734 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>';  | 
                                                        |
| 734 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>';  | 
                                                        |
| 735 | 735 | }  | 
                                                        
| 736 | 736 | |
| 737 | 737 | |
@@ -22,7 +22,7 @@ discard block  | 
                                                    ||
| 22 | 22 | |
| 23 | 23 | $this->label = esc_attr__( 'Approve Entries', 'gravityview' );  | 
                                                        
| 24 | 24 | |
| 25 | - $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' );  | 
                                                        |
| 25 | + $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' );  | 
                                                        |
| 26 | 26 | |
| 27 | 27 | $this->add_hooks();  | 
                                                        
| 28 | 28 | |
@@ -44,11 +44,11 @@ discard block  | 
                                                    ||
| 44 | 44 | */  | 
                                                        
| 45 | 45 |  	function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { | 
                                                        
| 46 | 46 | |
| 47 | - unset( $field_options['only_loggedin'] );  | 
                                                        |
| 47 | + unset( $field_options[ 'only_loggedin' ] );  | 
                                                        |
| 48 | 48 | |
| 49 | - unset( $field_options['new_window'] );  | 
                                                        |
| 49 | + unset( $field_options[ 'new_window' ] );  | 
                                                        |
| 50 | 50 | |
| 51 | - unset( $field_options['show_as_link'] );  | 
                                                        |
| 51 | + unset( $field_options[ 'show_as_link' ] );  | 
                                                        |
| 52 | 52 | |
| 53 | 53 | return $field_options;  | 
                                                        
| 54 | 54 | }  | 
                                                        
@@ -68,7 +68,7 @@ discard block  | 
                                                    ||
| 68 | 68 | |
| 69 | 69 | add_action( 'gravityview/field/approval/load_scripts', array( $this, 'enqueue_and_localize_script' ) );  | 
                                                        
| 70 | 70 | |
| 71 | - add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) );  | 
                                                        |
| 71 | + add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) );  | 
                                                        |
| 72 | 72 | |
| 73 | 73 | add_filter( 'gravityview_get_entries', array( $this, 'modify_search_parameters' ), 1000 );  | 
                                                        
| 74 | 74 | |
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 |  	public function maybe_prevent_field_render( $html, $args ) { | 
                                                        
| 89 | 89 | |
| 90 | 90 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render.  | 
                                                        
| 91 | -		if( $this->name === rgar( $args['field'], 'id' ) && ! GVCommon::has_cap('gravityview_moderate_entries') ) { | 
                                                        |
| 91 | +		if ( $this->name === rgar( $args[ 'field' ], 'id' ) && ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { | 
                                                        |
| 92 | 92 | return '';  | 
                                                        
| 93 | 93 | }  | 
                                                        
| 94 | 94 | |
@@ -104,8 +104,8 @@ discard block  | 
                                                    ||
| 104 | 104 | */  | 
                                                        
| 105 | 105 |  	public function modify_search_parameters( $parameters ) { | 
                                                        
| 106 | 106 | |
| 107 | -		if( $this->name === rgars( $parameters, 'sorting/key' ) ) { | 
                                                        |
| 108 | - $parameters['sorting']['key'] = 'is_approved';  | 
                                                        |
| 107 | +		if ( $this->name === rgars( $parameters, 'sorting/key' ) ) { | 
                                                        |
| 108 | + $parameters[ 'sorting' ][ 'key' ] = 'is_approved';  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | return $parameters;  | 
                                                        
@@ -121,18 +121,18 @@ discard block  | 
                                                    ||
| 121 | 121 |  	function register_scripts_and_styles() { | 
                                                        
| 122 | 122 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';  | 
                                                        
| 123 | 123 | |
| 124 | - wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval'.$script_debug.'.js', array( 'jquery' ), GravityView_Plugin::version, true );  | 
                                                        |
| 124 | + wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval' . $script_debug . '.js', array( 'jquery' ), GravityView_Plugin::version, true );  | 
                                                        |
| 125 | 125 | |
| 126 | 126 | $style_path = GRAVITYVIEW_DIR . 'templates/css/field-approval.css';  | 
                                                        
| 127 | 127 | |
| 128 | -		if( class_exists( 'GravityView_View' ) ) { | 
                                                        |
| 128 | +		if ( class_exists( 'GravityView_View' ) ) { | 
                                                        |
| 129 | 129 | /**  | 
                                                        
| 130 | 130 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory.  | 
                                                        
| 131 | 131 | */  | 
                                                        
| 132 | 132 | $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false );  | 
                                                        
| 133 | 133 | }  | 
                                                        
| 134 | 134 | |
| 135 | - $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) );  | 
                                                        |
| 135 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) );  | 
                                                        |
| 136 | 136 | |
| 137 | 137 | /**  | 
                                                        
| 138 | 138 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file.  | 
                                                        
@@ -141,7 +141,7 @@ discard block  | 
                                                    ||
| 141 | 141 | */  | 
                                                        
| 142 | 142 | $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url );  | 
                                                        
| 143 | 143 | |
| 144 | -		if( ! empty( $style_url ) ) { | 
                                                        |
| 144 | +		if ( ! empty( $style_url ) ) { | 
                                                        |
| 145 | 145 | wp_register_style( 'gravityview-field-approval', $style_url, array( 'dashicons' ), GravityView_Plugin::version, 'screen' );  | 
                                                        
| 146 | 146 | }  | 
                                                        
| 147 | 147 | |
@@ -156,7 +156,7 @@ discard block  | 
                                                    ||
| 156 | 156 |  	public function enqueue_and_localize_script() { | 
                                                        
| 157 | 157 | |
| 158 | 158 | // The script is already registered and enqueued  | 
                                                        
| 159 | -		if( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { | 
                                                        |
| 159 | +		if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { | 
                                                        |
| 160 | 160 | return;  | 
                                                        
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
@@ -166,9 +166,9 @@ discard block  | 
                                                    ||
| 166 | 166 | |
| 167 | 167 | wp_localize_script( 'gravityview-field-approval', 'gvApproval', array(  | 
                                                        
| 168 | 168 | 'ajaxurl' => admin_url( 'admin-ajax.php' ),  | 
                                                        
| 169 | -			'nonce' => wp_create_nonce('gravityview_entry_approval'), | 
                                                        |
| 169 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ),  | 
                                                        |
| 170 | 170 | 'status' => GravityView_Entry_Approval_Status::get_all(),  | 
                                                        
| 171 | - ));  | 
                                                        |
| 171 | + ) );  | 
                                                        |
| 172 | 172 | |
| 173 | 173 | }  | 
                                                        
| 174 | 174 | |
@@ -185,8 +185,8 @@ discard block  | 
                                                    ||
| 185 | 185 | */  | 
                                                        
| 186 | 186 |  	public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { | 
                                                        
| 187 | 187 | |
| 188 | -		if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { | 
                                                        |
| 189 | -			$entry_default_fields["{$this->name}"] = array( | 
                                                        |
| 188 | +		if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { | 
                                                        |
| 189 | +			$entry_default_fields[ "{$this->name}" ] = array( | 
                                                        |
| 190 | 190 | 'label' => $this->label,  | 
                                                        
| 191 | 191 | 'desc' => $this->description,  | 
                                                        
| 192 | 192 | 'type' => $this->name,  | 
                                                        
@@ -126,8 +126,8 @@ discard block  | 
                                                    ||
| 126 | 126 | |
| 127 | 127 | $form = false;  | 
                                                        
| 128 | 128 | |
| 129 | -		if( $entry ) { | 
                                                        |
| 130 | - $form = GFAPI::get_form( $entry['form_id'] );  | 
                                                        |
| 129 | +		if ( $entry ) { | 
                                                        |
| 130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] );  | 
                                                        |
| 131 | 131 | }  | 
                                                        
| 132 | 132 | |
| 133 | 133 | return $form;  | 
                                                        
@@ -186,7 +186,7 @@ discard block  | 
                                                    ||
| 186 | 186 | |
| 187 | 187 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging );  | 
                                                        
| 188 | 188 | |
| 189 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;  | 
                                                        |
| 189 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null;  | 
                                                        |
| 190 | 190 | |
| 191 | 191 | return $result;  | 
                                                        
| 192 | 192 | }  | 
                                                        
@@ -203,10 +203,10 @@ discard block  | 
                                                    ||
| 203 | 203 | *  | 
                                                        
| 204 | 204 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms  | 
                                                        
| 205 | 205 | */  | 
                                                        
| 206 | -	public static function get_forms(  $active = true, $trash = false ) { | 
                                                        |
| 206 | +	public static function get_forms( $active = true, $trash = false ) { | 
                                                        |
| 207 | 207 | $forms = array();  | 
                                                        
| 208 | 208 |  		if ( class_exists( 'GFAPI' ) ) { | 
                                                        
| 209 | -			if( 'any' === $active ) { | 
                                                        |
| 209 | +			if ( 'any' === $active ) { | 
                                                        |
| 210 | 210 | $active_forms = GFAPI::get_forms( true, $trash );  | 
                                                        
| 211 | 211 | $inactive_forms = GFAPI::get_forms( false, $trash );  | 
                                                        
| 212 | 212 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) );  | 
                                                        
@@ -237,9 +237,9 @@ discard block  | 
                                                    ||
| 237 | 237 | $has_post_fields = false;  | 
                                                        
| 238 | 238 | |
| 239 | 239 |  		if ( $form ) { | 
                                                        
| 240 | -			foreach ( $form['fields'] as $field ) { | 
                                                        |
| 241 | -				if ( $include_parent_field || empty( $field['inputs'] ) ) { | 
                                                        |
| 242 | -					$fields["{$field['id']}"] = array( | 
                                                        |
| 240 | +			foreach ( $form[ 'fields' ] as $field ) { | 
                                                        |
| 241 | +				if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { | 
                                                        |
| 242 | +					$fields[ "{$field[ 'id' ]}" ] = array( | 
                                                        |
| 243 | 243 | 'label' => rgar( $field, 'label' ),  | 
                                                        
| 244 | 244 | 'parent' => null,  | 
                                                        
| 245 | 245 | 'type' => rgar( $field, 'type' ),  | 
                                                        
@@ -248,10 +248,10 @@ discard block  | 
                                                    ||
| 248 | 248 | );  | 
                                                        
| 249 | 249 | }  | 
                                                        
| 250 | 250 | |
| 251 | -				if ( $add_default_properties && ! empty( $field['inputs'] ) ) { | 
                                                        |
| 252 | -					foreach ( $field['inputs'] as $input ) { | 
                                                        |
| 251 | +				if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { | 
                                                        |
| 252 | +					foreach ( $field[ 'inputs' ] as $input ) { | 
                                                        |
| 253 | 253 | |
| 254 | -						if( ! empty( $input['isHidden'] ) ) { | 
                                                        |
| 254 | +						if ( ! empty( $input[ 'isHidden' ] ) ) { | 
                                                        |
| 255 | 255 | continue;  | 
                                                        
| 256 | 256 | }  | 
                                                        
| 257 | 257 | |
@@ -259,10 +259,10 @@ discard block  | 
                                                    ||
| 259 | 259 | * @hack  | 
                                                        
| 260 | 260 | * In case of email/email confirmation, the input for email has the same id as the parent field  | 
                                                        
| 261 | 261 | */  | 
                                                        
| 262 | -						if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { | 
                                                        |
| 262 | +						if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { | 
                                                        |
| 263 | 263 | continue;  | 
                                                        
| 264 | 264 | }  | 
                                                        
| 265 | -						$fields["{$input['id']}"] = array( | 
                                                        |
| 265 | +						$fields[ "{$input[ 'id' ]}" ] = array( | 
                                                        |
| 266 | 266 | 'label' => rgar( $input, 'label' ),  | 
                                                        
| 267 | 267 | 'customLabel' => rgar( $input, 'customLabel' ),  | 
                                                        
| 268 | 268 | 'parent' => $field,  | 
                                                        
@@ -274,7 +274,7 @@ discard block  | 
                                                    ||
| 274 | 274 | }  | 
                                                        
| 275 | 275 | |
| 276 | 276 | |
| 277 | -				if( GFCommon::is_product_field( $field['type'] ) ){ | 
                                                        |
| 277 | +				if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { | 
                                                        |
| 278 | 278 | $has_product_fields = true;  | 
                                                        
| 279 | 279 | }  | 
                                                        
| 280 | 280 | |
@@ -288,7 +288,7 @@ discard block  | 
                                                    ||
| 288 | 288 | * @since 1.7  | 
                                                        
| 289 | 289 | */  | 
                                                        
| 290 | 290 |  		if ( $has_post_fields ) { | 
                                                        
| 291 | - $fields['post_id'] = array(  | 
                                                        |
| 291 | + $fields[ 'post_id' ] = array(  | 
                                                        |
| 292 | 292 | 'label' => __( 'Post ID', 'gravityview' ),  | 
                                                        
| 293 | 293 | 'type' => 'post_id',  | 
                                                        
| 294 | 294 | );  | 
                                                        
@@ -299,10 +299,10 @@ discard block  | 
                                                    ||
| 299 | 299 | $payment_fields = GravityView_Fields::get_all( 'pricing' );  | 
                                                        
| 300 | 300 | |
| 301 | 301 |  			foreach ( $payment_fields as $payment_field ) { | 
                                                        
| 302 | -				if( isset( $fields["{$payment_field->name}"] ) ) { | 
                                                        |
| 302 | +				if ( isset( $fields[ "{$payment_field->name}" ] ) ) { | 
                                                        |
| 303 | 303 | continue;  | 
                                                        
| 304 | 304 | }  | 
                                                        
| 305 | -				$fields["{$payment_field->name}"] = array( | 
                                                        |
| 305 | +				$fields[ "{$payment_field->name}" ] = array( | 
                                                        |
| 306 | 306 | 'label' => $payment_field->label,  | 
                                                        
| 307 | 307 | 'desc' => $payment_field->description,  | 
                                                        
| 308 | 308 | 'type' => $payment_field->name,  | 
                                                        
@@ -334,9 +334,9 @@ discard block  | 
                                                    ||
| 334 | 334 | |
| 335 | 335 | $fields = array();  | 
                                                        
| 336 | 336 | |
| 337 | -		foreach ( $extra_fields as $key => $field ){ | 
                                                        |
| 338 | -			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { | 
                                                        |
| 339 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );  | 
                                                        |
| 337 | +		foreach ( $extra_fields as $key => $field ) { | 
                                                        |
| 338 | +			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { | 
                                                        |
| 339 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );  | 
                                                        |
| 340 | 340 | }  | 
                                                        
| 341 | 341 | }  | 
                                                        
| 342 | 342 | |
@@ -376,32 +376,32 @@ discard block  | 
                                                    ||
| 376 | 376 | 'search_criteria' => null,  | 
                                                        
| 377 | 377 | 'sorting' => null,  | 
                                                        
| 378 | 378 | 'paging' => null,  | 
                                                        
| 379 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true),  | 
                                                        |
| 379 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ),  | 
                                                        |
| 380 | 380 | );  | 
                                                        
| 381 | 381 | |
| 382 | 382 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );  | 
                                                        
| 383 | 383 | |
| 384 | -		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { | 
                                                        |
| 385 | -			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { | 
                                                        |
| 384 | +		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { | 
                                                        |
| 385 | +			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { | 
                                                        |
| 386 | 386 | |
| 387 | 387 |  				if ( ! is_array( $filter ) ) { | 
                                                        
| 388 | 388 | continue;  | 
                                                        
| 389 | 389 | }  | 
                                                        
| 390 | 390 | |
| 391 | 391 | // By default, we want searches to be wildcard for each field.  | 
                                                        
| 392 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];  | 
                                                        |
| 392 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];  | 
                                                        |
| 393 | 393 | |
| 394 | 394 | /**  | 
                                                        
| 395 | 395 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)  | 
                                                        
| 396 | 396 | * @param string $operator Existing search operator  | 
                                                        
| 397 | 397 | * @param array $filter array with `key`, `value`, `operator`, `type` keys  | 
                                                        
| 398 | 398 | */  | 
                                                        
| 399 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );  | 
                                                        |
| 399 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );  | 
                                                        |
| 400 | 400 | }  | 
                                                        
| 401 | 401 | |
| 402 | 402 | // don't send just the [mode] without any field filter.  | 
                                                        
| 403 | -			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { | 
                                                        |
| 404 | - unset( $criteria['search_criteria']['field_filters']['mode'] );  | 
                                                        |
| 403 | +			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { | 
                                                        |
| 404 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );  | 
                                                        |
| 405 | 405 | }  | 
                                                        
| 406 | 406 | |
| 407 | 407 | }  | 
                                                        
@@ -412,21 +412,21 @@ discard block  | 
                                                    ||
| 412 | 412 | * Prepare date formats to be in Gravity Forms DB format;  | 
                                                        
| 413 | 413 | * $passed_criteria may include date formats incompatible with Gravity Forms.  | 
                                                        
| 414 | 414 | */  | 
                                                        
| 415 | -		foreach ( array('start_date', 'end_date' ) as $key ) { | 
                                                        |
| 415 | +		foreach ( array( 'start_date', 'end_date' ) as $key ) { | 
                                                        |
| 416 | 416 | |
| 417 | -			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { | 
                                                        |
| 417 | +			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { | 
                                                        |
| 418 | 418 | |
| 419 | 419 | // Use date_create instead of new DateTime so it returns false if invalid date format.  | 
                                                        
| 420 | - $date = date_create( $criteria['search_criteria'][ $key ] );  | 
                                                        |
| 420 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] );  | 
                                                        |
| 421 | 421 | |
| 422 | 422 |  				if ( $date ) { | 
                                                        
| 423 | 423 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format.  | 
                                                        
| 424 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );  | 
                                                        |
| 424 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );  | 
                                                        |
| 425 | 425 |  				} else { | 
                                                        
| 426 | 426 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise.  | 
                                                        
| 427 | - unset( $criteria['search_criteria'][ $key ] );  | 
                                                        |
| 427 | + unset( $criteria[ 'search_criteria' ][ $key ] );  | 
                                                        |
| 428 | 428 | |
| 429 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] );  | 
                                                        |
| 429 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] );  | 
                                                        |
| 430 | 430 | }  | 
                                                        
| 431 | 431 | }  | 
                                                        
| 432 | 432 | }  | 
                                                        
@@ -434,12 +434,12 @@ discard block  | 
                                                    ||
| 434 | 434 | |
| 435 | 435 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter  | 
                                                        
| 436 | 436 |  		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { | 
                                                        
| 437 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();  | 
                                                        |
| 437 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();  | 
                                                        |
| 438 | 438 |  		} elseif ( 'delete' === RGForms::get( 'action' ) ) { | 
                                                        
| 439 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null;  | 
                                                        |
| 440 | -		} elseif( !isset( $criteria['context_view_id'] ) ) { | 
                                                        |
| 439 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null;  | 
                                                        |
| 440 | +		} elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { | 
                                                        |
| 441 | 441 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)  | 
                                                        
| 442 | - $criteria['context_view_id'] = null;  | 
                                                        |
| 442 | + $criteria[ 'context_view_id' ] = null;  | 
                                                        |
| 443 | 443 | }  | 
                                                        
| 444 | 444 | |
| 445 | 445 | /**  | 
                                                        
@@ -448,7 +448,7 @@ discard block  | 
                                                    ||
| 448 | 448 | * @param array $form_ids Forms to search  | 
                                                        
| 449 | 449 | * @param int $view_id ID of the view being used to search  | 
                                                        
| 450 | 450 | */  | 
                                                        
| 451 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );  | 
                                                        |
| 451 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );  | 
                                                        |
| 452 | 452 | |
| 453 | 453 | return (array)$criteria;  | 
                                                        
| 454 | 454 | |
@@ -479,7 +479,7 @@ discard block  | 
                                                    ||
| 479 | 479 | /** Reduce # of database calls */  | 
                                                        
| 480 | 480 | add_filter( 'gform_is_encrypted_field', '__return_false' );  | 
                                                        
| 481 | 481 | |
| 482 | -		if ( ! empty( $criteria['cache'] ) ) { | 
                                                        |
| 482 | +		if ( ! empty( $criteria[ 'cache' ] ) ) { | 
                                                        |
| 483 | 483 | |
| 484 | 484 | $Cache = new GravityView_Cache( $form_ids, $criteria );  | 
                                                        
| 485 | 485 | |
@@ -487,7 +487,7 @@ discard block  | 
                                                    ||
| 487 | 487 | |
| 488 | 488 | // Still update the total count when using cached results  | 
                                                        
| 489 | 489 |  				if ( ! is_null( $total ) ) { | 
                                                        
| 490 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );  | 
                                                        |
| 490 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );  | 
                                                        |
| 491 | 491 | }  | 
                                                        
| 492 | 492 | |
| 493 | 493 | $return = $entries;  | 
                                                        
@@ -507,9 +507,9 @@ discard block  | 
                                                    ||
| 507 | 507 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );  | 
                                                        
| 508 | 508 | |
| 509 | 509 | // No entries returned from gravityview_before_get_entries  | 
                                                        
| 510 | -			if( is_null( $entries ) ) { | 
                                                        |
| 510 | +			if ( is_null( $entries ) ) { | 
                                                        |
| 511 | 511 | |
| 512 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );  | 
                                                        |
| 512 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );  | 
                                                        |
| 513 | 513 | |
| 514 | 514 |  				if ( is_wp_error( $entries ) ) { | 
                                                        
| 515 | 515 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );  | 
                                                        
@@ -518,7 +518,7 @@ discard block  | 
                                                    ||
| 518 | 518 | }  | 
                                                        
| 519 | 519 | }  | 
                                                        
| 520 | 520 | |
| 521 | -			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { | 
                                                        |
| 521 | +			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { | 
                                                        |
| 522 | 522 | |
| 523 | 523 | // Cache results  | 
                                                        
| 524 | 524 | $Cache->set( $entries, 'entries' );  | 
                                                        
@@ -623,7 +623,7 @@ discard block  | 
                                                    ||
| 623 | 623 | */  | 
                                                        
| 624 | 624 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );  | 
                                                        
| 625 | 625 | |
| 626 | -			if( $check_entry_display ) { | 
                                                        |
| 626 | +			if ( $check_entry_display ) { | 
                                                        |
| 627 | 627 | // Is the entry allowed  | 
                                                        
| 628 | 628 | $entry = self::check_entry_display( $entry );  | 
                                                        
| 629 | 629 | }  | 
                                                        
@@ -656,12 +656,12 @@ discard block  | 
                                                    ||
| 656 | 656 | |
| 657 | 657 | $value = false;  | 
                                                        
| 658 | 658 | |
| 659 | -		if( 'context' === $val1 ) { | 
                                                        |
| 659 | +		if ( 'context' === $val1 ) { | 
                                                        |
| 660 | 660 | |
| 661 | 661 | $matching_contexts = array( $val2 );  | 
                                                        
| 662 | 662 | |
| 663 | 663 | // We allow for non-standard contexts.  | 
                                                        
| 664 | -			switch( $val2 ) { | 
                                                        |
| 664 | +			switch ( $val2 ) { | 
                                                        |
| 665 | 665 | // Check for either single or edit  | 
                                                        
| 666 | 666 | case 'singular':  | 
                                                        
| 667 | 667 | $matching_contexts = array( 'single', 'edit' );  | 
                                                        
@@ -721,7 +721,7 @@ discard block  | 
                                                    ||
| 721 | 721 | return false;  | 
                                                        
| 722 | 722 | }  | 
                                                        
| 723 | 723 | |
| 724 | -		if ( empty( $entry['form_id'] ) ) { | 
                                                        |
| 724 | +		if ( empty( $entry[ 'form_id' ] ) ) { | 
                                                        |
| 725 | 725 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry );  | 
                                                        
| 726 | 726 | return false;  | 
                                                        
| 727 | 727 | }  | 
                                                        
@@ -729,26 +729,26 @@ discard block  | 
                                                    ||
| 729 | 729 | $criteria = self::calculate_get_entries_criteria();  | 
                                                        
| 730 | 730 | |
| 731 | 731 | // Make sure the current View is connected to the same form as the Entry  | 
                                                        
| 732 | -		if( ! empty( $criteria['context_view_id'] ) ) { | 
                                                        |
| 733 | - $context_view_id = intval( $criteria['context_view_id'] );  | 
                                                        |
| 732 | +		if ( ! empty( $criteria[ 'context_view_id' ] ) ) { | 
                                                        |
| 733 | + $context_view_id = intval( $criteria[ 'context_view_id' ] );  | 
                                                        |
| 734 | 734 | $context_form_id = gravityview_get_form_id( $context_view_id );  | 
                                                        
| 735 | -			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { | 
                                                        |
| 736 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] );  | 
                                                        |
| 735 | +			if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { | 
                                                        |
| 736 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] );  | 
                                                        |
| 737 | 737 | return false;  | 
                                                        
| 738 | 738 | }  | 
                                                        
| 739 | 739 | }  | 
                                                        
| 740 | 740 | |
| 741 | -		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { | 
                                                        |
| 741 | +		if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { | 
                                                        |
| 742 | 742 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );  | 
                                                        
| 743 | 743 | return $entry;  | 
                                                        
| 744 | 744 | }  | 
                                                        
| 745 | 745 | |
| 746 | - $search_criteria = $criteria['search_criteria'];  | 
                                                        |
| 746 | + $search_criteria = $criteria[ 'search_criteria' ];  | 
                                                        |
| 747 | 747 | unset( $criteria );  | 
                                                        
| 748 | 748 | |
| 749 | 749 | // check entry status  | 
                                                        
| 750 | -		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { | 
                                                        |
| 751 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );  | 
                                                        |
| 750 | +		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { | 
                                                        |
| 751 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria );  | 
                                                        |
| 752 | 752 | return false;  | 
                                                        
| 753 | 753 | }  | 
                                                        
| 754 | 754 | |
@@ -756,40 +756,40 @@ discard block  | 
                                                    ||
| 756 | 756 | // @todo: Does it make sense to apply the Date create filters to the single entry?  | 
                                                        
| 757 | 757 | |
| 758 | 758 | // field_filters  | 
                                                        
| 759 | -		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { | 
                                                        |
| 759 | +		if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { | 
                                                        |
| 760 | 760 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );  | 
                                                        
| 761 | 761 | return $entry;  | 
                                                        
| 762 | 762 | }  | 
                                                        
| 763 | 763 | |
| 764 | - $filters = $search_criteria['field_filters'];  | 
                                                        |
| 764 | + $filters = $search_criteria[ 'field_filters' ];  | 
                                                        |
| 765 | 765 | unset( $search_criteria );  | 
                                                        
| 766 | 766 | |
| 767 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';  | 
                                                        |
| 768 | - unset( $filters['mode'] );  | 
                                                        |
| 767 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all';  | 
                                                        |
| 768 | + unset( $filters[ 'mode' ] );  | 
                                                        |
| 769 | 769 | |
| 770 | - $form = self::get_form( $entry['form_id'] );  | 
                                                        |
| 770 | + $form = self::get_form( $entry[ 'form_id' ] );  | 
                                                        |
| 771 | 771 | |
| 772 | 772 |  		foreach ( $filters as $filter ) { | 
                                                        
| 773 | 773 | |
| 774 | -			if ( ! isset( $filter['key'] ) ) { | 
                                                        |
| 774 | +			if ( ! isset( $filter[ 'key' ] ) ) { | 
                                                        |
| 775 | 775 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter );  | 
                                                        
| 776 | 776 | continue;  | 
                                                        
| 777 | 777 | }  | 
                                                        
| 778 | 778 | |
| 779 | - $k = $filter['key'];  | 
                                                        |
| 779 | + $k = $filter[ 'key' ];  | 
                                                        |
| 780 | 780 | |
| 781 | 781 |  			if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { | 
                                                        
| 782 | 782 | $field_value = $entry[ $k ];  | 
                                                        
| 783 | 783 | $field = null;  | 
                                                        
| 784 | 784 |  			} else { | 
                                                        
| 785 | 785 | $field = self::get_field( $form, $k );  | 
                                                        
| 786 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field );  | 
                                                        |
| 786 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field );  | 
                                                        |
| 787 | 787 | // If it's a complex field, then fetch the input's value  | 
                                                        
| 788 | 788 | $field_value = is_array( $field_value ) ? rgar( $field_value, $k ) : $field_value;  | 
                                                        
| 789 | 789 | }  | 
                                                        
| 790 | 790 | |
| 791 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';  | 
                                                        |
| 792 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );  | 
                                                        |
| 791 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is';  | 
                                                        |
| 792 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field );  | 
                                                        |
| 793 | 793 | |
| 794 | 794 | // verify if we are already free to go!  | 
                                                        
| 795 | 795 |  			if ( ! $is_value_match && 'all' === $mode ) { | 
                                                        
@@ -847,18 +847,18 @@ discard block  | 
                                                    ||
| 847 | 847 | * Gravity Forms code to adjust date to locally-configured Time Zone  | 
                                                        
| 848 | 848 | * @see GFCommon::format_date() for original code  | 
                                                        
| 849 | 849 | */  | 
                                                        
| 850 | - $date_gmt_time = mysql2date( 'G', $date_string );  | 
                                                        |
| 850 | + $date_gmt_time = mysql2date( 'G', $date_string );  | 
                                                        |
| 851 | 851 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );  | 
                                                        
| 852 | 852 | |
| 853 | - $format = rgar( $atts, 'format' );  | 
                                                        |
| 854 | - $is_human = ! empty( $atts['human'] );  | 
                                                        |
| 855 | - $is_diff = ! empty( $atts['diff'] );  | 
                                                        |
| 856 | - $is_raw = ! empty( $atts['raw'] );  | 
                                                        |
| 857 | - $is_timestamp = ! empty( $atts['timestamp'] );  | 
                                                        |
| 858 | - $include_time = ! empty( $atts['time'] );  | 
                                                        |
| 853 | + $format = rgar( $atts, 'format' );  | 
                                                        |
| 854 | + $is_human = ! empty( $atts[ 'human' ] );  | 
                                                        |
| 855 | + $is_diff = ! empty( $atts[ 'diff' ] );  | 
                                                        |
| 856 | + $is_raw = ! empty( $atts[ 'raw' ] );  | 
                                                        |
| 857 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] );  | 
                                                        |
| 858 | + $include_time = ! empty( $atts[ 'time' ] );  | 
                                                        |
| 859 | 859 | |
| 860 | 860 | // If we're using time diff, we want to have a different default format  | 
                                                        
| 861 | -		if( empty( $format ) ) { | 
                                                        |
| 861 | +		if ( empty( $format ) ) { | 
                                                        |
| 862 | 862 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */  | 
                                                        
| 863 | 863 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );  | 
                                                        
| 864 | 864 | }  | 
                                                        
@@ -866,7 +866,7 @@ discard block  | 
                                                    ||
| 866 | 866 | // If raw was specified, don't modify the stored value  | 
                                                        
| 867 | 867 |  		if ( $is_raw ) { | 
                                                        
| 868 | 868 | $formatted_date = $date_string;  | 
                                                        
| 869 | -		} elseif( $is_timestamp ) { | 
                                                        |
| 869 | +		} elseif ( $is_timestamp ) { | 
                                                        |
| 870 | 870 | $formatted_date = $date_local_timestamp;  | 
                                                        
| 871 | 871 |  		} elseif ( $is_diff ) { | 
                                                        
| 872 | 872 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );  | 
                                                        
@@ -900,7 +900,7 @@ discard block  | 
                                                    ||
| 900 | 900 | |
| 901 | 901 | $label = rgar( $field, 'label' );  | 
                                                        
| 902 | 902 | |
| 903 | -		if( floor( $field_id ) !== floatval( $field_id ) ) { | 
                                                        |
| 903 | +		if ( floor( $field_id ) !== floatval( $field_id ) ) { | 
                                                        |
| 904 | 904 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id );  | 
                                                        
| 905 | 905 | }  | 
                                                        
| 906 | 906 | |
@@ -928,7 +928,7 @@ discard block  | 
                                                    ||
| 928 | 928 | $form = GFAPI::get_form( $form );  | 
                                                        
| 929 | 929 | }  | 
                                                        
| 930 | 930 | |
| 931 | -		if ( class_exists( 'GFFormsModel' ) ){ | 
                                                        |
| 931 | +		if ( class_exists( 'GFFormsModel' ) ) { | 
                                                        |
| 932 | 932 | return GFFormsModel::get_field( $form, $field_id );  | 
                                                        
| 933 | 933 |  		} else { | 
                                                        
| 934 | 934 | return null;  | 
                                                        
@@ -975,19 +975,19 @@ discard block  | 
                                                    ||
| 975 | 975 | $shortcodes = array();  | 
                                                        
| 976 | 976 | |
| 977 | 977 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );  | 
                                                        
| 978 | -			if ( empty( $matches ) ){ | 
                                                        |
| 978 | +			if ( empty( $matches ) ) { | 
                                                        |
| 979 | 979 | return false;  | 
                                                        
| 980 | 980 | }  | 
                                                        
| 981 | 981 | |
| 982 | 982 |  			foreach ( $matches as $shortcode ) { | 
                                                        
| 983 | -				if ( $tag === $shortcode[2] ) { | 
                                                        |
| 983 | +				if ( $tag === $shortcode[ 2 ] ) { | 
                                                        |
| 984 | 984 | |
| 985 | 985 | // Changed this to $shortcode instead of true so we get the parsed atts.  | 
                                                        
| 986 | - $shortcodes[] = $shortcode;  | 
                                                        |
| 986 | + $shortcodes[ ] = $shortcode;  | 
                                                        |
| 987 | 987 | |
| 988 | -				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { | 
                                                        |
| 989 | -					foreach( $results as $result ) { | 
                                                        |
| 990 | - $shortcodes[] = $result;  | 
                                                        |
| 988 | +				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { | 
                                                        |
| 989 | +					foreach ( $results as $result ) { | 
                                                        |
| 990 | + $shortcodes[ ] = $result;  | 
                                                        |
| 991 | 991 | }  | 
                                                        
| 992 | 992 | }  | 
                                                        
| 993 | 993 | }  | 
                                                        
@@ -1131,7 +1131,7 @@ discard block  | 
                                                    ||
| 1131 | 1131 |  	public static function get_directory_fields( $post_id, $apply_filter = true ) { | 
                                                        
| 1132 | 1132 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true );  | 
                                                        
| 1133 | 1133 | |
| 1134 | -		if( $apply_filter ) { | 
                                                        |
| 1134 | +		if ( $apply_filter ) { | 
                                                        |
| 1135 | 1135 | /**  | 
                                                        
| 1136 | 1136 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array  | 
                                                        
| 1137 | 1137 | * @since 1.6.5  | 
                                                        
@@ -1154,7 +1154,7 @@ discard block  | 
                                                    ||
| 1154 | 1154 | * @return string html  | 
                                                        
| 1155 | 1155 | */  | 
                                                        
| 1156 | 1156 |  	public static function get_sortable_fields( $formid, $current = '' ) { | 
                                                        
| 1157 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';  | 
                                                        |
| 1157 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';  | 
                                                        |
| 1158 | 1158 | |
| 1159 | 1159 |  		if ( empty( $formid ) ) { | 
                                                        
| 1160 | 1160 | return $output;  | 
                                                        
@@ -1167,11 +1167,11 @@ discard block  | 
                                                    ||
| 1167 | 1167 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );  | 
                                                        
| 1168 | 1168 | |
| 1169 | 1169 |  			foreach ( $fields as $id => $field ) { | 
                                                        
| 1170 | -				if ( in_array( $field['type'], $blacklist_field_types ) ) { | 
                                                        |
| 1170 | +				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { | 
                                                        |
| 1171 | 1171 | continue;  | 
                                                        
| 1172 | 1172 | }  | 
                                                        
| 1173 | 1173 | |
| 1174 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';  | 
                                                        |
| 1174 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';  | 
                                                        |
| 1175 | 1175 | }  | 
                                                        
| 1176 | 1176 | }  | 
                                                        
| 1177 | 1177 | |
@@ -1206,9 +1206,9 @@ discard block  | 
                                                    ||
| 1206 | 1206 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );  | 
                                                        
| 1207 | 1207 | |
| 1208 | 1208 | // TODO: Convert to using array_filter  | 
                                                        
| 1209 | -		foreach( $fields as $id => $field ) { | 
                                                        |
| 1209 | +		foreach ( $fields as $id => $field ) { | 
                                                        |
| 1210 | 1210 | |
| 1211 | -			if( in_array( $field['type'], $blacklist_field_types ) ) { | 
                                                        |
| 1211 | +			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { | 
                                                        |
| 1212 | 1212 | unset( $fields[ $id ] );  | 
                                                        
| 1213 | 1213 | }  | 
                                                        
| 1214 | 1214 | }  | 
                                                        
@@ -1249,14 +1249,14 @@ discard block  | 
                                                    ||
| 1249 | 1249 | * @param int|array $field field key or field array  | 
                                                        
| 1250 | 1250 | * @return boolean  | 
                                                        
| 1251 | 1251 | */  | 
                                                        
| 1252 | -	public static function is_field_numeric(  $form = null, $field = '' ) { | 
                                                        |
| 1252 | +	public static function is_field_numeric( $form = null, $field = '' ) { | 
                                                        |
| 1253 | 1253 | |
| 1254 | 1254 |  		if ( ! is_array( $form ) && ! is_array( $field ) ) { | 
                                                        
| 1255 | 1255 | $form = self::get_form( $form );  | 
                                                        
| 1256 | 1256 | }  | 
                                                        
| 1257 | 1257 | |
| 1258 | 1258 | // If entry meta, it's a string. Otherwise, numeric  | 
                                                        
| 1259 | -		if( ! is_numeric( $field ) && is_string( $field ) ) { | 
                                                        |
| 1259 | +		if ( ! is_numeric( $field ) && is_string( $field ) ) { | 
                                                        |
| 1260 | 1260 | $type = $field;  | 
                                                        
| 1261 | 1261 |  		} else { | 
                                                        
| 1262 | 1262 | $type = self::get_field_type( $form, $field );  | 
                                                        
@@ -1270,9 +1270,9 @@ discard block  | 
                                                    ||
| 1270 | 1270 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );  | 
                                                        
| 1271 | 1271 | |
| 1272 | 1272 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true  | 
                                                        
| 1273 | -		if( $gv_field = GravityView_Fields::get( $type ) ) { | 
                                                        |
| 1274 | -			if( true === $gv_field->is_numeric ) { | 
                                                        |
| 1275 | - $numeric_types[] = $gv_field->is_numeric;  | 
                                                        |
| 1273 | +		if ( $gv_field = GravityView_Fields::get( $type ) ) { | 
                                                        |
| 1274 | +			if ( true === $gv_field->is_numeric ) { | 
                                                        |
| 1275 | + $numeric_types[ ] = $gv_field->is_numeric;  | 
                                                        |
| 1276 | 1276 | }  | 
                                                        
| 1277 | 1277 | }  | 
                                                        
| 1278 | 1278 | |
@@ -1422,18 +1422,18 @@ discard block  | 
                                                    ||
| 1422 | 1422 | $final_atts = array_filter( $final_atts );  | 
                                                        
| 1423 | 1423 | |
| 1424 | 1424 | // If the href wasn't passed as an attribute, use the value passed to the function  | 
                                                        
| 1425 | -		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { | 
                                                        |
| 1426 | - $final_atts['href'] = $href;  | 
                                                        |
| 1425 | +		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { | 
                                                        |
| 1426 | + $final_atts[ 'href' ] = $href;  | 
                                                        |
| 1427 | 1427 | }  | 
                                                        
| 1428 | 1428 | |
| 1429 | - $final_atts['href'] = esc_url_raw( $href );  | 
                                                        |
| 1429 | + $final_atts[ 'href' ] = esc_url_raw( $href );  | 
                                                        |
| 1430 | 1430 | |
| 1431 | 1431 | /**  | 
                                                        
| 1432 | 1432 | * Fix potential security issue with target=_blank  | 
                                                        
| 1433 | 1433 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example  | 
                                                        
| 1434 | 1434 | */  | 
                                                        
| 1435 | -		if( '_blank' === rgar( $final_atts, 'target' ) ) { | 
                                                        |
| 1436 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' );  | 
                                                        |
| 1435 | +		if ( '_blank' === rgar( $final_atts, 'target' ) ) { | 
                                                        |
| 1436 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' );  | 
                                                        |
| 1437 | 1437 | }  | 
                                                        
| 1438 | 1438 | |
| 1439 | 1439 | // Sort the attributes alphabetically, to help testing  | 
                                                        
@@ -1445,7 +1445,7 @@ discard block  | 
                                                    ||
| 1445 | 1445 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );  | 
                                                        
| 1446 | 1446 | }  | 
                                                        
| 1447 | 1447 | |
| 1448 | -		if( '' !== $output ) { | 
                                                        |
| 1448 | +		if ( '' !== $output ) { | 
                                                        |
| 1449 | 1449 | $output = '<a' . $output . '>' . $anchor_text . '</a>';  | 
                                                        
| 1450 | 1450 | }  | 
                                                        
| 1451 | 1451 | |
@@ -1472,7 +1472,7 @@ discard block  | 
                                                    ||
| 1472 | 1472 |  			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { | 
                                                        
| 1473 | 1473 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );  | 
                                                        
| 1474 | 1474 |  			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { | 
                                                        
| 1475 | - $merged[] = $value;  | 
                                                        |
| 1475 | + $merged[ ] = $value;  | 
                                                        |
| 1476 | 1476 |  			} else { | 
                                                        
| 1477 | 1477 | $merged[ $key ] = $value;  | 
                                                        
| 1478 | 1478 | }  | 
                                                        
@@ -1505,7 +1505,7 @@ discard block  | 
                                                    ||
| 1505 | 1505 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)  | 
                                                        
| 1506 | 1506 | * @param array $settings Settings array, with `number` key defining the # of users to display  | 
                                                        
| 1507 | 1507 | */  | 
                                                        
| 1508 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );  | 
                                                        |
| 1508 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );  | 
                                                        |
| 1509 | 1509 | |
| 1510 | 1510 | return get_users( $get_users_settings );  | 
                                                        
| 1511 | 1511 | }  | 
                                                        
@@ -1525,11 +1525,11 @@ discard block  | 
                                                    ||
| 1525 | 1525 |      public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { | 
                                                        
| 1526 | 1526 | |
| 1527 | 1527 | // If $cap is defined, only show notice if user has capability  | 
                                                        
| 1528 | -    	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { | 
                                                        |
| 1528 | +    	if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { | 
                                                        |
| 1529 | 1529 | return '';  | 
                                                        
| 1530 | 1530 | }  | 
                                                        
| 1531 | 1531 | |
| 1532 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';  | 
                                                        |
| 1532 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';  | 
                                                        |
| 1533 | 1533 | }  | 
                                                        
| 1534 | 1534 | |
| 1535 | 1535 | /**  | 
                                                        
@@ -85,9 +85,9 @@ discard block  | 
                                                    ||
| 85 | 85 |  	private function __construct() {} | 
                                                        
| 86 | 86 | |
| 87 | 87 |  	private function initialize() { | 
                                                        
| 88 | - add_action( 'wp', array( $this, 'parse_content'), 11 );  | 
                                                        |
| 88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 );  | 
                                                        |
| 89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 );  | 
                                                        
| 90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 );  | 
                                                        |
| 90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 );  | 
                                                        |
| 91 | 91 | |
| 92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles()  | 
                                                        
| 93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 );  | 
                                                        
@@ -236,15 +236,15 @@ discard block  | 
                                                    ||
| 236 | 236 | |
| 237 | 237 | $this->context_view_id = $view_id;  | 
                                                        
| 238 | 238 | |
| 239 | -		} elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { | 
                                                        |
| 239 | +		} elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) { | 
                                                        |
| 240 | 240 | /**  | 
                                                        
| 241 | 241 | * used on a has_multiple_views context  | 
                                                        
| 242 | 242 | * @see GravityView_API::entry_link  | 
                                                        
| 243 | 243 | * @see GravityView_View_Data::getInstance()->has_multiple_views()  | 
                                                        
| 244 | 244 | */  | 
                                                        
| 245 | - $this->context_view_id = $_GET['gvid'];  | 
                                                        |
| 245 | + $this->context_view_id = $_GET[ 'gvid' ];  | 
                                                        |
| 246 | 246 | |
| 247 | -		} elseif ( ! $this->getGvOutputData()->has_multiple_views() )  { | 
                                                        |
| 247 | +		} elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { | 
                                                        |
| 248 | 248 | $array_keys = array_keys( $this->getGvOutputData()->get_views() );  | 
                                                        
| 249 | 249 | $this->context_view_id = array_pop( $array_keys );  | 
                                                        
| 250 | 250 | unset( $array_keys );  | 
                                                        
@@ -279,24 +279,24 @@ discard block  | 
                                                    ||
| 279 | 279 | global $wp_rewrite;  | 
                                                        
| 280 | 280 | |
| 281 | 281 | $is_front_page = ( $query->is_home || $query->is_page );  | 
                                                        
| 282 | -		$show_on_front = ( 'page' === get_option('show_on_front') ); | 
                                                        |
| 283 | -		$front_page_id = get_option('page_on_front'); | 
                                                        |
| 282 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) );  | 
                                                        |
| 283 | + $front_page_id = get_option( 'page_on_front' );  | 
                                                        |
| 284 | 284 | |
| 285 | -		if (  $is_front_page && $show_on_front && $front_page_id ) { | 
                                                        |
| 285 | +		if ( $is_front_page && $show_on_front && $front_page_id ) { | 
                                                        |
| 286 | 286 | |
| 287 | 287 | // Force to be an array, potentially a query string ( entry=16 )  | 
                                                        
| 288 | 288 | $_query = wp_parse_args( $query->query );  | 
                                                        
| 289 | 289 | |
| 290 | 290 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.  | 
                                                        
| 291 | -			if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { | 
                                                        |
| 292 | - unset( $_query['pagename'] );  | 
                                                        |
| 291 | +			if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { | 
                                                        |
| 292 | + unset( $_query[ 'pagename' ] );  | 
                                                        |
| 293 | 293 | }  | 
                                                        
| 294 | 294 | |
| 295 | 295 | // this is where will break from core wordpress  | 
                                                        
| 296 | 296 | $ignore = array( 'preview', 'page', 'paged', 'cpage' );  | 
                                                        
| 297 | 297 | $endpoints = rgobj( $wp_rewrite, 'endpoints' );  | 
                                                        
| 298 | -			foreach ( (array) $endpoints as $endpoint ) { | 
                                                        |
| 299 | - $ignore[] = $endpoint[1];  | 
                                                        |
| 298 | +			foreach ( (array)$endpoints as $endpoint ) { | 
                                                        |
| 299 | + $ignore[ ] = $endpoint[ 1 ];  | 
                                                        |
| 300 | 300 | }  | 
                                                        
| 301 | 301 | unset( $endpoints );  | 
                                                        
| 302 | 302 | |
@@ -306,21 +306,21 @@ discard block  | 
                                                    ||
| 306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example.  | 
                                                        
| 307 | 307 |  			if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { | 
                                                        
| 308 | 308 | |
| 309 | - $qv =& $query->query_vars;  | 
                                                        |
| 309 | + $qv = & $query->query_vars;  | 
                                                        |
| 310 | 310 | |
| 311 | 311 | // Prevent redirect when on the single entry endpoint  | 
                                                        
| 312 | -				if( self::is_single_entry() ) { | 
                                                        |
| 312 | +				if ( self::is_single_entry() ) { | 
                                                        |
| 313 | 313 | add_filter( 'redirect_canonical', '__return_false' );  | 
                                                        
| 314 | 314 | }  | 
                                                        
| 315 | 315 | |
| 316 | 316 | $query->is_page = true;  | 
                                                        
| 317 | 317 | $query->is_home = false;  | 
                                                        
| 318 | - $qv['page_id'] = $front_page_id;  | 
                                                        |
| 318 | + $qv[ 'page_id' ] = $front_page_id;  | 
                                                        |
| 319 | 319 | |
| 320 | 320 | // Correct <!--nextpage--> for page_on_front  | 
                                                        
| 321 | -				if ( ! empty( $qv['paged'] ) ) { | 
                                                        |
| 322 | - $qv['page'] = $qv['paged'];  | 
                                                        |
| 323 | - unset( $qv['paged'] );  | 
                                                        |
| 321 | +				if ( ! empty( $qv[ 'paged' ] ) ) { | 
                                                        |
| 322 | + $qv[ 'page' ] = $qv[ 'paged' ];  | 
                                                        |
| 323 | + unset( $qv[ 'paged' ] );  | 
                                                        |
| 324 | 324 | }  | 
                                                        
| 325 | 325 | }  | 
                                                        
| 326 | 326 | |
@@ -338,7 +338,7 @@ discard block  | 
                                                    ||
| 338 | 338 | global $post;  | 
                                                        
| 339 | 339 | |
| 340 | 340 | // If in admin and NOT AJAX request, get outta here.  | 
                                                        
| 341 | -		if ( GravityView_Plugin::is_admin() )  { | 
                                                        |
| 341 | +		if ( GravityView_Plugin::is_admin() ) { | 
                                                        |
| 342 | 342 | return;  | 
                                                        
| 343 | 343 | }  | 
                                                        
| 344 | 344 | |
@@ -350,7 +350,7 @@ discard block  | 
                                                    ||
| 350 | 350 | |
| 351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );  | 
                                                        
| 352 | 352 | |
| 353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );  | 
                                                        |
| 353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null );  | 
                                                        |
| 354 | 354 | $this->setPostId( $post_id );  | 
                                                        
| 355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;  | 
                                                        
| 356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );  | 
                                                        
@@ -386,7 +386,7 @@ discard block  | 
                                                    ||
| 386 | 386 | |
| 387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method();  | 
                                                        
| 388 | 388 | |
| 389 | -		if( 'post' === $search_method ) { | 
                                                        |
| 389 | +		if ( 'post' === $search_method ) { | 
                                                        |
| 390 | 390 | $get = $_POST;  | 
                                                        
| 391 | 391 |  		} else { | 
                                                        
| 392 | 392 | $get = $_GET;  | 
                                                        
@@ -442,20 +442,20 @@ discard block  | 
                                                    ||
| 442 | 442 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop  | 
                                                        
| 443 | 443 | * @param array $entry Current entry  | 
                                                        
| 444 | 444 | */  | 
                                                        
| 445 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );  | 
                                                        |
| 445 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry );  | 
                                                        |
| 446 | 446 | |
| 447 | 447 |  		if ( ! $apply_outside_loop ) { | 
                                                        
| 448 | 448 | return $title;  | 
                                                        
| 449 | 449 | }  | 
                                                        
| 450 | 450 | |
| 451 | 451 | // User reported WooCommerce doesn't pass two args.  | 
                                                        
| 452 | -		if ( empty( $passed_post_id ) )  { | 
                                                        |
| 452 | +		if ( empty( $passed_post_id ) ) { | 
                                                        |
| 453 | 453 | return $title;  | 
                                                        
| 454 | 454 | }  | 
                                                        
| 455 | 455 | |
| 456 | 456 | // Don't modify the title for anything other than the current view/post.  | 
                                                        
| 457 | 457 | // This is true for embedded shortcodes and Views.  | 
                                                        
| 458 | -		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { | 
                                                        |
| 458 | +		if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { | 
                                                        |
| 459 | 459 | return $title;  | 
                                                        
| 460 | 460 | }  | 
                                                        
| 461 | 461 | |
@@ -465,19 +465,19 @@ discard block  | 
                                                    ||
| 465 | 465 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id );  | 
                                                        
| 466 | 466 |  		} else { | 
                                                        
| 467 | 467 |  			foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { | 
                                                        
| 468 | -				if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { | 
                                                        |
| 468 | +				if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { | 
                                                        |
| 469 | 469 | $view_meta = $view_data;  | 
                                                        
| 470 | 470 | break;  | 
                                                        
| 471 | 471 | }  | 
                                                        
| 472 | 472 | }  | 
                                                        
| 473 | 473 | }  | 
                                                        
| 474 | 474 | |
| 475 | -		if ( ! empty( $view_meta['atts']['single_title'] ) ) { | 
                                                        |
| 475 | +		if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { | 
                                                        |
| 476 | 476 | |
| 477 | - $title = $view_meta['atts']['single_title'];  | 
                                                        |
| 477 | + $title = $view_meta[ 'atts' ][ 'single_title' ];  | 
                                                        |
| 478 | 478 | |
| 479 | 479 | // We are allowing HTML in the fields, so no escaping the output  | 
                                                        
| 480 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );  | 
                                                        |
| 480 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry );  | 
                                                        |
| 481 | 481 | |
| 482 | 482 | $title = do_shortcode( $title );  | 
                                                        
| 483 | 483 | }  | 
                                                        
@@ -513,7 +513,7 @@ discard block  | 
                                                    ||
| 513 | 513 | }  | 
                                                        
| 514 | 514 | |
| 515 | 515 | // Only render in the loop. Fixes issues with the_content filter being applied in places like the sidebar  | 
                                                        
| 516 | -		if( ! in_the_loop() ) { | 
                                                        |
| 516 | +		if ( ! in_the_loop() ) { | 
                                                        |
| 517 | 517 | return $content;  | 
                                                        
| 518 | 518 | }  | 
                                                        
| 519 | 519 | |
@@ -577,7 +577,7 @@ discard block  | 
                                                    ||
| 577 | 577 | |
| 578 | 578 | $context = GravityView_View::getInstance()->getContext();  | 
                                                        
| 579 | 579 | |
| 580 | -		switch( $context ) { | 
                                                        |
| 580 | +		switch ( $context ) { | 
                                                        |
| 581 | 581 | case 'directory':  | 
                                                        
| 582 | 582 | $tab = __( 'Multiple Entries', 'gravityview' );  | 
                                                        
| 583 | 583 | break;  | 
                                                        
@@ -591,9 +591,9 @@ discard block  | 
                                                    ||
| 591 | 591 | }  | 
                                                        
| 592 | 592 | |
| 593 | 593 | |
| 594 | -		$title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); | 
                                                        |
| 594 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab );  | 
                                                        |
| 595 | 595 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) );  | 
                                                        
| 596 | -		$action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); | 
                                                        |
| 596 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab );  | 
                                                        |
| 597 | 597 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' );  | 
                                                        
| 598 | 598 | |
| 599 | 599 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message );  | 
                                                        
@@ -626,7 +626,7 @@ discard block  | 
                                                    ||
| 626 | 626 |  	public function render_view( $passed_args ) { | 
                                                        
| 627 | 627 | |
| 628 | 628 | // validate attributes  | 
                                                        
| 629 | -		if ( empty( $passed_args['id'] ) ) { | 
                                                        |
| 629 | +		if ( empty( $passed_args[ 'id' ] ) ) { | 
                                                        |
| 630 | 630 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args );  | 
                                                        
| 631 | 631 | return null;  | 
                                                        
| 632 | 632 | }  | 
                                                        
@@ -648,7 +648,7 @@ discard block  | 
                                                    ||
| 648 | 648 | return null;  | 
                                                        
| 649 | 649 | }  | 
                                                        
| 650 | 650 | |
| 651 | - $view_id = $passed_args['id'];  | 
                                                        |
| 651 | + $view_id = $passed_args[ 'id' ];  | 
                                                        |
| 652 | 652 | |
| 653 | 653 | $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args );  | 
                                                        
| 654 | 654 | |
@@ -661,7 +661,7 @@ discard block  | 
                                                    ||
| 661 | 661 | $passed_args = array_filter( $passed_args, 'strlen' );  | 
                                                        
| 662 | 662 | |
| 663 | 663 | //Override shortcode args over View template settings  | 
                                                        
| 664 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] );  | 
                                                        |
| 664 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] );  | 
                                                        |
| 665 | 665 | |
| 666 | 666 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts );  | 
                                                        
| 667 | 667 | |
@@ -684,14 +684,14 @@ discard block  | 
                                                    ||
| 684 | 684 | * @since 1.15  | 
                                                        
| 685 | 685 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out.  | 
                                                        
| 686 | 686 | */  | 
                                                        
| 687 | -		if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { | 
                                                        |
| 687 | +		if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { | 
                                                        |
| 688 | 688 | |
| 689 | 689 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) );  | 
                                                        
| 690 | 690 | |
| 691 | 691 | return null;  | 
                                                        
| 692 | 692 | }  | 
                                                        
| 693 | 693 | |
| 694 | -		if( $this->isGravityviewPostType() ) { | 
                                                        |
| 694 | +		if ( $this->isGravityviewPostType() ) { | 
                                                        |
| 695 | 695 | |
| 696 | 696 | /**  | 
                                                        
| 697 | 697 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?  | 
                                                        
@@ -703,9 +703,9 @@ discard block  | 
                                                    ||
| 703 | 703 | */  | 
                                                        
| 704 | 704 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id );  | 
                                                        
| 705 | 705 | |
| 706 | - $embed_only = ! empty( $atts['embed_only'] );  | 
                                                        |
| 706 | + $embed_only = ! empty( $atts[ 'embed_only' ] );  | 
                                                        |
| 707 | 707 | |
| 708 | -			if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { | 
                                                        |
| 708 | +			if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { | 
                                                        |
| 709 | 709 | return __( 'You are not allowed to view this content.', 'gravityview' );  | 
                                                        
| 710 | 710 | }  | 
                                                        
| 711 | 711 | }  | 
                                                        
@@ -720,7 +720,7 @@ discard block  | 
                                                    ||
| 720 | 720 | |
| 721 | 721 | $gravityview_view = new GravityView_View( $view_data );  | 
                                                        
| 722 | 722 | |
| 723 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId();  | 
                                                        |
| 723 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId();  | 
                                                        |
| 724 | 724 | |
| 725 | 725 | $gravityview_view->setPostId( $post_id );  | 
                                                        
| 726 | 726 | |
@@ -730,20 +730,20 @@ discard block  | 
                                                    ||
| 730 | 730 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' );  | 
                                                        
| 731 | 731 | |
| 732 | 732 | //fetch template and slug  | 
                                                        
| 733 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' );  | 
                                                        |
| 733 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' );  | 
                                                        |
| 734 | 734 | |
| 735 | 735 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug );  | 
                                                        
| 736 | 736 | |
| 737 | 737 | /**  | 
                                                        
| 738 | 738 | * Disable fetching initial entries for views that don't need it (DataTables)  | 
                                                        
| 739 | 739 | */  | 
                                                        
| 740 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true );  | 
                                                        |
| 740 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true );  | 
                                                        |
| 741 | 741 | |
| 742 | 742 | /**  | 
                                                        
| 743 | 743 | * Hide View data until search is performed  | 
                                                        
| 744 | 744 | * @since 1.5.4  | 
                                                        
| 745 | 745 | */  | 
                                                        
| 746 | -			if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { | 
                                                        |
| 746 | +			if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) { | 
                                                        |
| 747 | 747 | $gravityview_view->setHideUntilSearched( true );  | 
                                                        
| 748 | 748 | $get_entries = false;  | 
                                                        
| 749 | 749 | }  | 
                                                        
@@ -751,23 +751,23 @@ discard block  | 
                                                    ||
| 751 | 751 | |
| 752 | 752 |  			if ( $get_entries ) { | 
                                                        
| 753 | 753 | |
| 754 | -				if ( ! empty( $atts['sort_columns'] ) ) { | 
                                                        |
| 754 | +				if ( ! empty( $atts[ 'sort_columns' ] ) ) { | 
                                                        |
| 755 | 755 | // add filter to enable column sorting  | 
                                                        
| 756 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 );  | 
                                                        |
| 756 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 );  | 
                                                        |
| 757 | 757 | }  | 
                                                        
| 758 | 758 | |
| 759 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] );  | 
                                                        |
| 759 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] );  | 
                                                        |
| 760 | 760 | |
| 761 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) );  | 
                                                        |
| 761 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) );  | 
                                                        |
| 762 | 762 | |
| 763 | 763 |  			} else { | 
                                                        
| 764 | 764 | |
| 765 | 765 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null );  | 
                                                        
| 766 | 766 | |
| 767 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' );  | 
                                                        |
| 767 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' );  | 
                                                        |
| 768 | 768 | }  | 
                                                        
| 769 | 769 | |
| 770 | - $gravityview_view->setPaging( $view_entries['paging'] );  | 
                                                        |
| 770 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] );  | 
                                                        |
| 771 | 771 | $gravityview_view->setContext( 'directory' );  | 
                                                        
| 772 | 772 | $sections = array( 'header', 'body', 'footer' );  | 
                                                        
| 773 | 773 | |
@@ -781,7 +781,7 @@ discard block  | 
                                                    ||
| 781 | 781 |  			 * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID | 
                                                        
| 782 | 782 | * @since 1.17  | 
                                                        
| 783 | 783 | */  | 
                                                        
| 784 | - do_action( 'gravityview_render_entry_'.$view_data['id'] );  | 
                                                        |
| 784 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] );  | 
                                                        |
| 785 | 785 | |
| 786 | 786 | $entry = $this->getEntry();  | 
                                                        
| 787 | 787 | |
@@ -791,7 +791,7 @@ discard block  | 
                                                    ||
| 791 | 791 | do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' );  | 
                                                        
| 792 | 792 | |
| 793 | 793 | // Only display warning once when multiple Views are embedded  | 
                                                        
| 794 | -				if( $view_id !== (int) GravityView_frontend::get_context_view_id() ) { | 
                                                        |
| 794 | +				if ( $view_id !== (int)GravityView_frontend::get_context_view_id() ) { | 
                                                        |
| 795 | 795 | return null;  | 
                                                        
| 796 | 796 | }  | 
                                                        
| 797 | 797 | |
@@ -813,20 +813,20 @@ discard block  | 
                                                    ||
| 813 | 813 | // We're in single view, but the view being processed is not the same view the single entry belongs to.  | 
                                                        
| 814 | 814 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms  | 
                                                        
| 815 | 815 |  			if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { | 
                                                        
| 816 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id );  | 
                                                        |
| 816 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id );  | 
                                                        |
| 817 | 817 | return null;  | 
                                                        
| 818 | 818 | }  | 
                                                        
| 819 | 819 | |
| 820 | 820 | //fetch template and slug  | 
                                                        
| 821 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' );  | 
                                                        |
| 821 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' );  | 
                                                        |
| 822 | 822 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug );  | 
                                                        
| 823 | 823 | |
| 824 | 824 | //fetch entry detail  | 
                                                        
| 825 | - $view_entries['count'] = 1;  | 
                                                        |
| 826 | - $view_entries['entries'][] = $entry;  | 
                                                        |
| 827 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] );  | 
                                                        |
| 825 | + $view_entries[ 'count' ] = 1;  | 
                                                        |
| 826 | + $view_entries[ 'entries' ][ ] = $entry;  | 
                                                        |
| 827 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] );  | 
                                                        |
| 828 | 828 | |
| 829 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null;  | 
                                                        |
| 829 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null;  | 
                                                        |
| 830 | 830 | |
| 831 | 831 | // set back link label  | 
                                                        
| 832 | 832 | $gravityview_view->setBackLinkLabel( $back_link_label );  | 
                                                        
@@ -836,11 +836,11 @@ discard block  | 
                                                    ||
| 836 | 836 | }  | 
                                                        
| 837 | 837 | |
| 838 | 838 | // add template style  | 
                                                        
| 839 | - self::add_style( $view_data['template_id'] );  | 
                                                        |
| 839 | + self::add_style( $view_data[ 'template_id' ] );  | 
                                                        |
| 840 | 840 | |
| 841 | 841 | // Prepare to render view and set vars  | 
                                                        
| 842 | - $gravityview_view->setEntries( $view_entries['entries'] );  | 
                                                        |
| 843 | - $gravityview_view->setTotalEntries( $view_entries['count'] );  | 
                                                        |
| 842 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] );  | 
                                                        |
| 843 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] );  | 
                                                        |
| 844 | 844 | |
| 845 | 845 | // If Edit  | 
                                                        
| 846 | 846 |  		if ( 'edit' === gravityview_get_context() ) { | 
                                                        
@@ -853,11 +853,11 @@ discard block  | 
                                                    ||
| 853 | 853 | |
| 854 | 854 |  		} else { | 
                                                        
| 855 | 855 | // finaly we'll render some html  | 
                                                        
| 856 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] );  | 
                                                        |
| 856 | + $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] );  | 
                                                        |
| 857 | 857 | |
| 858 | 858 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections );  | 
                                                        
| 859 | 859 |  			foreach ( $sections as $section ) { | 
                                                        
| 860 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' );  | 
                                                        |
| 860 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' );  | 
                                                        |
| 861 | 861 | $gravityview_view->render( $view_slug, $section, false );  | 
                                                        
| 862 | 862 | }  | 
                                                        
| 863 | 863 | }  | 
                                                        
@@ -911,7 +911,7 @@ discard block  | 
                                                    ||
| 911 | 911 | $datetime_format = 'Y-m-d H:i:s';  | 
                                                        
| 912 | 912 | $search_is_outside_view_bounds = false;  | 
                                                        
| 913 | 913 | |
| 914 | -				if( ! empty( $search_criteria[ $key ] ) ) { | 
                                                        |
| 914 | +				if ( ! empty( $search_criteria[ $key ] ) ) { | 
                                                        |
| 915 | 915 | |
| 916 | 916 | $search_date = strtotime( $search_criteria[ $key ] );  | 
                                                        
| 917 | 917 | |
@@ -939,14 +939,14 @@ discard block  | 
                                                    ||
| 939 | 939 |  				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { | 
                                                        
| 940 | 940 | |
| 941 | 941 | // Then we override the search and re-set the start date  | 
                                                        
| 942 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );  | 
                                                        |
| 942 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true );  | 
                                                        |
| 943 | 943 | }  | 
                                                        
| 944 | 944 | }  | 
                                                        
| 945 | 945 | }  | 
                                                        
| 946 | 946 | |
| 947 | -		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { | 
                                                        |
| 947 | +		if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { | 
                                                        |
| 948 | 948 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue.  | 
                                                        
| 949 | -			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { | 
                                                        |
| 949 | +			if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { | 
                                                        |
| 950 | 950 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria );  | 
                                                        
| 951 | 951 | }  | 
                                                        
| 952 | 952 | }  | 
                                                        
@@ -965,19 +965,19 @@ discard block  | 
                                                    ||
| 965 | 965 |  	public static function process_search_only_approved( $args, $search_criteria ) { | 
                                                        
| 966 | 966 | |
| 967 | 967 | /** @since 1.19 */  | 
                                                        
| 968 | -		if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { | 
                                                        |
| 968 | +		if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { | 
                                                        |
| 969 | 969 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' );  | 
                                                        
| 970 | 970 | return $search_criteria;  | 
                                                        
| 971 | 971 | }  | 
                                                        
| 972 | 972 | |
| 973 | -		if ( ! empty( $args['show_only_approved'] ) ) { | 
                                                        |
| 973 | +		if ( ! empty( $args[ 'show_only_approved' ] ) ) { | 
                                                        |
| 974 | 974 | |
| 975 | - $search_criteria['field_filters'][] = array(  | 
                                                        |
| 975 | + $search_criteria[ 'field_filters' ][ ] = array(  | 
                                                        |
| 976 | 976 | 'key' => GravityView_Entry_Approval::meta_key,  | 
                                                        
| 977 | 977 | 'value' => GravityView_Entry_Approval_Status::APPROVED  | 
                                                        
| 978 | 978 | );  | 
                                                        
| 979 | 979 | |
| 980 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met  | 
                                                        |
| 980 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met  | 
                                                        |
| 981 | 981 | |
| 982 | 982 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria );  | 
                                                        
| 983 | 983 | }  | 
                                                        
@@ -1004,18 +1004,18 @@ discard block  | 
                                                    ||
| 1004 | 1004 | */  | 
                                                        
| 1005 | 1005 |  	public static function is_entry_approved( $entry, $args = array() ) { | 
                                                        
| 1006 | 1006 | |
| 1007 | -		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { | 
                                                        |
| 1007 | +		if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { | 
                                                        |
| 1008 | 1008 | // is implicitly approved if entry is null or View settings doesn't require to check for approval  | 
                                                        
| 1009 | 1009 | return true;  | 
                                                        
| 1010 | 1010 | }  | 
                                                        
| 1011 | 1011 | |
| 1012 | 1012 | /** @since 1.19 */  | 
                                                        
| 1013 | -		if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { | 
                                                        |
| 1013 | +		if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { | 
                                                        |
| 1014 | 1014 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' );  | 
                                                        
| 1015 | 1015 | return true;  | 
                                                        
| 1016 | 1016 | }  | 
                                                        
| 1017 | 1017 | |
| 1018 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key );  | 
                                                        |
| 1018 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key );  | 
                                                        |
| 1019 | 1019 | |
| 1020 | 1020 | return GravityView_Entry_Approval_Status::is_approved( $is_approved );  | 
                                                        
| 1021 | 1021 | }  | 
                                                        
@@ -1049,26 +1049,26 @@ discard block  | 
                                                    ||
| 1049 | 1049 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria );  | 
                                                        
| 1050 | 1050 | |
| 1051 | 1051 | // implicity search  | 
                                                        
| 1052 | -		if ( ! empty( $args['search_value'] ) ) { | 
                                                        |
| 1052 | +		if ( ! empty( $args[ 'search_value' ] ) ) { | 
                                                        |
| 1053 | 1053 | |
| 1054 | 1054 | // Search operator options. Options: `is` or `contains`  | 
                                                        
| 1055 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';  | 
                                                        |
| 1055 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains';  | 
                                                        |
| 1056 | 1056 | |
| 1057 | - $search_criteria['field_filters'][] = array(  | 
                                                        |
| 1057 | + $search_criteria[ 'field_filters' ][ ] = array(  | 
                                                        |
| 1058 | 1058 | 'key' => rgget( 'search_field', $args ), // The field ID to search  | 
                                                        
| 1059 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes.  | 
                                                        |
| 1059 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes.  | 
                                                        |
| 1060 | 1060 | 'operator' => $operator,  | 
                                                        
| 1061 | 1061 | );  | 
                                                        
| 1062 | 1062 | }  | 
                                                        
| 1063 | 1063 | |
| 1064 | -		if( $search_criteria !== $original_search_criteria ) { | 
                                                        |
| 1064 | +		if ( $search_criteria !== $original_search_criteria ) { | 
                                                        |
| 1065 | 1065 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria );  | 
                                                        
| 1066 | 1066 | }  | 
                                                        
| 1067 | 1067 | |
| 1068 | 1068 | // Handle setting date range  | 
                                                        
| 1069 | 1069 | $search_criteria = self::process_search_dates( $args, $search_criteria );  | 
                                                        
| 1070 | 1070 | |
| 1071 | -		if( $search_criteria !== $original_search_criteria ) { | 
                                                        |
| 1071 | +		if ( $search_criteria !== $original_search_criteria ) { | 
                                                        |
| 1072 | 1072 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria );  | 
                                                        
| 1073 | 1073 | }  | 
                                                        
| 1074 | 1074 | |
@@ -1079,7 +1079,7 @@ discard block  | 
                                                    ||
| 1079 | 1079 | * @filter `gravityview_status` Modify entry status requirements to be included in search results.  | 
                                                        
| 1080 | 1080 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`  | 
                                                        
| 1081 | 1081 | */  | 
                                                        
| 1082 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );  | 
                                                        |
| 1082 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args );  | 
                                                        |
| 1083 | 1083 | |
| 1084 | 1084 | return $search_criteria;  | 
                                                        
| 1085 | 1085 | }  | 
                                                        
@@ -1125,16 +1125,16 @@ discard block  | 
                                                    ||
| 1125 | 1125 | $search_criteria = self::get_search_criteria( $args, $form_id );  | 
                                                        
| 1126 | 1126 | |
| 1127 | 1127 | // Paging & offset  | 
                                                        
| 1128 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 );  | 
                                                        |
| 1128 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 );  | 
                                                        |
| 1129 | 1129 | |
| 1130 | 1130 |  		if ( -1 === $page_size ) { | 
                                                        
| 1131 | 1131 | $page_size = PHP_INT_MAX;  | 
                                                        
| 1132 | 1132 | }  | 
                                                        
| 1133 | 1133 | |
| 1134 | -		if ( isset( $args['offset'] ) ) { | 
                                                        |
| 1135 | - $offset = intval( $args['offset'] );  | 
                                                        |
| 1134 | +		if ( isset( $args[ 'offset' ] ) ) { | 
                                                        |
| 1135 | + $offset = intval( $args[ 'offset' ] );  | 
                                                        |
| 1136 | 1136 |  		} else { | 
                                                        
| 1137 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );  | 
                                                        |
| 1137 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] );  | 
                                                        |
| 1138 | 1138 | $offset = ( $curr_page - 1 ) * $page_size;  | 
                                                        
| 1139 | 1139 | }  | 
                                                        
| 1140 | 1140 | |
@@ -1152,7 +1152,7 @@ discard block  | 
                                                    ||
| 1152 | 1152 | 'search_criteria' => $search_criteria,  | 
                                                        
| 1153 | 1153 | 'sorting' => $sorting,  | 
                                                        
| 1154 | 1154 | 'paging' => $paging,  | 
                                                        
| 1155 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true,  | 
                                                        |
| 1155 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true,  | 
                                                        |
| 1156 | 1156 | );  | 
                                                        
| 1157 | 1157 | |
| 1158 | 1158 | /**  | 
                                                        
@@ -1177,7 +1177,7 @@ discard block  | 
                                                    ||
| 1177 | 1177 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.  | 
                                                        
| 1178 | 1178 | * @param array $args View configuration args.  | 
                                                        
| 1179 | 1179 | */  | 
                                                        
| 1180 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id );  | 
                                                        |
| 1180 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id );  | 
                                                        |
| 1181 | 1181 | |
| 1182 | 1182 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters );  | 
                                                        
| 1183 | 1183 | |
@@ -1217,8 +1217,8 @@ discard block  | 
                                                    ||
| 1217 | 1217 | */  | 
                                                        
| 1218 | 1218 |  	public static function updateViewSorting( $args, $form_id ) { | 
                                                        
| 1219 | 1219 | $sorting = array();  | 
                                                        
| 1220 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' );  | 
                                                        |
| 1221 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' );  | 
                                                        |
| 1220 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' );  | 
                                                        |
| 1221 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' );  | 
                                                        |
| 1222 | 1222 | |
| 1223 | 1223 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id );  | 
                                                        
| 1224 | 1224 | |
@@ -1258,11 +1258,11 @@ discard block  | 
                                                    ||
| 1258 | 1258 | |
| 1259 | 1259 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id );  | 
                                                        
| 1260 | 1260 | |
| 1261 | -		if( ! $sort_field ) { | 
                                                        |
| 1261 | +		if ( ! $sort_field ) { | 
                                                        |
| 1262 | 1262 | return $sort_field_id;  | 
                                                        
| 1263 | 1263 | }  | 
                                                        
| 1264 | 1264 | |
| 1265 | -		switch ( $sort_field['type'] ) { | 
                                                        |
| 1265 | +		switch ( $sort_field[ 'type' ] ) { | 
                                                        |
| 1266 | 1266 | |
| 1267 | 1267 | case 'address':  | 
                                                        
| 1268 | 1268 | // Sorting by full address  | 
                                                        
@@ -1279,7 +1279,7 @@ discard block  | 
                                                    ||
| 1279 | 1279 | */  | 
                                                        
| 1280 | 1280 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );  | 
                                                        
| 1281 | 1281 | |
| 1282 | -					switch( strtolower( $address_part ) ){ | 
                                                        |
| 1282 | +					switch ( strtolower( $address_part ) ) { | 
                                                        |
| 1283 | 1283 | case 'street':  | 
                                                        
| 1284 | 1284 | $sort_field_id .= '.1';  | 
                                                        
| 1285 | 1285 | break;  | 
                                                        
@@ -1359,7 +1359,7 @@ discard block  | 
                                                    ||
| 1359 | 1359 | */  | 
                                                        
| 1360 | 1360 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );  | 
                                                        
| 1361 | 1361 | |
| 1362 | -		if ( empty( $single_entry ) ){ | 
                                                        |
| 1362 | +		if ( empty( $single_entry ) ) { | 
                                                        |
| 1363 | 1363 | return false;  | 
                                                        
| 1364 | 1364 |  		} else { | 
                                                        
| 1365 | 1365 | return $single_entry;  | 
                                                        
@@ -1386,7 +1386,7 @@ discard block  | 
                                                    ||
| 1386 | 1386 | * Don't enqueue the scripts or styles if it's not going to be displayed.  | 
                                                        
| 1387 | 1387 | * @since 1.15  | 
                                                        
| 1388 | 1388 | */  | 
                                                        
| 1389 | -				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { | 
                                                        |
| 1389 | +				if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { | 
                                                        |
| 1390 | 1390 | continue;  | 
                                                        
| 1391 | 1391 | }  | 
                                                        
| 1392 | 1392 | |
@@ -1395,19 +1395,19 @@ discard block  | 
                                                    ||
| 1395 | 1395 | $css_dependencies = array();  | 
                                                        
| 1396 | 1396 | |
| 1397 | 1397 | // If the thickbox is enqueued, add dependencies  | 
                                                        
| 1398 | -				if ( ! empty( $data['atts']['lightbox'] ) ) { | 
                                                        |
| 1398 | +				if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) { | 
                                                        |
| 1399 | 1399 | |
| 1400 | 1400 | /**  | 
                                                        
| 1401 | 1401 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`  | 
                                                        
| 1402 | 1402 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here.  | 
                                                        
| 1403 | 1403 | */  | 
                                                        
| 1404 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );  | 
                                                        |
| 1404 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );  | 
                                                        |
| 1405 | 1405 | |
| 1406 | 1406 | /**  | 
                                                        
| 1407 | 1407 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`  | 
                                                        
| 1408 | 1408 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.  | 
                                                        
| 1409 | 1409 | */  | 
                                                        
| 1410 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );  | 
                                                        |
| 1410 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );  | 
                                                        |
| 1411 | 1411 | }  | 
                                                        
| 1412 | 1412 | |
| 1413 | 1413 | /**  | 
                                                        
@@ -1415,25 +1415,25 @@ discard block  | 
                                                    ||
| 1415 | 1415 | * @see https://github.com/katzwebservices/GravityView/issues/536  | 
                                                        
| 1416 | 1416 | * @since 1.15  | 
                                                        
| 1417 | 1417 | */  | 
                                                        
| 1418 | -				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { | 
                                                        |
| 1419 | - $css_dependencies[] = 'dashicons';  | 
                                                        |
| 1418 | +				if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { | 
                                                        |
| 1419 | + $css_dependencies[ ] = 'dashicons';  | 
                                                        |
| 1420 | 1420 | }  | 
                                                        
| 1421 | 1421 | |
| 1422 | 1422 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );  | 
                                                        
| 1423 | 1423 | |
| 1424 | 1424 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';  | 
                                                        
| 1425 | 1425 | |
| 1426 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true );  | 
                                                        |
| 1426 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true );  | 
                                                        |
| 1427 | 1427 | |
| 1428 | 1428 | wp_enqueue_script( 'gravityview-fe-view' );  | 
                                                        
| 1429 | 1429 | |
| 1430 | -				if ( ! empty( $data['atts']['sort_columns'] ) ) { | 
                                                        |
| 1430 | +				if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { | 
                                                        |
| 1431 | 1431 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );  | 
                                                        
| 1432 | 1432 | }  | 
                                                        
| 1433 | 1433 | |
| 1434 | 1434 | $this->enqueue_default_style( $css_dependencies );  | 
                                                        
| 1435 | 1435 | |
| 1436 | - self::add_style( $data['template_id'] );  | 
                                                        |
| 1436 | + self::add_style( $data[ 'template_id' ] );  | 
                                                        |
| 1437 | 1437 | }  | 
                                                        
| 1438 | 1438 | |
| 1439 | 1439 |  			if ( 'wp_print_footer_scripts' === current_filter() ) { | 
                                                        
@@ -1495,7 +1495,7 @@ discard block  | 
                                                    ||
| 1495 | 1495 |  		} elseif ( empty( $template_id ) ) { | 
                                                        
| 1496 | 1496 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' );  | 
                                                        
| 1497 | 1497 |  		} else { | 
                                                        
| 1498 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) );  | 
                                                        |
| 1498 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) );  | 
                                                        |
| 1499 | 1499 | }  | 
                                                        
| 1500 | 1500 | |
| 1501 | 1501 | }  | 
                                                        
@@ -1520,11 +1520,11 @@ discard block  | 
                                                    ||
| 1520 | 1520 | * Not a table-based template; don't add sort icons  | 
                                                        
| 1521 | 1521 | * @since 1.12  | 
                                                        
| 1522 | 1522 | */  | 
                                                        
| 1523 | -		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { | 
                                                        |
| 1523 | +		if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { | 
                                                        |
| 1524 | 1524 | return $label;  | 
                                                        
| 1525 | 1525 | }  | 
                                                        
| 1526 | 1526 | |
| 1527 | -		if ( ! $this->is_field_sortable( $field['id'], $form ) ) { | 
                                                        |
| 1527 | +		if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { | 
                                                        |
| 1528 | 1528 | return $label;  | 
                                                        
| 1529 | 1529 | }  | 
                                                        
| 1530 | 1530 | |
@@ -1532,29 +1532,29 @@ discard block  | 
                                                    ||
| 1532 | 1532 | |
| 1533 | 1533 | $class = 'gv-sort';  | 
                                                        
| 1534 | 1534 | |
| 1535 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );  | 
                                                        |
| 1535 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] );  | 
                                                        |
| 1536 | 1536 | |
| 1537 | 1537 | $sort_args = array(  | 
                                                        
| 1538 | - 'sort' => $field['id'],  | 
                                                        |
| 1538 | + 'sort' => $field[ 'id' ],  | 
                                                        |
| 1539 | 1539 | 'dir' => 'asc',  | 
                                                        
| 1540 | 1540 | );  | 
                                                        
| 1541 | 1541 | |
| 1542 | -		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { | 
                                                        |
| 1542 | +		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { | 
                                                        |
| 1543 | 1543 | //toggle sorting direction.  | 
                                                        
| 1544 | -			if ( 'asc' === $sorting['direction'] ) { | 
                                                        |
| 1545 | - $sort_args['dir'] = 'desc';  | 
                                                        |
| 1544 | +			if ( 'asc' === $sorting[ 'direction' ] ) { | 
                                                        |
| 1545 | + $sort_args[ 'dir' ] = 'desc';  | 
                                                        |
| 1546 | 1546 | $class .= ' gv-icon-sort-desc';  | 
                                                        
| 1547 | 1547 |  			} else { | 
                                                        
| 1548 | - $sort_args['dir'] = 'asc';  | 
                                                        |
| 1548 | + $sort_args[ 'dir' ] = 'asc';  | 
                                                        |
| 1549 | 1549 | $class .= ' gv-icon-sort-asc';  | 
                                                        
| 1550 | 1550 | }  | 
                                                        
| 1551 | 1551 |  		} else { | 
                                                        
| 1552 | 1552 | $class .= ' gv-icon-caret-up-down';  | 
                                                        
| 1553 | 1553 | }  | 
                                                        
| 1554 | 1554 | |
| 1555 | -		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); | 
                                                        |
| 1555 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) );  | 
                                                        |
| 1556 | 1556 | |
| 1557 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label;  | 
                                                        |
| 1557 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label;  | 
                                                        |
| 1558 | 1558 | |
| 1559 | 1559 | }  | 
                                                        
| 1560 | 1560 | |
@@ -1572,7 +1572,7 @@ discard block  | 
                                                    ||
| 1572 | 1572 | |
| 1573 | 1573 | $field_type = $field_id;  | 
                                                        
| 1574 | 1574 | |
| 1575 | -		if( is_numeric( $field_id ) ) { | 
                                                        |
| 1575 | +		if ( is_numeric( $field_id ) ) { | 
                                                        |
| 1576 | 1576 | $field = GFFormsModel::get_field( $form, $field_id );  | 
                                                        
| 1577 | 1577 | $field_type = $field->type;  | 
                                                        
| 1578 | 1578 | }  | 
                                                        
@@ -1595,7 +1595,7 @@ discard block  | 
                                                    ||
| 1595 | 1595 | return false;  | 
                                                        
| 1596 | 1596 | }  | 
                                                        
| 1597 | 1597 | |
| 1598 | -		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); | 
                                                        |
| 1598 | +		return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); | 
                                                        |
| 1599 | 1599 | |
| 1600 | 1600 | }  | 
                                                        
| 1601 | 1601 | |
@@ -85,7 +85,7 @@ discard block  | 
                                                    ||
| 85 | 85 | */  | 
                                                        
| 86 | 86 |  	public static function get_instance() { | 
                                                        
| 87 | 87 | |
| 88 | -		if( empty( self::$instance ) ) { | 
                                                        |
| 88 | +		if ( empty( self::$instance ) ) { | 
                                                        |
| 89 | 89 | self::$instance = new self;  | 
                                                        
| 90 | 90 | }  | 
                                                        
| 91 | 91 | |
@@ -118,9 +118,9 @@ discard block  | 
                                                    ||
| 118 | 118 | |
| 119 | 119 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS );  | 
                                                        
| 120 | 120 | |
| 121 | -		if( $with_values ) { | 
                                                        |
| 121 | +		if ( $with_values ) { | 
                                                        |
| 122 | 122 | $operators_with_values = array();  | 
                                                        
| 123 | -			foreach( $operators as $key ) { | 
                                                        |
| 123 | +			foreach ( $operators as $key ) { | 
                                                        |
| 124 | 124 | $operators_with_values[ $key ] = '';  | 
                                                        
| 125 | 125 | }  | 
                                                        
| 126 | 126 | return $operators_with_values;  | 
                                                        
@@ -137,14 +137,14 @@ discard block  | 
                                                    ||
| 137 | 137 | */  | 
                                                        
| 138 | 138 |  	function set_operation( $operation = '' ) { | 
                                                        
| 139 | 139 | |
| 140 | -		if( empty( $operation ) ) { | 
                                                        |
| 140 | +		if ( empty( $operation ) ) { | 
                                                        |
| 141 | 141 | return false;  | 
                                                        
| 142 | 142 | }  | 
                                                        
| 143 | 143 | |
| 144 | 144 | $operators = $this->get_operators( false );  | 
                                                        
| 145 | 145 | |
| 146 | -		if( !in_array( $operation, $operators ) ) { | 
                                                        |
| 147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation );  | 
                                                        |
| 146 | +		if ( ! in_array( $operation, $operators ) ) { | 
                                                        |
| 147 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation );  | 
                                                        |
| 148 | 148 | return false;  | 
                                                        
| 149 | 149 | }  | 
                                                        
| 150 | 150 | |
@@ -164,11 +164,11 @@ discard block  | 
                                                    ||
| 164 | 164 | */  | 
                                                        
| 165 | 165 |  	private function setup_operation_and_comparison() { | 
                                                        
| 166 | 166 | |
| 167 | -		foreach( $this->atts as $key => $value ) { | 
                                                        |
| 167 | +		foreach ( $this->atts as $key => $value ) { | 
                                                        |
| 168 | 168 | |
| 169 | 169 | $valid = $this->set_operation( $key );  | 
                                                        
| 170 | 170 | |
| 171 | -			if( $valid ) { | 
                                                        |
| 171 | +			if ( $valid ) { | 
                                                        |
| 172 | 172 | $this->comparison = $value;  | 
                                                        
| 173 | 173 | return true;  | 
                                                        
| 174 | 174 | }  | 
                                                        
@@ -191,8 +191,8 @@ discard block  | 
                                                    ||
| 191 | 191 | return null;  | 
                                                        
| 192 | 192 | }  | 
                                                        
| 193 | 193 | |
| 194 | -		if( empty( $atts ) ) { | 
                                                        |
| 195 | - do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts );  | 
                                                        |
| 194 | +		if ( empty( $atts ) ) { | 
                                                        |
| 195 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts );  | 
                                                        |
| 196 | 196 | return null;  | 
                                                        
| 197 | 197 | }  | 
                                                        
| 198 | 198 | |
@@ -203,16 +203,16 @@ discard block  | 
                                                    ||
| 203 | 203 | $this->parse_atts();  | 
                                                        
| 204 | 204 | |
| 205 | 205 | // We need an "if"  | 
                                                        
| 206 | -		if( false === $this->if ) { | 
                                                        |
| 207 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts );  | 
                                                        |
| 206 | +		if ( false === $this->if ) { | 
                                                        |
| 207 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts );  | 
                                                        |
| 208 | 208 | return null;  | 
                                                        
| 209 | 209 | }  | 
                                                        
| 210 | 210 | |
| 211 | 211 | $setup = $this->setup_operation_and_comparison();  | 
                                                        
| 212 | 212 | |
| 213 | 213 | // We need an operation and comparison value  | 
                                                        
| 214 | -		if( ! $setup ) { | 
                                                        |
| 215 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts );  | 
                                                        |
| 214 | +		if ( ! $setup ) { | 
                                                        |
| 215 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts );  | 
                                                        |
| 216 | 216 | return null;  | 
                                                        
| 217 | 217 | }  | 
                                                        
| 218 | 218 | |
@@ -245,7 +245,7 @@ discard block  | 
                                                    ||
| 245 | 245 | */  | 
                                                        
| 246 | 246 |  	private function get_output() { | 
                                                        
| 247 | 247 | |
| 248 | -		if( $this->is_match ) { | 
                                                        |
| 248 | +		if ( $this->is_match ) { | 
                                                        |
| 249 | 249 | $output = $this->content;  | 
                                                        
| 250 | 250 |  		} else { | 
                                                        
| 251 | 251 | $output = $this->else_content;  | 
                                                        
@@ -259,9 +259,9 @@ discard block  | 
                                                    ||
| 259 | 259 | * @param string $output HTML/text output  | 
                                                        
| 260 | 260 | * @param GVLogic_Shortcode $this This class  | 
                                                        
| 261 | 261 | */  | 
                                                        
| 262 | -		$output = apply_filters('gravityview/gvlogic/output', $output, $this ); | 
                                                        |
| 262 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this );  | 
                                                        |
| 263 | 263 | |
| 264 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output );  | 
                                                        |
| 264 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output );  | 
                                                        |
| 265 | 265 | |
| 266 | 266 | return $output;  | 
                                                        
| 267 | 267 | }  | 
                                                        
@@ -277,11 +277,11 @@ discard block  | 
                                                    ||
| 277 | 277 | |
| 278 | 278 | $content = explode( '[else]', $this->passed_content );  | 
                                                        
| 279 | 279 | |
| 280 | - $this->content = $content[0];  | 
                                                        |
| 280 | + $this->content = $content[ 0 ];  | 
                                                        |
| 281 | 281 | |
| 282 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL;  | 
                                                        |
| 282 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL;  | 
                                                        |
| 283 | 283 | |
| 284 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr;  | 
                                                        |
| 284 | + $this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr;  | 
                                                        |
| 285 | 285 | }  | 
                                                        
| 286 | 286 | |
| 287 | 287 | /**  | 
                                                        
@@ -304,10 +304,10 @@ discard block  | 
                                                    ||
| 304 | 304 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts;  | 
                                                        
| 305 | 305 | |
| 306 | 306 | // Strip whitespace if it's not default false  | 
                                                        
| 307 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false;  | 
                                                        |
| 307 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false;  | 
                                                        |
| 308 | 308 | |
| 309 | 309 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison()  | 
                                                        
| 310 | - unset( $this->atts['if'] );  | 
                                                        |
| 310 | + unset( $this->atts[ 'if' ] );  | 
                                                        |
| 311 | 311 | }  | 
                                                        
| 312 | 312 | }  | 
                                                        
| 313 | 313 | |
@@ -86,7 +86,6 @@ discard block  | 
                                                    ||
| 86 | 86 | *  | 
                                                        
| 87 | 87 | * @since 1.19.3  | 
                                                        
| 88 | 88 | *  | 
                                                        
| 89 | - * @param bool $force Whether to force checking license, even if AJAX  | 
                                                        |
| 90 | 89 | *  | 
                                                        
| 91 | 90 | * @return void  | 
                                                        
| 92 | 91 | */  | 
                                                        
@@ -272,6 +271,9 @@ discard block  | 
                                                    ||
| 272 | 271 | return $implode ? implode( $implode, $extensions ) : $extensions;  | 
                                                        
| 273 | 272 | }  | 
                                                        
| 274 | 273 | |
| 274 | + /**  | 
                                                        |
| 275 | + * @param boolean $echo  | 
                                                        |
| 276 | + */  | 
                                                        |
| 275 | 277 |  	function settings_edd_license_activation( $field, $echo ) { | 
                                                        
| 276 | 278 | |
| 277 | 279 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';  | 
                                                        
@@ -464,7 +466,7 @@ discard block  | 
                                                    ||
| 464 | 466 | * Generate the status message box HTML based on the current status  | 
                                                        
| 465 | 467 | *  | 
                                                        
| 466 | 468 | * @since 1.7.4  | 
                                                        
| 467 | - * @param $message  | 
                                                        |
| 469 | + * @param string $message  | 
                                                        |
| 468 | 470 | * @param string $class  | 
                                                        
| 469 | 471 | *  | 
                                                        
| 470 | 472 | * @return string  | 
                                                        
@@ -115,14 +115,14 @@ discard block  | 
                                                    ||
| 115 | 115 | // Call the custom API.  | 
                                                        
| 116 | 116 | $response = wp_remote_post( self::url, array(  | 
                                                        
| 117 | 117 | 'timeout' => 15,  | 
                                                        
| 118 | - 'sslverify' => false,  | 
                                                        |
| 119 | - 'body' => array(  | 
                                                        |
| 120 | - 'edd_action' => 'check_license',  | 
                                                        |
| 121 | - 'license' => trim( $this->Addon->get_app_setting( 'license_key' ) ),  | 
                                                        |
| 122 | - 'item_name' => self::name,  | 
                                                        |
| 123 | - 'url' => home_url(),  | 
                                                        |
| 124 | - 'site_data' => $this->get_site_data(),  | 
                                                        |
| 125 | - ),  | 
                                                        |
| 118 | + 'sslverify' => false,  | 
                                                        |
| 119 | + 'body' => array(  | 
                                                        |
| 120 | + 'edd_action' => 'check_license',  | 
                                                        |
| 121 | + 'license' => trim( $this->Addon->get_app_setting( 'license_key' ) ),  | 
                                                        |
| 122 | + 'item_name' => self::name,  | 
                                                        |
| 123 | + 'url' => home_url(),  | 
                                                        |
| 124 | + 'site_data' => $this->get_site_data(),  | 
                                                        |
| 125 | + ),  | 
                                                        |
| 126 | 126 | ));  | 
                                                        
| 127 | 127 | |
| 128 | 128 | // make sure the response came back okay  | 
                                                        
@@ -675,7 +675,7 @@ discard block  | 
                                                    ||
| 675 | 675 | // Update option with passed data license  | 
                                                        
| 676 | 676 | $settings = $this->Addon->get_app_settings();  | 
                                                        
| 677 | 677 | |
| 678 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] );  | 
                                                        |
| 678 | + $settings['license_key'] = $license_data->license_key = trim( $data['license'] );  | 
                                                        |
| 679 | 679 | $settings['license_key_status'] = $license_data->license;  | 
                                                        
| 680 | 680 | $settings['license_key_response'] = (array)$license_data;  | 
                                                        
| 681 | 681 | |
@@ -46,7 +46,7 @@ discard block  | 
                                                    ||
| 46 | 46 | * @return GV_License_Handler  | 
                                                        
| 47 | 47 | */  | 
                                                        
| 48 | 48 |  	public static function get_instance( GravityView_Settings $GFAddOn ) { | 
                                                        
| 49 | -		if( empty( self::$instance ) ) { | 
                                                        |
| 49 | +		if ( empty( self::$instance ) ) { | 
                                                        |
| 50 | 50 | self::$instance = new self( $GFAddOn );  | 
                                                        
| 51 | 51 | }  | 
                                                        
| 52 | 52 | return self::$instance;  | 
                                                        
@@ -123,7 +123,7 @@ discard block  | 
                                                    ||
| 123 | 123 | 'url' => home_url(),  | 
                                                        
| 124 | 124 | 'site_data' => $this->get_site_data(),  | 
                                                        
| 125 | 125 | ),  | 
                                                        
| 126 | - ));  | 
                                                        |
| 126 | + ) );  | 
                                                        |
| 127 | 127 | |
| 128 | 128 | // make sure the response came back okay  | 
                                                        
| 129 | 129 |  			if ( is_wp_error( $response ) ) { | 
                                                        
@@ -149,12 +149,12 @@ discard block  | 
                                                    ||
| 149 | 149 | */  | 
                                                        
| 150 | 150 |  	public function refresh_license_status() { | 
                                                        
| 151 | 151 | |
| 152 | -		if ( defined('DOING_AJAX') && DOING_AJAX ) { | 
                                                        |
| 152 | +		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { | 
                                                        |
| 153 | 153 | return;  | 
                                                        
| 154 | 154 | }  | 
                                                        
| 155 | 155 | |
| 156 | 156 | // The transient is fresh; don't fetch.  | 
                                                        
| 157 | -		if( $status = get_transient( self::status_transient_key ) ) { | 
                                                        |
| 157 | +		if ( $status = get_transient( self::status_transient_key ) ) { | 
                                                        |
| 158 | 158 | return;  | 
                                                        
| 159 | 159 | }  | 
                                                        
| 160 | 160 | |
@@ -187,48 +187,48 @@ discard block  | 
                                                    ||
| 187 | 187 | $theme_data = wp_get_theme();  | 
                                                        
| 188 | 188 | $theme = $theme_data->Name . ' ' . $theme_data->Version;  | 
                                                        
| 189 | 189 | |
| 190 | - $data['gv_version'] = GravityView_Plugin::version;  | 
                                                        |
| 191 | - $data['php_version'] = phpversion();  | 
                                                        |
| 192 | - $data['wp_version'] = get_bloginfo( 'version' );  | 
                                                        |
| 193 | - $data['gf_version'] = GFForms::$version;  | 
                                                        |
| 194 | - $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';  | 
                                                        |
| 195 | - $data['multisite'] = is_multisite();  | 
                                                        |
| 196 | - $data['theme'] = $theme;  | 
                                                        |
| 197 | - $data['url'] = home_url();  | 
                                                        |
| 198 | - $data['license_key'] = GravityView_Settings::get_instance()->get_app_setting( 'license_key' );  | 
                                                        |
| 190 | + $data[ 'gv_version' ] = GravityView_Plugin::version;  | 
                                                        |
| 191 | + $data[ 'php_version' ] = phpversion();  | 
                                                        |
| 192 | + $data[ 'wp_version' ] = get_bloginfo( 'version' );  | 
                                                        |
| 193 | + $data[ 'gf_version' ] = GFForms::$version;  | 
                                                        |
| 194 | + $data[ 'server' ] = isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) ? $_SERVER[ 'SERVER_SOFTWARE' ] : '';  | 
                                                        |
| 195 | + $data[ 'multisite' ] = is_multisite();  | 
                                                        |
| 196 | + $data[ 'theme' ] = $theme;  | 
                                                        |
| 197 | + $data[ 'url' ] = home_url();  | 
                                                        |
| 198 | + $data[ 'license_key' ] = GravityView_Settings::get_instance()->get_app_setting( 'license_key' );  | 
                                                        |
| 199 | 199 | |
| 200 | 200 | // View Data  | 
                                                        
| 201 | -		$gravityview_posts = get_posts('numberposts=-1&post_type=gravityview&post_status=publish&order=ASC'); | 
                                                        |
| 201 | + $gravityview_posts = get_posts( 'numberposts=-1&post_type=gravityview&post_status=publish&order=ASC' );  | 
                                                        |
| 202 | 202 | |
| 203 | 203 |  		if ( ! empty( $gravityview_posts ) ) { | 
                                                        
| 204 | 204 | $first = array_shift( $gravityview_posts );  | 
                                                        
| 205 | 205 | $latest = array_pop( $gravityview_posts );  | 
                                                        
| 206 | - $data['view_count'] = count( $gravityview_posts );  | 
                                                        |
| 207 | - $data['view_first'] = $first->post_date;  | 
                                                        |
| 208 | - $data['view_latest'] = $latest->post_date;  | 
                                                        |
| 206 | + $data[ 'view_count' ] = count( $gravityview_posts );  | 
                                                        |
| 207 | + $data[ 'view_first' ] = $first->post_date;  | 
                                                        |
| 208 | + $data[ 'view_latest' ] = $latest->post_date;  | 
                                                        |
| 209 | 209 | }  | 
                                                        
| 210 | 210 | |
| 211 | 211 | // Form counts  | 
                                                        
| 212 | 212 |  		if ( class_exists( 'GFFormsModel' ) ) { | 
                                                        
| 213 | 213 | $form_data = GFFormsModel::get_form_count();  | 
                                                        
| 214 | - $data['forms_total'] = rgar( $form_data, 'total', 0 );  | 
                                                        |
| 215 | - $data['forms_active'] = rgar( $form_data, 'active', 0 );  | 
                                                        |
| 216 | - $data['forms_inactive'] = rgar( $form_data, 'inactive', 0 );  | 
                                                        |
| 217 | - $data['forms_trash'] = rgar( $form_data, 'inactive', 0 );  | 
                                                        |
| 214 | + $data[ 'forms_total' ] = rgar( $form_data, 'total', 0 );  | 
                                                        |
| 215 | + $data[ 'forms_active' ] = rgar( $form_data, 'active', 0 );  | 
                                                        |
| 216 | + $data[ 'forms_inactive' ] = rgar( $form_data, 'inactive', 0 );  | 
                                                        |
| 217 | + $data[ 'forms_trash' ] = rgar( $form_data, 'inactive', 0 );  | 
                                                        |
| 218 | 218 | }  | 
                                                        
| 219 | 219 | |
| 220 | 220 | // Retrieve current plugin information  | 
                                                        
| 221 | -		if( ! function_exists( 'get_plugins' ) ) { | 
                                                        |
| 221 | +		if ( ! function_exists( 'get_plugins' ) ) { | 
                                                        |
| 222 | 222 | include ABSPATH . '/wp-admin/includes/plugin.php';  | 
                                                        
| 223 | 223 | }  | 
                                                        
| 224 | 224 | |
| 225 | - $data['integrations'] = self::get_related_plugins_and_extensions();  | 
                                                        |
| 226 | - $data['active_plugins'] = get_option( 'active_plugins', array() );  | 
                                                        |
| 227 | - $data['inactive_plugins'] = array();  | 
                                                        |
| 228 | - $data['locale'] = get_locale();  | 
                                                        |
| 225 | + $data[ 'integrations' ] = self::get_related_plugins_and_extensions();  | 
                                                        |
| 226 | + $data[ 'active_plugins' ] = get_option( 'active_plugins', array() );  | 
                                                        |
| 227 | + $data[ 'inactive_plugins' ] = array();  | 
                                                        |
| 228 | + $data[ 'locale' ] = get_locale();  | 
                                                        |
| 229 | 229 | |
| 230 | 230 | // Validate request on the GV server  | 
                                                        
| 231 | - $data['hash'] = 'gv_version.url.locale:' . sha1( $data['gv_version'] . $data['url'] . $data['locale'] );  | 
                                                        |
| 231 | + $data[ 'hash' ] = 'gv_version.url.locale:' . sha1( $data[ 'gv_version' ] . $data[ 'url' ] . $data[ 'locale' ] );  | 
                                                        |
| 232 | 232 | |
| 233 | 233 | return $data;  | 
                                                        
| 234 | 234 | }  | 
                                                        
@@ -260,10 +260,10 @@ discard block  | 
                                                    ||
| 260 | 260 | |
| 261 | 261 | $plugin_data = get_plugin_data( $active_plugin );  | 
                                                        
| 262 | 262 | |
| 263 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] );  | 
                                                        |
| 263 | + $extensions[ ] = sprintf( '%s %s', $plugin_data[ 'Name' ], $plugin_data[ 'Version' ] );  | 
                                                        |
| 264 | 264 | }  | 
                                                        
| 265 | 265 | |
| 266 | -			if( ! empty( $extensions ) ) { | 
                                                        |
| 266 | +			if ( ! empty( $extensions ) ) { | 
                                                        |
| 267 | 267 | set_site_transient( self::related_plugins_key, $extensions, HOUR_IN_SECONDS );  | 
                                                        
| 268 | 268 |  			} else { | 
                                                        
| 269 | 269 | return 'There was an error fetching related plugins.';  | 
                                                        
@@ -282,37 +282,37 @@ discard block  | 
                                                    ||
| 282 | 282 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) );  | 
                                                        
| 283 | 283 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) );  | 
                                                        
| 284 | 284 | |
| 285 | -		if( !empty( $key ) ) { | 
                                                        |
| 285 | +		if ( ! empty( $key ) ) { | 
                                                        |
| 286 | 286 | $response = $this->Addon->get_app_setting( 'license_key_response' );  | 
                                                        
| 287 | - $response = is_array( $response ) ? (object) $response : json_decode( $response );  | 
                                                        |
| 287 | + $response = is_array( $response ) ? (object)$response : json_decode( $response );  | 
                                                        |
| 288 | 288 |  		} else { | 
                                                        
| 289 | 289 | $response = array();  | 
                                                        
| 290 | 290 | }  | 
                                                        
| 291 | 291 | |
| 292 | 292 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array(  | 
                                                        
| 293 | 293 | 'license_box' => $this->get_license_message( $response )  | 
                                                        
| 294 | - ));  | 
                                                        |
| 294 | + ) );  | 
                                                        |
| 295 | 295 | |
| 296 | 296 | |
| 297 | 297 | $fields = array(  | 
                                                        
| 298 | 298 | array(  | 
                                                        
| 299 | 299 | 'name' => 'edd-activate',  | 
                                                        
| 300 | -				'value' => __('Activate License', 'gravityview'), | 
                                                        |
| 301 | -				'data-pending_text' => __('Verifying license…', 'gravityview'), | 
                                                        |
| 300 | + 'value' => __( 'Activate License', 'gravityview' ),  | 
                                                        |
| 301 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ),  | 
                                                        |
| 302 | 302 | 'data-edd_action' => 'activate_license',  | 
                                                        
| 303 | 303 | 'class' => 'button-primary',  | 
                                                        
| 304 | 304 | ),  | 
                                                        
| 305 | 305 | array(  | 
                                                        
| 306 | 306 | 'name' => 'edd-deactivate',  | 
                                                        
| 307 | -				'value' => __('Deactivate License', 'gravityview'), | 
                                                        |
| 308 | -				'data-pending_text' => __('Deactivating license…', 'gravityview'), | 
                                                        |
| 307 | + 'value' => __( 'Deactivate License', 'gravityview' ),  | 
                                                        |
| 308 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ),  | 
                                                        |
| 309 | 309 | 'data-edd_action' => 'deactivate_license',  | 
                                                        
| 310 | 310 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ),  | 
                                                        
| 311 | 311 | ),  | 
                                                        
| 312 | 312 | array(  | 
                                                        
| 313 | 313 | 'name' => 'edd-check',  | 
                                                        
| 314 | -				'value' => __('Check License', 'gravityview'), | 
                                                        |
| 315 | -				'data-pending_text' => __('Verifying license…', 'gravityview'), | 
                                                        |
| 314 | + 'value' => __( 'Check License', 'gravityview' ),  | 
                                                        |
| 315 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ),  | 
                                                        |
| 316 | 316 | 'title' => 'Check the license before saving it',  | 
                                                        
| 317 | 317 | 'data-edd_action' => 'check_license',  | 
                                                        
| 318 | 318 | 'class' => 'button-secondary',  | 
                                                        
@@ -322,17 +322,17 @@ discard block  | 
                                                    ||
| 322 | 322 | |
| 323 | 323 | $class = 'button gv-edd-action';  | 
                                                        
| 324 | 324 | |
| 325 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide';  | 
                                                        |
| 325 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide';  | 
                                                        |
| 326 | 326 | |
| 327 | 327 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled';  | 
                                                        
| 328 | 328 | |
| 329 | 329 | $submit = '<div class="gv-edd-button-wrapper">';  | 
                                                        
| 330 | 330 |  		foreach ( $fields as $field ) { | 
                                                        
| 331 | - $field['type'] = 'button';  | 
                                                        |
| 332 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class;  | 
                                                        |
| 333 | - $field['style'] = 'margin-left: 10px;';  | 
                                                        |
| 334 | -			if( $disabled_attribute ) { | 
                                                        |
| 335 | - $field['disabled'] = $disabled_attribute;  | 
                                                        |
| 331 | + $field[ 'type' ] = 'button';  | 
                                                        |
| 332 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class;  | 
                                                        |
| 333 | + $field[ 'style' ] = 'margin-left: 10px;';  | 
                                                        |
| 334 | +			if ( $disabled_attribute ) { | 
                                                        |
| 335 | + $field[ 'disabled' ] = $disabled_attribute;  | 
                                                        |
| 336 | 336 | }  | 
                                                        
| 337 | 337 | $submit .= $this->Addon->settings_submit( $field, $echo );  | 
                                                        
| 338 | 338 | }  | 
                                                        
@@ -348,8 +348,8 @@ discard block  | 
                                                    ||
| 348 | 348 | */  | 
                                                        
| 349 | 349 |  	private function setup_edd() { | 
                                                        
| 350 | 350 | |
| 351 | -		if( !class_exists('EDD_SL_Plugin_Updater') ) { | 
                                                        |
| 352 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php');  | 
                                                        |
| 351 | +		if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { | 
                                                        |
| 352 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' );  | 
                                                        |
| 353 | 353 | }  | 
                                                        
| 354 | 354 | |
| 355 | 355 | // setup the updater  | 
                                                        
@@ -386,8 +386,8 @@ discard block  | 
                                                    ||
| 386 | 386 | 'url' => home_url(),  | 
                                                        
| 387 | 387 | );  | 
                                                        
| 388 | 388 | |
| 389 | -		if( !empty( $action ) ) { | 
                                                        |
| 390 | - $settings['edd_action'] = esc_attr( $action );  | 
                                                        |
| 389 | +		if ( ! empty( $action ) ) { | 
                                                        |
| 390 | + $settings[ 'edd_action' ] = esc_attr( $action );  | 
                                                        |
| 391 | 391 | }  | 
                                                        
| 392 | 392 | |
| 393 | 393 | $settings = array_map( 'urlencode', $settings );  | 
                                                        
@@ -401,14 +401,14 @@ discard block  | 
                                                    ||
| 401 | 401 | */  | 
                                                        
| 402 | 402 |  	private function _license_get_remote_response( $data, $license = '' ) { | 
                                                        
| 403 | 403 | |
| 404 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license );  | 
                                                        |
| 404 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license );  | 
                                                        |
| 405 | 405 | |
| 406 | 406 | $url = add_query_arg( $api_params, self::url );  | 
                                                        
| 407 | 407 | |
| 408 | 408 | $response = wp_remote_get( $url, array(  | 
                                                        
| 409 | 409 | 'timeout' => 15,  | 
                                                        
| 410 | 410 | 'sslverify' => false,  | 
                                                        
| 411 | - ));  | 
                                                        |
| 411 | + ) );  | 
                                                        |
| 412 | 412 | |
| 413 | 413 |  		if ( is_wp_error( $response ) ) { | 
                                                        
| 414 | 414 | return array();  | 
                                                        
@@ -441,11 +441,11 @@ discard block  | 
                                                    ||
| 441 | 441 | */  | 
                                                        
| 442 | 442 |  	function get_license_message( $license_data ) { | 
                                                        
| 443 | 443 | |
| 444 | -		if( empty( $license_data ) ) { | 
                                                        |
| 444 | +		if ( empty( $license_data ) ) { | 
                                                        |
| 445 | 445 | $message = '';  | 
                                                        
| 446 | 446 |  		} else { | 
                                                        
| 447 | 447 | |
| 448 | -			if( ! empty( $license_data->error ) ) { | 
                                                        |
| 448 | +			if ( ! empty( $license_data->error ) ) { | 
                                                        |
| 449 | 449 | $class = 'error';  | 
                                                        
| 450 | 450 | $string_key = $license_data->error;  | 
                                                        
| 451 | 451 |  			} else { | 
                                                        
@@ -453,7 +453,7 @@ discard block  | 
                                                    ||
| 453 | 453 | $string_key = $license_data->license;  | 
                                                        
| 454 | 454 | }  | 
                                                        
| 455 | 455 | |
| 456 | -			$message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); | 
                                                        |
| 456 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) );  | 
                                                        |
| 457 | 457 | |
| 458 | 458 | $message = $this->generate_license_box( $message, $class );  | 
                                                        
| 459 | 459 | }  | 
                                                        
@@ -490,18 +490,18 @@ discard block  | 
                                                    ||
| 490 | 490 | */  | 
                                                        
| 491 | 491 |  	public function license_details( $response = array() ) { | 
                                                        
| 492 | 492 | |
| 493 | - $response = (array) $response;  | 
                                                        |
| 493 | + $response = (array)$response;  | 
                                                        |
| 494 | 494 | |
| 495 | 495 | $return = '';  | 
                                                        
| 496 | 496 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>';  | 
                                                        
| 497 | 497 | |
| 498 | -		if( ! empty( $response['license_key'] ) ) { | 
                                                        |
| 498 | +		if ( ! empty( $response[ 'license_key' ] ) ) { | 
                                                        |
| 499 | 499 | |
| 500 | 500 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>';  | 
                                                        
| 501 | 501 | |
| 502 | 502 |  			if ( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { | 
                                                        
| 503 | - $return .= $this->strings( $response['license'], $response );  | 
                                                        |
| 504 | -			} elseif ( ! empty( $response['license_name'] ) ) { | 
                                                        |
| 503 | + $return .= $this->strings( $response[ 'license' ], $response );  | 
                                                        |
| 504 | +			} elseif ( ! empty( $response[ 'license_name' ] ) ) { | 
                                                        |
| 505 | 505 | |
| 506 | 506 | $response_keys = array(  | 
                                                        
| 507 | 507 | 'license_name' => '',  | 
                                                        
@@ -516,19 +516,19 @@ discard block  | 
                                                    ||
| 516 | 516 | // Make sure all the keys are set  | 
                                                        
| 517 | 517 | $response = wp_parse_args( $response, $response_keys );  | 
                                                        
| 518 | 518 | |
| 519 | - $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) );  | 
                                                        |
| 520 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' );  | 
                                                        |
| 519 | + $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) );  | 
                                                        |
| 520 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' );  | 
                                                        |
| 521 | 521 | $details = array(  | 
                                                        
| 522 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ),  | 
                                                        |
| 523 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . $login_link,  | 
                                                        |
| 524 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text,  | 
                                                        |
| 525 | - 'expires' => 'lifetime' === $response['expires'] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ),  | 
                                                        |
| 526 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ),  | 
                                                        |
| 522 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ),  | 
                                                        |
| 523 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . $login_link,  | 
                                                        |
| 524 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text,  | 
                                                        |
| 525 | + 'expires' => 'lifetime' === $response[ 'expires' ] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ),  | 
                                                        |
| 526 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ),  | 
                                                        |
| 527 | 527 | );  | 
                                                        
| 528 | 528 | |
| 529 | -				if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { | 
                                                        |
| 530 | - unset( $details['upgrade'] );  | 
                                                        |
| 531 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>';  | 
                                                        |
| 529 | +				if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { | 
                                                        |
| 530 | + unset( $details[ 'upgrade' ] );  | 
                                                        |
| 531 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>';  | 
                                                        |
| 532 | 532 | }  | 
                                                        
| 533 | 533 | |
| 534 | 534 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>';  | 
                                                        
@@ -551,11 +551,11 @@ discard block  | 
                                                    ||
| 551 | 551 | |
| 552 | 552 | $output = '';  | 
                                                        
| 553 | 553 | |
| 554 | -		if( ! empty( $upgrades ) ) { | 
                                                        |
| 554 | +		if ( ! empty( $upgrades ) ) { | 
                                                        |
| 555 | 555 | |
| 556 | 556 | $locale_parts = explode( '_', get_locale() );  | 
                                                        
| 557 | 557 | |
| 558 | - $is_english = ( 'en' === $locale_parts[0] );  | 
                                                        |
| 558 | + $is_english = ( 'en' === $locale_parts[ 0 ] );  | 
                                                        |
| 559 | 559 | |
| 560 | 560 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>';  | 
                                                        
| 561 | 561 | |
@@ -563,14 +563,14 @@ discard block  | 
                                                    ||
| 563 | 563 | |
| 564 | 564 |  			foreach ( $upgrades as $upgrade_id => $upgrade ) { | 
                                                        
| 565 | 565 | |
| 566 | - $upgrade = (object) $upgrade;  | 
                                                        |
| 566 | + $upgrade = (object)$upgrade;  | 
                                                        |
| 567 | 567 | |
| 568 | 568 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) );  | 
                                                        
| 569 | 569 | |
| 570 | -				if( $is_english && isset( $upgrade->description ) ) { | 
                                                        |
| 570 | +				if ( $is_english && isset( $upgrade->description ) ) { | 
                                                        |
| 571 | 571 | $message = esc_html( $upgrade->description );  | 
                                                        
| 572 | 572 |  				} else { | 
                                                        
| 573 | -					switch( $upgrade->price_id ) { | 
                                                        |
| 573 | +					switch ( $upgrade->price_id ) { | 
                                                        |
| 574 | 574 | // Interstellar  | 
                                                        
| 575 | 575 | case 1:  | 
                                                        
| 576 | 576 | default:  | 
                                                        
@@ -608,16 +608,16 @@ discard block  | 
                                                    ||
| 608 | 608 | */  | 
                                                        
| 609 | 609 |  	public function license_call( $array = array() ) { | 
                                                        
| 610 | 610 | |
| 611 | -		$is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); | 
                                                        |
| 612 | - $data = empty( $array ) ? $_POST['data'] : $array;  | 
                                                        |
| 611 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );  | 
                                                        |
| 612 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array;  | 
                                                        |
| 613 | 613 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' );  | 
                                                        
| 614 | 614 | |
| 615 | -		if ( $is_ajax && empty( $data['license'] ) ) { | 
                                                        |
| 616 | - die( - 1 );  | 
                                                        |
| 615 | +		if ( $is_ajax && empty( $data[ 'license' ] ) ) { | 
                                                        |
| 616 | + die( -1 );  | 
                                                        |
| 617 | 617 | }  | 
                                                        
| 618 | 618 | |
| 619 | 619 | // If the user isn't allowed to edit settings, show an error message  | 
                                                        
| 620 | -		if( ! $has_cap && empty( $data['all_caps'] ) ) { | 
                                                        |
| 620 | +		if ( ! $has_cap && empty( $data[ 'all_caps' ] ) ) { | 
                                                        |
| 621 | 621 | $license_data = new stdClass();  | 
                                                        
| 622 | 622 | $license_data->error = 'capability';  | 
                                                        
| 623 | 623 | $license_data->message = $this->get_license_message( $license_data );  | 
                                                        
@@ -641,9 +641,9 @@ discard block  | 
                                                    ||
| 641 | 641 | |
| 642 | 642 | $json = json_encode( $license_data );  | 
                                                        
| 643 | 643 | |
| 644 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) );  | 
                                                        |
| 644 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) );  | 
                                                        |
| 645 | 645 | |
| 646 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX );  | 
                                                        |
| 646 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX );  | 
                                                        |
| 647 | 647 | |
| 648 | 648 | // Failed is the response from trying to de-activate a license and it didn't work.  | 
                                                        
| 649 | 649 | // This likely happened because people entered in a different key and clicked "Deactivate",  | 
                                                        
@@ -651,7 +651,7 @@ discard block  | 
                                                    ||
| 651 | 651 | // most likely a mistake.  | 
                                                        
| 652 | 652 |  			if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { | 
                                                        
| 653 | 653 | |
| 654 | -				if ( ! empty( $data['field_id'] ) ) { | 
                                                        |
| 654 | +				if ( ! empty( $data[ 'field_id' ] ) ) { | 
                                                        |
| 655 | 655 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS );  | 
                                                        
| 656 | 656 | }  | 
                                                        
| 657 | 657 | |
@@ -662,7 +662,7 @@ discard block  | 
                                                    ||
| 662 | 662 |  		if ( $is_ajax ) { | 
                                                        
| 663 | 663 | exit( $json );  | 
                                                        
| 664 | 664 |  		} else { // Non-ajax call | 
                                                        
| 665 | -			return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; | 
                                                        |
| 665 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json;  | 
                                                        |
| 666 | 666 | }  | 
                                                        
| 667 | 667 | }  | 
                                                        
| 668 | 668 | |
@@ -676,9 +676,9 @@ discard block  | 
                                                    ||
| 676 | 676 | // Update option with passed data license  | 
                                                        
| 677 | 677 | $settings = $this->Addon->get_app_settings();  | 
                                                        
| 678 | 678 | |
| 679 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] );  | 
                                                        |
| 680 | - $settings['license_key_status'] = $license_data->license;  | 
                                                        |
| 681 | - $settings['license_key_response'] = (array)$license_data;  | 
                                                        |
| 679 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] );  | 
                                                        |
| 680 | + $settings[ 'license_key_status' ] = $license_data->license;  | 
                                                        |
| 681 | + $settings[ 'license_key_response' ] = (array)$license_data;  | 
                                                        |
| 682 | 682 | |
| 683 | 683 | $this->Addon->update_app_settings( $settings );  | 
                                                        
| 684 | 684 | }  | 
                                                        
@@ -691,7 +691,7 @@ discard block  | 
                                                    ||
| 691 | 691 | */  | 
                                                        
| 692 | 692 |  	private function get_license_renewal_url( $license_data ) { | 
                                                        
| 693 | 693 | $license_data = is_array( $license_data ) ? (object)$license_data : $license_data;  | 
                                                        
| 694 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/';  | 
                                                        |
| 694 | + $renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/';  | 
                                                        |
| 695 | 695 | return $renew_license_url;  | 
                                                        
| 696 | 696 | }  | 
                                                        
| 697 | 697 | |
@@ -706,31 +706,31 @@ discard block  | 
                                                    ||
| 706 | 706 | |
| 707 | 707 | |
| 708 | 708 | $strings = array(  | 
                                                        
| 709 | -			'status' => esc_html__('Status', 'gravityview'), | 
                                                        |
| 710 | -			'error' => esc_html__('There was an error processing the request.', 'gravityview'), | 
                                                        |
| 711 | -			'failed'  => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), | 
                                                        |
| 712 | -			'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), | 
                                                        |
| 713 | -			'inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), | 
                                                        |
| 714 | -			'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), | 
                                                        |
| 715 | -			'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), | 
                                                        |
| 716 | -			'valid' => esc_html__('The license key is valid and active.', 'gravityview'), | 
                                                        |
| 717 | -			'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), | 
                                                        |
| 718 | -			'missing' => esc_html__('Invalid license key.', 'gravityview'), | 
                                                        |
| 719 | -			'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), | 
                                                        |
| 720 | -			'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), | 
                                                        |
| 709 | + 'status' => esc_html__( 'Status', 'gravityview' ),  | 
                                                        |
| 710 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ),  | 
                                                        |
| 711 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ),  | 
                                                        |
| 712 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ),  | 
                                                        |
| 713 | + 'inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ),  | 
                                                        |
| 714 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ),  | 
                                                        |
| 715 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ),  | 
                                                        |
| 716 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ),  | 
                                                        |
| 717 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ),  | 
                                                        |
| 718 | + 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ),  | 
                                                        |
| 719 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ),  | 
                                                        |
| 720 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ),  | 
                                                        |
| 721 | 721 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ),  | 
                                                        
| 722 | 722 | |
| 723 | -			'verifying_license' => esc_html__('Verifying license…', 'gravityview'), | 
                                                        |
| 724 | -			'activate_license' => esc_html__('Activate License', 'gravityview'), | 
                                                        |
| 725 | -			'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), | 
                                                        |
| 726 | -			'check_license' => esc_html__('Verify License', 'gravityview'), | 
                                                        |
| 723 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ),  | 
                                                        |
| 724 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ),  | 
                                                        |
| 725 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ),  | 
                                                        |
| 726 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ),  | 
                                                        |
| 727 | 727 | );  | 
                                                        
| 728 | 728 | |
| 729 | -		if( empty( $status ) ) { | 
                                                        |
| 729 | +		if ( empty( $status ) ) { | 
                                                        |
| 730 | 730 | return $strings;  | 
                                                        
| 731 | 731 | }  | 
                                                        
| 732 | 732 | |
| 733 | -		if( isset( $strings[ $status ] ) ) { | 
                                                        |
| 733 | +		if ( isset( $strings[ $status ] ) ) { | 
                                                        |
| 734 | 734 | return $strings[ $status ];  | 
                                                        
| 735 | 735 | }  | 
                                                        
| 736 | 736 | |
@@ -107,9 +107,9 @@ discard block  | 
                                                    ||
| 107 | 107 | ) );  | 
                                                        
| 108 | 108 | |
| 109 | 109 | // This is just HTML we don't need.  | 
                                                        
| 110 | - unset( $response['message'] );  | 
                                                        |
| 110 | + unset( $response[ 'message' ] );  | 
                                                        |
| 111 | 111 | |
| 112 | -		switch ( intval( $response['license_limit'] ) ) { | 
                                                        |
| 112 | +		switch ( intval( $response[ 'license_limit' ] ) ) { | 
                                                        |
| 113 | 113 | case 1:  | 
                                                        
| 114 | 114 | $package = 'Sol';  | 
                                                        
| 115 | 115 | break;  | 
                                                        
@@ -120,24 +120,24 @@ discard block  | 
                                                    ||
| 120 | 120 | $package = 'Interstellar';  | 
                                                        
| 121 | 121 | break;  | 
                                                        
| 122 | 122 | default:  | 
                                                        
| 123 | - $package = sprintf( '%d-Site License', $response['license_limit'] );  | 
                                                        |
| 123 | + $package = sprintf( '%d-Site License', $response[ 'license_limit' ] );  | 
                                                        |
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
| 126 | 126 | $data = array(  | 
                                                        
| 127 | 127 | 'email' => GravityView_Settings::getSetting( 'support-email' ),  | 
                                                        
| 128 | - 'name' => $response['customer_name'],  | 
                                                        |
| 129 | - 'Valid License?' => ucwords( $response['license'] ),  | 
                                                        |
| 130 | - 'License Key' => $response['license_key'],  | 
                                                        |
| 128 | + 'name' => $response[ 'customer_name' ],  | 
                                                        |
| 129 | + 'Valid License?' => ucwords( $response[ 'license' ] ),  | 
                                                        |
| 130 | + 'License Key' => $response[ 'license_key' ],  | 
                                                        |
| 131 | 131 | 'License Level' => $package,  | 
                                                        
| 132 | 132 | 'Site Admin Email' => get_bloginfo( 'admin_email' ),  | 
                                                        
| 133 | 133 | 'Support Email' => GravityView_Settings::getSetting( 'support-email' ),  | 
                                                        
| 134 | - 'License Limit' => $response['license_limit'],  | 
                                                        |
| 135 | - 'Site Count' => $response['site_count'],  | 
                                                        |
| 136 | - 'License Expires' => $response['expires'],  | 
                                                        |
| 137 | - 'Activations Left' => $response['activations_left'],  | 
                                                        |
| 138 | - 'Payment ID' => $response['payment_id'],  | 
                                                        |
| 139 | - 'Payment Name' => $response['customer_name'],  | 
                                                        |
| 140 | - 'Payment Email' => $response['customer_email'],  | 
                                                        |
| 134 | + 'License Limit' => $response[ 'license_limit' ],  | 
                                                        |
| 135 | + 'Site Count' => $response[ 'site_count' ],  | 
                                                        |
| 136 | + 'License Expires' => $response[ 'expires' ],  | 
                                                        |
| 137 | + 'Activations Left' => $response[ 'activations_left' ],  | 
                                                        |
| 138 | + 'Payment ID' => $response[ 'payment_id' ],  | 
                                                        |
| 139 | + 'Payment Name' => $response[ 'customer_name' ],  | 
                                                        |
| 140 | + 'Payment Email' => $response[ 'customer_email' ],  | 
                                                        |
| 141 | 141 | 'WordPress Version' => get_bloginfo( 'version', 'display' ),  | 
                                                        
| 142 | 142 | 'PHP Version' => phpversion(),  | 
                                                        
| 143 | 143 | 'GravityView Version' => GravityView_Plugin::version,  | 
                                                        
@@ -10,21 +10,21 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 44 | 44 | */  | 
                                                        
| 45 | 45 | private static $supports_product_fields = false;  | 
                                                        
| 46 | 46 | |
| 47 | - /**  | 
                                                        |
| 48 | - * Gravity Forms entry array  | 
                                                        |
| 49 | - *  | 
                                                        |
| 50 | - * @var array  | 
                                                        |
| 51 | - */  | 
                                                        |
| 52 | - public $entry;  | 
                                                        |
| 47 | + /**  | 
                                                        |
| 48 | + * Gravity Forms entry array  | 
                                                        |
| 49 | + *  | 
                                                        |
| 50 | + * @var array  | 
                                                        |
| 51 | + */  | 
                                                        |
| 52 | + public $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  | 
                                                    ||
| 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 | - */  | 
                                                        |
| 61 | + /**  | 
                                                        |
| 62 | + * Gravity Forms form array (GravityView modifies the content through this class lifecycle)  | 
                                                        |
| 63 | + *  | 
                                                        |
| 64 | + * @var array  | 
                                                        |
| 65 | + */  | 
                                                        |
| 66 | 66 | public $form;  | 
                                                        
| 67 | 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 | - */  | 
                                                        |
| 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 | 80 | public $form_after_validation = null;  | 
                                                        
| 81 | 81 | |
| 82 | - /**  | 
                                                        |
| 83 | - * Hold an array of GF field objects that have calculation rules  | 
                                                        |
| 84 | - * @var array  | 
                                                        |
| 85 | - */  | 
                                                        |
| 82 | + /**  | 
                                                        |
| 83 | + * Hold an array of GF field objects that have calculation rules  | 
                                                        |
| 84 | + * @var array  | 
                                                        |
| 85 | + */  | 
                                                        |
| 86 | 86 | public $fields_with_calculation = array();  | 
                                                        
| 87 | 87 | |
| 88 | - /**  | 
                                                        |
| 89 | - * Hold an array of GF field objects with type 'total'  | 
                                                        |
| 90 | - * @var array  | 
                                                        |
| 91 | - */  | 
                                                        |
| 88 | + /**  | 
                                                        |
| 89 | + * Hold an array of GF field objects with type 'total'  | 
                                                        |
| 90 | + * @var array  | 
                                                        |
| 91 | + */  | 
                                                        |
| 92 | 92 | public $total_fields = array();  | 
                                                        
| 93 | 93 | |
| 94 | - /**  | 
                                                        |
| 95 | - * Gravity Forms form id  | 
                                                        |
| 96 | - *  | 
                                                        |
| 97 | - * @var int  | 
                                                        |
| 98 | - */  | 
                                                        |
| 94 | + /**  | 
                                                        |
| 95 | + * Gravity Forms form id  | 
                                                        |
| 96 | + *  | 
                                                        |
| 97 | + * @var int  | 
                                                        |
| 98 | + */  | 
                                                        |
| 99 | 99 | public $form_id;  | 
                                                        
| 100 | 100 | |
| 101 | - /**  | 
                                                        |
| 102 | - * ID of the current view  | 
                                                        |
| 103 | - *  | 
                                                        |
| 104 | - * @var int  | 
                                                        |
| 105 | - */  | 
                                                        |
| 101 | + /**  | 
                                                        |
| 102 | + * ID of the current view  | 
                                                        |
| 103 | + *  | 
                                                        |
| 104 | + * @var int  | 
                                                        |
| 105 | + */  | 
                                                        |
| 106 | 106 | public $view_id;  | 
                                                        
| 107 | 107 | |
| 108 | - /**  | 
                                                        |
| 109 | - * Updated entry is valid (GF Validation object)  | 
                                                        |
| 110 | - *  | 
                                                        |
| 111 | - * @var array  | 
                                                        |
| 112 | - */  | 
                                                        |
| 108 | + /**  | 
                                                        |
| 109 | + * Updated entry is valid (GF Validation object)  | 
                                                        |
| 110 | + *  | 
                                                        |
| 111 | + * @var array  | 
                                                        |
| 112 | + */  | 
                                                        |
| 113 | 113 | public $is_valid = NULL;  | 
                                                        
| 114 | 114 | |
| 115 | -    function __construct( GravityView_Edit_Entry $loader ) { | 
                                                        |
| 116 | - $this->loader = $loader;  | 
                                                        |
| 117 | - }  | 
                                                        |
| 115 | +	function __construct( GravityView_Edit_Entry $loader ) { | 
                                                        |
| 116 | + $this->loader = $loader;  | 
                                                        |
| 117 | + }  | 
                                                        |
| 118 | 118 | |
| 119 | -    function load() { | 
                                                        |
| 119 | +	function load() { | 
                                                        |
| 120 | 120 | |
| 121 | - /** @define "GRAVITYVIEW_DIR" "../../../" */  | 
                                                        |
| 122 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );  | 
                                                        |
| 121 | + /** @define "GRAVITYVIEW_DIR" "../../../" */  | 
                                                        |
| 122 | + include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );  | 
                                                        |
| 123 | 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' ) );  | 
                                                        |
| 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 | 127 | |
| 128 | - // Stop Gravity Forms processing what is ours!  | 
                                                        |
| 129 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );  | 
                                                        |
| 128 | + // Stop Gravity Forms processing what is ours!  | 
                                                        |
| 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 | - add_action( 'gravityview_edit_entry', array( $this, 'init' ) );  | 
                                                        |
| 133 | + add_action( 'gravityview_edit_entry', array( $this, 'init' ) );  | 
                                                        |
| 134 | 134 | |
| 135 | - // Disable conditional logic if needed (since 1.9)  | 
                                                        |
| 136 | - add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 );  | 
                                                        |
| 135 | + // Disable conditional logic if needed (since 1.9)  | 
                                                        |
| 136 | + add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 );  | 
                                                        |
| 137 | 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 );  | 
                                                        |
| 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 | 140 | |
| 141 | - // Add fields expected by GFFormDisplay::validate()  | 
                                                        |
| 142 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );  | 
                                                        |
| 141 | + // Add fields expected by GFFormDisplay::validate()  | 
                                                        |
| 142 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );  | 
                                                        |
| 143 | 143 | |
| 144 | - }  | 
                                                        |
| 144 | + }  | 
                                                        |
| 145 | 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 | -    public 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 | - }  | 
                                                        |
| 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 | +	public 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 | 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 | -    public function prevent_maybe_process_form() { | 
                                                        |
| 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 | +	public 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 );  | 
                                                        |
| 177 | - }  | 
                                                        |
| 178 | - }  | 
                                                        |
| 175 | +		if( $this->is_edit_entry_submission() && $this->verify_nonce() ) { | 
                                                        |
| 176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 );  | 
                                                        |
| 177 | + }  | 
                                                        |
| 178 | + }  | 
                                                        |
| 179 | 179 | |
| 180 | - /**  | 
                                                        |
| 181 | - * Is the current page an Edit Entry page?  | 
                                                        |
| 182 | - * @return boolean  | 
                                                        |
| 183 | - */  | 
                                                        |
| 184 | -    public function is_edit_entry() { | 
                                                        |
| 180 | + /**  | 
                                                        |
| 181 | + * Is the current page an Edit Entry page?  | 
                                                        |
| 182 | + * @return boolean  | 
                                                        |
| 183 | + */  | 
                                                        |
| 184 | +	public function is_edit_entry() { | 
                                                        |
| 185 | 185 | |
| 186 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );  | 
                                                        |
| 186 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );  | 
                                                        |
| 187 | 187 | |
| 188 | - return ( $is_edit_entry || $this->is_edit_entry_submission() );  | 
                                                        |
| 189 | - }  | 
                                                        |
| 188 | + return ( $is_edit_entry || $this->is_edit_entry_submission() );  | 
                                                        |
| 189 | + }  | 
                                                        |
| 190 | 190 | |
| 191 | 191 | /**  | 
                                                        
| 192 | 192 | * Is the current page an Edit Entry page?  | 
                                                        
@@ -197,658 +197,658 @@ discard block  | 
                                                    ||
| 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 | -    private function setup_vars() { | 
                                                        |
| 204 | - $gravityview_view = GravityView_View::getInstance();  | 
                                                        |
| 200 | + /**  | 
                                                        |
| 201 | + * When Edit entry view is requested setup the vars  | 
                                                        |
| 202 | + */  | 
                                                        |
| 203 | +	private function setup_vars() { | 
                                                        |
| 204 | + $gravityview_view = GravityView_View::getInstance();  | 
                                                        |
| 205 | 205 | |
| 206 | 206 | |
| 207 | - $entries = $gravityview_view->getEntries();  | 
                                                        |
| 208 | - self::$original_entry = $entries[0];  | 
                                                        |
| 209 | - $this->entry = $entries[0];  | 
                                                        |
| 207 | + $entries = $gravityview_view->getEntries();  | 
                                                        |
| 208 | + self::$original_entry = $entries[0];  | 
                                                        |
| 209 | + $this->entry = $entries[0];  | 
                                                        |
| 210 | 210 | |
| 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();  | 
                                                        |
| 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();  | 
                                                        |
| 215 | 215 | |
| 216 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );  | 
                                                        |
| 217 | - }  | 
                                                        |
| 216 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );  | 
                                                        |
| 217 | + }  | 
                                                        |
| 218 | 218 | |
| 219 | 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 | -    public function init( $gv_data ) { | 
                                                        |
| 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 | +	public function init( $gv_data ) { | 
                                                        |
| 229 | 229 | |
| 230 | - require_once( GFCommon::get_base_path() . '/form_display.php' );  | 
                                                        |
| 231 | - require_once( GFCommon::get_base_path() . '/entry_detail.php' );  | 
                                                        |
| 230 | + require_once( GFCommon::get_base_path() . '/form_display.php' );  | 
                                                        |
| 231 | + require_once( GFCommon::get_base_path() . '/entry_detail.php' );  | 
                                                        |
| 232 | 232 | |
| 233 | - $this->setup_vars();  | 
                                                        |
| 233 | + $this->setup_vars();  | 
                                                        |
| 234 | 234 | |
| 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 | -            do_action('gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); | 
                                                        |
| 238 | - return;  | 
                                                        |
| 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 | +			do_action('gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); | 
                                                        |
| 238 | + return;  | 
                                                        |
| 239 | + }  | 
                                                        |
| 240 | 240 | |
| 241 | - // Sorry, you're not allowed here.  | 
                                                        |
| 242 | -        if( false === $this->user_can_edit_entry( true ) ) { | 
                                                        |
| 243 | -            do_action('gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); | 
                                                        |
| 244 | - return;  | 
                                                        |
| 245 | - }  | 
                                                        |
| 241 | + // Sorry, you're not allowed here.  | 
                                                        |
| 242 | +		if( false === $this->user_can_edit_entry( true ) ) { | 
                                                        |
| 243 | +			do_action('gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); | 
                                                        |
| 244 | + return;  | 
                                                        |
| 245 | + }  | 
                                                        |
| 246 | 246 | |
| 247 | - $this->print_scripts();  | 
                                                        |
| 247 | + $this->print_scripts();  | 
                                                        |
| 248 | 248 | |
| 249 | - $this->process_save();  | 
                                                        |
| 249 | + $this->process_save();  | 
                                                        |
| 250 | 250 | |
| 251 | - $this->edit_entry_form();  | 
                                                        |
| 251 | + $this->edit_entry_form();  | 
                                                        |
| 252 | 252 | |
| 253 | - }  | 
                                                        |
| 253 | + }  | 
                                                        |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - /**  | 
                                                        |
| 257 | - * Force Gravity Forms to output scripts as if it were in the admin  | 
                                                        |
| 258 | - * @return void  | 
                                                        |
| 259 | - */  | 
                                                        |
| 260 | -    private function print_scripts() { | 
                                                        |
| 261 | - $gravityview_view = GravityView_View::getInstance();  | 
                                                        |
| 256 | + /**  | 
                                                        |
| 257 | + * Force Gravity Forms to output scripts as if it were in the admin  | 
                                                        |
| 258 | + * @return void  | 
                                                        |
| 259 | + */  | 
                                                        |
| 260 | +	private function print_scripts() { | 
                                                        |
| 261 | + $gravityview_view = GravityView_View::getInstance();  | 
                                                        |
| 262 | 262 | |
| 263 | - 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 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );  | 
                                                        |
| 264 | 264 | |
| 265 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);  | 
                                                        |
| 265 | + GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);  | 
                                                        |
| 266 | 266 | |
| 267 | - // Sack is required for images  | 
                                                        |
| 268 | - wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );  | 
                                                        |
| 269 | - }  | 
                                                        |
| 267 | + // Sack is required for images  | 
                                                        |
| 268 | + wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );  | 
                                                        |
| 269 | + }  | 
                                                        |
| 270 | 270 | |
| 271 | 271 | |
| 272 | - /**  | 
                                                        |
| 273 | - * Process edit entry form save  | 
                                                        |
| 274 | - */  | 
                                                        |
| 275 | -    private function process_save() { | 
                                                        |
| 272 | + /**  | 
                                                        |
| 273 | + * Process edit entry form save  | 
                                                        |
| 274 | + */  | 
                                                        |
| 275 | +	private function process_save() { | 
                                                        |
| 276 | 276 | |
| 277 | -        if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { | 
                                                        |
| 278 | - return;  | 
                                                        |
| 279 | - }  | 
                                                        |
| 277 | +		if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { | 
                                                        |
| 278 | + return;  | 
                                                        |
| 279 | + }  | 
                                                        |
| 280 | 280 | |
| 281 | - // Make sure the entry, view, and form IDs are all correct  | 
                                                        |
| 282 | - $valid = $this->verify_nonce();  | 
                                                        |
| 281 | + // Make sure the entry, view, and form IDs are all correct  | 
                                                        |
| 282 | + $valid = $this->verify_nonce();  | 
                                                        |
| 283 | 283 | |
| 284 | -        if( !$valid ) { | 
                                                        |
| 285 | -            do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); | 
                                                        |
| 286 | - return;  | 
                                                        |
| 287 | - }  | 
                                                        |
| 284 | +		if( !$valid ) { | 
                                                        |
| 285 | +			do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); | 
                                                        |
| 286 | + return;  | 
                                                        |
| 287 | + }  | 
                                                        |
| 288 | 288 | |
| 289 | -        if( $this->entry['id'] !== $_POST['lid'] ) { | 
                                                        |
| 290 | -            do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); | 
                                                        |
| 291 | - return;  | 
                                                        |
| 292 | - }  | 
                                                        |
| 289 | +		if( $this->entry['id'] !== $_POST['lid'] ) { | 
                                                        |
| 290 | +			do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); | 
                                                        |
| 291 | + return;  | 
                                                        |
| 292 | + }  | 
                                                        |
| 293 | 293 | |
| 294 | -        do_action('gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); | 
                                                        |
| 294 | +		do_action('gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); | 
                                                        |
| 295 | 295 | |
| 296 | - $this->process_save_process_files( $this->form_id );  | 
                                                        |
| 296 | + $this->process_save_process_files( $this->form_id );  | 
                                                        |
| 297 | 297 | |
| 298 | - $this->validate();  | 
                                                        |
| 298 | + $this->validate();  | 
                                                        |
| 299 | 299 | |
| 300 | -        if( $this->is_valid ) { | 
                                                        |
| 300 | +		if( $this->is_valid ) { | 
                                                        |
| 301 | 301 | |
| 302 | -            do_action('gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); | 
                                                        |
| 302 | +			do_action('gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); | 
                                                        |
| 303 | 303 | |
| 304 | - /**  | 
                                                        |
| 305 | - * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields  | 
                                                        |
| 306 | - */  | 
                                                        |
| 307 | - $form = $this->form_prepare_for_save();  | 
                                                        |
| 304 | + /**  | 
                                                        |
| 305 | + * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields  | 
                                                        |
| 306 | + */  | 
                                                        |
| 307 | + $form = $this->form_prepare_for_save();  | 
                                                        |
| 308 | 308 | |
| 309 | - /**  | 
                                                        |
| 310 | - * @hack to avoid the capability validation of the method save_lead for GF 1.9+  | 
                                                        |
| 311 | - */  | 
                                                        |
| 312 | - unset( $_GET['page'] );  | 
                                                        |
| 309 | + /**  | 
                                                        |
| 310 | + * @hack to avoid the capability validation of the method save_lead for GF 1.9+  | 
                                                        |
| 311 | + */  | 
                                                        |
| 312 | + unset( $_GET['page'] );  | 
                                                        |
| 313 | 313 | |
| 314 | - $date_created = $this->entry['date_created'];  | 
                                                        |
| 314 | + $date_created = $this->entry['date_created'];  | 
                                                        |
| 315 | 315 | |
| 316 | - /**  | 
                                                        |
| 317 | - * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()  | 
                                                        |
| 318 | - * @since 1.17.2  | 
                                                        |
| 319 | - */  | 
                                                        |
| 320 | - unset( $this->entry['date_created'] );  | 
                                                        |
| 316 | + /**  | 
                                                        |
| 317 | + * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()  | 
                                                        |
| 318 | + * @since 1.17.2  | 
                                                        |
| 319 | + */  | 
                                                        |
| 320 | + unset( $this->entry['date_created'] );  | 
                                                        |
| 321 | 321 | |
| 322 | - GFFormsModel::save_lead( $form, $this->entry );  | 
                                                        |
| 322 | + GFFormsModel::save_lead( $form, $this->entry );  | 
                                                        |
| 323 | 323 | |
| 324 | - // Delete the values for hidden inputs  | 
                                                        |
| 325 | - $this->unset_hidden_field_values();  | 
                                                        |
| 324 | + // Delete the values for hidden inputs  | 
                                                        |
| 325 | + $this->unset_hidden_field_values();  | 
                                                        |
| 326 | 326 | |
| 327 | - $this->entry['date_created'] = $date_created;  | 
                                                        |
| 327 | + $this->entry['date_created'] = $date_created;  | 
                                                        |
| 328 | 328 | |
| 329 | - // Process calculation fields  | 
                                                        |
| 330 | - $this->update_calculation_fields();  | 
                                                        |
| 329 | + // Process calculation fields  | 
                                                        |
| 330 | + $this->update_calculation_fields();  | 
                                                        |
| 331 | 331 | |
| 332 | - // Perform actions normally performed after updating a lead  | 
                                                        |
| 333 | - $this->after_update();  | 
                                                        |
| 332 | + // Perform actions normally performed after updating a lead  | 
                                                        |
| 333 | + $this->after_update();  | 
                                                        |
| 334 | 334 | |
| 335 | - /**  | 
                                                        |
| 336 | - * Must be AFTER after_update()!  | 
                                                        |
| 337 | - * @see https://github.com/gravityview/GravityView/issues/764  | 
                                                        |
| 338 | - */  | 
                                                        |
| 339 | - $this->maybe_update_post_fields( $form );  | 
                                                        |
| 335 | + /**  | 
                                                        |
| 336 | + * Must be AFTER after_update()!  | 
                                                        |
| 337 | + * @see https://github.com/gravityview/GravityView/issues/764  | 
                                                        |
| 338 | + */  | 
                                                        |
| 339 | + $this->maybe_update_post_fields( $form );  | 
                                                        |
| 340 | 340 | |
| 341 | - /**  | 
                                                        |
| 342 | - * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry  | 
                                                        |
| 343 | - * @param array $form Gravity Forms form array  | 
                                                        |
| 344 | - * @param string $entry_id Numeric ID of the entry that was updated  | 
                                                        |
| 345 | - */  | 
                                                        |
| 346 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );  | 
                                                        |
| 341 | + /**  | 
                                                        |
| 342 | + * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry  | 
                                                        |
| 343 | + * @param array $form Gravity Forms form array  | 
                                                        |
| 344 | + * @param string $entry_id Numeric ID of the entry that was updated  | 
                                                        |
| 345 | + */  | 
                                                        |
| 346 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );  | 
                                                        |
| 347 | 347 | |
| 348 | -        } else { | 
                                                        |
| 349 | -            do_action('gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); | 
                                                        |
| 350 | - }  | 
                                                        |
| 348 | +		} else { | 
                                                        |
| 349 | +			do_action('gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); | 
                                                        |
| 350 | + }  | 
                                                        |
| 351 | 351 | |
| 352 | - } // process_save  | 
                                                        |
| 352 | + } // process_save  | 
                                                        |
| 353 | 353 | |
| 354 | 354 | /**  | 
                                                        
| 355 | 355 | * Delete the value of fields hidden by conditional logic when the entry is edited  | 
                                                        
| 356 | - *  | 
                                                        |
| 357 | - * @uses GFFormsModel::update_lead_field_value()  | 
                                                        |
| 358 | - *  | 
                                                        |
| 359 | - * @since 1.17.4  | 
                                                        |
| 360 | - *  | 
                                                        |
| 361 | - * @return void  | 
                                                        |
| 356 | + *  | 
                                                        |
| 357 | + * @uses GFFormsModel::update_lead_field_value()  | 
                                                        |
| 358 | + *  | 
                                                        |
| 359 | + * @since 1.17.4  | 
                                                        |
| 360 | + *  | 
                                                        |
| 361 | + * @return void  | 
                                                        |
| 362 | + */  | 
                                                        |
| 363 | +	private function unset_hidden_field_values() { | 
                                                        |
| 364 | + global $wpdb;  | 
                                                        |
| 365 | +  | 
                                                        |
| 366 | + $lead_detail_table = GFFormsModel::get_lead_details_table_name();  | 
                                                        |
| 367 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );  | 
                                                        |
| 368 | +  | 
                                                        |
| 369 | +		foreach ( $this->entry as $input_id => $field_value ) { | 
                                                        |
| 370 | +  | 
                                                        |
| 371 | + $field = RGFormsModel::get_field( $this->form, $input_id );  | 
                                                        |
| 372 | +  | 
                                                        |
| 373 | + // Reset fields that are hidden  | 
                                                        |
| 374 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic  | 
                                                        |
| 375 | +			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { | 
                                                        |
| 376 | +  | 
                                                        |
| 377 | + // List fields are stored as empty arrays when empty  | 
                                                        |
| 378 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : '';  | 
                                                        |
| 379 | +  | 
                                                        |
| 380 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );  | 
                                                        |
| 381 | +  | 
                                                        |
| 382 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );  | 
                                                        |
| 383 | +  | 
                                                        |
| 384 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form  | 
                                                        |
| 385 | + // after submission  | 
                                                        |
| 386 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id );  | 
                                                        |
| 387 | + $_POST[ $post_input_id ] = '';  | 
                                                        |
| 388 | + }  | 
                                                        |
| 389 | + }  | 
                                                        |
| 390 | + }  | 
                                                        |
| 391 | +  | 
                                                        |
| 392 | + /**  | 
                                                        |
| 393 | + * Have GF handle file uploads  | 
                                                        |
| 394 | + *  | 
                                                        |
| 395 | + * Copy of code from GFFormDisplay::process_form()  | 
                                                        |
| 396 | + *  | 
                                                        |
| 397 | + * @param int $form_id  | 
                                                        |
| 398 | + */  | 
                                                        |
| 399 | +	private function process_save_process_files( $form_id ) { | 
                                                        |
| 400 | +  | 
                                                        |
| 401 | + //Loading files that have been uploaded to temp folder  | 
                                                        |
| 402 | + $files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) );  | 
                                                        |
| 403 | +		if ( ! is_array( $files ) ) { | 
                                                        |
| 404 | + $files = array();  | 
                                                        |
| 405 | + }  | 
                                                        |
| 406 | +  | 
                                                        |
| 407 | + RGFormsModel::$uploaded_files[ $form_id ] = $files;  | 
                                                        |
| 408 | + }  | 
                                                        |
| 409 | +  | 
                                                        |
| 410 | + /**  | 
                                                        |
| 411 | + * Remove max_files validation (done on gravityforms.js) to avoid conflicts with GravityView  | 
                                                        |
| 412 | + * Late validation done on self::custom_validation  | 
                                                        |
| 413 | + *  | 
                                                        |
| 414 | + * @param $plupload_init array Plupload settings  | 
                                                        |
| 415 | + * @param $form_id  | 
                                                        |
| 416 | + * @param $instance  | 
                                                        |
| 417 | + * @return mixed  | 
                                                        |
| 418 | + */  | 
                                                        |
| 419 | +	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { | 
                                                        |
| 420 | +		if( ! $this->is_edit_entry() ) { | 
                                                        |
| 421 | + return $plupload_init;  | 
                                                        |
| 422 | + }  | 
                                                        |
| 423 | +  | 
                                                        |
| 424 | + $plupload_init['gf_vars']['max_files'] = 0;  | 
                                                        |
| 425 | +  | 
                                                        |
| 426 | + return $plupload_init;  | 
                                                        |
| 427 | + }  | 
                                                        |
| 428 | +  | 
                                                        |
| 429 | +  | 
                                                        |
| 430 | + /**  | 
                                                        |
| 431 | + * Unset adminOnly and convert field input key to string  | 
                                                        |
| 432 | + * @return array $form  | 
                                                        |
| 433 | + */  | 
                                                        |
| 434 | +	private function form_prepare_for_save() { | 
                                                        |
| 435 | +  | 
                                                        |
| 436 | + $form = $this->form;  | 
                                                        |
| 437 | +  | 
                                                        |
| 438 | + /** @var GF_Field $field */  | 
                                                        |
| 439 | +		foreach( $form['fields'] as $k => &$field ) { | 
                                                        |
| 440 | +  | 
                                                        |
| 441 | + /**  | 
                                                        |
| 442 | + * Remove the fields with calculation formulas before save to avoid conflicts with GF logic  | 
                                                        |
| 443 | + * @since 1.16.3  | 
                                                        |
| 444 | + * @var GF_Field $field  | 
                                                        |
| 445 | + */  | 
                                                        |
| 446 | +			if( $field->has_calculation() ) { | 
                                                        |
| 447 | + unset( $form['fields'][ $k ] );  | 
                                                        |
| 448 | + }  | 
                                                        |
| 449 | +  | 
                                                        |
| 450 | + $field->adminOnly = false;  | 
                                                        |
| 451 | +  | 
                                                        |
| 452 | +			if( isset( $field->inputs ) && is_array( $field->inputs ) ) { | 
                                                        |
| 453 | +				foreach( $field->inputs as $key => $input ) { | 
                                                        |
| 454 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id'];  | 
                                                        |
| 455 | + }  | 
                                                        |
| 456 | + }  | 
                                                        |
| 457 | + }  | 
                                                        |
| 458 | +  | 
                                                        |
| 459 | + return $form;  | 
                                                        |
| 460 | + }  | 
                                                        |
| 461 | +  | 
                                                        |
| 462 | +	private function update_calculation_fields() { | 
                                                        |
| 463 | +  | 
                                                        |
| 464 | + $form = self::$original_form;  | 
                                                        |
| 465 | + $update = false;  | 
                                                        |
| 466 | +  | 
                                                        |
| 467 | + // get the most up to date entry values  | 
                                                        |
| 468 | + $entry = GFAPI::get_entry( $this->entry['id'] );  | 
                                                        |
| 469 | +  | 
                                                        |
| 470 | +		if( !empty( $this->fields_with_calculation ) ) { | 
                                                        |
| 471 | + $update = true;  | 
                                                        |
| 472 | +			foreach ( $this->fields_with_calculation as $calc_field ) { | 
                                                        |
| 473 | + $inputs = $calc_field->get_entry_inputs();  | 
                                                        |
| 474 | +				if ( is_array( $inputs ) ) { | 
                                                        |
| 475 | +					foreach ( $inputs as $input ) { | 
                                                        |
| 476 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] );  | 
                                                        |
| 477 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 478 | + }  | 
                                                        |
| 479 | +				} else { | 
                                                        |
| 480 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);  | 
                                                        |
| 481 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 482 | + }  | 
                                                        |
| 483 | + }  | 
                                                        |
| 484 | +  | 
                                                        |
| 485 | + }  | 
                                                        |
| 486 | +  | 
                                                        |
| 487 | + //saving total field as the last field of the form.  | 
                                                        |
| 488 | +		if ( ! empty( $this->total_fields ) ) { | 
                                                        |
| 489 | + $update = true;  | 
                                                        |
| 490 | +			foreach ( $this->total_fields as $total_field ) { | 
                                                        |
| 491 | + $input_name = 'input_' . str_replace( '.', '_', $total_field->id);  | 
                                                        |
| 492 | + $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 493 | + }  | 
                                                        |
| 494 | + }  | 
                                                        |
| 495 | +  | 
                                                        |
| 496 | +		if( $update ) { | 
                                                        |
| 497 | +  | 
                                                        |
| 498 | + $return_entry = GFAPI::update_entry( $entry );  | 
                                                        |
| 499 | +  | 
                                                        |
| 500 | +			if( is_wp_error( $return_entry ) ) { | 
                                                        |
| 501 | + do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry );  | 
                                                        |
| 502 | +			} else { | 
                                                        |
| 503 | + do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' );  | 
                                                        |
| 504 | + }  | 
                                                        |
| 505 | + }  | 
                                                        |
| 506 | + }  | 
                                                        |
| 507 | +  | 
                                                        |
| 508 | + /**  | 
                                                        |
| 509 | + * Handle updating the Post Image field  | 
                                                        |
| 510 | + *  | 
                                                        |
| 511 | + * Sets a new Featured Image if configured in Gravity Forms; otherwise uploads/updates media  | 
                                                        |
| 512 | + *  | 
                                                        |
| 513 | + * @since 1.17  | 
                                                        |
| 514 | + *  | 
                                                        |
| 515 | + * @uses GFFormsModel::media_handle_upload  | 
                                                        |
| 516 | + * @uses set_post_thumbnail  | 
                                                        |
| 517 | + *  | 
                                                        |
| 518 | + * @param array $form GF Form array  | 
                                                        |
| 519 | + * @param GF_Field $field GF Field  | 
                                                        |
| 520 | + * @param string $field_id Numeric ID of the field  | 
                                                        |
| 521 | + * @param string $value  | 
                                                        |
| 522 | + * @param array $entry GF Entry currently being edited  | 
                                                        |
| 523 | + * @param int $post_id ID of the Post being edited  | 
                                                        |
| 524 | + *  | 
                                                        |
| 525 | + * @return mixed|string  | 
                                                        |
| 526 | + */  | 
                                                        |
| 527 | +	private function update_post_image( $form, $field, $field_id, $value, $entry, $post_id ) { | 
                                                        |
| 528 | +  | 
                                                        |
| 529 | + $input_name = 'input_' . $field_id;  | 
                                                        |
| 530 | +  | 
                                                        |
| 531 | +		if ( !empty( $_FILES[ $input_name ]['name'] ) ) { | 
                                                        |
| 532 | +  | 
                                                        |
| 533 | + // We have a new image  | 
                                                        |
| 534 | +  | 
                                                        |
| 535 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );  | 
                                                        |
| 536 | +  | 
                                                        |
| 537 | + $ary = ! empty( $value ) ? explode( '|:|', $value ) : array();  | 
                                                        |
| 538 | + $img_url = rgar( $ary, 0 );  | 
                                                        |
| 539 | +  | 
                                                        |
| 540 | + $img_title = count( $ary ) > 1 ? $ary[1] : '';  | 
                                                        |
| 541 | + $img_caption = count( $ary ) > 2 ? $ary[2] : '';  | 
                                                        |
| 542 | + $img_description = count( $ary ) > 3 ? $ary[3] : '';  | 
                                                        |
| 543 | +  | 
                                                        |
| 544 | + $image_meta = array(  | 
                                                        |
| 545 | + 'post_excerpt' => $img_caption,  | 
                                                        |
| 546 | + 'post_content' => $img_description,  | 
                                                        |
| 547 | + );  | 
                                                        |
| 548 | +  | 
                                                        |
| 549 | + //adding title only if it is not empty. It will default to the file name if it is not in the array  | 
                                                        |
| 550 | +			if ( ! empty( $img_title ) ) { | 
                                                        |
| 551 | + $image_meta['post_title'] = $img_title;  | 
                                                        |
| 552 | + }  | 
                                                        |
| 553 | +  | 
                                                        |
| 554 | + /**  | 
                                                        |
| 555 | + * 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.  | 
                                                        |
| 556 | + * Note: the method became public in GF 1.9.17.7, but we don't require that version yet.  | 
                                                        |
| 557 | + */  | 
                                                        |
| 558 | + require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';  | 
                                                        |
| 559 | + $media_id = GravityView_GFFormsModel::media_handle_upload( $img_url, $post_id, $image_meta );  | 
                                                        |
| 560 | +  | 
                                                        |
| 561 | + // is this field set as featured image?  | 
                                                        |
| 562 | +			if ( $media_id && $field->postFeaturedImage ) { | 
                                                        |
| 563 | + set_post_thumbnail( $post_id, $media_id );  | 
                                                        |
| 564 | + }  | 
                                                        |
| 565 | +  | 
                                                        |
| 566 | +		} elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { | 
                                                        |
| 567 | +  | 
                                                        |
| 568 | + // Same image although the image title, caption or description might have changed  | 
                                                        |
| 569 | +  | 
                                                        |
| 570 | + $ary = array();  | 
                                                        |
| 571 | +			if( ! empty( $entry[ $field_id ] ) ) { | 
                                                        |
| 572 | + $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] );  | 
                                                        |
| 573 | + }  | 
                                                        |
| 574 | + $img_url = rgar( $ary, 0 );  | 
                                                        |
| 575 | +  | 
                                                        |
| 576 | + // is this really the same image or something went wrong ?  | 
                                                        |
| 577 | +			if( $img_url === $_POST[ $input_name ] ) { | 
                                                        |
| 578 | +  | 
                                                        |
| 579 | + $img_title = rgar( $value, $field_id .'.1' );  | 
                                                        |
| 580 | + $img_caption = rgar( $value, $field_id .'.4' );  | 
                                                        |
| 581 | + $img_description = rgar( $value, $field_id .'.7' );  | 
                                                        |
| 582 | +  | 
                                                        |
| 583 | + $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : '';  | 
                                                        |
| 584 | +  | 
                                                        |
| 585 | +				if ( $field->postFeaturedImage ) { | 
                                                        |
| 586 | +  | 
                                                        |
| 587 | + $image_meta = array(  | 
                                                        |
| 588 | + 'ID' => get_post_thumbnail_id( $post_id ),  | 
                                                        |
| 589 | + 'post_title' => $img_title,  | 
                                                        |
| 590 | + 'post_excerpt' => $img_caption,  | 
                                                        |
| 591 | + 'post_content' => $img_description,  | 
                                                        |
| 592 | + );  | 
                                                        |
| 593 | +  | 
                                                        |
| 594 | + // update image title, caption or description  | 
                                                        |
| 595 | + wp_update_post( $image_meta );  | 
                                                        |
| 596 | + }  | 
                                                        |
| 597 | + }  | 
                                                        |
| 598 | +  | 
                                                        |
| 599 | +		} else { | 
                                                        |
| 600 | +  | 
                                                        |
| 601 | + // if we get here, image was removed or not set.  | 
                                                        |
| 602 | + $value = '';  | 
                                                        |
| 603 | +  | 
                                                        |
| 604 | +			if ( $field->postFeaturedImage ) { | 
                                                        |
| 605 | + delete_post_thumbnail( $post_id );  | 
                                                        |
| 606 | + }  | 
                                                        |
| 607 | + }  | 
                                                        |
| 608 | +  | 
                                                        |
| 609 | + return $value;  | 
                                                        |
| 610 | + }  | 
                                                        |
| 611 | +  | 
                                                        |
| 612 | + /**  | 
                                                        |
| 613 | + * Loop through the fields being edited and if they include Post fields, update the Entry's post object  | 
                                                        |
| 614 | + *  | 
                                                        |
| 615 | + * @param array $form Gravity Forms form  | 
                                                        |
| 616 | + *  | 
                                                        |
| 617 | + * @return void  | 
                                                        |
| 362 | 618 | */  | 
                                                        
| 363 | -    private function unset_hidden_field_values() { | 
                                                        |
| 364 | - global $wpdb;  | 
                                                        |
| 365 | -  | 
                                                        |
| 366 | - $lead_detail_table = GFFormsModel::get_lead_details_table_name();  | 
                                                        |
| 367 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );  | 
                                                        |
| 368 | -  | 
                                                        |
| 369 | -	    foreach ( $this->entry as $input_id => $field_value ) { | 
                                                        |
| 370 | -  | 
                                                        |
| 371 | - $field = RGFormsModel::get_field( $this->form, $input_id );  | 
                                                        |
| 372 | -  | 
                                                        |
| 373 | - // Reset fields that are hidden  | 
                                                        |
| 374 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic  | 
                                                        |
| 375 | -		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { | 
                                                        |
| 376 | -  | 
                                                        |
| 377 | - // List fields are stored as empty arrays when empty  | 
                                                        |
| 378 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : '';  | 
                                                        |
| 379 | -  | 
                                                        |
| 380 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );  | 
                                                        |
| 381 | -  | 
                                                        |
| 382 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );  | 
                                                        |
| 383 | -  | 
                                                        |
| 384 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form  | 
                                                        |
| 385 | - // after submission  | 
                                                        |
| 386 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id );  | 
                                                        |
| 387 | - $_POST[ $post_input_id ] = '';  | 
                                                        |
| 388 | - }  | 
                                                        |
| 389 | - }  | 
                                                        |
| 390 | - }  | 
                                                        |
| 391 | -  | 
                                                        |
| 392 | - /**  | 
                                                        |
| 393 | - * Have GF handle file uploads  | 
                                                        |
| 394 | - *  | 
                                                        |
| 395 | - * Copy of code from GFFormDisplay::process_form()  | 
                                                        |
| 396 | - *  | 
                                                        |
| 397 | - * @param int $form_id  | 
                                                        |
| 398 | - */  | 
                                                        |
| 399 | -    private function process_save_process_files( $form_id ) { | 
                                                        |
| 400 | -  | 
                                                        |
| 401 | - //Loading files that have been uploaded to temp folder  | 
                                                        |
| 402 | - $files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) );  | 
                                                        |
| 403 | -        if ( ! is_array( $files ) ) { | 
                                                        |
| 404 | - $files = array();  | 
                                                        |
| 405 | - }  | 
                                                        |
| 406 | -  | 
                                                        |
| 407 | - RGFormsModel::$uploaded_files[ $form_id ] = $files;  | 
                                                        |
| 408 | - }  | 
                                                        |
| 409 | -  | 
                                                        |
| 410 | - /**  | 
                                                        |
| 411 | - * Remove max_files validation (done on gravityforms.js) to avoid conflicts with GravityView  | 
                                                        |
| 412 | - * Late validation done on self::custom_validation  | 
                                                        |
| 413 | - *  | 
                                                        |
| 414 | - * @param $plupload_init array Plupload settings  | 
                                                        |
| 415 | - * @param $form_id  | 
                                                        |
| 416 | - * @param $instance  | 
                                                        |
| 417 | - * @return mixed  | 
                                                        |
| 418 | - */  | 
                                                        |
| 419 | -    public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { | 
                                                        |
| 420 | -        if( ! $this->is_edit_entry() ) { | 
                                                        |
| 421 | - return $plupload_init;  | 
                                                        |
| 422 | - }  | 
                                                        |
| 423 | -  | 
                                                        |
| 424 | - $plupload_init['gf_vars']['max_files'] = 0;  | 
                                                        |
| 425 | -  | 
                                                        |
| 426 | - return $plupload_init;  | 
                                                        |
| 427 | - }  | 
                                                        |
| 428 | -  | 
                                                        |
| 429 | -  | 
                                                        |
| 430 | - /**  | 
                                                        |
| 431 | - * Unset adminOnly and convert field input key to string  | 
                                                        |
| 432 | - * @return array $form  | 
                                                        |
| 433 | - */  | 
                                                        |
| 434 | -    private function form_prepare_for_save() { | 
                                                        |
| 435 | -  | 
                                                        |
| 436 | - $form = $this->form;  | 
                                                        |
| 437 | -  | 
                                                        |
| 438 | - /** @var GF_Field $field */  | 
                                                        |
| 439 | -        foreach( $form['fields'] as $k => &$field ) { | 
                                                        |
| 440 | -  | 
                                                        |
| 441 | - /**  | 
                                                        |
| 442 | - * Remove the fields with calculation formulas before save to avoid conflicts with GF logic  | 
                                                        |
| 443 | - * @since 1.16.3  | 
                                                        |
| 444 | - * @var GF_Field $field  | 
                                                        |
| 445 | - */  | 
                                                        |
| 446 | -            if( $field->has_calculation() ) { | 
                                                        |
| 447 | - unset( $form['fields'][ $k ] );  | 
                                                        |
| 448 | - }  | 
                                                        |
| 449 | -  | 
                                                        |
| 450 | - $field->adminOnly = false;  | 
                                                        |
| 451 | -  | 
                                                        |
| 452 | -            if( isset( $field->inputs ) && is_array( $field->inputs ) ) { | 
                                                        |
| 453 | -                foreach( $field->inputs as $key => $input ) { | 
                                                        |
| 454 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id'];  | 
                                                        |
| 455 | - }  | 
                                                        |
| 456 | - }  | 
                                                        |
| 457 | - }  | 
                                                        |
| 458 | -  | 
                                                        |
| 459 | - return $form;  | 
                                                        |
| 460 | - }  | 
                                                        |
| 461 | -  | 
                                                        |
| 462 | -    private function update_calculation_fields() { | 
                                                        |
| 463 | -  | 
                                                        |
| 464 | - $form = self::$original_form;  | 
                                                        |
| 465 | - $update = false;  | 
                                                        |
| 466 | -  | 
                                                        |
| 467 | - // get the most up to date entry values  | 
                                                        |
| 468 | - $entry = GFAPI::get_entry( $this->entry['id'] );  | 
                                                        |
| 469 | -  | 
                                                        |
| 470 | -        if( !empty( $this->fields_with_calculation ) ) { | 
                                                        |
| 471 | - $update = true;  | 
                                                        |
| 472 | -            foreach ( $this->fields_with_calculation as $calc_field ) { | 
                                                        |
| 473 | - $inputs = $calc_field->get_entry_inputs();  | 
                                                        |
| 474 | -                if ( is_array( $inputs ) ) { | 
                                                        |
| 475 | -                    foreach ( $inputs as $input ) { | 
                                                        |
| 476 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] );  | 
                                                        |
| 477 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 478 | - }  | 
                                                        |
| 479 | -                } else { | 
                                                        |
| 480 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);  | 
                                                        |
| 481 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 482 | - }  | 
                                                        |
| 483 | - }  | 
                                                        |
| 484 | -  | 
                                                        |
| 485 | - }  | 
                                                        |
| 486 | -  | 
                                                        |
| 487 | - //saving total field as the last field of the form.  | 
                                                        |
| 488 | -        if ( ! empty( $this->total_fields ) ) { | 
                                                        |
| 489 | - $update = true;  | 
                                                        |
| 490 | -            foreach ( $this->total_fields as $total_field ) { | 
                                                        |
| 491 | - $input_name = 'input_' . str_replace( '.', '_', $total_field->id);  | 
                                                        |
| 492 | - $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 493 | - }  | 
                                                        |
| 494 | - }  | 
                                                        |
| 495 | -  | 
                                                        |
| 496 | -        if( $update ) { | 
                                                        |
| 497 | -  | 
                                                        |
| 498 | - $return_entry = GFAPI::update_entry( $entry );  | 
                                                        |
| 499 | -  | 
                                                        |
| 500 | -            if( is_wp_error( $return_entry ) ) { | 
                                                        |
| 501 | - do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry );  | 
                                                        |
| 502 | -            } else { | 
                                                        |
| 503 | - do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' );  | 
                                                        |
| 504 | - }  | 
                                                        |
| 505 | - }  | 
                                                        |
| 506 | - }  | 
                                                        |
| 507 | -  | 
                                                        |
| 508 | - /**  | 
                                                        |
| 509 | - * Handle updating the Post Image field  | 
                                                        |
| 510 | - *  | 
                                                        |
| 511 | - * Sets a new Featured Image if configured in Gravity Forms; otherwise uploads/updates media  | 
                                                        |
| 512 | - *  | 
                                                        |
| 513 | - * @since 1.17  | 
                                                        |
| 514 | - *  | 
                                                        |
| 515 | - * @uses GFFormsModel::media_handle_upload  | 
                                                        |
| 516 | - * @uses set_post_thumbnail  | 
                                                        |
| 517 | - *  | 
                                                        |
| 518 | - * @param array $form GF Form array  | 
                                                        |
| 519 | - * @param GF_Field $field GF Field  | 
                                                        |
| 520 | - * @param string $field_id Numeric ID of the field  | 
                                                        |
| 521 | - * @param string $value  | 
                                                        |
| 522 | - * @param array $entry GF Entry currently being edited  | 
                                                        |
| 523 | - * @param int $post_id ID of the Post being edited  | 
                                                        |
| 524 | - *  | 
                                                        |
| 525 | - * @return mixed|string  | 
                                                        |
| 526 | - */  | 
                                                        |
| 527 | -    private function update_post_image( $form, $field, $field_id, $value, $entry, $post_id ) { | 
                                                        |
| 528 | -  | 
                                                        |
| 529 | - $input_name = 'input_' . $field_id;  | 
                                                        |
| 530 | -  | 
                                                        |
| 531 | -        if ( !empty( $_FILES[ $input_name ]['name'] ) ) { | 
                                                        |
| 532 | -  | 
                                                        |
| 533 | - // We have a new image  | 
                                                        |
| 534 | -  | 
                                                        |
| 535 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );  | 
                                                        |
| 536 | -  | 
                                                        |
| 537 | - $ary = ! empty( $value ) ? explode( '|:|', $value ) : array();  | 
                                                        |
| 538 | - $img_url = rgar( $ary, 0 );  | 
                                                        |
| 539 | -  | 
                                                        |
| 540 | - $img_title = count( $ary ) > 1 ? $ary[1] : '';  | 
                                                        |
| 541 | - $img_caption = count( $ary ) > 2 ? $ary[2] : '';  | 
                                                        |
| 542 | - $img_description = count( $ary ) > 3 ? $ary[3] : '';  | 
                                                        |
| 543 | -  | 
                                                        |
| 544 | - $image_meta = array(  | 
                                                        |
| 545 | - 'post_excerpt' => $img_caption,  | 
                                                        |
| 546 | - 'post_content' => $img_description,  | 
                                                        |
| 547 | - );  | 
                                                        |
| 548 | -  | 
                                                        |
| 549 | - //adding title only if it is not empty. It will default to the file name if it is not in the array  | 
                                                        |
| 550 | -            if ( ! empty( $img_title ) ) { | 
                                                        |
| 551 | - $image_meta['post_title'] = $img_title;  | 
                                                        |
| 552 | - }  | 
                                                        |
| 553 | -  | 
                                                        |
| 554 | - /**  | 
                                                        |
| 555 | - * 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.  | 
                                                        |
| 556 | - * Note: the method became public in GF 1.9.17.7, but we don't require that version yet.  | 
                                                        |
| 557 | - */  | 
                                                        |
| 558 | - require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';  | 
                                                        |
| 559 | - $media_id = GravityView_GFFormsModel::media_handle_upload( $img_url, $post_id, $image_meta );  | 
                                                        |
| 560 | -  | 
                                                        |
| 561 | - // is this field set as featured image?  | 
                                                        |
| 562 | -            if ( $media_id && $field->postFeaturedImage ) { | 
                                                        |
| 563 | - set_post_thumbnail( $post_id, $media_id );  | 
                                                        |
| 564 | - }  | 
                                                        |
| 565 | -  | 
                                                        |
| 566 | -        } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { | 
                                                        |
| 567 | -  | 
                                                        |
| 568 | - // Same image although the image title, caption or description might have changed  | 
                                                        |
| 569 | -  | 
                                                        |
| 570 | - $ary = array();  | 
                                                        |
| 571 | -            if( ! empty( $entry[ $field_id ] ) ) { | 
                                                        |
| 572 | - $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] );  | 
                                                        |
| 573 | - }  | 
                                                        |
| 574 | - $img_url = rgar( $ary, 0 );  | 
                                                        |
| 575 | -  | 
                                                        |
| 576 | - // is this really the same image or something went wrong ?  | 
                                                        |
| 577 | -            if( $img_url === $_POST[ $input_name ] ) { | 
                                                        |
| 578 | -  | 
                                                        |
| 579 | - $img_title = rgar( $value, $field_id .'.1' );  | 
                                                        |
| 580 | - $img_caption = rgar( $value, $field_id .'.4' );  | 
                                                        |
| 581 | - $img_description = rgar( $value, $field_id .'.7' );  | 
                                                        |
| 582 | -  | 
                                                        |
| 583 | - $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : '';  | 
                                                        |
| 584 | -  | 
                                                        |
| 585 | -                if ( $field->postFeaturedImage ) { | 
                                                        |
| 586 | -  | 
                                                        |
| 587 | - $image_meta = array(  | 
                                                        |
| 588 | - 'ID' => get_post_thumbnail_id( $post_id ),  | 
                                                        |
| 589 | - 'post_title' => $img_title,  | 
                                                        |
| 590 | - 'post_excerpt' => $img_caption,  | 
                                                        |
| 591 | - 'post_content' => $img_description,  | 
                                                        |
| 592 | - );  | 
                                                        |
| 593 | -  | 
                                                        |
| 594 | - // update image title, caption or description  | 
                                                        |
| 595 | - wp_update_post( $image_meta );  | 
                                                        |
| 596 | - }  | 
                                                        |
| 597 | - }  | 
                                                        |
| 598 | -  | 
                                                        |
| 599 | -        } else { | 
                                                        |
| 600 | -  | 
                                                        |
| 601 | - // if we get here, image was removed or not set.  | 
                                                        |
| 602 | - $value = '';  | 
                                                        |
| 603 | -  | 
                                                        |
| 604 | -            if ( $field->postFeaturedImage ) { | 
                                                        |
| 605 | - delete_post_thumbnail( $post_id );  | 
                                                        |
| 606 | - }  | 
                                                        |
| 607 | - }  | 
                                                        |
| 608 | -  | 
                                                        |
| 609 | - return $value;  | 
                                                        |
| 610 | - }  | 
                                                        |
| 611 | -  | 
                                                        |
| 612 | - /**  | 
                                                        |
| 613 | - * Loop through the fields being edited and if they include Post fields, update the Entry's post object  | 
                                                        |
| 614 | - *  | 
                                                        |
| 615 | - * @param array $form Gravity Forms form  | 
                                                        |
| 616 | - *  | 
                                                        |
| 617 | - * @return void  | 
                                                        |
| 618 | - */  | 
                                                        |
| 619 | -    private function maybe_update_post_fields( $form ) { | 
                                                        |
| 619 | +	private function maybe_update_post_fields( $form ) { | 
                                                        |
| 620 | +  | 
                                                        |
| 621 | +		if( empty( $this->entry['post_id'] ) ) { | 
                                                        |
| 622 | + do_action( 'gravityview_log_debug', __METHOD__ . ': This entry has no post fields. Continuing...' );  | 
                                                        |
| 623 | + return;  | 
                                                        |
| 624 | + }  | 
                                                        |
| 625 | +  | 
                                                        |
| 626 | + $post_id = $this->entry['post_id'];  | 
                                                        |
| 627 | +  | 
                                                        |
| 628 | + // Security check  | 
                                                        |
| 629 | +		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { | 
                                                        |
| 630 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );  | 
                                                        |
| 631 | + return;  | 
                                                        |
| 632 | + }  | 
                                                        |
| 633 | +  | 
                                                        |
| 634 | + $update_entry = false;  | 
                                                        |
| 635 | +  | 
                                                        |
| 636 | + $updated_post = $original_post = get_post( $post_id );  | 
                                                        |
| 637 | +  | 
                                                        |
| 638 | +		foreach ( $this->entry as $field_id => $value ) { | 
                                                        |
| 620 | 639 | |
| 621 | -        if( empty( $this->entry['post_id'] ) ) { | 
                                                        |
| 622 | - do_action( 'gravityview_log_debug', __METHOD__ . ': This entry has no post fields. Continuing...' );  | 
                                                        |
| 623 | - return;  | 
                                                        |
| 624 | - }  | 
                                                        |
| 640 | + $field = RGFormsModel::get_field( $form, $field_id );  | 
                                                        |
| 625 | 641 | |
| 626 | - $post_id = $this->entry['post_id'];  | 
                                                        |
| 642 | +			if( ! $field ) { | 
                                                        |
| 643 | + continue;  | 
                                                        |
| 644 | + }  | 
                                                        |
| 627 | 645 | |
| 628 | - // Security check  | 
                                                        |
| 629 | -        if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { | 
                                                        |
| 630 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );  | 
                                                        |
| 631 | - return;  | 
                                                        |
| 632 | - }  | 
                                                        |
| 646 | +			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { | 
                                                        |
| 633 | 647 | |
| 634 | - $update_entry = false;  | 
                                                        |
| 648 | + // Get the value of the field, including $_POSTed value  | 
                                                        |
| 649 | + $value = RGFormsModel::get_field_value( $field );  | 
                                                        |
| 635 | 650 | |
| 636 | - $updated_post = $original_post = get_post( $post_id );  | 
                                                        |
| 637 | -  | 
                                                        |
| 638 | -        foreach ( $this->entry as $field_id => $value ) { | 
                                                        |
| 651 | + // Use temporary entry variable, to make values available to fill_post_template() and update_post_image()  | 
                                                        |
| 652 | + $entry_tmp = $this->entry;  | 
                                                        |
| 653 | +				$entry_tmp["{$field_id}"] = $value; | 
                                                        |
| 639 | 654 | |
| 640 | - $field = RGFormsModel::get_field( $form, $field_id );  | 
                                                        |
| 641 | -  | 
                                                        |
| 642 | -            if( ! $field ) { | 
                                                        |
| 643 | - continue;  | 
                                                        |
| 644 | - }  | 
                                                        |
| 645 | -  | 
                                                        |
| 646 | -            if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { | 
                                                        |
| 655 | +				switch( $field->type ) { | 
                                                        |
| 647 | 656 | |
| 648 | - // Get the value of the field, including $_POSTed value  | 
                                                        |
| 649 | - $value = RGFormsModel::get_field_value( $field );  | 
                                                        |
| 657 | + case 'post_title':  | 
                                                        |
| 658 | + $post_title = $value;  | 
                                                        |
| 659 | +						if( rgar( $form, 'postTitleTemplateEnabled' ) ) { | 
                                                        |
| 660 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );  | 
                                                        |
| 661 | + }  | 
                                                        |
| 662 | + $updated_post->post_title = $post_title;  | 
                                                        |
| 663 | + $updated_post->post_name = $post_title;  | 
                                                        |
| 664 | + unset( $post_title );  | 
                                                        |
| 665 | + break;  | 
                                                        |
| 650 | 666 | |
| 651 | - // Use temporary entry variable, to make values available to fill_post_template() and update_post_image()  | 
                                                        |
| 652 | - $entry_tmp = $this->entry;  | 
                                                        |
| 653 | -                $entry_tmp["{$field_id}"] = $value; | 
                                                        |
| 667 | + case 'post_content':  | 
                                                        |
| 668 | + $post_content = $value;  | 
                                                        |
| 669 | +						if( rgar( $form, 'postContentTemplateEnabled' ) ) { | 
                                                        |
| 670 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );  | 
                                                        |
| 671 | + }  | 
                                                        |
| 672 | + $updated_post->post_content = $post_content;  | 
                                                        |
| 673 | + unset( $post_content );  | 
                                                        |
| 674 | + break;  | 
                                                        |
| 675 | + case 'post_excerpt':  | 
                                                        |
| 676 | + $updated_post->post_excerpt = $value;  | 
                                                        |
| 677 | + break;  | 
                                                        |
| 678 | + case 'post_tags':  | 
                                                        |
| 679 | + wp_set_post_tags( $post_id, $value, false );  | 
                                                        |
| 680 | + break;  | 
                                                        |
| 681 | + case 'post_category':  | 
                                                        |
| 682 | + break;  | 
                                                        |
| 683 | + case 'post_custom_field':  | 
                                                        |
| 684 | +						if( ! empty( $field->customFieldTemplateEnabled ) ) { | 
                                                        |
| 685 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );  | 
                                                        |
| 686 | + }  | 
                                                        |
| 654 | 687 | |
| 655 | -                switch( $field->type ) { | 
                                                        |
| 688 | +						if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { | 
                                                        |
| 689 | +							$value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); | 
                                                        |
| 690 | + }  | 
                                                        |
| 656 | 691 | |
| 657 | - case 'post_title':  | 
                                                        |
| 658 | - $post_title = $value;  | 
                                                        |
| 659 | -                        if( rgar( $form, 'postTitleTemplateEnabled' ) ) { | 
                                                        |
| 660 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );  | 
                                                        |
| 661 | - }  | 
                                                        |
| 662 | - $updated_post->post_title = $post_title;  | 
                                                        |
| 663 | - $updated_post->post_name = $post_title;  | 
                                                        |
| 664 | - unset( $post_title );  | 
                                                        |
| 665 | - break;  | 
                                                        |
| 692 | + update_post_meta( $post_id, $field->postCustomFieldName, $value );  | 
                                                        |
| 693 | + break;  | 
                                                        |
| 666 | 694 | |
| 667 | - case 'post_content':  | 
                                                        |
| 668 | - $post_content = $value;  | 
                                                        |
| 669 | -                        if( rgar( $form, 'postContentTemplateEnabled' ) ) { | 
                                                        |
| 670 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );  | 
                                                        |
| 671 | - }  | 
                                                        |
| 672 | - $updated_post->post_content = $post_content;  | 
                                                        |
| 673 | - unset( $post_content );  | 
                                                        |
| 674 | - break;  | 
                                                        |
| 675 | - case 'post_excerpt':  | 
                                                        |
| 676 | - $updated_post->post_excerpt = $value;  | 
                                                        |
| 677 | - break;  | 
                                                        |
| 678 | - case 'post_tags':  | 
                                                        |
| 679 | - wp_set_post_tags( $post_id, $value, false );  | 
                                                        |
| 680 | - break;  | 
                                                        |
| 681 | - case 'post_category':  | 
                                                        |
| 682 | - break;  | 
                                                        |
| 683 | - case 'post_custom_field':  | 
                                                        |
| 684 | -                        if( ! empty( $field->customFieldTemplateEnabled ) ) { | 
                                                        |
| 685 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );  | 
                                                        |
| 686 | - }  | 
                                                        |
| 687 | -  | 
                                                        |
| 688 | -	                    if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { | 
                                                        |
| 689 | -		                    $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); | 
                                                        |
| 690 | - }  | 
                                                        |
| 695 | + case 'post_image':  | 
                                                        |
| 696 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );  | 
                                                        |
| 697 | + break;  | 
                                                        |
| 691 | 698 | |
| 692 | - update_post_meta( $post_id, $field->postCustomFieldName, $value );  | 
                                                        |
| 693 | - break;  | 
                                                        |
| 699 | + }  | 
                                                        |
| 694 | 700 | |
| 695 | - case 'post_image':  | 
                                                        |
| 696 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );  | 
                                                        |
| 697 | - break;  | 
                                                        |
| 701 | + // update entry after  | 
                                                        |
| 702 | +				$this->entry["{$field_id}"] = $value; | 
                                                        |
| 698 | 703 | |
| 699 | - }  | 
                                                        |
| 704 | + $update_entry = true;  | 
                                                        |
| 700 | 705 | |
| 701 | - // update entry after  | 
                                                        |
| 702 | -                $this->entry["{$field_id}"] = $value; | 
                                                        |
| 706 | + unset( $entry_tmp );  | 
                                                        |
| 707 | + }  | 
                                                        |
| 703 | 708 | |
| 704 | - $update_entry = true;  | 
                                                        |
| 705 | -  | 
                                                        |
| 706 | - unset( $entry_tmp );  | 
                                                        |
| 707 | - }  | 
                                                        |
| 709 | + }  | 
                                                        |
| 708 | 710 | |
| 709 | - }  | 
                                                        |
| 711 | +		if( $update_entry ) { | 
                                                        |
| 710 | 712 | |
| 711 | -        if( $update_entry ) { | 
                                                        |
| 712 | -  | 
                                                        |
| 713 | - $return_entry = GFAPI::update_entry( $this->entry );  | 
                                                        |
| 713 | + $return_entry = GFAPI::update_entry( $this->entry );  | 
                                                        |
| 714 | 714 | |
| 715 | -            if( is_wp_error( $return_entry ) ) { | 
                                                        |
| 716 | - do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) );  | 
                                                        |
| 717 | -            } else { | 
                                                        |
| 718 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );  | 
                                                        |
| 719 | - }  | 
                                                        |
| 715 | +			if( is_wp_error( $return_entry ) ) { | 
                                                        |
| 716 | + do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) );  | 
                                                        |
| 717 | +			} else { | 
                                                        |
| 718 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );  | 
                                                        |
| 719 | + }  | 
                                                        |
| 720 | 720 | |
| 721 | - }  | 
                                                        |
| 721 | + }  | 
                                                        |
| 722 | 722 | |
| 723 | - $return_post = wp_update_post( $updated_post, true );  | 
                                                        |
| 723 | + $return_post = wp_update_post( $updated_post, true );  | 
                                                        |
| 724 | 724 | |
| 725 | -        if( is_wp_error( $return_post ) ) { | 
                                                        |
| 726 | - $return_post->add_data( $updated_post, '$updated_post' );  | 
                                                        |
| 727 | - do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) );  | 
                                                        |
| 728 | -        } else { | 
                                                        |
| 729 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post );  | 
                                                        |
| 730 | - }  | 
                                                        |
| 731 | - }  | 
                                                        |
| 725 | +		if( is_wp_error( $return_post ) ) { | 
                                                        |
| 726 | + $return_post->add_data( $updated_post, '$updated_post' );  | 
                                                        |
| 727 | + do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) );  | 
                                                        |
| 728 | +		} else { | 
                                                        |
| 729 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post );  | 
                                                        |
| 730 | + }  | 
                                                        |
| 731 | + }  | 
                                                        |
| 732 | 732 | |
| 733 | 733 | /**  | 
                                                        
| 734 | - * Is the field stored in a JSON-encoded manner?  | 
                                                        |
| 735 | - *  | 
                                                        |
| 734 | + * Is the field stored in a JSON-encoded manner?  | 
                                                        |
| 735 | + *  | 
                                                        |
| 736 | 736 | * @param GF_Field $field  | 
                                                        
| 737 | 737 | *  | 
                                                        
| 738 | 738 | * @return bool True: stored in DB json_encode()'d; False: not encoded  | 
                                                        
| 739 | 739 | */  | 
                                                        
| 740 | -    private function is_field_json_encoded( $field ) { | 
                                                        |
| 740 | +	private function is_field_json_encoded( $field ) { | 
                                                        |
| 741 | 741 | |
| 742 | - $json_encoded = false;  | 
                                                        |
| 742 | + $json_encoded = false;  | 
                                                        |
| 743 | 743 | |
| 744 | - $input_type = RGFormsModel::get_input_type( $field );  | 
                                                        |
| 744 | + $input_type = RGFormsModel::get_input_type( $field );  | 
                                                        |
| 745 | 745 | |
| 746 | - // Only certain custom field types are supported  | 
                                                        |
| 747 | -	    switch( $input_type ) { | 
                                                        |
| 748 | - case 'fileupload':  | 
                                                        |
| 749 | - case 'list':  | 
                                                        |
| 750 | - case 'multiselect':  | 
                                                        |
| 751 | - $json_encoded = true;  | 
                                                        |
| 752 | - break;  | 
                                                        |
| 753 | - }  | 
                                                        |
| 746 | + // Only certain custom field types are supported  | 
                                                        |
| 747 | +		switch( $input_type ) { | 
                                                        |
| 748 | + case 'fileupload':  | 
                                                        |
| 749 | + case 'list':  | 
                                                        |
| 750 | + case 'multiselect':  | 
                                                        |
| 751 | + $json_encoded = true;  | 
                                                        |
| 752 | + break;  | 
                                                        |
| 753 | + }  | 
                                                        |
| 754 | 754 | |
| 755 | - return $json_encoded;  | 
                                                        |
| 756 | - }  | 
                                                        |
| 755 | + return $json_encoded;  | 
                                                        |
| 756 | + }  | 
                                                        |
| 757 | 757 | |
| 758 | - /**  | 
                                                        |
| 759 | - * Convert a field content template into prepared output  | 
                                                        |
| 760 | - *  | 
                                                        |
| 761 | - * @uses GravityView_GFFormsModel::get_post_field_images()  | 
                                                        |
| 762 | - *  | 
                                                        |
| 763 | - * @since 1.17  | 
                                                        |
| 764 | - *  | 
                                                        |
| 765 | - * @param string $template The content template for the field  | 
                                                        |
| 766 | - * @param array $form Gravity Forms form  | 
                                                        |
| 767 | - * @param bool $do_shortcode Whether to process shortcode inside content. In GF, only run on Custom Field and Post Content fields  | 
                                                        |
| 768 | - *  | 
                                                        |
| 769 | - * @return mixed|string|void  | 
                                                        |
| 770 | - */  | 
                                                        |
| 771 | -    private function fill_post_template( $template, $form, $entry, $do_shortcode = false ) { | 
                                                        |
| 758 | + /**  | 
                                                        |
| 759 | + * Convert a field content template into prepared output  | 
                                                        |
| 760 | + *  | 
                                                        |
| 761 | + * @uses GravityView_GFFormsModel::get_post_field_images()  | 
                                                        |
| 762 | + *  | 
                                                        |
| 763 | + * @since 1.17  | 
                                                        |
| 764 | + *  | 
                                                        |
| 765 | + * @param string $template The content template for the field  | 
                                                        |
| 766 | + * @param array $form Gravity Forms form  | 
                                                        |
| 767 | + * @param bool $do_shortcode Whether to process shortcode inside content. In GF, only run on Custom Field and Post Content fields  | 
                                                        |
| 768 | + *  | 
                                                        |
| 769 | + * @return mixed|string|void  | 
                                                        |
| 770 | + */  | 
                                                        |
| 771 | +	private function fill_post_template( $template, $form, $entry, $do_shortcode = false ) { | 
                                                        |
| 772 | 772 | |
| 773 | - require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';  | 
                                                        |
| 773 | + require_once GRAVITYVIEW_DIR . 'includes/class-gravityview-gfformsmodel.php';  | 
                                                        |
| 774 | 774 | |
| 775 | - $post_images = GravityView_GFFormsModel::get_post_field_images( $form, $entry );  | 
                                                        |
| 775 | + $post_images = GravityView_GFFormsModel::get_post_field_images( $form, $entry );  | 
                                                        |
| 776 | 776 | |
| 777 | - //replacing post image variables  | 
                                                        |
| 778 | - $output = GFCommon::replace_variables_post_image( $template, $post_images, $entry );  | 
                                                        |
| 777 | + //replacing post image variables  | 
                                                        |
| 778 | + $output = GFCommon::replace_variables_post_image( $template, $post_images, $entry );  | 
                                                        |
| 779 | 779 | |
| 780 | - //replacing all other variables  | 
                                                        |
| 781 | - $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );  | 
                                                        |
| 780 | + //replacing all other variables  | 
                                                        |
| 781 | + $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );  | 
                                                        |
| 782 | 782 | |
| 783 | - // replace conditional shortcodes  | 
                                                        |
| 784 | -        if( $do_shortcode ) { | 
                                                        |
| 785 | - $output = do_shortcode( $output );  | 
                                                        |
| 786 | - }  | 
                                                        |
| 783 | + // replace conditional shortcodes  | 
                                                        |
| 784 | +		if( $do_shortcode ) { | 
                                                        |
| 785 | + $output = do_shortcode( $output );  | 
                                                        |
| 786 | + }  | 
                                                        |
| 787 | 787 | |
| 788 | - return $output;  | 
                                                        |
| 789 | - }  | 
                                                        |
| 788 | + return $output;  | 
                                                        |
| 789 | + }  | 
                                                        |
| 790 | 790 | |
| 791 | 791 | |
| 792 | - /**  | 
                                                        |
| 793 | - * Perform actions normally performed after updating a lead  | 
                                                        |
| 794 | - *  | 
                                                        |
| 795 | - * @since 1.8  | 
                                                        |
| 796 | - *  | 
                                                        |
| 797 | - * @see GFEntryDetail::lead_detail_page()  | 
                                                        |
| 798 | - *  | 
                                                        |
| 799 | - * @return void  | 
                                                        |
| 800 | - */  | 
                                                        |
| 801 | -    private function after_update() { | 
                                                        |
| 792 | + /**  | 
                                                        |
| 793 | + * Perform actions normally performed after updating a lead  | 
                                                        |
| 794 | + *  | 
                                                        |
| 795 | + * @since 1.8  | 
                                                        |
| 796 | + *  | 
                                                        |
| 797 | + * @see GFEntryDetail::lead_detail_page()  | 
                                                        |
| 798 | + *  | 
                                                        |
| 799 | + * @return void  | 
                                                        |
| 800 | + */  | 
                                                        |
| 801 | +	private function after_update() { | 
                                                        |
| 802 | 802 | |
| 803 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );  | 
                                                        |
| 804 | -        do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); | 
                                                        |
| 803 | + do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );  | 
                                                        |
| 804 | +		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); | 
                                                        |
| 805 | 805 | |
| 806 | - // Re-define the entry now that we've updated it.  | 
                                                        |
| 807 | - $entry = RGFormsModel::get_lead( $this->entry['id'] );  | 
                                                        |
| 806 | + // Re-define the entry now that we've updated it.  | 
                                                        |
| 807 | + $entry = RGFormsModel::get_lead( $this->entry['id'] );  | 
                                                        |
| 808 | 808 | |
| 809 | - $entry = GFFormsModel::set_entry_meta( $entry, $this->form );  | 
                                                        |
| 809 | + $entry = GFFormsModel::set_entry_meta( $entry, $this->form );  | 
                                                        |
| 810 | 810 | |
| 811 | - // We need to clear the cache because Gravity Forms caches the field values, which  | 
                                                        |
| 812 | - // we have just updated.  | 
                                                        |
| 813 | -        foreach ($this->form['fields'] as $key => $field) { | 
                                                        |
| 814 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );  | 
                                                        |
| 815 | - }  | 
                                                        |
| 811 | + // We need to clear the cache because Gravity Forms caches the field values, which  | 
                                                        |
| 812 | + // we have just updated.  | 
                                                        |
| 813 | +		foreach ($this->form['fields'] as $key => $field) { | 
                                                        |
| 814 | + GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );  | 
                                                        |
| 815 | + }  | 
                                                        |
| 816 | 816 | |
| 817 | - $this->entry = $entry;  | 
                                                        |
| 818 | - }  | 
                                                        |
| 817 | + $this->entry = $entry;  | 
                                                        |
| 818 | + }  | 
                                                        |
| 819 | 819 | |
| 820 | 820 | |
| 821 | - /**  | 
                                                        |
| 822 | - * Display the Edit Entry form  | 
                                                        |
| 823 | - *  | 
                                                        |
| 824 | - * @return void  | 
                                                        |
| 825 | - */  | 
                                                        |
| 826 | -    public function edit_entry_form() { | 
                                                        |
| 821 | + /**  | 
                                                        |
| 822 | + * Display the Edit Entry form  | 
                                                        |
| 823 | + *  | 
                                                        |
| 824 | + * @return void  | 
                                                        |
| 825 | + */  | 
                                                        |
| 826 | +	public function edit_entry_form() { | 
                                                        |
| 827 | 827 | |
| 828 | - ?>  | 
                                                        |
| 828 | + ?>  | 
                                                        |
| 829 | 829 | |
| 830 | 830 | <div class="gv-edit-entry-wrapper"><?php  | 
                                                        
| 831 | 831 | |
| 832 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );  | 
                                                        |
| 832 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );  | 
                                                        |
| 833 | 833 | |
| 834 | - /**  | 
                                                        |
| 835 | - * Fixes weird wpautop() issue  | 
                                                        |
| 836 | - * @see https://github.com/katzwebservices/GravityView/issues/451  | 
                                                        |
| 837 | - */  | 
                                                        |
| 838 | - echo gravityview_strip_whitespace( $javascript );  | 
                                                        |
| 834 | + /**  | 
                                                        |
| 835 | + * Fixes weird wpautop() issue  | 
                                                        |
| 836 | + * @see https://github.com/katzwebservices/GravityView/issues/451  | 
                                                        |
| 837 | + */  | 
                                                        |
| 838 | + echo gravityview_strip_whitespace( $javascript );  | 
                                                        |
| 839 | 839 | |
| 840 | - ?><h2 class="gv-edit-entry-title">  | 
                                                        |
| 840 | + ?><h2 class="gv-edit-entry-title">  | 
                                                        |
| 841 | 841 | <span><?php  | 
                                                        
| 842 | 842 | |
| 843 | - /**  | 
                                                        |
| 844 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title  | 
                                                        |
| 845 | - * @param string $edit_entry_title Modify the "Edit Entry" title  | 
                                                        |
| 846 | - * @param GravityView_Edit_Entry_Render $this This object  | 
                                                        |
| 847 | - */  | 
                                                        |
| 848 | -                    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); | 
                                                        |
| 843 | + /**  | 
                                                        |
| 844 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title  | 
                                                        |
| 845 | + * @param string $edit_entry_title Modify the "Edit Entry" title  | 
                                                        |
| 846 | + * @param GravityView_Edit_Entry_Render $this This object  | 
                                                        |
| 847 | + */  | 
                                                        |
| 848 | +					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); | 
                                                        |
| 849 | 849 | |
| 850 | - echo esc_attr( $edit_entry_title );  | 
                                                        |
| 851 | - ?></span>  | 
                                                        |
| 850 | + echo esc_attr( $edit_entry_title );  | 
                                                        |
| 851 | + ?></span>  | 
                                                        |
| 852 | 852 | </h2>  | 
                                                        
| 853 | 853 | |
| 854 | 854 | <?php $this->maybe_print_message(); ?>  | 
                                                        
@@ -859,14 +859,14 @@ discard block  | 
                                                    ||
| 859 | 859 | |
| 860 | 860 | <?php  | 
                                                        
| 861 | 861 | |
| 862 | - wp_nonce_field( self::$nonce_key, self::$nonce_key );  | 
                                                        |
| 862 | + wp_nonce_field( self::$nonce_key, self::$nonce_key );  | 
                                                        |
| 863 | 863 | |
| 864 | - wp_nonce_field( self::$nonce_field, self::$nonce_field, false );  | 
                                                        |
| 864 | + wp_nonce_field( self::$nonce_field, self::$nonce_field, false );  | 
                                                        |
| 865 | 865 | |
| 866 | - // Print the actual form HTML  | 
                                                        |
| 867 | - $this->render_edit_form();  | 
                                                        |
| 866 | + // Print the actual form HTML  | 
                                                        |
| 867 | + $this->render_edit_form();  | 
                                                        |
| 868 | 868 | |
| 869 | - ?>  | 
                                                        |
| 869 | + ?>  | 
                                                        |
| 870 | 870 | </form>  | 
                                                        
| 871 | 871 | |
| 872 | 872 | <script>  | 
                                                        
@@ -878,1132 +878,1132 @@ discard block  | 
                                                    ||
| 878 | 878 | </div>  | 
                                                        
| 879 | 879 | |
| 880 | 880 | <?php  | 
                                                        
| 881 | - }  | 
                                                        |
| 882 | -  | 
                                                        |
| 883 | - /**  | 
                                                        |
| 884 | - * Display success or error message if the form has been submitted  | 
                                                        |
| 885 | - *  | 
                                                        |
| 886 | - * @uses GVCommon::generate_notice  | 
                                                        |
| 887 | - *  | 
                                                        |
| 888 | - * @since 1.16.2.2  | 
                                                        |
| 889 | - *  | 
                                                        |
| 890 | - * @return void  | 
                                                        |
| 891 | - */  | 
                                                        |
| 892 | -    private function maybe_print_message() { | 
                                                        |
| 893 | -  | 
                                                        |
| 894 | -        if( rgpost('action') === 'update' ) { | 
                                                        |
| 895 | -  | 
                                                        |
| 896 | - $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );  | 
                                                        |
| 897 | -  | 
                                                        |
| 898 | -            if( ! $this->is_valid ){ | 
                                                        |
| 899 | -  | 
                                                        |
| 900 | - // Keeping this compatible with Gravity Forms.  | 
                                                        |
| 901 | -                $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; | 
                                                        |
| 902 | -                $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); | 
                                                        |
| 903 | -  | 
                                                        |
| 904 | - echo GVCommon::generate_notice( $message , 'gv-error' );  | 
                                                        |
| 905 | -  | 
                                                        |
| 906 | -            } else { | 
                                                        |
| 907 | -                $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); | 
                                                        |
| 908 | -  | 
                                                        |
| 909 | - /**  | 
                                                        |
| 910 | - * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)  | 
                                                        |
| 911 | - * @since 1.5.4  | 
                                                        |
| 912 | - * @param string $entry_updated_message Existing message  | 
                                                        |
| 913 | - * @param int $view_id View ID  | 
                                                        |
| 914 | - * @param array $entry Gravity Forms entry array  | 
                                                        |
| 915 | - * @param string $back_link URL to return to the original entry. @since 1.6  | 
                                                        |
| 916 | - */  | 
                                                        |
| 917 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );  | 
                                                        |
| 918 | -  | 
                                                        |
| 919 | - echo GVCommon::generate_notice( $message );  | 
                                                        |
| 920 | - }  | 
                                                        |
| 921 | -  | 
                                                        |
| 922 | - }  | 
                                                        |
| 923 | - }  | 
                                                        |
| 924 | -  | 
                                                        |
| 925 | - /**  | 
                                                        |
| 926 | - * Display the Edit Entry form in the original Gravity Forms format  | 
                                                        |
| 927 | - *  | 
                                                        |
| 928 | - * @since 1.9  | 
                                                        |
| 929 | - *  | 
                                                        |
| 930 | - * @return void  | 
                                                        |
| 931 | - */  | 
                                                        |
| 932 | -    private function render_edit_form() { | 
                                                        |
| 933 | -  | 
                                                        |
| 934 | - /**  | 
                                                        |
| 935 | - * @action `gravityview/edit-entry/render/before` Before rendering the Edit Entry form  | 
                                                        |
| 936 | - * @since 1.17  | 
                                                        |
| 937 | - * @param GravityView_Edit_Entry_Render $this  | 
                                                        |
| 938 | - */  | 
                                                        |
| 939 | - do_action( 'gravityview/edit-entry/render/before', $this );  | 
                                                        |
| 940 | -  | 
                                                        |
| 941 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );  | 
                                                        |
| 942 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );  | 
                                                        |
| 943 | - add_filter( 'gform_disable_view_counter', '__return_true' );  | 
                                                        |
| 944 | -  | 
                                                        |
| 945 | - add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );  | 
                                                        |
| 946 | - add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );  | 
                                                        |
| 947 | -  | 
                                                        |
| 948 | - // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.  | 
                                                        |
| 949 | - unset( $_GET['page'] );  | 
                                                        |
| 950 | -  | 
                                                        |
| 951 | - // TODO: Verify multiple-page forms  | 
                                                        |
| 952 | - // TODO: Product fields are not editable  | 
                                                        |
| 953 | -  | 
                                                        |
| 954 | - ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic  | 
                                                        |
| 955 | -  | 
                                                        |
| 956 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );  | 
                                                        |
| 957 | -  | 
                                                        |
| 958 | - ob_get_clean();  | 
                                                        |
| 959 | -  | 
                                                        |
| 960 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );  | 
                                                        |
| 961 | - remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );  | 
                                                        |
| 962 | - remove_filter( 'gform_disable_view_counter', '__return_true' );  | 
                                                        |
| 963 | - remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );  | 
                                                        |
| 964 | - remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 );  | 
                                                        |
| 965 | -  | 
                                                        |
| 966 | - echo $html;  | 
                                                        |
| 967 | -  | 
                                                        |
| 968 | - /**  | 
                                                        |
| 969 | - * @action `gravityview/edit-entry/render/after` After rendering the Edit Entry form  | 
                                                        |
| 970 | - * @since 1.17  | 
                                                        |
| 971 | - * @param GravityView_Edit_Entry_Render $this  | 
                                                        |
| 972 | - */  | 
                                                        |
| 973 | - do_action( 'gravityview/edit-entry/render/after', $this );  | 
                                                        |
| 974 | - }  | 
                                                        |
| 975 | -  | 
                                                        |
| 976 | - /**  | 
                                                        |
| 977 | - * Display the Update/Cancel/Delete buttons for the Edit Entry form  | 
                                                        |
| 978 | - * @since 1.8  | 
                                                        |
| 979 | - * @return string  | 
                                                        |
| 980 | - */  | 
                                                        |
| 981 | -    public function render_form_buttons() { | 
                                                        |
| 982 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );  | 
                                                        |
| 983 | - }  | 
                                                        |
| 984 | -  | 
                                                        |
| 985 | -  | 
                                                        |
| 986 | - /**  | 
                                                        |
| 987 | - * Modify the form fields that are shown when using GFFormDisplay::get_form()  | 
                                                        |
| 988 | - *  | 
                                                        |
| 989 | - * By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.  | 
                                                        |
| 990 | - *  | 
                                                        |
| 991 | - * @param array $form  | 
                                                        |
| 992 | - * @param boolean $ajax Whether in AJAX mode  | 
                                                        |
| 993 | - * @param array|string $field_values Passed parameters to the form  | 
                                                        |
| 994 | - *  | 
                                                        |
| 995 | - * @since 1.9  | 
                                                        |
| 996 | - *  | 
                                                        |
| 997 | - * @return array Modified form array  | 
                                                        |
| 998 | - */  | 
                                                        |
| 999 | -    public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { | 
                                                        |
| 1000 | -  | 
                                                        |
| 1001 | - // In case we have validated the form, use it to inject the validation results into the form render  | 
                                                        |
| 1002 | -        if( isset( $this->form_after_validation ) ) { | 
                                                        |
| 1003 | - $form = $this->form_after_validation;  | 
                                                        |
| 1004 | -        } else { | 
                                                        |
| 1005 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );  | 
                                                        |
| 1006 | - }  | 
                                                        |
| 1007 | -  | 
                                                        |
| 1008 | - $form = $this->filter_conditional_logic( $form );  | 
                                                        |
| 1009 | -  | 
                                                        |
| 1010 | - $form = $this->prefill_conditional_logic( $form );  | 
                                                        |
| 1011 | -  | 
                                                        |
| 1012 | - // for now we don't support Save and Continue feature.  | 
                                                        |
| 1013 | -        if( ! self::$supports_save_and_continue ) { | 
                                                        |
| 1014 | - unset( $form['save'] );  | 
                                                        |
| 1015 | - }  | 
                                                        |
| 1016 | -  | 
                                                        |
| 1017 | - return $form;  | 
                                                        |
| 1018 | - }  | 
                                                        |
| 1019 | -  | 
                                                        |
| 1020 | - /**  | 
                                                        |
| 1021 | - * 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.  | 
                                                        |
| 1022 | - *  | 
                                                        |
| 1023 | - * @since 1.16.2.2  | 
                                                        |
| 1024 | - *  | 
                                                        |
| 1025 | - * @param string $field_content Always empty. Returning not-empty overrides the input.  | 
                                                        |
| 1026 | - * @param GF_Field $field  | 
                                                        |
| 1027 | - * @param string|array $value If array, it's a field with multiple inputs. If string, single input.  | 
                                                        |
| 1028 | - * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.  | 
                                                        |
| 1029 | - * @param int $form_id Form ID  | 
                                                        |
| 1030 | - *  | 
                                                        |
| 1031 | - * @return string If error, the error message. If no error, blank string (modify_edit_field_input() runs next)  | 
                                                        |
| 1032 | - */  | 
                                                        |
| 1033 | -    public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { | 
                                                        |
| 1034 | -  | 
                                                        |
| 1035 | -        if( GFCommon::is_post_field( $field ) ) { | 
                                                        |
| 1036 | -  | 
                                                        |
| 1037 | - $message = null;  | 
                                                        |
| 1038 | -  | 
                                                        |
| 1039 | - // First, make sure they have the capability to edit the post.  | 
                                                        |
| 1040 | -            if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { | 
                                                        |
| 1041 | -  | 
                                                        |
| 1042 | - /**  | 
                                                        |
| 1043 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post  | 
                                                        |
| 1044 | - * @param string $message The existing "You don't have permission..." text  | 
                                                        |
| 1045 | - */  | 
                                                        |
| 1046 | -                $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); | 
                                                        |
| 1047 | -  | 
                                                        |
| 1048 | -            } elseif( null === get_post( $this->entry['post_id'] ) ) { | 
                                                        |
| 1049 | - /**  | 
                                                        |
| 1050 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists  | 
                                                        |
| 1051 | - * @param string $message The existing "This field is not editable; the post no longer exists." text  | 
                                                        |
| 1052 | - */  | 
                                                        |
| 1053 | -                $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); | 
                                                        |
| 1054 | - }  | 
                                                        |
| 1055 | -  | 
                                                        |
| 1056 | -            if( $message ) { | 
                                                        |
| 1057 | -                $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); | 
                                                        |
| 1058 | - }  | 
                                                        |
| 1059 | - }  | 
                                                        |
| 1060 | -  | 
                                                        |
| 1061 | - return $field_content;  | 
                                                        |
| 1062 | - }  | 
                                                        |
| 1063 | -  | 
                                                        |
| 1064 | - /**  | 
                                                        |
| 1065 | - *  | 
                                                        |
| 1066 | - * Fill-in the saved values into the form inputs  | 
                                                        |
| 1067 | - *  | 
                                                        |
| 1068 | - * @param string $field_content Always empty. Returning not-empty overrides the input.  | 
                                                        |
| 1069 | - * @param GF_Field $field  | 
                                                        |
| 1070 | - * @param string|array $value If array, it's a field with multiple inputs. If string, single input.  | 
                                                        |
| 1071 | - * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.  | 
                                                        |
| 1072 | - * @param int $form_id Form ID  | 
                                                        |
| 1073 | - *  | 
                                                        |
| 1074 | - * @return mixed  | 
                                                        |
| 1075 | - */  | 
                                                        |
| 1076 | -    public function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { | 
                                                        |
| 1077 | -  | 
                                                        |
| 1078 | - $gv_field = GravityView_Fields::get_associated_field( $field );  | 
                                                        |
| 1079 | -  | 
                                                        |
| 1080 | - // If the form has been submitted, then we don't need to pre-fill the values,  | 
                                                        |
| 1081 | - // Except for fileupload type and when a field input is overridden- run always!!  | 
                                                        |
| 1082 | - if(  | 
                                                        |
| 1083 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )  | 
                                                        |
| 1084 | - && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )  | 
                                                        |
| 1085 | - || ! empty( $field_content )  | 
                                                        |
| 1086 | - || in_array( $field->type, array( 'honeypot' ) )  | 
                                                        |
| 1087 | - || GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable  | 
                                                        |
| 1088 | -        ) { | 
                                                        |
| 1089 | - return $field_content;  | 
                                                        |
| 1090 | - }  | 
                                                        |
| 1091 | -  | 
                                                        |
| 1092 | - // Turn on Admin-style display for file upload fields only  | 
                                                        |
| 1093 | -        if( 'fileupload' === $field->type ) { | 
                                                        |
| 1094 | - $_GET['page'] = 'gf_entries';  | 
                                                        |
| 1095 | - }  | 
                                                        |
| 1096 | -  | 
                                                        |
| 1097 | - // SET SOME FIELD DEFAULTS TO PREVENT ISSUES  | 
                                                        |
| 1098 | - $field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */  | 
                                                        |
| 1099 | -  | 
                                                        |
| 1100 | - // add categories as choices for Post Category field  | 
                                                        |
| 1101 | -        if ( 'post_category' === $field->type ) { | 
                                                        |
| 1102 | - $field = GFCommon::add_categories_as_choices( $field, $value );  | 
                                                        |
| 1103 | - }  | 
                                                        |
| 1104 | -  | 
                                                        |
| 1105 | - $field_value = $this->get_field_value( $field );  | 
                                                        |
| 1106 | -  | 
                                                        |
| 1107 | - /**  | 
                                                        |
| 1108 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed  | 
                                                        |
| 1109 | - * @since 1.11  | 
                                                        |
| 1110 | - * @param mixed $field_value field value used to populate the input  | 
                                                        |
| 1111 | - * @param object $field Gravity Forms field object ( Class GF_Field )  | 
                                                        |
| 1112 | - */  | 
                                                        |
| 1113 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field );  | 
                                                        |
| 1114 | -  | 
                                                        |
| 1115 | - /**  | 
                                                        |
| 1116 | -         * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type | 
                                                        |
| 1117 | - * @since 1.17  | 
                                                        |
| 1118 | - * @param mixed $field_value field value used to populate the input  | 
                                                        |
| 1119 | - * @param GF_Field $field Gravity Forms field object  | 
                                                        |
| 1120 | - */  | 
                                                        |
| 1121 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field );  | 
                                                        |
| 1122 | -  | 
                                                        |
| 1123 | - // Prevent any PHP warnings, like undefined index  | 
                                                        |
| 1124 | - ob_start();  | 
                                                        |
| 1125 | -  | 
                                                        |
| 1126 | - /** @var GravityView_Field $gv_field */  | 
                                                        |
| 1127 | -        if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { | 
                                                        |
| 1128 | - $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );  | 
                                                        |
| 1129 | -        } else { | 
                                                        |
| 1130 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry );  | 
                                                        |
| 1131 | - }  | 
                                                        |
| 1132 | -  | 
                                                        |
| 1133 | -  | 
                                                        |
| 1134 | - // If there was output, it's an error  | 
                                                        |
| 1135 | - $warnings = ob_get_clean();  | 
                                                        |
| 1136 | -  | 
                                                        |
| 1137 | -	    if( !empty( $warnings ) ) { | 
                                                        |
| 1138 | - do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );  | 
                                                        |
| 1139 | - }  | 
                                                        |
| 1140 | -  | 
                                                        |
| 1141 | - /**  | 
                                                        |
| 1142 | - * Unset hack $_GET['page'] = 'gf_entries'  | 
                                                        |
| 1143 | - * We need the fileupload html field to render with the proper id  | 
                                                        |
| 1144 | - * ( <li id="field_80_16" ... > )  | 
                                                        |
| 1145 | - */  | 
                                                        |
| 1146 | - unset( $_GET['page'] );  | 
                                                        |
| 1147 | -  | 
                                                        |
| 1148 | - return $return;  | 
                                                        |
| 1149 | - }  | 
                                                        |
| 1150 | -  | 
                                                        |
| 1151 | - /**  | 
                                                        |
| 1152 | - * Modify the value for the current field input  | 
                                                        |
| 1153 | - *  | 
                                                        |
| 1154 | - * @param GF_Field $field  | 
                                                        |
| 1155 | - *  | 
                                                        |
| 1156 | - * @return array|mixed|string|void  | 
                                                        |
| 1157 | - */  | 
                                                        |
| 1158 | -    private function get_field_value( $field ) { | 
                                                        |
| 1159 | -  | 
                                                        |
| 1160 | - /**  | 
                                                        |
| 1161 | - * @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.  | 
                                                        |
| 1162 | - * @param boolean True: override saved values; False: don't override (default)  | 
                                                        |
| 1163 | - * @param $field GF_Field object Gravity Forms field object  | 
                                                        |
| 1164 | - * @since 1.13  | 
                                                        |
| 1165 | - */  | 
                                                        |
| 1166 | - $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );  | 
                                                        |
| 1167 | -  | 
                                                        |
| 1168 | - // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)  | 
                                                        |
| 1169 | -        if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { | 
                                                        |
| 1170 | -  | 
                                                        |
| 1171 | - $field_value = array();  | 
                                                        |
| 1172 | -  | 
                                                        |
| 1173 | - // only accept pre-populated values if the field doesn't have any choice selected.  | 
                                                        |
| 1174 | - $allow_pre_populated = $field->allowsPrepopulate;  | 
                                                        |
| 1175 | -  | 
                                                        |
| 1176 | -            foreach ( (array)$field->inputs as $input ) { | 
                                                        |
| 1177 | -  | 
                                                        |
| 1178 | - $input_id = strval( $input['id'] );  | 
                                                        |
| 881 | + }  | 
                                                        |
| 882 | +  | 
                                                        |
| 883 | + /**  | 
                                                        |
| 884 | + * Display success or error message if the form has been submitted  | 
                                                        |
| 885 | + *  | 
                                                        |
| 886 | + * @uses GVCommon::generate_notice  | 
                                                        |
| 887 | + *  | 
                                                        |
| 888 | + * @since 1.16.2.2  | 
                                                        |
| 889 | + *  | 
                                                        |
| 890 | + * @return void  | 
                                                        |
| 891 | + */  | 
                                                        |
| 892 | +	private function maybe_print_message() { | 
                                                        |
| 893 | +  | 
                                                        |
| 894 | +		if( rgpost('action') === 'update' ) { | 
                                                        |
| 895 | +  | 
                                                        |
| 896 | + $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );  | 
                                                        |
| 897 | +  | 
                                                        |
| 898 | +			if( ! $this->is_valid ){ | 
                                                        |
| 899 | +  | 
                                                        |
| 900 | + // Keeping this compatible with Gravity Forms.  | 
                                                        |
| 901 | +				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; | 
                                                        |
| 902 | +				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); | 
                                                        |
| 903 | +  | 
                                                        |
| 904 | + echo GVCommon::generate_notice( $message , 'gv-error' );  | 
                                                        |
| 905 | +  | 
                                                        |
| 906 | +			} else { | 
                                                        |
| 907 | +				$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); | 
                                                        |
| 908 | +  | 
                                                        |
| 909 | + /**  | 
                                                        |
| 910 | + * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)  | 
                                                        |
| 911 | + * @since 1.5.4  | 
                                                        |
| 912 | + * @param string $entry_updated_message Existing message  | 
                                                        |
| 913 | + * @param int $view_id View ID  | 
                                                        |
| 914 | + * @param array $entry Gravity Forms entry array  | 
                                                        |
| 915 | + * @param string $back_link URL to return to the original entry. @since 1.6  | 
                                                        |
| 916 | + */  | 
                                                        |
| 917 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );  | 
                                                        |
| 918 | +  | 
                                                        |
| 919 | + echo GVCommon::generate_notice( $message );  | 
                                                        |
| 920 | + }  | 
                                                        |
| 921 | +  | 
                                                        |
| 922 | + }  | 
                                                        |
| 923 | + }  | 
                                                        |
| 924 | +  | 
                                                        |
| 925 | + /**  | 
                                                        |
| 926 | + * Display the Edit Entry form in the original Gravity Forms format  | 
                                                        |
| 927 | + *  | 
                                                        |
| 928 | + * @since 1.9  | 
                                                        |
| 929 | + *  | 
                                                        |
| 930 | + * @return void  | 
                                                        |
| 931 | + */  | 
                                                        |
| 932 | +	private function render_edit_form() { | 
                                                        |
| 933 | +  | 
                                                        |
| 934 | + /**  | 
                                                        |
| 935 | + * @action `gravityview/edit-entry/render/before` Before rendering the Edit Entry form  | 
                                                        |
| 936 | + * @since 1.17  | 
                                                        |
| 937 | + * @param GravityView_Edit_Entry_Render $this  | 
                                                        |
| 938 | + */  | 
                                                        |
| 939 | + do_action( 'gravityview/edit-entry/render/before', $this );  | 
                                                        |
| 940 | +  | 
                                                        |
| 941 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );  | 
                                                        |
| 942 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );  | 
                                                        |
| 943 | + add_filter( 'gform_disable_view_counter', '__return_true' );  | 
                                                        |
| 944 | +  | 
                                                        |
| 945 | + add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );  | 
                                                        |
| 946 | + add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );  | 
                                                        |
| 947 | +  | 
                                                        |
| 948 | + // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.  | 
                                                        |
| 949 | + unset( $_GET['page'] );  | 
                                                        |
| 950 | +  | 
                                                        |
| 951 | + // TODO: Verify multiple-page forms  | 
                                                        |
| 952 | + // TODO: Product fields are not editable  | 
                                                        |
| 953 | +  | 
                                                        |
| 954 | + ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic  | 
                                                        |
| 955 | +  | 
                                                        |
| 956 | + $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );  | 
                                                        |
| 957 | +  | 
                                                        |
| 958 | + ob_get_clean();  | 
                                                        |
| 959 | +  | 
                                                        |
| 960 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );  | 
                                                        |
| 961 | + remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );  | 
                                                        |
| 962 | + remove_filter( 'gform_disable_view_counter', '__return_true' );  | 
                                                        |
| 963 | + remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );  | 
                                                        |
| 964 | + remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 );  | 
                                                        |
| 965 | +  | 
                                                        |
| 966 | + echo $html;  | 
                                                        |
| 967 | +  | 
                                                        |
| 968 | + /**  | 
                                                        |
| 969 | + * @action `gravityview/edit-entry/render/after` After rendering the Edit Entry form  | 
                                                        |
| 970 | + * @since 1.17  | 
                                                        |
| 971 | + * @param GravityView_Edit_Entry_Render $this  | 
                                                        |
| 972 | + */  | 
                                                        |
| 973 | + do_action( 'gravityview/edit-entry/render/after', $this );  | 
                                                        |
| 974 | + }  | 
                                                        |
| 975 | +  | 
                                                        |
| 976 | + /**  | 
                                                        |
| 977 | + * Display the Update/Cancel/Delete buttons for the Edit Entry form  | 
                                                        |
| 978 | + * @since 1.8  | 
                                                        |
| 979 | + * @return string  | 
                                                        |
| 980 | + */  | 
                                                        |
| 981 | +	public function render_form_buttons() { | 
                                                        |
| 982 | + return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );  | 
                                                        |
| 983 | + }  | 
                                                        |
| 984 | +  | 
                                                        |
| 985 | +  | 
                                                        |
| 986 | + /**  | 
                                                        |
| 987 | + * Modify the form fields that are shown when using GFFormDisplay::get_form()  | 
                                                        |
| 988 | + *  | 
                                                        |
| 989 | + * By default, all fields will be shown. We only want the Edit Tab configured fields to be shown.  | 
                                                        |
| 990 | + *  | 
                                                        |
| 991 | + * @param array $form  | 
                                                        |
| 992 | + * @param boolean $ajax Whether in AJAX mode  | 
                                                        |
| 993 | + * @param array|string $field_values Passed parameters to the form  | 
                                                        |
| 994 | + *  | 
                                                        |
| 995 | + * @since 1.9  | 
                                                        |
| 996 | + *  | 
                                                        |
| 997 | + * @return array Modified form array  | 
                                                        |
| 998 | + */  | 
                                                        |
| 999 | +	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { | 
                                                        |
| 1000 | +  | 
                                                        |
| 1001 | + // In case we have validated the form, use it to inject the validation results into the form render  | 
                                                        |
| 1002 | +		if( isset( $this->form_after_validation ) ) { | 
                                                        |
| 1003 | + $form = $this->form_after_validation;  | 
                                                        |
| 1004 | +		} else { | 
                                                        |
| 1005 | + $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );  | 
                                                        |
| 1006 | + }  | 
                                                        |
| 1007 | +  | 
                                                        |
| 1008 | + $form = $this->filter_conditional_logic( $form );  | 
                                                        |
| 1009 | +  | 
                                                        |
| 1010 | + $form = $this->prefill_conditional_logic( $form );  | 
                                                        |
| 1011 | +  | 
                                                        |
| 1012 | + // for now we don't support Save and Continue feature.  | 
                                                        |
| 1013 | +		if( ! self::$supports_save_and_continue ) { | 
                                                        |
| 1014 | + unset( $form['save'] );  | 
                                                        |
| 1015 | + }  | 
                                                        |
| 1016 | +  | 
                                                        |
| 1017 | + return $form;  | 
                                                        |
| 1018 | + }  | 
                                                        |
| 1019 | +  | 
                                                        |
| 1020 | + /**  | 
                                                        |
| 1021 | + * 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.  | 
                                                        |
| 1022 | + *  | 
                                                        |
| 1023 | + * @since 1.16.2.2  | 
                                                        |
| 1024 | + *  | 
                                                        |
| 1025 | + * @param string $field_content Always empty. Returning not-empty overrides the input.  | 
                                                        |
| 1026 | + * @param GF_Field $field  | 
                                                        |
| 1027 | + * @param string|array $value If array, it's a field with multiple inputs. If string, single input.  | 
                                                        |
| 1028 | + * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.  | 
                                                        |
| 1029 | + * @param int $form_id Form ID  | 
                                                        |
| 1030 | + *  | 
                                                        |
| 1031 | + * @return string If error, the error message. If no error, blank string (modify_edit_field_input() runs next)  | 
                                                        |
| 1032 | + */  | 
                                                        |
| 1033 | +	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { | 
                                                        |
| 1034 | +  | 
                                                        |
| 1035 | +		if( GFCommon::is_post_field( $field ) ) { | 
                                                        |
| 1036 | +  | 
                                                        |
| 1037 | + $message = null;  | 
                                                        |
| 1038 | +  | 
                                                        |
| 1039 | + // First, make sure they have the capability to edit the post.  | 
                                                        |
| 1040 | +			if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { | 
                                                        |
| 1041 | +  | 
                                                        |
| 1042 | + /**  | 
                                                        |
| 1043 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post  | 
                                                        |
| 1044 | + * @param string $message The existing "You don't have permission..." text  | 
                                                        |
| 1045 | + */  | 
                                                        |
| 1046 | +				$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); | 
                                                        |
| 1047 | +  | 
                                                        |
| 1048 | +			} elseif( null === get_post( $this->entry['post_id'] ) ) { | 
                                                        |
| 1049 | + /**  | 
                                                        |
| 1050 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists  | 
                                                        |
| 1051 | + * @param string $message The existing "This field is not editable; the post no longer exists." text  | 
                                                        |
| 1052 | + */  | 
                                                        |
| 1053 | +				$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); | 
                                                        |
| 1054 | + }  | 
                                                        |
| 1055 | +  | 
                                                        |
| 1056 | +			if( $message ) { | 
                                                        |
| 1057 | +				$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); | 
                                                        |
| 1058 | + }  | 
                                                        |
| 1059 | + }  | 
                                                        |
| 1060 | +  | 
                                                        |
| 1061 | + return $field_content;  | 
                                                        |
| 1062 | + }  | 
                                                        |
| 1063 | +  | 
                                                        |
| 1064 | + /**  | 
                                                        |
| 1065 | + *  | 
                                                        |
| 1066 | + * Fill-in the saved values into the form inputs  | 
                                                        |
| 1067 | + *  | 
                                                        |
| 1068 | + * @param string $field_content Always empty. Returning not-empty overrides the input.  | 
                                                        |
| 1069 | + * @param GF_Field $field  | 
                                                        |
| 1070 | + * @param string|array $value If array, it's a field with multiple inputs. If string, single input.  | 
                                                        |
| 1071 | + * @param int $lead_id Lead ID. Always 0 for the `gform_field_input` filter.  | 
                                                        |
| 1072 | + * @param int $form_id Form ID  | 
                                                        |
| 1073 | + *  | 
                                                        |
| 1074 | + * @return mixed  | 
                                                        |
| 1075 | + */  | 
                                                        |
| 1076 | +	public function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { | 
                                                        |
| 1077 | +  | 
                                                        |
| 1078 | + $gv_field = GravityView_Fields::get_associated_field( $field );  | 
                                                        |
| 1079 | +  | 
                                                        |
| 1080 | + // If the form has been submitted, then we don't need to pre-fill the values,  | 
                                                        |
| 1081 | + // Except for fileupload type and when a field input is overridden- run always!!  | 
                                                        |
| 1082 | + if(  | 
                                                        |
| 1083 | + ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )  | 
                                                        |
| 1084 | + && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )  | 
                                                        |
| 1085 | + || ! empty( $field_content )  | 
                                                        |
| 1086 | + || in_array( $field->type, array( 'honeypot' ) )  | 
                                                        |
| 1087 | + || GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable  | 
                                                        |
| 1088 | +		) { | 
                                                        |
| 1089 | + return $field_content;  | 
                                                        |
| 1090 | + }  | 
                                                        |
| 1091 | +  | 
                                                        |
| 1092 | + // Turn on Admin-style display for file upload fields only  | 
                                                        |
| 1093 | +		if( 'fileupload' === $field->type ) { | 
                                                        |
| 1094 | + $_GET['page'] = 'gf_entries';  | 
                                                        |
| 1095 | + }  | 
                                                        |
| 1096 | +  | 
                                                        |
| 1097 | + // SET SOME FIELD DEFAULTS TO PREVENT ISSUES  | 
                                                        |
| 1098 | + $field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */  | 
                                                        |
| 1099 | +  | 
                                                        |
| 1100 | + // add categories as choices for Post Category field  | 
                                                        |
| 1101 | +		if ( 'post_category' === $field->type ) { | 
                                                        |
| 1102 | + $field = GFCommon::add_categories_as_choices( $field, $value );  | 
                                                        |
| 1103 | + }  | 
                                                        |
| 1104 | +  | 
                                                        |
| 1105 | + $field_value = $this->get_field_value( $field );  | 
                                                        |
| 1106 | +  | 
                                                        |
| 1107 | + /**  | 
                                                        |
| 1108 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed  | 
                                                        |
| 1109 | + * @since 1.11  | 
                                                        |
| 1110 | + * @param mixed $field_value field value used to populate the input  | 
                                                        |
| 1111 | + * @param object $field Gravity Forms field object ( Class GF_Field )  | 
                                                        |
| 1112 | + */  | 
                                                        |
| 1113 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field );  | 
                                                        |
| 1114 | +  | 
                                                        |
| 1115 | + /**  | 
                                                        |
| 1116 | +		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type | 
                                                        |
| 1117 | + * @since 1.17  | 
                                                        |
| 1118 | + * @param mixed $field_value field value used to populate the input  | 
                                                        |
| 1119 | + * @param GF_Field $field Gravity Forms field object  | 
                                                        |
| 1120 | + */  | 
                                                        |
| 1121 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field );  | 
                                                        |
| 1122 | +  | 
                                                        |
| 1123 | + // Prevent any PHP warnings, like undefined index  | 
                                                        |
| 1124 | + ob_start();  | 
                                                        |
| 1125 | +  | 
                                                        |
| 1126 | + /** @var GravityView_Field $gv_field */  | 
                                                        |
| 1127 | +		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { | 
                                                        |
| 1128 | + $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );  | 
                                                        |
| 1129 | +		} else { | 
                                                        |
| 1130 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry );  | 
                                                        |
| 1131 | + }  | 
                                                        |
| 1132 | +  | 
                                                        |
| 1133 | +  | 
                                                        |
| 1134 | + // If there was output, it's an error  | 
                                                        |
| 1135 | + $warnings = ob_get_clean();  | 
                                                        |
| 1136 | +  | 
                                                        |
| 1137 | +		if( !empty( $warnings ) ) { | 
                                                        |
| 1138 | + do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );  | 
                                                        |
| 1139 | + }  | 
                                                        |
| 1140 | +  | 
                                                        |
| 1141 | + /**  | 
                                                        |
| 1142 | + * Unset hack $_GET['page'] = 'gf_entries'  | 
                                                        |
| 1143 | + * We need the fileupload html field to render with the proper id  | 
                                                        |
| 1144 | + * ( <li id="field_80_16" ... > )  | 
                                                        |
| 1145 | + */  | 
                                                        |
| 1146 | + unset( $_GET['page'] );  | 
                                                        |
| 1147 | +  | 
                                                        |
| 1148 | + return $return;  | 
                                                        |
| 1149 | + }  | 
                                                        |
| 1150 | +  | 
                                                        |
| 1151 | + /**  | 
                                                        |
| 1152 | + * Modify the value for the current field input  | 
                                                        |
| 1153 | + *  | 
                                                        |
| 1154 | + * @param GF_Field $field  | 
                                                        |
| 1155 | + *  | 
                                                        |
| 1156 | + * @return array|mixed|string|void  | 
                                                        |
| 1157 | + */  | 
                                                        |
| 1158 | +	private function get_field_value( $field ) { | 
                                                        |
| 1159 | +  | 
                                                        |
| 1160 | + /**  | 
                                                        |
| 1161 | + * @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.  | 
                                                        |
| 1162 | + * @param boolean True: override saved values; False: don't override (default)  | 
                                                        |
| 1163 | + * @param $field GF_Field object Gravity Forms field object  | 
                                                        |
| 1164 | + * @since 1.13  | 
                                                        |
| 1165 | + */  | 
                                                        |
| 1166 | + $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );  | 
                                                        |
| 1167 | +  | 
                                                        |
| 1168 | + // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)  | 
                                                        |
| 1169 | +		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { | 
                                                        |
| 1170 | +  | 
                                                        |
| 1171 | + $field_value = array();  | 
                                                        |
| 1172 | +  | 
                                                        |
| 1173 | + // only accept pre-populated values if the field doesn't have any choice selected.  | 
                                                        |
| 1174 | + $allow_pre_populated = $field->allowsPrepopulate;  | 
                                                        |
| 1175 | +  | 
                                                        |
| 1176 | +			foreach ( (array)$field->inputs as $input ) { | 
                                                        |
| 1177 | +  | 
                                                        |
| 1178 | + $input_id = strval( $input['id'] );  | 
                                                        |
| 1179 | 1179 | |
| 1180 | -                if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { | 
                                                        |
| 1181 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];  | 
                                                        |
| 1182 | - $allow_pre_populated = false;  | 
                                                        |
| 1183 | - }  | 
                                                        |
| 1180 | +				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { | 
                                                        |
| 1181 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];  | 
                                                        |
| 1182 | + $allow_pre_populated = false;  | 
                                                        |
| 1183 | + }  | 
                                                        |
| 1184 | 1184 | |
| 1185 | - }  | 
                                                        |
| 1185 | + }  | 
                                                        |
| 1186 | 1186 | |
| 1187 | - $pre_value = $field->get_value_submission( array(), false );  | 
                                                        |
| 1187 | + $pre_value = $field->get_value_submission( array(), false );  | 
                                                        |
| 1188 | 1188 | |
| 1189 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;  | 
                                                        |
| 1189 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;  | 
                                                        |
| 1190 | 1190 | |
| 1191 | -        } else { | 
                                                        |
| 1191 | +		} else { | 
                                                        |
| 1192 | 1192 | |
| 1193 | - $id = intval( $field->id );  | 
                                                        |
| 1193 | + $id = intval( $field->id );  | 
                                                        |
| 1194 | 1194 | |
| 1195 | - // get pre-populated value if exists  | 
                                                        |
| 1196 | - $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : '';  | 
                                                        |
| 1195 | + // get pre-populated value if exists  | 
                                                        |
| 1196 | + $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : '';  | 
                                                        |
| 1197 | 1197 | |
| 1198 | - // saved field entry value (if empty, fallback to the pre-populated value, if exists)  | 
                                                        |
| 1199 | - // or pre-populated value if not empty and set to override saved value  | 
                                                        |
| 1200 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;  | 
                                                        |
| 1198 | + // saved field entry value (if empty, fallback to the pre-populated value, if exists)  | 
                                                        |
| 1199 | + // or pre-populated value if not empty and set to override saved value  | 
                                                        |
| 1200 | + $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;  | 
                                                        |
| 1201 | 1201 | |
| 1202 | - // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.  | 
                                                        |
| 1203 | -            if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { | 
                                                        |
| 1204 | - $categories = array();  | 
                                                        |
| 1205 | -                foreach ( explode( ',', $field_value ) as $cat_string ) { | 
                                                        |
| 1206 | - $categories[] = GFCommon::format_post_category( $cat_string, true );  | 
                                                        |
| 1207 | - }  | 
                                                        |
| 1208 | - $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );  | 
                                                        |
| 1209 | - }  | 
                                                        |
| 1202 | + // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.  | 
                                                        |
| 1203 | +			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { | 
                                                        |
| 1204 | + $categories = array();  | 
                                                        |
| 1205 | +				foreach ( explode( ',', $field_value ) as $cat_string ) { | 
                                                        |
| 1206 | + $categories[] = GFCommon::format_post_category( $cat_string, true );  | 
                                                        |
| 1207 | + }  | 
                                                        |
| 1208 | + $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );  | 
                                                        |
| 1209 | + }  | 
                                                        |
| 1210 | 1210 | |
| 1211 | - }  | 
                                                        |
| 1211 | + }  | 
                                                        |
| 1212 | 1212 | |
| 1213 | - // if value is empty get the default value if defined  | 
                                                        |
| 1214 | - $field_value = $field->get_value_default_if_empty( $field_value );  | 
                                                        |
| 1213 | + // if value is empty get the default value if defined  | 
                                                        |
| 1214 | + $field_value = $field->get_value_default_if_empty( $field_value );  | 
                                                        |
| 1215 | 1215 | |
| 1216 | - return $field_value;  | 
                                                        |
| 1217 | - }  | 
                                                        |
| 1216 | + return $field_value;  | 
                                                        |
| 1217 | + }  | 
                                                        |
| 1218 | 1218 | |
| 1219 | 1219 | |
| 1220 | - // ---- Entry validation  | 
                                                        |
| 1220 | + // ---- Entry validation  | 
                                                        |
| 1221 | 1221 | |
| 1222 | - /**  | 
                                                        |
| 1223 | - * Add field keys that Gravity Forms expects.  | 
                                                        |
| 1224 | - *  | 
                                                        |
| 1225 | - * @see GFFormDisplay::validate()  | 
                                                        |
| 1226 | - * @param array $form GF Form  | 
                                                        |
| 1227 | - * @return array Modified GF Form  | 
                                                        |
| 1228 | - */  | 
                                                        |
| 1229 | -    public function gform_pre_validation( $form ) { | 
                                                        |
| 1222 | + /**  | 
                                                        |
| 1223 | + * Add field keys that Gravity Forms expects.  | 
                                                        |
| 1224 | + *  | 
                                                        |
| 1225 | + * @see GFFormDisplay::validate()  | 
                                                        |
| 1226 | + * @param array $form GF Form  | 
                                                        |
| 1227 | + * @return array Modified GF Form  | 
                                                        |
| 1228 | + */  | 
                                                        |
| 1229 | +	public function gform_pre_validation( $form ) { | 
                                                        |
| 1230 | 1230 | |
| 1231 | -        if( ! $this->verify_nonce() ) { | 
                                                        |
| 1232 | - return $form;  | 
                                                        |
| 1233 | - }  | 
                                                        |
| 1231 | +		if( ! $this->verify_nonce() ) { | 
                                                        |
| 1232 | + return $form;  | 
                                                        |
| 1233 | + }  | 
                                                        |
| 1234 | 1234 | |
| 1235 | - // Fix PHP warning regarding undefined index.  | 
                                                        |
| 1236 | -        foreach ( $form['fields'] as &$field) { | 
                                                        |
| 1235 | + // Fix PHP warning regarding undefined index.  | 
                                                        |
| 1236 | +		foreach ( $form['fields'] as &$field) { | 
                                                        |
| 1237 | 1237 | |
| 1238 | - // This is because we're doing admin form pretending to be front-end, so Gravity Forms  | 
                                                        |
| 1239 | - // expects certain field array items to be set.  | 
                                                        |
| 1240 | -            foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { | 
                                                        |
| 1241 | -	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; | 
                                                        |
| 1242 | - }  | 
                                                        |
| 1238 | + // This is because we're doing admin form pretending to be front-end, so Gravity Forms  | 
                                                        |
| 1239 | + // expects certain field array items to be set.  | 
                                                        |
| 1240 | +			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { | 
                                                        |
| 1241 | +				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; | 
                                                        |
| 1242 | + }  | 
                                                        |
| 1243 | 1243 | |
| 1244 | - // unset emailConfirmEnabled for email type fields  | 
                                                        |
| 1245 | -           /* if( 'email' === $field['type'] && !empty( $field['emailConfirmEnabled'] ) ) { | 
                                                        |
| 1244 | + // unset emailConfirmEnabled for email type fields  | 
                                                        |
| 1245 | +		   /* if( 'email' === $field['type'] && !empty( $field['emailConfirmEnabled'] ) ) { | 
                                                        |
| 1246 | 1246 | $field['emailConfirmEnabled'] = '';  | 
                                                        
| 1247 | 1247 | }*/  | 
                                                        
| 1248 | 1248 | |
| 1249 | -            switch( RGFormsModel::get_input_type( $field ) ) { | 
                                                        |
| 1249 | +			switch( RGFormsModel::get_input_type( $field ) ) { | 
                                                        |
| 1250 | +  | 
                                                        |
| 1251 | + /**  | 
                                                        |
| 1252 | + * 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.  | 
                                                        |
| 1253 | + *  | 
                                                        |
| 1254 | + * 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.  | 
                                                        |
| 1255 | + *  | 
                                                        |
| 1256 | + * @hack  | 
                                                        |
| 1257 | + */  | 
                                                        |
| 1258 | + case 'fileupload':  | 
                                                        |
| 1259 | +  | 
                                                        |
| 1260 | + // Set the previous value  | 
                                                        |
| 1261 | + $entry = $this->get_entry();  | 
                                                        |
| 1250 | 1262 | |
| 1251 | - /**  | 
                                                        |
| 1252 | - * 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.  | 
                                                        |
| 1253 | - *  | 
                                                        |
| 1254 | - * 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.  | 
                                                        |
| 1255 | - *  | 
                                                        |
| 1256 | - * @hack  | 
                                                        |
| 1257 | - */  | 
                                                        |
| 1258 | - case 'fileupload':  | 
                                                        |
| 1259 | -  | 
                                                        |
| 1260 | - // Set the previous value  | 
                                                        |
| 1261 | - $entry = $this->get_entry();  | 
                                                        |
| 1262 | -  | 
                                                        |
| 1263 | - $input_name = 'input_'.$field->id;  | 
                                                        |
| 1264 | - $form_id = $form['id'];  | 
                                                        |
| 1265 | -  | 
                                                        |
| 1266 | - $value = NULL;  | 
                                                        |
| 1267 | -  | 
                                                        |
| 1268 | - // Use the previous entry value as the default.  | 
                                                        |
| 1269 | -                    if( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1270 | - $value = $entry[ $field->id ];  | 
                                                        |
| 1271 | - }  | 
                                                        |
| 1263 | + $input_name = 'input_'.$field->id;  | 
                                                        |
| 1264 | + $form_id = $form['id'];  | 
                                                        |
| 1272 | 1265 | |
| 1273 | - // If this is a single upload file  | 
                                                        |
| 1274 | -                    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { | 
                                                        |
| 1275 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );  | 
                                                        |
| 1276 | - $value = $file_path['url'];  | 
                                                        |
| 1266 | + $value = NULL;  | 
                                                        |
| 1277 | 1267 | |
| 1278 | -                    } else { | 
                                                        |
| 1279 | -  | 
                                                        |
| 1280 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields  | 
                                                        |
| 1281 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511  | 
                                                        |
| 1282 | -                        $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); | 
                                                        |
| 1283 | -  | 
                                                        |
| 1284 | - }  | 
                                                        |
| 1285 | -  | 
                                                        |
| 1286 | -                    if( rgar($field, "multipleFiles") ) { | 
                                                        |
| 1287 | -  | 
                                                        |
| 1288 | - // If there are fresh uploads, process and merge them.  | 
                                                        |
| 1289 | - // Otherwise, use the passed values, which should be json-encoded array of URLs  | 
                                                        |
| 1290 | -                        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { | 
                                                        |
| 1291 | - $value = empty( $value ) ? '[]' : $value;  | 
                                                        |
| 1292 | - $value = stripslashes_deep( $value );  | 
                                                        |
| 1293 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());  | 
                                                        |
| 1294 | - }  | 
                                                        |
| 1268 | + // Use the previous entry value as the default.  | 
                                                        |
| 1269 | +					if( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1270 | + $value = $entry[ $field->id ];  | 
                                                        |
| 1271 | + }  | 
                                                        |
| 1295 | 1272 | |
| 1296 | -                    } else { | 
                                                        |
| 1273 | + // If this is a single upload file  | 
                                                        |
| 1274 | +					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { | 
                                                        |
| 1275 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );  | 
                                                        |
| 1276 | + $value = $file_path['url'];  | 
                                                        |
| 1297 | 1277 | |
| 1298 | - // A file already exists when editing an entry  | 
                                                        |
| 1299 | - // We set this to solve issue when file upload fields are required.  | 
                                                        |
| 1300 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;  | 
                                                        |
| 1278 | +					} else { | 
                                                        |
| 1301 | 1279 | |
| 1302 | - }  | 
                                                        |
| 1280 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields  | 
                                                        |
| 1281 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511  | 
                                                        |
| 1282 | +						$_FILES[ $input_name ] = array('name' => '', 'size' => '' ); | 
                                                        |
| 1303 | 1283 | |
| 1304 | - $this->entry[ $input_name ] = $value;  | 
                                                        |
| 1305 | - $_POST[ $input_name ] = $value;  | 
                                                        |
| 1284 | + }  | 
                                                        |
| 1306 | 1285 | |
| 1307 | - break;  | 
                                                        |
| 1286 | +					if( rgar($field, "multipleFiles") ) { | 
                                                        |
| 1308 | 1287 | |
| 1309 | - case 'number':  | 
                                                        |
| 1310 | - // Fix "undefined index" issue at line 1286 in form_display.php  | 
                                                        |
| 1311 | -                    if( !isset( $_POST['input_'.$field->id ] ) ) { | 
                                                        |
| 1312 | - $_POST['input_'.$field->id ] = NULL;  | 
                                                        |
| 1313 | - }  | 
                                                        |
| 1314 | - break;  | 
                                                        |
| 1315 | - case 'captcha':  | 
                                                        |
| 1316 | - // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php  | 
                                                        |
| 1317 | - $_POST['recaptcha_challenge_field'] = NULL;  | 
                                                        |
| 1318 | - $_POST['recaptcha_response_field'] = NULL;  | 
                                                        |
| 1319 | - break;  | 
                                                        |
| 1320 | - }  | 
                                                        |
| 1288 | + // If there are fresh uploads, process and merge them.  | 
                                                        |
| 1289 | + // Otherwise, use the passed values, which should be json-encoded array of URLs  | 
                                                        |
| 1290 | +						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { | 
                                                        |
| 1291 | + $value = empty( $value ) ? '[]' : $value;  | 
                                                        |
| 1292 | + $value = stripslashes_deep( $value );  | 
                                                        |
| 1293 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());  | 
                                                        |
| 1294 | + }  | 
                                                        |
| 1321 | 1295 | |
| 1322 | - }  | 
                                                        |
| 1296 | +					} else { | 
                                                        |
| 1323 | 1297 | |
| 1324 | - return $form;  | 
                                                        |
| 1325 | - }  | 
                                                        |
| 1298 | + // A file already exists when editing an entry  | 
                                                        |
| 1299 | + // We set this to solve issue when file upload fields are required.  | 
                                                        |
| 1300 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;  | 
                                                        |
| 1326 | 1301 | |
| 1302 | + }  | 
                                                        |
| 1327 | 1303 | |
| 1328 | - /**  | 
                                                        |
| 1329 | - * Process validation for a edit entry submission  | 
                                                        |
| 1330 | - *  | 
                                                        |
| 1331 | - * Sets the `is_valid` object var  | 
                                                        |
| 1332 | - *  | 
                                                        |
| 1333 | - * @return void  | 
                                                        |
| 1334 | - */  | 
                                                        |
| 1335 | -    private function validate() { | 
                                                        |
| 1304 | + $this->entry[ $input_name ] = $value;  | 
                                                        |
| 1305 | + $_POST[ $input_name ] = $value;  | 
                                                        |
| 1336 | 1306 | |
| 1337 | - /**  | 
                                                        |
| 1338 | - * If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry  | 
                                                        |
| 1339 | - * GF User Registration Add-on version > 3.x has a different class name  | 
                                                        |
| 1340 | - * @since 1.16.2  | 
                                                        |
| 1341 | - */  | 
                                                        |
| 1342 | -        if ( class_exists( 'GF_User_Registration' ) ) { | 
                                                        |
| 1343 | - remove_filter( 'gform_validation', array( GF_User_Registration::get_instance(), 'validate' ) );  | 
                                                        |
| 1344 | -        } else  if ( class_exists( 'GFUser' ) ) { | 
                                                        |
| 1345 | - remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) );  | 
                                                        |
| 1346 | - }  | 
                                                        |
| 1307 | + break;  | 
                                                        |
| 1347 | 1308 | |
| 1309 | + case 'number':  | 
                                                        |
| 1310 | + // Fix "undefined index" issue at line 1286 in form_display.php  | 
                                                        |
| 1311 | +					if( !isset( $_POST['input_'.$field->id ] ) ) { | 
                                                        |
| 1312 | + $_POST['input_'.$field->id ] = NULL;  | 
                                                        |
| 1313 | + }  | 
                                                        |
| 1314 | + break;  | 
                                                        |
| 1315 | + case 'captcha':  | 
                                                        |
| 1316 | + // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php  | 
                                                        |
| 1317 | + $_POST['recaptcha_challenge_field'] = NULL;  | 
                                                        |
| 1318 | + $_POST['recaptcha_response_field'] = NULL;  | 
                                                        |
| 1319 | + break;  | 
                                                        |
| 1320 | + }  | 
                                                        |
| 1321 | +  | 
                                                        |
| 1322 | + }  | 
                                                        |
| 1323 | +  | 
                                                        |
| 1324 | + return $form;  | 
                                                        |
| 1325 | + }  | 
                                                        |
| 1326 | +  | 
                                                        |
| 1327 | +  | 
                                                        |
| 1328 | + /**  | 
                                                        |
| 1329 | + * Process validation for a edit entry submission  | 
                                                        |
| 1330 | + *  | 
                                                        |
| 1331 | + * Sets the `is_valid` object var  | 
                                                        |
| 1332 | + *  | 
                                                        |
| 1333 | + * @return void  | 
                                                        |
| 1334 | + */  | 
                                                        |
| 1335 | +	private function validate() { | 
                                                        |
| 1348 | 1336 | |
| 1349 | - /**  | 
                                                        |
| 1350 | - * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.  | 
                                                        |
| 1351 | - * You can enter whatever you want!  | 
                                                        |
| 1352 | - * We try validating, and customize the results using `self::custom_validation()`  | 
                                                        |
| 1353 | - */  | 
                                                        |
| 1354 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);  | 
                                                        |
| 1337 | + /**  | 
                                                        |
| 1338 | + * If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry  | 
                                                        |
| 1339 | + * GF User Registration Add-on version > 3.x has a different class name  | 
                                                        |
| 1340 | + * @since 1.16.2  | 
                                                        |
| 1341 | + */  | 
                                                        |
| 1342 | +		if ( class_exists( 'GF_User_Registration' ) ) { | 
                                                        |
| 1343 | + remove_filter( 'gform_validation', array( GF_User_Registration::get_instance(), 'validate' ) );  | 
                                                        |
| 1344 | +		} else  if ( class_exists( 'GFUser' ) ) { | 
                                                        |
| 1345 | + remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) );  | 
                                                        |
| 1346 | + }  | 
                                                        |
| 1355 | 1347 | |
| 1356 | - // Needed by the validate funtion  | 
                                                        |
| 1357 | - $failed_validation_page = NULL;  | 
                                                        |
| 1358 | - $field_values = RGForms::post( 'gform_field_values' );  | 
                                                        |
| 1359 | 1348 | |
| 1360 | - // Prevent entry limit from running when editing an entry, also  | 
                                                        |
| 1361 | - // prevent form scheduling from preventing editing  | 
                                                        |
| 1362 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] );  | 
                                                        |
| 1349 | + /**  | 
                                                        |
| 1350 | + * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.  | 
                                                        |
| 1351 | + * You can enter whatever you want!  | 
                                                        |
| 1352 | + * We try validating, and customize the results using `self::custom_validation()`  | 
                                                        |
| 1353 | + */  | 
                                                        |
| 1354 | + add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);  | 
                                                        |
| 1363 | 1355 | |
| 1364 | - // Hide fields depending on Edit Entry settings  | 
                                                        |
| 1365 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );  | 
                                                        |
| 1356 | + // Needed by the validate funtion  | 
                                                        |
| 1357 | + $failed_validation_page = NULL;  | 
                                                        |
| 1358 | + $field_values = RGForms::post( 'gform_field_values' );  | 
                                                        |
| 1366 | 1359 | |
| 1367 | - $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );  | 
                                                        |
| 1360 | + // Prevent entry limit from running when editing an entry, also  | 
                                                        |
| 1361 | + // prevent form scheduling from preventing editing  | 
                                                        |
| 1362 | + unset( $this->form['limitEntries'], $this->form['scheduleForm'] );  | 
                                                        |
| 1368 | 1363 | |
| 1369 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );  | 
                                                        |
| 1370 | - }  | 
                                                        |
| 1364 | + // Hide fields depending on Edit Entry settings  | 
                                                        |
| 1365 | + $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );  | 
                                                        |
| 1371 | 1366 | |
| 1367 | + $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );  | 
                                                        |
| 1372 | 1368 | |
| 1373 | - /**  | 
                                                        |
| 1374 | - * Make validation work for Edit Entry  | 
                                                        |
| 1375 | - *  | 
                                                        |
| 1376 | - * Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end  | 
                                                        |
| 1377 | - * form pretending to be a back-end form), validate() doesn't know we _can't_ edit post  | 
                                                        |
| 1378 | - * fields. This goes through all the fields and if they're an invalid post field, we  | 
                                                        |
| 1379 | - * set them as valid. If there are still issues, we'll return false.  | 
                                                        |
| 1380 | - *  | 
                                                        |
| 1381 | - * @param [type] $validation_results [description]  | 
                                                        |
| 1382 | - * @return [type] [description]  | 
                                                        |
| 1383 | - */  | 
                                                        |
| 1384 | -    public function custom_validation( $validation_results ) { | 
                                                        |
| 1369 | + remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );  | 
                                                        |
| 1370 | + }  | 
                                                        |
| 1385 | 1371 | |
| 1386 | -        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); | 
                                                        |
| 1387 | 1372 | |
| 1388 | -        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); | 
                                                        |
| 1373 | + /**  | 
                                                        |
| 1374 | + * Make validation work for Edit Entry  | 
                                                        |
| 1375 | + *  | 
                                                        |
| 1376 | + * Because we're calling the GFFormDisplay::validate() in an unusual way (as a front-end  | 
                                                        |
| 1377 | + * form pretending to be a back-end form), validate() doesn't know we _can't_ edit post  | 
                                                        |
| 1378 | + * fields. This goes through all the fields and if they're an invalid post field, we  | 
                                                        |
| 1379 | + * set them as valid. If there are still issues, we'll return false.  | 
                                                        |
| 1380 | + *  | 
                                                        |
| 1381 | + * @param [type] $validation_results [description]  | 
                                                        |
| 1382 | + * @return [type] [description]  | 
                                                        |
| 1383 | + */  | 
                                                        |
| 1384 | +	public function custom_validation( $validation_results ) { | 
                                                        |
| 1389 | 1385 | |
| 1390 | - $gv_valid = true;  | 
                                                        |
| 1386 | +		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); | 
                                                        |
| 1391 | 1387 | |
| 1392 | -        foreach ( $validation_results['form']['fields'] as $key => &$field ) { | 
                                                        |
| 1388 | +		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); | 
                                                        |
| 1393 | 1389 | |
| 1394 | - $value = RGFormsModel::get_field_value( $field );  | 
                                                        |
| 1395 | - $field_type = RGFormsModel::get_input_type( $field );  | 
                                                        |
| 1390 | + $gv_valid = true;  | 
                                                        |
| 1396 | 1391 | |
| 1397 | - // Validate always  | 
                                                        |
| 1398 | -            switch ( $field_type ) { | 
                                                        |
| 1392 | +		foreach ( $validation_results['form']['fields'] as $key => &$field ) { | 
                                                        |
| 1399 | 1393 | |
| 1394 | + $value = RGFormsModel::get_field_value( $field );  | 
                                                        |
| 1395 | + $field_type = RGFormsModel::get_input_type( $field );  | 
                                                        |
| 1400 | 1396 | |
| 1401 | - case 'fileupload' :  | 
                                                        |
| 1402 | - case 'post_image':  | 
                                                        |
| 1397 | + // Validate always  | 
                                                        |
| 1398 | +			switch ( $field_type ) { | 
                                                        |
| 1403 | 1399 | |
| 1404 | - // in case nothing is uploaded but there are already files saved  | 
                                                        |
| 1405 | -                    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { | 
                                                        |
| 1406 | - $field->failed_validation = false;  | 
                                                        |
| 1407 | - unset( $field->validation_message );  | 
                                                        |
| 1408 | - }  | 
                                                        |
| 1409 | 1400 | |
| 1410 | - // validate if multi file upload reached max number of files [maxFiles] => 2  | 
                                                        |
| 1411 | -                    if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { | 
                                                        |
| 1401 | + case 'fileupload' :  | 
                                                        |
| 1402 | + case 'post_image':  | 
                                                        |
| 1412 | 1403 | |
| 1413 | - $input_name = 'input_' . $field->id;  | 
                                                        |
| 1414 | - //uploaded  | 
                                                        |
| 1415 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();  | 
                                                        |
| 1404 | + // in case nothing is uploaded but there are already files saved  | 
                                                        |
| 1405 | +					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { | 
                                                        |
| 1406 | + $field->failed_validation = false;  | 
                                                        |
| 1407 | + unset( $field->validation_message );  | 
                                                        |
| 1408 | + }  | 
                                                        |
| 1416 | 1409 | |
| 1417 | - //existent  | 
                                                        |
| 1418 | - $entry = $this->get_entry();  | 
                                                        |
| 1419 | - $value = NULL;  | 
                                                        |
| 1420 | -                        if( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1421 | - $value = json_decode( $entry[ $field->id ], true );  | 
                                                        |
| 1422 | - }  | 
                                                        |
| 1410 | + // validate if multi file upload reached max number of files [maxFiles] => 2  | 
                                                        |
| 1411 | +					if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { | 
                                                        |
| 1423 | 1412 | |
| 1424 | - // count uploaded files and existent entry files  | 
                                                        |
| 1425 | - $count_files = count( $file_names ) + count( $value );  | 
                                                        |
| 1413 | + $input_name = 'input_' . $field->id;  | 
                                                        |
| 1414 | + //uploaded  | 
                                                        |
| 1415 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();  | 
                                                        |
| 1426 | 1416 | |
| 1427 | -                        if( $count_files > $field->maxFiles ) { | 
                                                        |
| 1428 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );  | 
                                                        |
| 1429 | - $field->failed_validation = 1;  | 
                                                        |
| 1430 | - $gv_valid = false;  | 
                                                        |
| 1417 | + //existent  | 
                                                        |
| 1418 | + $entry = $this->get_entry();  | 
                                                        |
| 1419 | + $value = NULL;  | 
                                                        |
| 1420 | +						if( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1421 | + $value = json_decode( $entry[ $field->id ], true );  | 
                                                        |
| 1422 | + }  | 
                                                        |
| 1431 | 1423 | |
| 1432 | - // in case of error make sure the newest upload files are removed from the upload input  | 
                                                        |
| 1433 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;  | 
                                                        |
| 1434 | - }  | 
                                                        |
| 1424 | + // count uploaded files and existent entry files  | 
                                                        |
| 1425 | + $count_files = count( $file_names ) + count( $value );  | 
                                                        |
| 1435 | 1426 | |
| 1436 | - }  | 
                                                        |
| 1427 | +						if( $count_files > $field->maxFiles ) { | 
                                                        |
| 1428 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );  | 
                                                        |
| 1429 | + $field->failed_validation = 1;  | 
                                                        |
| 1430 | + $gv_valid = false;  | 
                                                        |
| 1437 | 1431 | |
| 1432 | + // in case of error make sure the newest upload files are removed from the upload input  | 
                                                        |
| 1433 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;  | 
                                                        |
| 1434 | + }  | 
                                                        |
| 1438 | 1435 | |
| 1439 | - break;  | 
                                                        |
| 1436 | + }  | 
                                                        |
| 1440 | 1437 | |
| 1441 | - }  | 
                                                        |
| 1442 | 1438 | |
| 1443 | - // This field has failed validation.  | 
                                                        |
| 1444 | -            if( !empty( $field->failed_validation ) ) { | 
                                                        |
| 1439 | + break;  | 
                                                        |
| 1445 | 1440 | |
| 1446 | - do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );  | 
                                                        |
| 1441 | + }  | 
                                                        |
| 1447 | 1442 | |
| 1448 | -                switch ( $field_type ) { | 
                                                        |
| 1443 | + // This field has failed validation.  | 
                                                        |
| 1444 | +			if( !empty( $field->failed_validation ) ) { | 
                                                        |
| 1449 | 1445 | |
| 1450 | - // Captchas don't need to be re-entered.  | 
                                                        |
| 1451 | - case 'captcha':  | 
                                                        |
| 1446 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );  | 
                                                        |
| 1452 | 1447 | |
| 1453 | - // Post Image fields aren't editable, so we un-fail them.  | 
                                                        |
| 1454 | - case 'post_image':  | 
                                                        |
| 1455 | - $field->failed_validation = false;  | 
                                                        |
| 1456 | - unset( $field->validation_message );  | 
                                                        |
| 1457 | - break;  | 
                                                        |
| 1448 | +				switch ( $field_type ) { | 
                                                        |
| 1458 | 1449 | |
| 1459 | - }  | 
                                                        |
| 1450 | + // Captchas don't need to be re-entered.  | 
                                                        |
| 1451 | + case 'captcha':  | 
                                                        |
| 1460 | 1452 | |
| 1461 | - // You can't continue inside a switch, so we do it after.  | 
                                                        |
| 1462 | -                if( empty( $field->failed_validation ) ) { | 
                                                        |
| 1463 | - continue;  | 
                                                        |
| 1464 | - }  | 
                                                        |
| 1453 | + // Post Image fields aren't editable, so we un-fail them.  | 
                                                        |
| 1454 | + case 'post_image':  | 
                                                        |
| 1455 | + $field->failed_validation = false;  | 
                                                        |
| 1456 | + unset( $field->validation_message );  | 
                                                        |
| 1457 | + break;  | 
                                                        |
| 1465 | 1458 | |
| 1466 | - // checks if the No Duplicates option is not validating entry against itself, since  | 
                                                        |
| 1467 | - // we're editing a stored entry, it would also assume it's a duplicate.  | 
                                                        |
| 1468 | -                if( !empty( $field->noDuplicates ) ) { | 
                                                        |
| 1459 | + }  | 
                                                        |
| 1469 | 1460 | |
| 1470 | - $entry = $this->get_entry();  | 
                                                        |
| 1461 | + // You can't continue inside a switch, so we do it after.  | 
                                                        |
| 1462 | +				if( empty( $field->failed_validation ) ) { | 
                                                        |
| 1463 | + continue;  | 
                                                        |
| 1464 | + }  | 
                                                        |
| 1471 | 1465 | |
| 1472 | - // If the value of the entry is the same as the stored value  | 
                                                        |
| 1473 | - // Then we can assume it's not a duplicate, it's the same.  | 
                                                        |
| 1474 | -                    if( !empty( $entry ) && $value == $entry[ $field->id ] ) { | 
                                                        |
| 1475 | - //if value submitted was not changed, then don't validate  | 
                                                        |
| 1476 | - $field->failed_validation = false;  | 
                                                        |
| 1466 | + // checks if the No Duplicates option is not validating entry against itself, since  | 
                                                        |
| 1467 | + // we're editing a stored entry, it would also assume it's a duplicate.  | 
                                                        |
| 1468 | +				if( !empty( $field->noDuplicates ) ) { | 
                                                        |
| 1477 | 1469 | |
| 1478 | - unset( $field->validation_message );  | 
                                                        |
| 1470 | + $entry = $this->get_entry();  | 
                                                        |
| 1479 | 1471 | |
| 1480 | -                        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); | 
                                                        |
| 1472 | + // If the value of the entry is the same as the stored value  | 
                                                        |
| 1473 | + // Then we can assume it's not a duplicate, it's the same.  | 
                                                        |
| 1474 | +					if( !empty( $entry ) && $value == $entry[ $field->id ] ) { | 
                                                        |
| 1475 | + //if value submitted was not changed, then don't validate  | 
                                                        |
| 1476 | + $field->failed_validation = false;  | 
                                                        |
| 1481 | 1477 | |
| 1482 | - continue;  | 
                                                        |
| 1483 | - }  | 
                                                        |
| 1484 | - }  | 
                                                        |
| 1478 | + unset( $field->validation_message );  | 
                                                        |
| 1485 | 1479 | |
| 1486 | - // if here then probably we are facing the validation 'At least one field must be filled out'  | 
                                                        |
| 1487 | -                if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) { | 
                                                        |
| 1488 | - unset( $field->validation_message );  | 
                                                        |
| 1489 | - $field->validation_message = false;  | 
                                                        |
| 1490 | - continue;  | 
                                                        |
| 1491 | - }  | 
                                                        |
| 1480 | +						do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); | 
                                                        |
| 1492 | 1481 | |
| 1493 | - $gv_valid = false;  | 
                                                        |
| 1482 | + continue;  | 
                                                        |
| 1483 | + }  | 
                                                        |
| 1484 | + }  | 
                                                        |
| 1494 | 1485 | |
| 1495 | - }  | 
                                                        |
| 1486 | + // if here then probably we are facing the validation 'At least one field must be filled out'  | 
                                                        |
| 1487 | +				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) { | 
                                                        |
| 1488 | + unset( $field->validation_message );  | 
                                                        |
| 1489 | + $field->validation_message = false;  | 
                                                        |
| 1490 | + continue;  | 
                                                        |
| 1491 | + }  | 
                                                        |
| 1496 | 1492 | |
| 1497 | - }  | 
                                                        |
| 1493 | + $gv_valid = false;  | 
                                                        |
| 1498 | 1494 | |
| 1499 | - $validation_results['is_valid'] = $gv_valid;  | 
                                                        |
| 1495 | + }  | 
                                                        |
| 1500 | 1496 | |
| 1501 | -        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); | 
                                                        |
| 1497 | + }  | 
                                                        |
| 1502 | 1498 | |
| 1503 | - // We'll need this result when rendering the form ( on GFFormDisplay::get_form )  | 
                                                        |
| 1504 | - $this->form_after_validation = $validation_results['form'];  | 
                                                        |
| 1499 | + $validation_results['is_valid'] = $gv_valid;  | 
                                                        |
| 1505 | 1500 | |
| 1506 | - return $validation_results;  | 
                                                        |
| 1507 | - }  | 
                                                        |
| 1501 | +		do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); | 
                                                        |
| 1508 | 1502 | |
| 1503 | + // We'll need this result when rendering the form ( on GFFormDisplay::get_form )  | 
                                                        |
| 1504 | + $this->form_after_validation = $validation_results['form'];  | 
                                                        |
| 1509 | 1505 | |
| 1510 | - /**  | 
                                                        |
| 1511 | - * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!  | 
                                                        |
| 1512 | - * Get the current entry and set it if it's not yet set.  | 
                                                        |
| 1513 | - * @return array Gravity Forms entry array  | 
                                                        |
| 1514 | - */  | 
                                                        |
| 1515 | -    public function get_entry() { | 
                                                        |
| 1506 | + return $validation_results;  | 
                                                        |
| 1507 | + }  | 
                                                        |
| 1516 | 1508 | |
| 1517 | -        if( empty( $this->entry ) ) { | 
                                                        |
| 1518 | - // Get the database value of the entry that's being edited  | 
                                                        |
| 1519 | - $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );  | 
                                                        |
| 1520 | - }  | 
                                                        |
| 1521 | 1509 | |
| 1522 | - return $this->entry;  | 
                                                        |
| 1523 | - }  | 
                                                        |
| 1510 | + /**  | 
                                                        |
| 1511 | + * TODO: This seems to be hacky... we should remove it. Entry is set when updating the form using setup_vars()!  | 
                                                        |
| 1512 | + * Get the current entry and set it if it's not yet set.  | 
                                                        |
| 1513 | + * @return array Gravity Forms entry array  | 
                                                        |
| 1514 | + */  | 
                                                        |
| 1515 | +	public function get_entry() { | 
                                                        |
| 1524 | 1516 | |
| 1517 | +		if( empty( $this->entry ) ) { | 
                                                        |
| 1518 | + // Get the database value of the entry that's being edited  | 
                                                        |
| 1519 | + $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );  | 
                                                        |
| 1520 | + }  | 
                                                        |
| 1525 | 1521 | |
| 1522 | + return $this->entry;  | 
                                                        |
| 1523 | + }  | 
                                                        |
| 1526 | 1524 | |
| 1527 | - // --- Filters  | 
                                                        |
| 1528 | 1525 | |
| 1529 | - /**  | 
                                                        |
| 1530 | - * Get the Edit Entry fields as configured in the View  | 
                                                        |
| 1531 | - *  | 
                                                        |
| 1532 | - * @since 1.8  | 
                                                        |
| 1533 | - *  | 
                                                        |
| 1534 | - * @param int $view_id  | 
                                                        |
| 1535 | - *  | 
                                                        |
| 1536 | - * @return array Array of fields that are configured in the Edit tab in the Admin  | 
                                                        |
| 1537 | - */  | 
                                                        |
| 1538 | -    private function get_configured_edit_fields( $form, $view_id ) { | 
                                                        |
| 1539 | 1526 | |
| 1540 | - // Get all fields for form  | 
                                                        |
| 1541 | - $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );  | 
                                                        |
| 1527 | + // --- Filters  | 
                                                        |
| 1542 | 1528 | |
| 1543 | - // If edit tab not yet configured, show all fields  | 
                                                        |
| 1544 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;  | 
                                                        |
| 1529 | + /**  | 
                                                        |
| 1530 | + * Get the Edit Entry fields as configured in the View  | 
                                                        |
| 1531 | + *  | 
                                                        |
| 1532 | + * @since 1.8  | 
                                                        |
| 1533 | + *  | 
                                                        |
| 1534 | + * @param int $view_id  | 
                                                        |
| 1535 | + *  | 
                                                        |
| 1536 | + * @return array Array of fields that are configured in the Edit tab in the Admin  | 
                                                        |
| 1537 | + */  | 
                                                        |
| 1538 | +	private function get_configured_edit_fields( $form, $view_id ) { | 
                                                        |
| 1545 | 1539 | |
| 1546 | - // Hide fields depending on admin settings  | 
                                                        |
| 1547 | - $fields = $this->filter_fields( $form['fields'], $edit_fields );  | 
                                                        |
| 1540 | + // Get all fields for form  | 
                                                        |
| 1541 | + $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );  | 
                                                        |
| 1548 | 1542 | |
| 1549 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.  | 
                                                        |
| 1550 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );  | 
                                                        |
| 1543 | + // If edit tab not yet configured, show all fields  | 
                                                        |
| 1544 | + $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;  | 
                                                        |
| 1551 | 1545 | |
| 1552 | - /**  | 
                                                        |
| 1553 | - * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form  | 
                                                        |
| 1554 | - * @since 1.17  | 
                                                        |
| 1555 | - * @param GF_Field[] $fields Gravity Forms form fields  | 
                                                        |
| 1556 | - * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration  | 
                                                        |
| 1557 | - * @param array $form GF Form array (`fields` key modified to have only fields configured to show in Edit Entry)  | 
                                                        |
| 1558 | - * @param int $view_id View ID  | 
                                                        |
| 1559 | - */  | 
                                                        |
| 1560 | - $fields = apply_filters( 'gravityview/edit_entry/form_fields', $fields, $edit_fields, $form, $view_id );  | 
                                                        |
| 1546 | + // Hide fields depending on admin settings  | 
                                                        |
| 1547 | + $fields = $this->filter_fields( $form['fields'], $edit_fields );  | 
                                                        |
| 1561 | 1548 | |
| 1562 | - return $fields;  | 
                                                        |
| 1563 | - }  | 
                                                        |
| 1549 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.  | 
                                                        |
| 1550 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );  | 
                                                        |
| 1564 | 1551 | |
| 1552 | + /**  | 
                                                        |
| 1553 | + * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form  | 
                                                        |
| 1554 | + * @since 1.17  | 
                                                        |
| 1555 | + * @param GF_Field[] $fields Gravity Forms form fields  | 
                                                        |
| 1556 | + * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration  | 
                                                        |
| 1557 | + * @param array $form GF Form array (`fields` key modified to have only fields configured to show in Edit Entry)  | 
                                                        |
| 1558 | + * @param int $view_id View ID  | 
                                                        |
| 1559 | + */  | 
                                                        |
| 1560 | + $fields = apply_filters( 'gravityview/edit_entry/form_fields', $fields, $edit_fields, $form, $view_id );  | 
                                                        |
| 1565 | 1561 | |
| 1566 | - /**  | 
                                                        |
| 1567 | - * Filter area fields based on specified conditions  | 
                                                        |
| 1568 | - * - This filter removes the fields that have calculation configured  | 
                                                        |
| 1569 | - *  | 
                                                        |
| 1570 | - * @uses GravityView_Edit_Entry::user_can_edit_field() Check caps  | 
                                                        |
| 1571 | - * @access private  | 
                                                        |
| 1572 | - * @param GF_Field[] $fields  | 
                                                        |
| 1573 | - * @param array $configured_fields  | 
                                                        |
| 1574 | - * @since 1.5  | 
                                                        |
| 1575 | - * @return array $fields  | 
                                                        |
| 1576 | - */  | 
                                                        |
| 1577 | -    private function filter_fields( $fields, $configured_fields ) { | 
                                                        |
| 1562 | + return $fields;  | 
                                                        |
| 1563 | + }  | 
                                                        |
| 1578 | 1564 | |
| 1579 | -        if( empty( $fields ) || !is_array( $fields ) ) { | 
                                                        |
| 1580 | - return $fields;  | 
                                                        |
| 1581 | - }  | 
                                                        |
| 1582 | -  | 
                                                        |
| 1583 | - $edit_fields = array();  | 
                                                        |
| 1584 | -  | 
                                                        |
| 1585 | - $field_type_blacklist = array(  | 
                                                        |
| 1586 | - 'page',  | 
                                                        |
| 1587 | - );  | 
                                                        |
| 1588 | -  | 
                                                        |
| 1589 | - /**  | 
                                                        |
| 1590 | - * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable.  | 
                                                        |
| 1591 | - * @since 1.9.1  | 
                                                        |
| 1592 | - * @param boolean $hide_product_fields Whether to hide product fields in the editor. Default: false  | 
                                                        |
| 1593 | - */  | 
                                                        |
| 1594 | - $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );  | 
                                                        |
| 1595 | -  | 
                                                        |
| 1596 | -	    if( $hide_product_fields ) { | 
                                                        |
| 1597 | - $field_type_blacklist[] = 'option';  | 
                                                        |
| 1598 | - $field_type_blacklist[] = 'quantity';  | 
                                                        |
| 1599 | - $field_type_blacklist[] = 'product';  | 
                                                        |
| 1600 | - $field_type_blacklist[] = 'total';  | 
                                                        |
| 1601 | - $field_type_blacklist[] = 'shipping';  | 
                                                        |
| 1602 | - $field_type_blacklist[] = 'calculation';  | 
                                                        |
| 1603 | - }  | 
                                                        |
| 1604 | -  | 
                                                        |
| 1605 | - // First, remove blacklist or calculation fields  | 
                                                        |
| 1606 | -        foreach ( $fields as $key => $field ) { | 
                                                        |
| 1607 | -  | 
                                                        |
| 1608 | - // Remove the fields that have calculation properties and keep them to be used later  | 
                                                        |
| 1609 | - // @since 1.16.2  | 
                                                        |
| 1610 | -            if( $field->has_calculation() ) { | 
                                                        |
| 1611 | - $this->fields_with_calculation[] = $field;  | 
                                                        |
| 1612 | - // don't remove the calculation fields on form render.  | 
                                                        |
| 1613 | - }  | 
                                                        |
| 1614 | -  | 
                                                        |
| 1615 | - // process total field after all fields have been saved  | 
                                                        |
| 1616 | -            if ( $field->type == 'total' ) { | 
                                                        |
| 1617 | - $this->total_fields[] = $field;  | 
                                                        |
| 1618 | - unset( $fields[ $key ] );  | 
                                                        |
| 1619 | - }  | 
                                                        |
| 1620 | -  | 
                                                        |
| 1621 | -            if( in_array( $field->type, $field_type_blacklist ) ) { | 
                                                        |
| 1622 | - unset( $fields[ $key ] );  | 
                                                        |
| 1623 | - }  | 
                                                        |
| 1624 | - }  | 
                                                        |
| 1625 | -  | 
                                                        |
| 1626 | - // The Edit tab has not been configured, so we return all fields by default.  | 
                                                        |
| 1627 | -        if( empty( $configured_fields ) ) { | 
                                                        |
| 1628 | - return $fields;  | 
                                                        |
| 1629 | - }  | 
                                                        |
| 1630 | -  | 
                                                        |
| 1631 | - // The edit tab has been configured, so we loop through to configured settings  | 
                                                        |
| 1632 | -        foreach ( $configured_fields as $configured_field ) { | 
                                                        |
| 1633 | -  | 
                                                        |
| 1634 | - /** @var GF_Field $field */  | 
                                                        |
| 1635 | -	        foreach ( $fields as $field ) { | 
                                                        |
| 1636 | -  | 
                                                        |
| 1637 | -                if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { | 
                                                        |
| 1638 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field );  | 
                                                        |
| 1639 | - break;  | 
                                                        |
| 1640 | - }  | 
                                                        |
| 1641 | -  | 
                                                        |
| 1642 | - }  | 
                                                        |
| 1643 | -  | 
                                                        |
| 1644 | - }  | 
                                                        |
| 1645 | -  | 
                                                        |
| 1646 | - return $edit_fields;  | 
                                                        |
| 1647 | -  | 
                                                        |
| 1648 | - }  | 
                                                        |
| 1649 | -  | 
                                                        |
| 1650 | - /**  | 
                                                        |
| 1651 | - * Override GF Form field properties with the ones defined on the View  | 
                                                        |
| 1652 | - * @param GF_Field $field GF Form field object  | 
                                                        |
| 1653 | - * @param array $field_setting GV field options  | 
                                                        |
| 1654 | - * @since 1.5  | 
                                                        |
| 1655 | - * @return array|GF_Field  | 
                                                        |
| 1656 | - */  | 
                                                        |
| 1657 | -    private function merge_field_properties( $field, $field_setting ) { | 
                                                        |
| 1658 | -  | 
                                                        |
| 1659 | - $return_field = $field;  | 
                                                        |
| 1660 | -  | 
                                                        |
| 1661 | -        if( empty( $field_setting['show_label'] ) ) { | 
                                                        |
| 1662 | - $return_field->label = '';  | 
                                                        |
| 1663 | -        } elseif ( !empty( $field_setting['custom_label'] ) ) { | 
                                                        |
| 1664 | - $return_field->label = $field_setting['custom_label'];  | 
                                                        |
| 1665 | - }  | 
                                                        |
| 1666 | -  | 
                                                        |
| 1667 | -        if( !empty( $field_setting['custom_class'] ) ) { | 
                                                        |
| 1668 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );  | 
                                                        |
| 1669 | - }  | 
                                                        |
| 1670 | -  | 
                                                        |
| 1671 | - /**  | 
                                                        |
| 1672 | - * Normalize page numbers - avoid conflicts with page validation  | 
                                                        |
| 1673 | - * @since 1.6  | 
                                                        |
| 1674 | - */  | 
                                                        |
| 1675 | - $return_field->pageNumber = 1;  | 
                                                        |
| 1676 | -  | 
                                                        |
| 1677 | - return $return_field;  | 
                                                        |
| 1678 | -  | 
                                                        |
| 1679 | - }  | 
                                                        |
| 1680 | -  | 
                                                        |
| 1681 | - /**  | 
                                                        |
| 1682 | - * Remove fields that shouldn't be visible based on the Gravity Forms adminOnly field property  | 
                                                        |
| 1683 | - *  | 
                                                        |
| 1684 | - * @since 1.9.1  | 
                                                        |
| 1685 | - *  | 
                                                        |
| 1686 | - * @param array|GF_Field[] $fields Gravity Forms form fields  | 
                                                        |
| 1687 | - * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration  | 
                                                        |
| 1688 | - * @param array $form GF Form array  | 
                                                        |
| 1689 | - * @param int $view_id View ID  | 
                                                        |
| 1690 | - *  | 
                                                        |
| 1691 | - * @return array Possibly modified form array  | 
                                                        |
| 1692 | - */  | 
                                                        |
| 1693 | -    private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { | 
                                                        |
| 1694 | -  | 
                                                        |
| 1695 | - /**  | 
                                                        |
| 1696 | - * @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  | 
                                                        |
| 1697 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.  | 
                                                        |
| 1698 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions  | 
                                                        |
| 1699 | - * @since 1.9.1  | 
                                                        |
| 1700 | - * @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.  | 
                                                        |
| 1701 | - * @param array $form GF Form array  | 
                                                        |
| 1702 | - * @param int $view_id View ID  | 
                                                        |
| 1703 | - */  | 
                                                        |
| 1704 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );  | 
                                                        |
| 1705 | -  | 
                                                        |
| 1706 | -	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { | 
                                                        |
| 1707 | -            foreach( $fields as $k => $field ) { | 
                                                        |
| 1708 | -                if( $field->adminOnly ) { | 
                                                        |
| 1709 | - unset( $fields[ $k ] );  | 
                                                        |
| 1710 | - }  | 
                                                        |
| 1711 | - }  | 
                                                        |
| 1712 | - return $fields;  | 
                                                        |
| 1713 | - }  | 
                                                        |
| 1714 | -  | 
                                                        |
| 1715 | -	    foreach( $fields as &$field ) { | 
                                                        |
| 1716 | - $field->adminOnly = false;  | 
                                                        |
| 1717 | - }  | 
                                                        |
| 1718 | -  | 
                                                        |
| 1719 | - return $fields;  | 
                                                        |
| 1720 | - }  | 
                                                        |
| 1721 | -  | 
                                                        |
| 1722 | - // --- Conditional Logic  | 
                                                        |
| 1723 | -  | 
                                                        |
| 1724 | - /**  | 
                                                        |
| 1725 | - * Conditional logic isn't designed to work with forms that already have content. When switching input values,  | 
                                                        |
| 1726 | - * the dependent fields will be blank.  | 
                                                        |
| 1727 | - *  | 
                                                        |
| 1728 | - * Note: This is because GF populates a JavaScript variable with the input values. This is tough to filter at the input level;  | 
                                                        |
| 1729 | - * via the `gform_field_value` filter; it requires lots of legwork. Doing it at the form level is easier.  | 
                                                        |
| 1730 | - *  | 
                                                        |
| 1731 | - * @since 1.17.4  | 
                                                        |
| 1732 | - *  | 
                                                        |
| 1733 | - * @param array $form Gravity Forms array object  | 
                                                        |
| 1734 | - *  | 
                                                        |
| 1735 | - * @return array $form, modified to fix conditional  | 
                                                        |
| 1736 | - */  | 
                                                        |
| 1737 | -    function prefill_conditional_logic( $form ) { | 
                                                        |
| 1738 | -  | 
                                                        |
| 1739 | -        if( ! GFFormDisplay::has_conditional_logic( $form ) ) { | 
                                                        |
| 1740 | - return $form;  | 
                                                        |
| 1741 | - }  | 
                                                        |
| 1742 | -  | 
                                                        |
| 1743 | - // Have Conditional Logic pre-fill fields as if the data were default values  | 
                                                        |
| 1744 | - /** @var GF_Field $field */  | 
                                                        |
| 1745 | -        foreach ( $form['fields'] as &$field ) { | 
                                                        |
| 1746 | -  | 
                                                        |
| 1747 | -            if( 'checkbox' === $field->type ) { | 
                                                        |
| 1748 | -                foreach ( $field->get_entry_inputs() as $key => $input ) { | 
                                                        |
| 1749 | - $input_id = $input['id'];  | 
                                                        |
| 1750 | - $choice = $field->choices[ $key ];  | 
                                                        |
| 1751 | - $value = rgar( $this->entry, $input_id );  | 
                                                        |
| 1752 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value );  | 
                                                        |
| 1753 | -                    if( $match ) { | 
                                                        |
| 1754 | - $field->choices[ $key ]['isSelected'] = true;  | 
                                                        |
| 1755 | - }  | 
                                                        |
| 1756 | - }  | 
                                                        |
| 1757 | -            } else { | 
                                                        |
| 1758 | -  | 
                                                        |
| 1759 | - // We need to run through each field to set the default values  | 
                                                        |
| 1760 | -                foreach ( $this->entry as $field_id => $field_value ) { | 
                                                        |
| 1761 | -  | 
                                                        |
| 1762 | -                    if( floatval( $field_id ) === floatval( $field->id ) ) { | 
                                                        |
| 1763 | -  | 
                                                        |
| 1764 | -                        if( 'list' === $field->type ) { | 
                                                        |
| 1765 | - $list_rows = maybe_unserialize( $field_value );  | 
                                                        |
| 1766 | -  | 
                                                        |
| 1767 | - $list_field_value = array();  | 
                                                        |
| 1768 | -                            foreach ( (array) $list_rows as $row ) { | 
                                                        |
| 1769 | -                                foreach ( (array) $row as $column ) { | 
                                                        |
| 1770 | - $list_field_value[] = $column;  | 
                                                        |
| 1771 | - }  | 
                                                        |
| 1772 | - }  | 
                                                        |
| 1773 | -  | 
                                                        |
| 1774 | - $field->defaultValue = serialize( $list_field_value );  | 
                                                        |
| 1775 | -                        } else { | 
                                                        |
| 1776 | - $field->defaultValue = $field_value;  | 
                                                        |
| 1777 | - }  | 
                                                        |
| 1778 | - }  | 
                                                        |
| 1779 | - }  | 
                                                        |
| 1780 | - }  | 
                                                        |
| 1781 | - }  | 
                                                        |
| 1782 | -  | 
                                                        |
| 1783 | - return $form;  | 
                                                        |
| 1784 | - }  | 
                                                        |
| 1785 | -  | 
                                                        |
| 1786 | - /**  | 
                                                        |
| 1787 | - * Remove the conditional logic rules from the form button and the form fields, if needed.  | 
                                                        |
| 1788 | - *  | 
                                                        |
| 1789 | - * @todo Merge with caller method  | 
                                                        |
| 1790 | - * @since 1.9  | 
                                                        |
| 1791 | - *  | 
                                                        |
| 1792 | - * @param array $form Gravity Forms form  | 
                                                        |
| 1793 | - * @return array Modified form, if not using Conditional Logic  | 
                                                        |
| 1794 | - */  | 
                                                        |
| 1795 | -    private function filter_conditional_logic( $form ) { | 
                                                        |
| 1796 | -  | 
                                                        |
| 1797 | - /**  | 
                                                        |
| 1798 | - * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?  | 
                                                        |
| 1799 | - * @since 1.9  | 
                                                        |
| 1800 | - * @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  | 
                                                        |
| 1801 | - * @param array $form Gravity Forms form  | 
                                                        |
| 1802 | - */  | 
                                                        |
| 1803 | - $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );  | 
                                                        |
| 1804 | -  | 
                                                        |
| 1805 | -        if( $use_conditional_logic ) { | 
                                                        |
| 1806 | - return $form;  | 
                                                        |
| 1807 | - }  | 
                                                        |
| 1808 | -  | 
                                                        |
| 1809 | -        foreach( $form['fields'] as &$field ) { | 
                                                        |
| 1810 | - /* @var GF_Field $field */  | 
                                                        |
| 1811 | - $field->conditionalLogic = null;  | 
                                                        |
| 1812 | - }  | 
                                                        |
| 1813 | -  | 
                                                        |
| 1814 | - unset( $form['button']['conditionalLogic'] );  | 
                                                        |
| 1815 | -  | 
                                                        |
| 1816 | - return $form;  | 
                                                        |
| 1817 | -  | 
                                                        |
| 1818 | - }  | 
                                                        |
| 1819 | -  | 
                                                        |
| 1820 | - /**  | 
                                                        |
| 1821 | - * Disable the Gravity Forms conditional logic script and features on the Edit Entry screen  | 
                                                        |
| 1822 | - *  | 
                                                        |
| 1823 | - * @since 1.9  | 
                                                        |
| 1824 | - *  | 
                                                        |
| 1825 | - * @param $has_conditional_logic  | 
                                                        |
| 1826 | - * @param $form  | 
                                                        |
| 1827 | - * @return mixed|void  | 
                                                        |
| 1828 | - */  | 
                                                        |
| 1829 | -    public function manage_conditional_logic( $has_conditional_logic, $form ) { | 
                                                        |
| 1830 | -  | 
                                                        |
| 1831 | -        if( ! $this->is_edit_entry() ) { | 
                                                        |
| 1832 | - return $has_conditional_logic;  | 
                                                        |
| 1833 | - }  | 
                                                        |
| 1834 | -  | 
                                                        |
| 1835 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */  | 
                                                        |
| 1836 | - return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );  | 
                                                        |
| 1837 | - }  | 
                                                        |
| 1838 | -  | 
                                                        |
| 1839 | -  | 
                                                        |
| 1840 | - // --- User checks and nonces  | 
                                                        |
| 1841 | -  | 
                                                        |
| 1842 | - /**  | 
                                                        |
| 1843 | - * Check if the user can edit the entry  | 
                                                        |
| 1844 | - *  | 
                                                        |
| 1845 | - * - Is the nonce valid?  | 
                                                        |
| 1846 | - * - Does the user have the right caps for the entry  | 
                                                        |
| 1847 | - * - Is the entry in the trash?  | 
                                                        |
| 1848 | - *  | 
                                                        |
| 1849 | - * @todo Move to GVCommon  | 
                                                        |
| 1850 | - *  | 
                                                        |
| 1851 | - * @param boolean $echo Show error messages in the form?  | 
                                                        |
| 1852 | - * @return boolean True: can edit form. False: nope.  | 
                                                        |
| 1853 | - */  | 
                                                        |
| 1854 | -    private function user_can_edit_entry( $echo = false ) { | 
                                                        |
| 1855 | -  | 
                                                        |
| 1856 | - $error = NULL;  | 
                                                        |
| 1857 | -  | 
                                                        |
| 1858 | - /**  | 
                                                        |
| 1859 | - * 1. Permalinks are turned off  | 
                                                        |
| 1860 | - * 2. There are two entries embedded using oEmbed  | 
                                                        |
| 1861 | - * 3. One of the entries has just been saved  | 
                                                        |
| 1862 | - */  | 
                                                        |
| 1863 | -        if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { | 
                                                        |
| 1864 | -  | 
                                                        |
| 1865 | - $error = true;  | 
                                                        |
| 1866 | -  | 
                                                        |
| 1867 | - }  | 
                                                        |
| 1868 | -  | 
                                                        |
| 1869 | -        if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { | 
                                                        |
| 1870 | -  | 
                                                        |
| 1871 | - $error = true;  | 
                                                        |
| 1872 | -  | 
                                                        |
| 1873 | -        } elseif( ! $this->verify_nonce() ) { | 
                                                        |
| 1874 | -  | 
                                                        |
| 1875 | - /**  | 
                                                        |
| 1876 | - * If the Entry is embedded, there may be two entries on the same page.  | 
                                                        |
| 1877 | - * If that's the case, and one is being edited, the other should fail gracefully and not display an error.  | 
                                                        |
| 1878 | - */  | 
                                                        |
| 1879 | -            if( GravityView_oEmbed::getInstance()->get_entry_id() ) { | 
                                                        |
| 1880 | - $error = true;  | 
                                                        |
| 1881 | -            } else { | 
                                                        |
| 1882 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');  | 
                                                        |
| 1883 | - }  | 
                                                        |
| 1884 | -  | 
                                                        |
| 1885 | - }  | 
                                                        |
| 1886 | -  | 
                                                        |
| 1887 | -        if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { | 
                                                        |
| 1888 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview');  | 
                                                        |
| 1889 | - }  | 
                                                        |
| 1890 | -  | 
                                                        |
| 1891 | -        if( $this->entry['status'] === 'trash' ) { | 
                                                        |
| 1892 | -            $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); | 
                                                        |
| 1893 | - }  | 
                                                        |
| 1894 | 1565 | |
| 1895 | - // No errors; everything's fine here!  | 
                                                        |
| 1896 | -        if( empty( $error ) ) { | 
                                                        |
| 1897 | - return true;  | 
                                                        |
| 1898 | - }  | 
                                                        |
| 1566 | + /**  | 
                                                        |
| 1567 | + * Filter area fields based on specified conditions  | 
                                                        |
| 1568 | + * - This filter removes the fields that have calculation configured  | 
                                                        |
| 1569 | + *  | 
                                                        |
| 1570 | + * @uses GravityView_Edit_Entry::user_can_edit_field() Check caps  | 
                                                        |
| 1571 | + * @access private  | 
                                                        |
| 1572 | + * @param GF_Field[] $fields  | 
                                                        |
| 1573 | + * @param array $configured_fields  | 
                                                        |
| 1574 | + * @since 1.5  | 
                                                        |
| 1575 | + * @return array $fields  | 
                                                        |
| 1576 | + */  | 
                                                        |
| 1577 | +	private function filter_fields( $fields, $configured_fields ) { | 
                                                        |
| 1899 | 1578 | |
| 1900 | -        if( $echo && $error !== true ) { | 
                                                        |
| 1579 | +		if( empty( $fields ) || !is_array( $fields ) ) { | 
                                                        |
| 1580 | + return $fields;  | 
                                                        |
| 1581 | + }  | 
                                                        |
| 1901 | 1582 | |
| 1902 | - $error = esc_html( $error );  | 
                                                        |
| 1583 | + $edit_fields = array();  | 
                                                        |
| 1903 | 1584 | |
| 1904 | - /**  | 
                                                        |
| 1905 | - * @since 1.9  | 
                                                        |
| 1906 | - */  | 
                                                        |
| 1907 | -	        if ( ! empty( $this->entry ) ) { | 
                                                        |
| 1908 | -		        $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;" ) ); | 
                                                        |
| 1909 | - }  | 
                                                        |
| 1585 | + $field_type_blacklist = array(  | 
                                                        |
| 1586 | + 'page',  | 
                                                        |
| 1587 | + );  | 
                                                        |
| 1910 | 1588 | |
| 1911 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');  | 
                                                        |
| 1912 | - }  | 
                                                        |
| 1589 | + /**  | 
                                                        |
| 1590 | + * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable.  | 
                                                        |
| 1591 | + * @since 1.9.1  | 
                                                        |
| 1592 | + * @param boolean $hide_product_fields Whether to hide product fields in the editor. Default: false  | 
                                                        |
| 1593 | + */  | 
                                                        |
| 1594 | + $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );  | 
                                                        |
| 1913 | 1595 | |
| 1914 | -        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); | 
                                                        |
| 1596 | +		if( $hide_product_fields ) { | 
                                                        |
| 1597 | + $field_type_blacklist[] = 'option';  | 
                                                        |
| 1598 | + $field_type_blacklist[] = 'quantity';  | 
                                                        |
| 1599 | + $field_type_blacklist[] = 'product';  | 
                                                        |
| 1600 | + $field_type_blacklist[] = 'total';  | 
                                                        |
| 1601 | + $field_type_blacklist[] = 'shipping';  | 
                                                        |
| 1602 | + $field_type_blacklist[] = 'calculation';  | 
                                                        |
| 1603 | + }  | 
                                                        |
| 1915 | 1604 | |
| 1916 | - return false;  | 
                                                        |
| 1917 | - }  | 
                                                        |
| 1918 | -  | 
                                                        |
| 1919 | -  | 
                                                        |
| 1920 | - /**  | 
                                                        |
| 1921 | - * Check whether a field is editable by the current user, and optionally display an error message  | 
                                                        |
| 1922 | - * @uses GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities  | 
                                                        |
| 1923 | - * @param array $field Field or field settings array  | 
                                                        |
| 1924 | - * @param boolean $echo Whether to show error message telling user they aren't allowed  | 
                                                        |
| 1925 | - * @return boolean True: user can edit the current field; False: nope, they can't.  | 
                                                        |
| 1926 | - */  | 
                                                        |
| 1927 | -    private function user_can_edit_field( $field, $echo = false ) { | 
                                                        |
| 1605 | + // First, remove blacklist or calculation fields  | 
                                                        |
| 1606 | +		foreach ( $fields as $key => $field ) { | 
                                                        |
| 1928 | 1607 | |
| 1929 | - $error = NULL;  | 
                                                        |
| 1608 | + // Remove the fields that have calculation properties and keep them to be used later  | 
                                                        |
| 1609 | + // @since 1.16.2  | 
                                                        |
| 1610 | +			if( $field->has_calculation() ) { | 
                                                        |
| 1611 | + $this->fields_with_calculation[] = $field;  | 
                                                        |
| 1612 | + // don't remove the calculation fields on form render.  | 
                                                        |
| 1613 | + }  | 
                                                        |
| 1930 | 1614 | |
| 1931 | -        if( ! $this->check_user_cap_edit_field( $field ) ) { | 
                                                        |
| 1932 | - $error = __( 'You do not have permission to edit this field.', 'gravityview');  | 
                                                        |
| 1933 | - }  | 
                                                        |
| 1615 | + // process total field after all fields have been saved  | 
                                                        |
| 1616 | +			if ( $field->type == 'total' ) { | 
                                                        |
| 1617 | + $this->total_fields[] = $field;  | 
                                                        |
| 1618 | + unset( $fields[ $key ] );  | 
                                                        |
| 1619 | + }  | 
                                                        |
| 1934 | 1620 | |
| 1935 | - // No errors; everything's fine here!  | 
                                                        |
| 1936 | -        if( empty( $error ) ) { | 
                                                        |
| 1937 | - return true;  | 
                                                        |
| 1938 | - }  | 
                                                        |
| 1621 | +			if( in_array( $field->type, $field_type_blacklist ) ) { | 
                                                        |
| 1622 | + unset( $fields[ $key ] );  | 
                                                        |
| 1623 | + }  | 
                                                        |
| 1624 | + }  | 
                                                        |
| 1939 | 1625 | |
| 1940 | -        if( $echo ) { | 
                                                        |
| 1941 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');  | 
                                                        |
| 1942 | - }  | 
                                                        |
| 1943 | -  | 
                                                        |
| 1944 | -        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); | 
                                                        |
| 1626 | + // The Edit tab has not been configured, so we return all fields by default.  | 
                                                        |
| 1627 | +		if( empty( $configured_fields ) ) { | 
                                                        |
| 1628 | + return $fields;  | 
                                                        |
| 1629 | + }  | 
                                                        |
| 1945 | 1630 | |
| 1946 | - return false;  | 
                                                        |
| 1631 | + // The edit tab has been configured, so we loop through to configured settings  | 
                                                        |
| 1632 | +		foreach ( $configured_fields as $configured_field ) { | 
                                                        |
| 1947 | 1633 | |
| 1948 | - }  | 
                                                        |
| 1634 | + /** @var GF_Field $field */  | 
                                                        |
| 1635 | +			foreach ( $fields as $field ) { | 
                                                        |
| 1949 | 1636 | |
| 1637 | +				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { | 
                                                        |
| 1638 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field );  | 
                                                        |
| 1639 | + break;  | 
                                                        |
| 1640 | + }  | 
                                                        |
| 1950 | 1641 | |
| 1951 | - /**  | 
                                                        |
| 1952 | - * checks if user has permissions to edit a specific field  | 
                                                        |
| 1953 | - *  | 
                                                        |
| 1954 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!  | 
                                                        |
| 1955 | - *  | 
                                                        |
| 1956 | - * @param [type] $field [description]  | 
                                                        |
| 1957 | - * @return bool  | 
                                                        |
| 1958 | - */  | 
                                                        |
| 1959 | -    private function check_user_cap_edit_field( $field ) { | 
                                                        |
| 1642 | + }  | 
                                                        |
| 1960 | 1643 | |
| 1961 | - // If they can edit any entries (as defined in Gravity Forms), we're good.  | 
                                                        |
| 1962 | -        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { | 
                                                        |
| 1963 | - return true;  | 
                                                        |
| 1964 | - }  | 
                                                        |
| 1644 | + }  | 
                                                        |
| 1965 | 1645 | |
| 1966 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;  | 
                                                        |
| 1646 | + return $edit_fields;  | 
                                                        |
| 1967 | 1647 | |
| 1968 | - // If the field has custom editing capaibilities set, check those  | 
                                                        |
| 1969 | -        if( $field_cap ) { | 
                                                        |
| 1970 | - return GVCommon::has_cap( $field['allow_edit_cap'] );  | 
                                                        |
| 1971 | - }  | 
                                                        |
| 1972 | -  | 
                                                        |
| 1973 | - return false;  | 
                                                        |
| 1974 | - }  | 
                                                        |
| 1648 | + }  | 
                                                        |
| 1975 | 1649 | |
| 1650 | + /**  | 
                                                        |
| 1651 | + * Override GF Form field properties with the ones defined on the View  | 
                                                        |
| 1652 | + * @param GF_Field $field GF Form field object  | 
                                                        |
| 1653 | + * @param array $field_setting GV field options  | 
                                                        |
| 1654 | + * @since 1.5  | 
                                                        |
| 1655 | + * @return array|GF_Field  | 
                                                        |
| 1656 | + */  | 
                                                        |
| 1657 | +	private function merge_field_properties( $field, $field_setting ) { | 
                                                        |
| 1976 | 1658 | |
| 1977 | - /**  | 
                                                        |
| 1978 | - * Is the current nonce valid for editing the entry?  | 
                                                        |
| 1979 | - * @return boolean  | 
                                                        |
| 1980 | - */  | 
                                                        |
| 1981 | -    public function verify_nonce() { | 
                                                        |
| 1659 | + $return_field = $field;  | 
                                                        |
| 1982 | 1660 | |
| 1983 | - // Verify form submitted for editing single  | 
                                                        |
| 1984 | -        if( $this->is_edit_entry_submission() ) { | 
                                                        |
| 1985 | - $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );  | 
                                                        |
| 1986 | - }  | 
                                                        |
| 1661 | +		if( empty( $field_setting['show_label'] ) ) { | 
                                                        |
| 1662 | + $return_field->label = '';  | 
                                                        |
| 1663 | +		} elseif ( !empty( $field_setting['custom_label'] ) ) { | 
                                                        |
| 1664 | + $return_field->label = $field_setting['custom_label'];  | 
                                                        |
| 1665 | + }  | 
                                                        |
| 1987 | 1666 | |
| 1988 | - // Verify  | 
                                                        |
| 1989 | -        else if( ! $this->is_edit_entry() ) { | 
                                                        |
| 1990 | - $valid = false;  | 
                                                        |
| 1991 | - }  | 
                                                        |
| 1667 | +		if( !empty( $field_setting['custom_class'] ) ) { | 
                                                        |
| 1668 | + $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );  | 
                                                        |
| 1669 | + }  | 
                                                        |
| 1992 | 1670 | |
| 1993 | -        else { | 
                                                        |
| 1994 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );  | 
                                                        |
| 1995 | - }  | 
                                                        |
| 1671 | + /**  | 
                                                        |
| 1672 | + * Normalize page numbers - avoid conflicts with page validation  | 
                                                        |
| 1673 | + * @since 1.6  | 
                                                        |
| 1674 | + */  | 
                                                        |
| 1675 | + $return_field->pageNumber = 1;  | 
                                                        |
| 1996 | 1676 | |
| 1997 | - /**  | 
                                                        |
| 1998 | - * @filter `gravityview/edit_entry/verify_nonce` Override Edit Entry nonce validation. Return true to declare nonce valid.  | 
                                                        |
| 1999 | - * @since 1.13  | 
                                                        |
| 2000 | - * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated  | 
                                                        |
| 2001 | - * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry  | 
                                                        |
| 2002 | - */  | 
                                                        |
| 2003 | - $valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field );  | 
                                                        |
| 1677 | + return $return_field;  | 
                                                        |
| 2004 | 1678 | |
| 2005 | - return $valid;  | 
                                                        |
| 2006 | - }  | 
                                                        |
| 1679 | + }  | 
                                                        |
| 1680 | +  | 
                                                        |
| 1681 | + /**  | 
                                                        |
| 1682 | + * Remove fields that shouldn't be visible based on the Gravity Forms adminOnly field property  | 
                                                        |
| 1683 | + *  | 
                                                        |
| 1684 | + * @since 1.9.1  | 
                                                        |
| 1685 | + *  | 
                                                        |
| 1686 | + * @param array|GF_Field[] $fields Gravity Forms form fields  | 
                                                        |
| 1687 | + * @param array|null $edit_fields Fields for the Edit Entry tab configured in the View Configuration  | 
                                                        |
| 1688 | + * @param array $form GF Form array  | 
                                                        |
| 1689 | + * @param int $view_id View ID  | 
                                                        |
| 1690 | + *  | 
                                                        |
| 1691 | + * @return array Possibly modified form array  | 
                                                        |
| 1692 | + */  | 
                                                        |
| 1693 | +	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { | 
                                                        |
| 1694 | +  | 
                                                        |
| 1695 | + /**  | 
                                                        |
| 1696 | + * @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  | 
                                                        |
| 1697 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.  | 
                                                        |
| 1698 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions  | 
                                                        |
| 1699 | + * @since 1.9.1  | 
                                                        |
| 1700 | + * @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.  | 
                                                        |
| 1701 | + * @param array $form GF Form array  | 
                                                        |
| 1702 | + * @param int $view_id View ID  | 
                                                        |
| 1703 | + */  | 
                                                        |
| 1704 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );  | 
                                                        |
| 1705 | +  | 
                                                        |
| 1706 | +		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { | 
                                                        |
| 1707 | +			foreach( $fields as $k => $field ) { | 
                                                        |
| 1708 | +				if( $field->adminOnly ) { | 
                                                        |
| 1709 | + unset( $fields[ $k ] );  | 
                                                        |
| 1710 | + }  | 
                                                        |
| 1711 | + }  | 
                                                        |
| 1712 | + return $fields;  | 
                                                        |
| 1713 | + }  | 
                                                        |
| 1714 | +  | 
                                                        |
| 1715 | +		foreach( $fields as &$field ) { | 
                                                        |
| 1716 | + $field->adminOnly = false;  | 
                                                        |
| 1717 | + }  | 
                                                        |
| 1718 | +  | 
                                                        |
| 1719 | + return $fields;  | 
                                                        |
| 1720 | + }  | 
                                                        |
| 1721 | +  | 
                                                        |
| 1722 | + // --- Conditional Logic  | 
                                                        |
| 1723 | +  | 
                                                        |
| 1724 | + /**  | 
                                                        |
| 1725 | + * Conditional logic isn't designed to work with forms that already have content. When switching input values,  | 
                                                        |
| 1726 | + * the dependent fields will be blank.  | 
                                                        |
| 1727 | + *  | 
                                                        |
| 1728 | + * Note: This is because GF populates a JavaScript variable with the input values. This is tough to filter at the input level;  | 
                                                        |
| 1729 | + * via the `gform_field_value` filter; it requires lots of legwork. Doing it at the form level is easier.  | 
                                                        |
| 1730 | + *  | 
                                                        |
| 1731 | + * @since 1.17.4  | 
                                                        |
| 1732 | + *  | 
                                                        |
| 1733 | + * @param array $form Gravity Forms array object  | 
                                                        |
| 1734 | + *  | 
                                                        |
| 1735 | + * @return array $form, modified to fix conditional  | 
                                                        |
| 1736 | + */  | 
                                                        |
| 1737 | +	function prefill_conditional_logic( $form ) { | 
                                                        |
| 1738 | +  | 
                                                        |
| 1739 | +		if( ! GFFormDisplay::has_conditional_logic( $form ) ) { | 
                                                        |
| 1740 | + return $form;  | 
                                                        |
| 1741 | + }  | 
                                                        |
| 1742 | +  | 
                                                        |
| 1743 | + // Have Conditional Logic pre-fill fields as if the data were default values  | 
                                                        |
| 1744 | + /** @var GF_Field $field */  | 
                                                        |
| 1745 | +		foreach ( $form['fields'] as &$field ) { | 
                                                        |
| 1746 | +  | 
                                                        |
| 1747 | +			if( 'checkbox' === $field->type ) { | 
                                                        |
| 1748 | +				foreach ( $field->get_entry_inputs() as $key => $input ) { | 
                                                        |
| 1749 | + $input_id = $input['id'];  | 
                                                        |
| 1750 | + $choice = $field->choices[ $key ];  | 
                                                        |
| 1751 | + $value = rgar( $this->entry, $input_id );  | 
                                                        |
| 1752 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value );  | 
                                                        |
| 1753 | +					if( $match ) { | 
                                                        |
| 1754 | + $field->choices[ $key ]['isSelected'] = true;  | 
                                                        |
| 1755 | + }  | 
                                                        |
| 1756 | + }  | 
                                                        |
| 1757 | +			} else { | 
                                                        |
| 1758 | +  | 
                                                        |
| 1759 | + // We need to run through each field to set the default values  | 
                                                        |
| 1760 | +				foreach ( $this->entry as $field_id => $field_value ) { | 
                                                        |
| 1761 | +  | 
                                                        |
| 1762 | +					if( floatval( $field_id ) === floatval( $field->id ) ) { | 
                                                        |
| 1763 | +  | 
                                                        |
| 1764 | +						if( 'list' === $field->type ) { | 
                                                        |
| 1765 | + $list_rows = maybe_unserialize( $field_value );  | 
                                                        |
| 1766 | +  | 
                                                        |
| 1767 | + $list_field_value = array();  | 
                                                        |
| 1768 | +							foreach ( (array) $list_rows as $row ) { | 
                                                        |
| 1769 | +								foreach ( (array) $row as $column ) { | 
                                                        |
| 1770 | + $list_field_value[] = $column;  | 
                                                        |
| 1771 | + }  | 
                                                        |
| 1772 | + }  | 
                                                        |
| 1773 | +  | 
                                                        |
| 1774 | + $field->defaultValue = serialize( $list_field_value );  | 
                                                        |
| 1775 | +						} else { | 
                                                        |
| 1776 | + $field->defaultValue = $field_value;  | 
                                                        |
| 1777 | + }  | 
                                                        |
| 1778 | + }  | 
                                                        |
| 1779 | + }  | 
                                                        |
| 1780 | + }  | 
                                                        |
| 1781 | + }  | 
                                                        |
| 1782 | +  | 
                                                        |
| 1783 | + return $form;  | 
                                                        |
| 1784 | + }  | 
                                                        |
| 1785 | +  | 
                                                        |
| 1786 | + /**  | 
                                                        |
| 1787 | + * Remove the conditional logic rules from the form button and the form fields, if needed.  | 
                                                        |
| 1788 | + *  | 
                                                        |
| 1789 | + * @todo Merge with caller method  | 
                                                        |
| 1790 | + * @since 1.9  | 
                                                        |
| 1791 | + *  | 
                                                        |
| 1792 | + * @param array $form Gravity Forms form  | 
                                                        |
| 1793 | + * @return array Modified form, if not using Conditional Logic  | 
                                                        |
| 1794 | + */  | 
                                                        |
| 1795 | +	private function filter_conditional_logic( $form ) { | 
                                                        |
| 1796 | +  | 
                                                        |
| 1797 | + /**  | 
                                                        |
| 1798 | + * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?  | 
                                                        |
| 1799 | + * @since 1.9  | 
                                                        |
| 1800 | + * @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  | 
                                                        |
| 1801 | + * @param array $form Gravity Forms form  | 
                                                        |
| 1802 | + */  | 
                                                        |
| 1803 | + $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );  | 
                                                        |
| 1804 | +  | 
                                                        |
| 1805 | +		if( $use_conditional_logic ) { | 
                                                        |
| 1806 | + return $form;  | 
                                                        |
| 1807 | + }  | 
                                                        |
| 1808 | +  | 
                                                        |
| 1809 | +		foreach( $form['fields'] as &$field ) { | 
                                                        |
| 1810 | + /* @var GF_Field $field */  | 
                                                        |
| 1811 | + $field->conditionalLogic = null;  | 
                                                        |
| 1812 | + }  | 
                                                        |
| 1813 | +  | 
                                                        |
| 1814 | + unset( $form['button']['conditionalLogic'] );  | 
                                                        |
| 1815 | +  | 
                                                        |
| 1816 | + return $form;  | 
                                                        |
| 1817 | +  | 
                                                        |
| 1818 | + }  | 
                                                        |
| 1819 | +  | 
                                                        |
| 1820 | + /**  | 
                                                        |
| 1821 | + * Disable the Gravity Forms conditional logic script and features on the Edit Entry screen  | 
                                                        |
| 1822 | + *  | 
                                                        |
| 1823 | + * @since 1.9  | 
                                                        |
| 1824 | + *  | 
                                                        |
| 1825 | + * @param $has_conditional_logic  | 
                                                        |
| 1826 | + * @param $form  | 
                                                        |
| 1827 | + * @return mixed|void  | 
                                                        |
| 1828 | + */  | 
                                                        |
| 1829 | +	public function manage_conditional_logic( $has_conditional_logic, $form ) { | 
                                                        |
| 1830 | +  | 
                                                        |
| 1831 | +		if( ! $this->is_edit_entry() ) { | 
                                                        |
| 1832 | + return $has_conditional_logic;  | 
                                                        |
| 1833 | + }  | 
                                                        |
| 1834 | +  | 
                                                        |
| 1835 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */  | 
                                                        |
| 1836 | + return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );  | 
                                                        |
| 1837 | + }  | 
                                                        |
| 1838 | +  | 
                                                        |
| 1839 | +  | 
                                                        |
| 1840 | + // --- User checks and nonces  | 
                                                        |
| 1841 | +  | 
                                                        |
| 1842 | + /**  | 
                                                        |
| 1843 | + * Check if the user can edit the entry  | 
                                                        |
| 1844 | + *  | 
                                                        |
| 1845 | + * - Is the nonce valid?  | 
                                                        |
| 1846 | + * - Does the user have the right caps for the entry  | 
                                                        |
| 1847 | + * - Is the entry in the trash?  | 
                                                        |
| 1848 | + *  | 
                                                        |
| 1849 | + * @todo Move to GVCommon  | 
                                                        |
| 1850 | + *  | 
                                                        |
| 1851 | + * @param boolean $echo Show error messages in the form?  | 
                                                        |
| 1852 | + * @return boolean True: can edit form. False: nope.  | 
                                                        |
| 1853 | + */  | 
                                                        |
| 1854 | +	private function user_can_edit_entry( $echo = false ) { | 
                                                        |
| 1855 | +  | 
                                                        |
| 1856 | + $error = NULL;  | 
                                                        |
| 1857 | +  | 
                                                        |
| 1858 | + /**  | 
                                                        |
| 1859 | + * 1. Permalinks are turned off  | 
                                                        |
| 1860 | + * 2. There are two entries embedded using oEmbed  | 
                                                        |
| 1861 | + * 3. One of the entries has just been saved  | 
                                                        |
| 1862 | + */  | 
                                                        |
| 1863 | +		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { | 
                                                        |
| 1864 | +  | 
                                                        |
| 1865 | + $error = true;  | 
                                                        |
| 1866 | +  | 
                                                        |
| 1867 | + }  | 
                                                        |
| 1868 | +  | 
                                                        |
| 1869 | +		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { | 
                                                        |
| 1870 | +  | 
                                                        |
| 1871 | + $error = true;  | 
                                                        |
| 1872 | +  | 
                                                        |
| 1873 | +		} elseif( ! $this->verify_nonce() ) { | 
                                                        |
| 1874 | +  | 
                                                        |
| 1875 | + /**  | 
                                                        |
| 1876 | + * If the Entry is embedded, there may be two entries on the same page.  | 
                                                        |
| 1877 | + * If that's the case, and one is being edited, the other should fail gracefully and not display an error.  | 
                                                        |
| 1878 | + */  | 
                                                        |
| 1879 | +			if( GravityView_oEmbed::getInstance()->get_entry_id() ) { | 
                                                        |
| 1880 | + $error = true;  | 
                                                        |
| 1881 | +			} else { | 
                                                        |
| 1882 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');  | 
                                                        |
| 1883 | + }  | 
                                                        |
| 1884 | +  | 
                                                        |
| 1885 | + }  | 
                                                        |
| 1886 | +  | 
                                                        |
| 1887 | +		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { | 
                                                        |
| 1888 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview');  | 
                                                        |
| 1889 | + }  | 
                                                        |
| 1890 | +  | 
                                                        |
| 1891 | +		if( $this->entry['status'] === 'trash' ) { | 
                                                        |
| 1892 | +			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); | 
                                                        |
| 1893 | + }  | 
                                                        |
| 1894 | +  | 
                                                        |
| 1895 | + // No errors; everything's fine here!  | 
                                                        |
| 1896 | +		if( empty( $error ) ) { | 
                                                        |
| 1897 | + return true;  | 
                                                        |
| 1898 | + }  | 
                                                        |
| 1899 | +  | 
                                                        |
| 1900 | +		if( $echo && $error !== true ) { | 
                                                        |
| 1901 | +  | 
                                                        |
| 1902 | + $error = esc_html( $error );  | 
                                                        |
| 1903 | +  | 
                                                        |
| 1904 | + /**  | 
                                                        |
| 1905 | + * @since 1.9  | 
                                                        |
| 1906 | + */  | 
                                                        |
| 1907 | +			if ( ! empty( $this->entry ) ) { | 
                                                        |
| 1908 | +				$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;" ) ); | 
                                                        |
| 1909 | + }  | 
                                                        |
| 1910 | +  | 
                                                        |
| 1911 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');  | 
                                                        |
| 1912 | + }  | 
                                                        |
| 1913 | +  | 
                                                        |
| 1914 | +		do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); | 
                                                        |
| 1915 | +  | 
                                                        |
| 1916 | + return false;  | 
                                                        |
| 1917 | + }  | 
                                                        |
| 1918 | +  | 
                                                        |
| 1919 | +  | 
                                                        |
| 1920 | + /**  | 
                                                        |
| 1921 | + * Check whether a field is editable by the current user, and optionally display an error message  | 
                                                        |
| 1922 | + * @uses GravityView_Edit_Entry->check_user_cap_edit_field() Check user capabilities  | 
                                                        |
| 1923 | + * @param array $field Field or field settings array  | 
                                                        |
| 1924 | + * @param boolean $echo Whether to show error message telling user they aren't allowed  | 
                                                        |
| 1925 | + * @return boolean True: user can edit the current field; False: nope, they can't.  | 
                                                        |
| 1926 | + */  | 
                                                        |
| 1927 | +	private function user_can_edit_field( $field, $echo = false ) { | 
                                                        |
| 1928 | +  | 
                                                        |
| 1929 | + $error = NULL;  | 
                                                        |
| 1930 | +  | 
                                                        |
| 1931 | +		if( ! $this->check_user_cap_edit_field( $field ) ) { | 
                                                        |
| 1932 | + $error = __( 'You do not have permission to edit this field.', 'gravityview');  | 
                                                        |
| 1933 | + }  | 
                                                        |
| 1934 | +  | 
                                                        |
| 1935 | + // No errors; everything's fine here!  | 
                                                        |
| 1936 | +		if( empty( $error ) ) { | 
                                                        |
| 1937 | + return true;  | 
                                                        |
| 1938 | + }  | 
                                                        |
| 1939 | +  | 
                                                        |
| 1940 | +		if( $echo ) { | 
                                                        |
| 1941 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');  | 
                                                        |
| 1942 | + }  | 
                                                        |
| 1943 | +  | 
                                                        |
| 1944 | +		do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); | 
                                                        |
| 1945 | +  | 
                                                        |
| 1946 | + return false;  | 
                                                        |
| 1947 | +  | 
                                                        |
| 1948 | + }  | 
                                                        |
| 1949 | +  | 
                                                        |
| 1950 | +  | 
                                                        |
| 1951 | + /**  | 
                                                        |
| 1952 | + * checks if user has permissions to edit a specific field  | 
                                                        |
| 1953 | + *  | 
                                                        |
| 1954 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_field for maximum security!!  | 
                                                        |
| 1955 | + *  | 
                                                        |
| 1956 | + * @param [type] $field [description]  | 
                                                        |
| 1957 | + * @return bool  | 
                                                        |
| 1958 | + */  | 
                                                        |
| 1959 | +	private function check_user_cap_edit_field( $field ) { | 
                                                        |
| 1960 | +  | 
                                                        |
| 1961 | + // If they can edit any entries (as defined in Gravity Forms), we're good.  | 
                                                        |
| 1962 | +		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { | 
                                                        |
| 1963 | + return true;  | 
                                                        |
| 1964 | + }  | 
                                                        |
| 1965 | +  | 
                                                        |
| 1966 | + $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;  | 
                                                        |
| 1967 | +  | 
                                                        |
| 1968 | + // If the field has custom editing capaibilities set, check those  | 
                                                        |
| 1969 | +		if( $field_cap ) { | 
                                                        |
| 1970 | + return GVCommon::has_cap( $field['allow_edit_cap'] );  | 
                                                        |
| 1971 | + }  | 
                                                        |
| 1972 | +  | 
                                                        |
| 1973 | + return false;  | 
                                                        |
| 1974 | + }  | 
                                                        |
| 1975 | +  | 
                                                        |
| 1976 | +  | 
                                                        |
| 1977 | + /**  | 
                                                        |
| 1978 | + * Is the current nonce valid for editing the entry?  | 
                                                        |
| 1979 | + * @return boolean  | 
                                                        |
| 1980 | + */  | 
                                                        |
| 1981 | +	public function verify_nonce() { | 
                                                        |
| 1982 | +  | 
                                                        |
| 1983 | + // Verify form submitted for editing single  | 
                                                        |
| 1984 | +		if( $this->is_edit_entry_submission() ) { | 
                                                        |
| 1985 | + $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );  | 
                                                        |
| 1986 | + }  | 
                                                        |
| 1987 | +  | 
                                                        |
| 1988 | + // Verify  | 
                                                        |
| 1989 | +		else if( ! $this->is_edit_entry() ) { | 
                                                        |
| 1990 | + $valid = false;  | 
                                                        |
| 1991 | + }  | 
                                                        |
| 1992 | +  | 
                                                        |
| 1993 | +		else { | 
                                                        |
| 1994 | + $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );  | 
                                                        |
| 1995 | + }  | 
                                                        |
| 1996 | +  | 
                                                        |
| 1997 | + /**  | 
                                                        |
| 1998 | + * @filter `gravityview/edit_entry/verify_nonce` Override Edit Entry nonce validation. Return true to declare nonce valid.  | 
                                                        |
| 1999 | + * @since 1.13  | 
                                                        |
| 2000 | + * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated  | 
                                                        |
| 2001 | + * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry  | 
                                                        |
| 2002 | + */  | 
                                                        |
| 2003 | + $valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field );  | 
                                                        |
| 2004 | +  | 
                                                        |
| 2005 | + return $valid;  | 
                                                        |
| 2006 | + }  | 
                                                        |
| 2007 | 2007 | |
| 2008 | 2008 | |
| 2009 | 2009 | |
@@ -119,16 +119,16 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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  | 
                                                    ||
| 154 | 154 | * @return void  | 
                                                        
| 155 | 155 | */  | 
                                                        
| 156 | 156 |      public 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  | 
                                                    ||
| 170 | 170 | */  | 
                                                        
| 171 | 171 |      public 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  | 
                                                    ||
| 183 | 183 | */  | 
                                                        
| 184 | 184 |      public function is_edit_entry() { | 
                                                        
| 185 | 185 | |
| 186 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );  | 
                                                        |
| 186 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );  | 
                                                        |
| 187 | 187 | |
| 188 | 188 | return ( $is_edit_entry || $this->is_edit_entry_submission() );  | 
                                                        
| 189 | 189 | }  | 
                                                        
@@ -194,7 +194,7 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 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,14 +233,14 @@ discard block  | 
                                                    ||
| 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 ) ) { | 
                                                        |
| 237 | -            do_action('gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); | 
                                                        |
| 236 | +        if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { | 
                                                        |
| 237 | + do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' );  | 
                                                        |
| 238 | 238 | return;  | 
                                                        
| 239 | 239 | }  | 
                                                        
| 240 | 240 | |
| 241 | 241 | // Sorry, you're not allowed here.  | 
                                                        
| 242 | -        if( false === $this->user_can_edit_entry( true ) ) { | 
                                                        |
| 243 | -            do_action('gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); | 
                                                        |
| 242 | +        if ( false === $this->user_can_edit_entry( true ) ) { | 
                                                        |
| 243 | + do_action( 'gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry );  | 
                                                        |
| 244 | 244 | return;  | 
                                                        
| 245 | 245 | }  | 
                                                        
| 246 | 246 | |
@@ -260,9 +260,9 @@ discard block  | 
                                                    ||
| 260 | 260 |      private function print_scripts() { | 
                                                        
| 261 | 261 | $gravityview_view = GravityView_View::getInstance();  | 
                                                        
| 262 | 262 | |
| 263 | - 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 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );  | 
                                                        |
| 264 | 264 | |
| 265 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);  | 
                                                        |
| 265 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );  | 
                                                        |
| 266 | 266 | |
| 267 | 267 | // Sack is required for images  | 
                                                        
| 268 | 268 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) );  | 
                                                        
@@ -274,32 +274,32 @@ discard block  | 
                                                    ||
| 274 | 274 | */  | 
                                                        
| 275 | 275 |      private function process_save() { | 
                                                        
| 276 | 276 | |
| 277 | -        if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { | 
                                                        |
| 277 | +        if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { | 
                                                        |
| 278 | 278 | return;  | 
                                                        
| 279 | 279 | }  | 
                                                        
| 280 | 280 | |
| 281 | 281 | // Make sure the entry, view, and form IDs are all correct  | 
                                                        
| 282 | 282 | $valid = $this->verify_nonce();  | 
                                                        
| 283 | 283 | |
| 284 | -        if( !$valid ) { | 
                                                        |
| 285 | -            do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); | 
                                                        |
| 284 | +        if ( ! $valid ) { | 
                                                        |
| 285 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' );  | 
                                                        |
| 286 | 286 | return;  | 
                                                        
| 287 | 287 | }  | 
                                                        
| 288 | 288 | |
| 289 | -        if( $this->entry['id'] !== $_POST['lid'] ) { | 
                                                        |
| 290 | -            do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); | 
                                                        |
| 289 | +        if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { | 
                                                        |
| 290 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' );  | 
                                                        |
| 291 | 291 | return;  | 
                                                        
| 292 | 292 | }  | 
                                                        
| 293 | 293 | |
| 294 | -        do_action('gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); | 
                                                        |
| 294 | + do_action( 'gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );  | 
                                                        |
| 295 | 295 | |
| 296 | 296 | $this->process_save_process_files( $this->form_id );  | 
                                                        
| 297 | 297 | |
| 298 | 298 | $this->validate();  | 
                                                        
| 299 | 299 | |
| 300 | -        if( $this->is_valid ) { | 
                                                        |
| 300 | +        if ( $this->is_valid ) { | 
                                                        |
| 301 | 301 | |
| 302 | -            do_action('gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); | 
                                                        |
| 302 | + do_action( 'gravityview_log_debug', __METHOD__ . ': Submission is valid.' );  | 
                                                        |
| 303 | 303 | |
| 304 | 304 | /**  | 
                                                        
| 305 | 305 | * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields  | 
                                                        
@@ -309,22 +309,22 @@ discard block  | 
                                                    ||
| 309 | 309 | /**  | 
                                                        
| 310 | 310 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+  | 
                                                        
| 311 | 311 | */  | 
                                                        
| 312 | - unset( $_GET['page'] );  | 
                                                        |
| 312 | + unset( $_GET[ 'page' ] );  | 
                                                        |
| 313 | 313 | |
| 314 | - $date_created = $this->entry['date_created'];  | 
                                                        |
| 314 | + $date_created = $this->entry[ 'date_created' ];  | 
                                                        |
| 315 | 315 | |
| 316 | 316 | /**  | 
                                                        
| 317 | 317 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()  | 
                                                        
| 318 | 318 | * @since 1.17.2  | 
                                                        
| 319 | 319 | */  | 
                                                        
| 320 | - unset( $this->entry['date_created'] );  | 
                                                        |
| 320 | + unset( $this->entry[ 'date_created' ] );  | 
                                                        |
| 321 | 321 | |
| 322 | 322 | GFFormsModel::save_lead( $form, $this->entry );  | 
                                                        
| 323 | 323 | |
| 324 | 324 | // Delete the values for hidden inputs  | 
                                                        
| 325 | 325 | $this->unset_hidden_field_values();  | 
                                                        
| 326 | 326 | |
| 327 | - $this->entry['date_created'] = $date_created;  | 
                                                        |
| 327 | + $this->entry[ 'date_created' ] = $date_created;  | 
                                                        |
| 328 | 328 | |
| 329 | 329 | // Process calculation fields  | 
                                                        
| 330 | 330 | $this->update_calculation_fields();  | 
                                                        
@@ -343,10 +343,10 @@ discard block  | 
                                                    ||
| 343 | 343 | * @param array $form Gravity Forms form array  | 
                                                        
| 344 | 344 | * @param string $entry_id Numeric ID of the entry that was updated  | 
                                                        
| 345 | 345 | */  | 
                                                        
| 346 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] );  | 
                                                        |
| 346 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] );  | 
                                                        |
| 347 | 347 | |
| 348 | 348 |          } else { | 
                                                        
| 349 | -            do_action('gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); | 
                                                        |
| 349 | + do_action( 'gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry );  | 
                                                        |
| 350 | 350 | }  | 
                                                        
| 351 | 351 | |
| 352 | 352 | } // process_save  | 
                                                        
@@ -363,8 +363,8 @@ discard block  | 
                                                    ||
| 363 | 363 |      private function unset_hidden_field_values() { | 
                                                        
| 364 | 364 | global $wpdb;  | 
                                                        
| 365 | 365 | |
| 366 | - $lead_detail_table = GFFormsModel::get_lead_details_table_name();  | 
                                                        |
| 367 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );  | 
                                                        |
| 366 | + $lead_detail_table = GFFormsModel::get_lead_details_table_name();  | 
                                                        |
| 367 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );  | 
                                                        |
| 368 | 368 | |
| 369 | 369 |  	    foreach ( $this->entry as $input_id => $field_value ) { | 
                                                        
| 370 | 370 | |
@@ -417,11 +417,11 @@ discard block  | 
                                                    ||
| 417 | 417 | * @return mixed  | 
                                                        
| 418 | 418 | */  | 
                                                        
| 419 | 419 |      public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { | 
                                                        
| 420 | -        if( ! $this->is_edit_entry() ) { | 
                                                        |
| 420 | +        if ( ! $this->is_edit_entry() ) { | 
                                                        |
| 421 | 421 | return $plupload_init;  | 
                                                        
| 422 | 422 | }  | 
                                                        
| 423 | 423 | |
| 424 | - $plupload_init['gf_vars']['max_files'] = 0;  | 
                                                        |
| 424 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;  | 
                                                        |
| 425 | 425 | |
| 426 | 426 | return $plupload_init;  | 
                                                        
| 427 | 427 | }  | 
                                                        
@@ -436,22 +436,22 @@ discard block  | 
                                                    ||
| 436 | 436 | $form = $this->form;  | 
                                                        
| 437 | 437 | |
| 438 | 438 | /** @var GF_Field $field */  | 
                                                        
| 439 | -        foreach( $form['fields'] as $k => &$field ) { | 
                                                        |
| 439 | +        foreach ( $form[ 'fields' ] as $k => &$field ) { | 
                                                        |
| 440 | 440 | |
| 441 | 441 | /**  | 
                                                        
| 442 | 442 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic  | 
                                                        
| 443 | 443 | * @since 1.16.3  | 
                                                        
| 444 | 444 | * @var GF_Field $field  | 
                                                        
| 445 | 445 | */  | 
                                                        
| 446 | -            if( $field->has_calculation() ) { | 
                                                        |
| 447 | - unset( $form['fields'][ $k ] );  | 
                                                        |
| 446 | +            if ( $field->has_calculation() ) { | 
                                                        |
| 447 | + unset( $form[ 'fields' ][ $k ] );  | 
                                                        |
| 448 | 448 | }  | 
                                                        
| 449 | 449 | |
| 450 | 450 | $field->adminOnly = false;  | 
                                                        
| 451 | 451 | |
| 452 | -            if( isset( $field->inputs ) && is_array( $field->inputs ) ) { | 
                                                        |
| 453 | -                foreach( $field->inputs as $key => $input ) { | 
                                                        |
| 454 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id'];  | 
                                                        |
| 452 | +            if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { | 
                                                        |
| 453 | +                foreach ( $field->inputs as $key => $input ) { | 
                                                        |
| 454 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];  | 
                                                        |
| 455 | 455 | }  | 
                                                        
| 456 | 456 | }  | 
                                                        
| 457 | 457 | }  | 
                                                        
@@ -465,20 +465,20 @@ discard block  | 
                                                    ||
| 465 | 465 | $update = false;  | 
                                                        
| 466 | 466 | |
| 467 | 467 | // get the most up to date entry values  | 
                                                        
| 468 | - $entry = GFAPI::get_entry( $this->entry['id'] );  | 
                                                        |
| 468 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] );  | 
                                                        |
| 469 | 469 | |
| 470 | -        if( !empty( $this->fields_with_calculation ) ) { | 
                                                        |
| 470 | +        if ( ! empty( $this->fields_with_calculation ) ) { | 
                                                        |
| 471 | 471 | $update = true;  | 
                                                        
| 472 | 472 |              foreach ( $this->fields_with_calculation as $calc_field ) { | 
                                                        
| 473 | 473 | $inputs = $calc_field->get_entry_inputs();  | 
                                                        
| 474 | 474 |                  if ( is_array( $inputs ) ) { | 
                                                        
| 475 | 475 |                      foreach ( $inputs as $input ) { | 
                                                        
| 476 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] );  | 
                                                        |
| 477 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 476 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );  | 
                                                        |
| 477 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry );  | 
                                                        |
| 478 | 478 | }  | 
                                                        
| 479 | 479 |                  } else { | 
                                                        
| 480 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);  | 
                                                        |
| 481 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 480 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id );  | 
                                                        |
| 481 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry );  | 
                                                        |
| 482 | 482 | }  | 
                                                        
| 483 | 483 | }  | 
                                                        
| 484 | 484 | |
@@ -488,16 +488,16 @@ discard block  | 
                                                    ||
| 488 | 488 |          if ( ! empty( $this->total_fields ) ) { | 
                                                        
| 489 | 489 | $update = true;  | 
                                                        
| 490 | 490 |              foreach ( $this->total_fields as $total_field ) { | 
                                                        
| 491 | - $input_name = 'input_' . str_replace( '.', '_', $total_field->id);  | 
                                                        |
| 492 | - $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry );  | 
                                                        |
| 491 | + $input_name = 'input_' . str_replace( '.', '_', $total_field->id );  | 
                                                        |
| 492 | + $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry[ 'id' ], $entry );  | 
                                                        |
| 493 | 493 | }  | 
                                                        
| 494 | 494 | }  | 
                                                        
| 495 | 495 | |
| 496 | -        if( $update ) { | 
                                                        |
| 496 | +        if ( $update ) { | 
                                                        |
| 497 | 497 | |
| 498 | 498 | $return_entry = GFAPI::update_entry( $entry );  | 
                                                        
| 499 | 499 | |
| 500 | -            if( is_wp_error( $return_entry ) ) { | 
                                                        |
| 500 | +            if ( is_wp_error( $return_entry ) ) { | 
                                                        |
| 501 | 501 | do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry );  | 
                                                        
| 502 | 502 |              } else { | 
                                                        
| 503 | 503 | do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' );  | 
                                                        
@@ -528,18 +528,18 @@ discard block  | 
                                                    ||
| 528 | 528 | |
| 529 | 529 | $input_name = 'input_' . $field_id;  | 
                                                        
| 530 | 530 | |
| 531 | -        if ( !empty( $_FILES[ $input_name ]['name'] ) ) { | 
                                                        |
| 531 | +        if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { | 
                                                        |
| 532 | 532 | |
| 533 | 533 | // We have a new image  | 
                                                        
| 534 | 534 | |
| 535 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );  | 
                                                        |
| 535 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );  | 
                                                        |
| 536 | 536 | |
| 537 | 537 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array();  | 
                                                        
| 538 | 538 | $img_url = rgar( $ary, 0 );  | 
                                                        
| 539 | 539 | |
| 540 | - $img_title = count( $ary ) > 1 ? $ary[1] : '';  | 
                                                        |
| 541 | - $img_caption = count( $ary ) > 2 ? $ary[2] : '';  | 
                                                        |
| 542 | - $img_description = count( $ary ) > 3 ? $ary[3] : '';  | 
                                                        |
| 540 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : '';  | 
                                                        |
| 541 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : '';  | 
                                                        |
| 542 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';  | 
                                                        |
| 543 | 543 | |
| 544 | 544 | $image_meta = array(  | 
                                                        
| 545 | 545 | 'post_excerpt' => $img_caption,  | 
                                                        
@@ -548,7 +548,7 @@ discard block  | 
                                                    ||
| 548 | 548 | |
| 549 | 549 | //adding title only if it is not empty. It will default to the file name if it is not in the array  | 
                                                        
| 550 | 550 |              if ( ! empty( $img_title ) ) { | 
                                                        
| 551 | - $image_meta['post_title'] = $img_title;  | 
                                                        |
| 551 | + $image_meta[ 'post_title' ] = $img_title;  | 
                                                        |
| 552 | 552 | }  | 
                                                        
| 553 | 553 | |
| 554 | 554 | /**  | 
                                                        
@@ -563,22 +563,22 @@ discard block  | 
                                                    ||
| 563 | 563 | set_post_thumbnail( $post_id, $media_id );  | 
                                                        
| 564 | 564 | }  | 
                                                        
| 565 | 565 | |
| 566 | -        } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { | 
                                                        |
| 566 | +        } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) { | 
                                                        |
| 567 | 567 | |
| 568 | 568 | // Same image although the image title, caption or description might have changed  | 
                                                        
| 569 | 569 | |
| 570 | 570 | $ary = array();  | 
                                                        
| 571 | -            if( ! empty( $entry[ $field_id ] ) ) { | 
                                                        |
| 571 | +            if ( ! empty( $entry[ $field_id ] ) ) { | 
                                                        |
| 572 | 572 | $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] );  | 
                                                        
| 573 | 573 | }  | 
                                                        
| 574 | 574 | $img_url = rgar( $ary, 0 );  | 
                                                        
| 575 | 575 | |
| 576 | 576 | // is this really the same image or something went wrong ?  | 
                                                        
| 577 | -            if( $img_url === $_POST[ $input_name ] ) { | 
                                                        |
| 577 | +            if ( $img_url === $_POST[ $input_name ] ) { | 
                                                        |
| 578 | 578 | |
| 579 | - $img_title = rgar( $value, $field_id .'.1' );  | 
                                                        |
| 580 | - $img_caption = rgar( $value, $field_id .'.4' );  | 
                                                        |
| 581 | - $img_description = rgar( $value, $field_id .'.7' );  | 
                                                        |
| 579 | + $img_title = rgar( $value, $field_id . '.1' );  | 
                                                        |
| 580 | + $img_caption = rgar( $value, $field_id . '.4' );  | 
                                                        |
| 581 | + $img_description = rgar( $value, $field_id . '.7' );  | 
                                                        |
| 582 | 582 | |
| 583 | 583 | $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : '';  | 
                                                        
| 584 | 584 | |
@@ -618,16 +618,16 @@ discard block  | 
                                                    ||
| 618 | 618 | */  | 
                                                        
| 619 | 619 |      private function maybe_update_post_fields( $form ) { | 
                                                        
| 620 | 620 | |
| 621 | -        if( empty( $this->entry['post_id'] ) ) { | 
                                                        |
| 621 | +        if ( empty( $this->entry[ 'post_id' ] ) ) { | 
                                                        |
| 622 | 622 | do_action( 'gravityview_log_debug', __METHOD__ . ': This entry has no post fields. Continuing...' );  | 
                                                        
| 623 | 623 | return;  | 
                                                        
| 624 | 624 | }  | 
                                                        
| 625 | 625 | |
| 626 | - $post_id = $this->entry['post_id'];  | 
                                                        |
| 626 | + $post_id = $this->entry[ 'post_id' ];  | 
                                                        |
| 627 | 627 | |
| 628 | 628 | // Security check  | 
                                                        
| 629 | -        if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { | 
                                                        |
| 630 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id );  | 
                                                        |
| 629 | +        if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { | 
                                                        |
| 630 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id );  | 
                                                        |
| 631 | 631 | return;  | 
                                                        
| 632 | 632 | }  | 
                                                        
| 633 | 633 | |
@@ -639,25 +639,25 @@ discard block  | 
                                                    ||
| 639 | 639 | |
| 640 | 640 | $field = RGFormsModel::get_field( $form, $field_id );  | 
                                                        
| 641 | 641 | |
| 642 | -            if( ! $field ) { | 
                                                        |
| 642 | +            if ( ! $field ) { | 
                                                        |
| 643 | 643 | continue;  | 
                                                        
| 644 | 644 | }  | 
                                                        
| 645 | 645 | |
| 646 | -            if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { | 
                                                        |
| 646 | +            if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { | 
                                                        |
| 647 | 647 | |
| 648 | 648 | // Get the value of the field, including $_POSTed value  | 
                                                        
| 649 | 649 | $value = RGFormsModel::get_field_value( $field );  | 
                                                        
| 650 | 650 | |
| 651 | 651 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image()  | 
                                                        
| 652 | 652 | $entry_tmp = $this->entry;  | 
                                                        
| 653 | -                $entry_tmp["{$field_id}"] = $value; | 
                                                        |
| 653 | +                $entry_tmp[ "{$field_id}" ] = $value; | 
                                                        |
| 654 | 654 | |
| 655 | -                switch( $field->type ) { | 
                                                        |
| 655 | +                switch ( $field->type ) { | 
                                                        |
| 656 | 656 | |
| 657 | 657 | case 'post_title':  | 
                                                        
| 658 | 658 | $post_title = $value;  | 
                                                        
| 659 | -                        if( rgar( $form, 'postTitleTemplateEnabled' ) ) { | 
                                                        |
| 660 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );  | 
                                                        |
| 659 | +                        if ( rgar( $form, 'postTitleTemplateEnabled' ) ) { | 
                                                        |
| 660 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );  | 
                                                        |
| 661 | 661 | }  | 
                                                        
| 662 | 662 | $updated_post->post_title = $post_title;  | 
                                                        
| 663 | 663 | $updated_post->post_name = $post_title;  | 
                                                        
@@ -666,8 +666,8 @@ discard block  | 
                                                    ||
| 666 | 666 | |
| 667 | 667 | case 'post_content':  | 
                                                        
| 668 | 668 | $post_content = $value;  | 
                                                        
| 669 | -                        if( rgar( $form, 'postContentTemplateEnabled' ) ) { | 
                                                        |
| 670 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );  | 
                                                        |
| 669 | +                        if ( rgar( $form, 'postContentTemplateEnabled' ) ) { | 
                                                        |
| 670 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );  | 
                                                        |
| 671 | 671 | }  | 
                                                        
| 672 | 672 | $updated_post->post_content = $post_content;  | 
                                                        
| 673 | 673 | unset( $post_content );  | 
                                                        
@@ -681,12 +681,12 @@ discard block  | 
                                                    ||
| 681 | 681 | case 'post_category':  | 
                                                        
| 682 | 682 | break;  | 
                                                        
| 683 | 683 | case 'post_custom_field':  | 
                                                        
| 684 | -                        if( ! empty( $field->customFieldTemplateEnabled ) ) { | 
                                                        |
| 684 | +                        if ( ! empty( $field->customFieldTemplateEnabled ) ) { | 
                                                        |
| 685 | 685 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );  | 
                                                        
| 686 | 686 | }  | 
                                                        
| 687 | 687 | |
| 688 | 688 |  	                    if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { | 
                                                        
| 689 | -		                    $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); | 
                                                        |
| 689 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value );  | 
                                                        |
| 690 | 690 | }  | 
                                                        
| 691 | 691 | |
| 692 | 692 | update_post_meta( $post_id, $field->postCustomFieldName, $value );  | 
                                                        
@@ -699,7 +699,7 @@ discard block  | 
                                                    ||
| 699 | 699 | }  | 
                                                        
| 700 | 700 | |
| 701 | 701 | // update entry after  | 
                                                        
| 702 | -                $this->entry["{$field_id}"] = $value; | 
                                                        |
| 702 | +                $this->entry[ "{$field_id}" ] = $value; | 
                                                        |
| 703 | 703 | |
| 704 | 704 | $update_entry = true;  | 
                                                        
| 705 | 705 | |
@@ -708,25 +708,25 @@ discard block  | 
                                                    ||
| 708 | 708 | |
| 709 | 709 | }  | 
                                                        
| 710 | 710 | |
| 711 | -        if( $update_entry ) { | 
                                                        |
| 711 | +        if ( $update_entry ) { | 
                                                        |
| 712 | 712 | |
| 713 | 713 | $return_entry = GFAPI::update_entry( $this->entry );  | 
                                                        
| 714 | 714 | |
| 715 | -            if( is_wp_error( $return_entry ) ) { | 
                                                        |
| 715 | +            if ( is_wp_error( $return_entry ) ) { | 
                                                        |
| 716 | 716 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) );  | 
                                                        
| 717 | 717 |              } else { | 
                                                        
| 718 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' );  | 
                                                        |
| 718 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' );  | 
                                                        |
| 719 | 719 | }  | 
                                                        
| 720 | 720 | |
| 721 | 721 | }  | 
                                                        
| 722 | 722 | |
| 723 | 723 | $return_post = wp_update_post( $updated_post, true );  | 
                                                        
| 724 | 724 | |
| 725 | -        if( is_wp_error( $return_post ) ) { | 
                                                        |
| 725 | +        if ( is_wp_error( $return_post ) ) { | 
                                                        |
| 726 | 726 | $return_post->add_data( $updated_post, '$updated_post' );  | 
                                                        
| 727 | 727 | do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) );  | 
                                                        
| 728 | 728 |          } else { | 
                                                        
| 729 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post );  | 
                                                        |
| 729 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post );  | 
                                                        |
| 730 | 730 | }  | 
                                                        
| 731 | 731 | }  | 
                                                        
| 732 | 732 | |
@@ -744,7 +744,7 @@ discard block  | 
                                                    ||
| 744 | 744 | $input_type = RGFormsModel::get_input_type( $field );  | 
                                                        
| 745 | 745 | |
| 746 | 746 | // Only certain custom field types are supported  | 
                                                        
| 747 | -	    switch( $input_type ) { | 
                                                        |
| 747 | +	    switch ( $input_type ) { | 
                                                        |
| 748 | 748 | case 'fileupload':  | 
                                                        
| 749 | 749 | case 'list':  | 
                                                        
| 750 | 750 | case 'multiselect':  | 
                                                        
@@ -781,7 +781,7 @@ discard block  | 
                                                    ||
| 781 | 781 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );  | 
                                                        
| 782 | 782 | |
| 783 | 783 | // replace conditional shortcodes  | 
                                                        
| 784 | -        if( $do_shortcode ) { | 
                                                        |
| 784 | +        if ( $do_shortcode ) { | 
                                                        |
| 785 | 785 | $output = do_shortcode( $output );  | 
                                                        
| 786 | 786 | }  | 
                                                        
| 787 | 787 | |
@@ -800,18 +800,18 @@ discard block  | 
                                                    ||
| 800 | 800 | */  | 
                                                        
| 801 | 801 |      private function after_update() { | 
                                                        
| 802 | 802 | |
| 803 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );  | 
                                                        |
| 804 | -        do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); | 
                                                        |
| 803 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );  | 
                                                        |
| 804 | +        do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] ); | 
                                                        |
| 805 | 805 | |
| 806 | 806 | // Re-define the entry now that we've updated it.  | 
                                                        
| 807 | - $entry = RGFormsModel::get_lead( $this->entry['id'] );  | 
                                                        |
| 807 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );  | 
                                                        |
| 808 | 808 | |
| 809 | 809 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form );  | 
                                                        
| 810 | 810 | |
| 811 | 811 | // We need to clear the cache because Gravity Forms caches the field values, which  | 
                                                        
| 812 | 812 | // we have just updated.  | 
                                                        
| 813 | -        foreach ($this->form['fields'] as $key => $field) { | 
                                                        |
| 814 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );  | 
                                                        |
| 813 | +        foreach ( $this->form[ 'fields' ] as $key => $field ) { | 
                                                        |
| 814 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );  | 
                                                        |
| 815 | 815 | }  | 
                                                        
| 816 | 816 | |
| 817 | 817 | $this->entry = $entry;  | 
                                                        
@@ -829,7 +829,7 @@ discard block  | 
                                                    ||
| 829 | 829 | |
| 830 | 830 | <div class="gv-edit-entry-wrapper"><?php  | 
                                                        
| 831 | 831 | |
| 832 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );  | 
                                                        |
| 832 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );  | 
                                                        |
| 833 | 833 | |
| 834 | 834 | /**  | 
                                                        
| 835 | 835 | * Fixes weird wpautop() issue  | 
                                                        
@@ -845,7 +845,7 @@ discard block  | 
                                                    ||
| 845 | 845 | * @param string $edit_entry_title Modify the "Edit Entry" title  | 
                                                        
| 846 | 846 | * @param GravityView_Edit_Entry_Render $this This object  | 
                                                        
| 847 | 847 | */  | 
                                                        
| 848 | -                    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); | 
                                                        |
| 848 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );  | 
                                                        |
| 849 | 849 | |
| 850 | 850 | echo esc_attr( $edit_entry_title );  | 
                                                        
| 851 | 851 | ?></span>  | 
                                                        
@@ -891,20 +891,20 @@ discard block  | 
                                                    ||
| 891 | 891 | */  | 
                                                        
| 892 | 892 |      private function maybe_print_message() { | 
                                                        
| 893 | 893 | |
| 894 | -        if( rgpost('action') === 'update' ) { | 
                                                        |
| 894 | +        if ( rgpost( 'action' ) === 'update' ) { | 
                                                        |
| 895 | 895 | |
| 896 | 896 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) );  | 
                                                        
| 897 | 897 | |
| 898 | -            if( ! $this->is_valid ){ | 
                                                        |
| 898 | +            if ( ! $this->is_valid ) { | 
                                                        |
| 899 | 899 | |
| 900 | 900 | // Keeping this compatible with Gravity Forms.  | 
                                                        
| 901 | -                $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; | 
                                                        |
| 902 | -                $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); | 
                                                        |
| 901 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";  | 
                                                        |
| 902 | +                $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); | 
                                                        |
| 903 | 903 | |
| 904 | - echo GVCommon::generate_notice( $message , 'gv-error' );  | 
                                                        |
| 904 | + echo GVCommon::generate_notice( $message, 'gv-error' );  | 
                                                        |
| 905 | 905 | |
| 906 | 906 |              } else { | 
                                                        
| 907 | -                $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); | 
                                                        |
| 907 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' );  | 
                                                        |
| 908 | 908 | |
| 909 | 909 | /**  | 
                                                        
| 910 | 910 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link)  | 
                                                        
@@ -914,7 +914,7 @@ discard block  | 
                                                    ||
| 914 | 914 | * @param array $entry Gravity Forms entry array  | 
                                                        
| 915 | 915 | * @param string $back_link URL to return to the original entry. @since 1.6  | 
                                                        
| 916 | 916 | */  | 
                                                        
| 917 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );  | 
                                                        |
| 917 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );  | 
                                                        |
| 918 | 918 | |
| 919 | 919 | echo GVCommon::generate_notice( $message );  | 
                                                        
| 920 | 920 | }  | 
                                                        
@@ -938,22 +938,22 @@ discard block  | 
                                                    ||
| 938 | 938 | */  | 
                                                        
| 939 | 939 | do_action( 'gravityview/edit-entry/render/before', $this );  | 
                                                        
| 940 | 940 | |
| 941 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );  | 
                                                        |
| 942 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );  | 
                                                        |
| 941 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );  | 
                                                        |
| 942 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );  | 
                                                        |
| 943 | 943 | add_filter( 'gform_disable_view_counter', '__return_true' );  | 
                                                        
| 944 | 944 | |
| 945 | 945 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );  | 
                                                        
| 946 | 946 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );  | 
                                                        
| 947 | 947 | |
| 948 | 948 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.  | 
                                                        
| 949 | - unset( $_GET['page'] );  | 
                                                        |
| 949 | + unset( $_GET[ 'page' ] );  | 
                                                        |
| 950 | 950 | |
| 951 | 951 | // TODO: Verify multiple-page forms  | 
                                                        
| 952 | 952 | // TODO: Product fields are not editable  | 
                                                        
| 953 | 953 | |
| 954 | 954 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic  | 
                                                        
| 955 | 955 | |
| 956 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );  | 
                                                        |
| 956 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );  | 
                                                        |
| 957 | 957 | |
| 958 | 958 | ob_get_clean();  | 
                                                        
| 959 | 959 | |
@@ -979,7 +979,7 @@ discard block  | 
                                                    ||
| 979 | 979 | * @return string  | 
                                                        
| 980 | 980 | */  | 
                                                        
| 981 | 981 |      public function render_form_buttons() { | 
                                                        
| 982 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );  | 
                                                        |
| 982 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );  | 
                                                        |
| 983 | 983 | }  | 
                                                        
| 984 | 984 | |
| 985 | 985 | |
@@ -999,10 +999,10 @@ discard block  | 
                                                    ||
| 999 | 999 |      public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { | 
                                                        
| 1000 | 1000 | |
| 1001 | 1001 | // In case we have validated the form, use it to inject the validation results into the form render  | 
                                                        
| 1002 | -        if( isset( $this->form_after_validation ) ) { | 
                                                        |
| 1002 | +        if ( isset( $this->form_after_validation ) ) { | 
                                                        |
| 1003 | 1003 | $form = $this->form_after_validation;  | 
                                                        
| 1004 | 1004 |          } else { | 
                                                        
| 1005 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );  | 
                                                        |
| 1005 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );  | 
                                                        |
| 1006 | 1006 | }  | 
                                                        
| 1007 | 1007 | |
| 1008 | 1008 | $form = $this->filter_conditional_logic( $form );  | 
                                                        
@@ -1010,8 +1010,8 @@ discard block  | 
                                                    ||
| 1010 | 1010 | $form = $this->prefill_conditional_logic( $form );  | 
                                                        
| 1011 | 1011 | |
| 1012 | 1012 | // for now we don't support Save and Continue feature.  | 
                                                        
| 1013 | -        if( ! self::$supports_save_and_continue ) { | 
                                                        |
| 1014 | - unset( $form['save'] );  | 
                                                        |
| 1013 | +        if ( ! self::$supports_save_and_continue ) { | 
                                                        |
| 1014 | + unset( $form[ 'save' ] );  | 
                                                        |
| 1015 | 1015 | }  | 
                                                        
| 1016 | 1016 | |
| 1017 | 1017 | return $form;  | 
                                                        
@@ -1032,29 +1032,29 @@ discard block  | 
                                                    ||
| 1032 | 1032 | */  | 
                                                        
| 1033 | 1033 |      public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { | 
                                                        
| 1034 | 1034 | |
| 1035 | -        if( GFCommon::is_post_field( $field ) ) { | 
                                                        |
| 1035 | +        if ( GFCommon::is_post_field( $field ) ) { | 
                                                        |
| 1036 | 1036 | |
| 1037 | 1037 | $message = null;  | 
                                                        
| 1038 | 1038 | |
| 1039 | 1039 | // First, make sure they have the capability to edit the post.  | 
                                                        
| 1040 | -            if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { | 
                                                        |
| 1040 | +            if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { | 
                                                        |
| 1041 | 1041 | |
| 1042 | 1042 | /**  | 
                                                        
| 1043 | 1043 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post  | 
                                                        
| 1044 | 1044 | * @param string $message The existing "You don't have permission..." text  | 
                                                        
| 1045 | 1045 | */  | 
                                                        
| 1046 | -                $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); | 
                                                        |
| 1046 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) );  | 
                                                        |
| 1047 | 1047 | |
| 1048 | -            } elseif( null === get_post( $this->entry['post_id'] ) ) { | 
                                                        |
| 1048 | +            } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { | 
                                                        |
| 1049 | 1049 | /**  | 
                                                        
| 1050 | 1050 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists  | 
                                                        
| 1051 | 1051 | * @param string $message The existing "This field is not editable; the post no longer exists." text  | 
                                                        
| 1052 | 1052 | */  | 
                                                        
| 1053 | -                $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); | 
                                                        |
| 1053 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );  | 
                                                        |
| 1054 | 1054 | }  | 
                                                        
| 1055 | 1055 | |
| 1056 | -            if( $message ) { | 
                                                        |
| 1057 | -                $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); | 
                                                        |
| 1056 | +            if ( $message ) { | 
                                                        |
| 1057 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );  | 
                                                        |
| 1058 | 1058 | }  | 
                                                        
| 1059 | 1059 | }  | 
                                                        
| 1060 | 1060 | |
@@ -1079,8 +1079,8 @@ discard block  | 
                                                    ||
| 1079 | 1079 | |
| 1080 | 1080 | // If the form has been submitted, then we don't need to pre-fill the values,  | 
                                                        
| 1081 | 1081 | // Except for fileupload type and when a field input is overridden- run always!!  | 
                                                        
| 1082 | - if(  | 
                                                        |
| 1083 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )  | 
                                                        |
| 1082 | + if (  | 
                                                        |
| 1083 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )  | 
                                                        |
| 1084 | 1084 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )  | 
                                                        
| 1085 | 1085 | || ! empty( $field_content )  | 
                                                        
| 1086 | 1086 | || in_array( $field->type, array( 'honeypot' ) )  | 
                                                        
@@ -1090,8 +1090,8 @@ discard block  | 
                                                    ||
| 1090 | 1090 | }  | 
                                                        
| 1091 | 1091 | |
| 1092 | 1092 | // Turn on Admin-style display for file upload fields only  | 
                                                        
| 1093 | -        if( 'fileupload' === $field->type ) { | 
                                                        |
| 1094 | - $_GET['page'] = 'gf_entries';  | 
                                                        |
| 1093 | +        if ( 'fileupload' === $field->type ) { | 
                                                        |
| 1094 | + $_GET[ 'page' ] = 'gf_entries';  | 
                                                        |
| 1095 | 1095 | }  | 
                                                        
| 1096 | 1096 | |
| 1097 | 1097 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES  | 
                                                        
@@ -1118,13 +1118,13 @@ discard block  | 
                                                    ||
| 1118 | 1118 | * @param mixed $field_value field value used to populate the input  | 
                                                        
| 1119 | 1119 | * @param GF_Field $field Gravity Forms field object  | 
                                                        
| 1120 | 1120 | */  | 
                                                        
| 1121 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field );  | 
                                                        |
| 1121 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field );  | 
                                                        |
| 1122 | 1122 | |
| 1123 | 1123 | // Prevent any PHP warnings, like undefined index  | 
                                                        
| 1124 | 1124 | ob_start();  | 
                                                        
| 1125 | 1125 | |
| 1126 | 1126 | /** @var GravityView_Field $gv_field */  | 
                                                        
| 1127 | -        if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { | 
                                                        |
| 1127 | +        if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { | 
                                                        |
| 1128 | 1128 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );  | 
                                                        
| 1129 | 1129 |          } else { | 
                                                        
| 1130 | 1130 | $return = $field->get_field_input( $this->form, $field_value, $this->entry );  | 
                                                        
@@ -1134,7 +1134,7 @@ discard block  | 
                                                    ||
| 1134 | 1134 | // If there was output, it's an error  | 
                                                        
| 1135 | 1135 | $warnings = ob_get_clean();  | 
                                                        
| 1136 | 1136 | |
| 1137 | -	    if( !empty( $warnings ) ) { | 
                                                        |
| 1137 | +	    if ( ! empty( $warnings ) ) { | 
                                                        |
| 1138 | 1138 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value );  | 
                                                        
| 1139 | 1139 | }  | 
                                                        
| 1140 | 1140 | |
@@ -1143,7 +1143,7 @@ discard block  | 
                                                    ||
| 1143 | 1143 | * We need the fileupload html field to render with the proper id  | 
                                                        
| 1144 | 1144 | * ( <li id="field_80_16" ... > )  | 
                                                        
| 1145 | 1145 | */  | 
                                                        
| 1146 | - unset( $_GET['page'] );  | 
                                                        |
| 1146 | + unset( $_GET[ 'page' ] );  | 
                                                        |
| 1147 | 1147 | |
| 1148 | 1148 | return $return;  | 
                                                        
| 1149 | 1149 | }  | 
                                                        
@@ -1166,7 +1166,7 @@ discard block  | 
                                                    ||
| 1166 | 1166 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );  | 
                                                        
| 1167 | 1167 | |
| 1168 | 1168 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)  | 
                                                        
| 1169 | -        if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { | 
                                                        |
| 1169 | +        if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { | 
                                                        |
| 1170 | 1170 | |
| 1171 | 1171 | $field_value = array();  | 
                                                        
| 1172 | 1172 | |
@@ -1175,10 +1175,10 @@ discard block  | 
                                                    ||
| 1175 | 1175 | |
| 1176 | 1176 |              foreach ( (array)$field->inputs as $input ) { | 
                                                        
| 1177 | 1177 | |
| 1178 | - $input_id = strval( $input['id'] );  | 
                                                        |
| 1178 | + $input_id = strval( $input[ 'id' ] );  | 
                                                        |
| 1179 | 1179 | |
| 1180 | 1180 |                  if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { | 
                                                        
| 1181 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];  | 
                                                        |
| 1181 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];  | 
                                                        |
| 1182 | 1182 | $allow_pre_populated = false;  | 
                                                        
| 1183 | 1183 | }  | 
                                                        
| 1184 | 1184 | |
@@ -1186,7 +1186,7 @@ discard block  | 
                                                    ||
| 1186 | 1186 | |
| 1187 | 1187 | $pre_value = $field->get_value_submission( array(), false );  | 
                                                        
| 1188 | 1188 | |
| 1189 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;  | 
                                                        |
| 1189 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;  | 
                                                        |
| 1190 | 1190 | |
| 1191 | 1191 |          } else { | 
                                                        
| 1192 | 1192 | |
@@ -1197,13 +1197,13 @@ discard block  | 
                                                    ||
| 1197 | 1197 | |
| 1198 | 1198 | // saved field entry value (if empty, fallback to the pre-populated value, if exists)  | 
                                                        
| 1199 | 1199 | // or pre-populated value if not empty and set to override saved value  | 
                                                        
| 1200 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;  | 
                                                        |
| 1200 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;  | 
                                                        |
| 1201 | 1201 | |
| 1202 | 1202 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.  | 
                                                        
| 1203 | -            if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { | 
                                                        |
| 1203 | +            if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { | 
                                                        |
| 1204 | 1204 | $categories = array();  | 
                                                        
| 1205 | 1205 |                  foreach ( explode( ',', $field_value ) as $cat_string ) { | 
                                                        
| 1206 | - $categories[] = GFCommon::format_post_category( $cat_string, true );  | 
                                                        |
| 1206 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true );  | 
                                                        |
| 1207 | 1207 | }  | 
                                                        
| 1208 | 1208 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );  | 
                                                        
| 1209 | 1209 | }  | 
                                                        
@@ -1228,12 +1228,12 @@ discard block  | 
                                                    ||
| 1228 | 1228 | */  | 
                                                        
| 1229 | 1229 |      public function gform_pre_validation( $form ) { | 
                                                        
| 1230 | 1230 | |
| 1231 | -        if( ! $this->verify_nonce() ) { | 
                                                        |
| 1231 | +        if ( ! $this->verify_nonce() ) { | 
                                                        |
| 1232 | 1232 | return $form;  | 
                                                        
| 1233 | 1233 | }  | 
                                                        
| 1234 | 1234 | |
| 1235 | 1235 | // Fix PHP warning regarding undefined index.  | 
                                                        
| 1236 | -        foreach ( $form['fields'] as &$field) { | 
                                                        |
| 1236 | +        foreach ( $form[ 'fields' ] as &$field ) { | 
                                                        |
| 1237 | 1237 | |
| 1238 | 1238 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms  | 
                                                        
| 1239 | 1239 | // expects certain field array items to be set.  | 
                                                        
@@ -1246,7 +1246,7 @@ discard block  | 
                                                    ||
| 1246 | 1246 | $field['emailConfirmEnabled'] = '';  | 
                                                        
| 1247 | 1247 | }*/  | 
                                                        
| 1248 | 1248 | |
| 1249 | -            switch( RGFormsModel::get_input_type( $field ) ) { | 
                                                        |
| 1249 | +            switch ( RGFormsModel::get_input_type( $field ) ) { | 
                                                        |
| 1250 | 1250 | |
| 1251 | 1251 | /**  | 
                                                        
| 1252 | 1252 | * 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.  | 
                                                        
@@ -1260,37 +1260,37 @@ discard block  | 
                                                    ||
| 1260 | 1260 | // Set the previous value  | 
                                                        
| 1261 | 1261 | $entry = $this->get_entry();  | 
                                                        
| 1262 | 1262 | |
| 1263 | - $input_name = 'input_'.$field->id;  | 
                                                        |
| 1264 | - $form_id = $form['id'];  | 
                                                        |
| 1263 | + $input_name = 'input_' . $field->id;  | 
                                                        |
| 1264 | + $form_id = $form[ 'id' ];  | 
                                                        |
| 1265 | 1265 | |
| 1266 | 1266 | $value = NULL;  | 
                                                        
| 1267 | 1267 | |
| 1268 | 1268 | // Use the previous entry value as the default.  | 
                                                        
| 1269 | -                    if( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1269 | +                    if ( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1270 | 1270 | $value = $entry[ $field->id ];  | 
                                                        
| 1271 | 1271 | }  | 
                                                        
| 1272 | 1272 | |
| 1273 | 1273 | // If this is a single upload file  | 
                                                        
| 1274 | -                    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { | 
                                                        |
| 1275 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );  | 
                                                        |
| 1276 | - $value = $file_path['url'];  | 
                                                        |
| 1274 | +                    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { | 
                                                        |
| 1275 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );  | 
                                                        |
| 1276 | + $value = $file_path[ 'url' ];  | 
                                                        |
| 1277 | 1277 | |
| 1278 | 1278 |                      } else { | 
                                                        
| 1279 | 1279 | |
| 1280 | 1280 | // Fix PHP warning on line 1498 of form_display.php for post_image fields  | 
                                                        
| 1281 | 1281 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511  | 
                                                        
| 1282 | -                        $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); | 
                                                        |
| 1282 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );  | 
                                                        |
| 1283 | 1283 | |
| 1284 | 1284 | }  | 
                                                        
| 1285 | 1285 | |
| 1286 | -                    if( rgar($field, "multipleFiles") ) { | 
                                                        |
| 1286 | +                    if ( rgar( $field, "multipleFiles" ) ) { | 
                                                        |
| 1287 | 1287 | |
| 1288 | 1288 | // If there are fresh uploads, process and merge them.  | 
                                                        
| 1289 | 1289 | // Otherwise, use the passed values, which should be json-encoded array of URLs  | 
                                                        
| 1290 | -                        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { | 
                                                        |
| 1290 | +                        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { | 
                                                        |
| 1291 | 1291 | $value = empty( $value ) ? '[]' : $value;  | 
                                                        
| 1292 | 1292 | $value = stripslashes_deep( $value );  | 
                                                        
| 1293 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());  | 
                                                        |
| 1293 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );  | 
                                                        |
| 1294 | 1294 | }  | 
                                                        
| 1295 | 1295 | |
| 1296 | 1296 |                      } else { | 
                                                        
@@ -1308,14 +1308,14 @@ discard block  | 
                                                    ||
| 1308 | 1308 | |
| 1309 | 1309 | case 'number':  | 
                                                        
| 1310 | 1310 | // Fix "undefined index" issue at line 1286 in form_display.php  | 
                                                        
| 1311 | -                    if( !isset( $_POST['input_'.$field->id ] ) ) { | 
                                                        |
| 1312 | - $_POST['input_'.$field->id ] = NULL;  | 
                                                        |
| 1311 | +                    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { | 
                                                        |
| 1312 | + $_POST[ 'input_' . $field->id ] = NULL;  | 
                                                        |
| 1313 | 1313 | }  | 
                                                        
| 1314 | 1314 | break;  | 
                                                        
| 1315 | 1315 | case 'captcha':  | 
                                                        
| 1316 | 1316 | // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php  | 
                                                        
| 1317 | - $_POST['recaptcha_challenge_field'] = NULL;  | 
                                                        |
| 1318 | - $_POST['recaptcha_response_field'] = NULL;  | 
                                                        |
| 1317 | + $_POST[ 'recaptcha_challenge_field' ] = NULL;  | 
                                                        |
| 1318 | + $_POST[ 'recaptcha_response_field' ] = NULL;  | 
                                                        |
| 1319 | 1319 | break;  | 
                                                        
| 1320 | 1320 | }  | 
                                                        
| 1321 | 1321 | |
@@ -1351,7 +1351,7 @@ discard block  | 
                                                    ||
| 1351 | 1351 | * You can enter whatever you want!  | 
                                                        
| 1352 | 1352 | * We try validating, and customize the results using `self::custom_validation()`  | 
                                                        
| 1353 | 1353 | */  | 
                                                        
| 1354 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);  | 
                                                        |
| 1354 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );  | 
                                                        |
| 1355 | 1355 | |
| 1356 | 1356 | // Needed by the validate funtion  | 
                                                        
| 1357 | 1357 | $failed_validation_page = NULL;  | 
                                                        
@@ -1359,14 +1359,14 @@ discard block  | 
                                                    ||
| 1359 | 1359 | |
| 1360 | 1360 | // Prevent entry limit from running when editing an entry, also  | 
                                                        
| 1361 | 1361 | // prevent form scheduling from preventing editing  | 
                                                        
| 1362 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] );  | 
                                                        |
| 1362 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );  | 
                                                        |
| 1363 | 1363 | |
| 1364 | 1364 | // Hide fields depending on Edit Entry settings  | 
                                                        
| 1365 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );  | 
                                                        |
| 1365 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );  | 
                                                        |
| 1366 | 1366 | |
| 1367 | 1367 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );  | 
                                                        
| 1368 | 1368 | |
| 1369 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );  | 
                                                        |
| 1369 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );  | 
                                                        |
| 1370 | 1370 | }  | 
                                                        
| 1371 | 1371 | |
| 1372 | 1372 | |
@@ -1383,13 +1383,13 @@ discard block  | 
                                                    ||
| 1383 | 1383 | */  | 
                                                        
| 1384 | 1384 |      public function custom_validation( $validation_results ) { | 
                                                        
| 1385 | 1385 | |
| 1386 | -        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); | 
                                                        |
| 1386 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results );  | 
                                                        |
| 1387 | 1387 | |
| 1388 | -        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); | 
                                                        |
| 1388 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) );  | 
                                                        |
| 1389 | 1389 | |
| 1390 | 1390 | $gv_valid = true;  | 
                                                        
| 1391 | 1391 | |
| 1392 | -        foreach ( $validation_results['form']['fields'] as $key => &$field ) { | 
                                                        |
| 1392 | +        foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { | 
                                                        |
| 1393 | 1393 | |
| 1394 | 1394 | $value = RGFormsModel::get_field_value( $field );  | 
                                                        
| 1395 | 1395 | $field_type = RGFormsModel::get_input_type( $field );  | 
                                                        
@@ -1402,35 +1402,35 @@ discard block  | 
                                                    ||
| 1402 | 1402 | case 'post_image':  | 
                                                        
| 1403 | 1403 | |
| 1404 | 1404 | // in case nothing is uploaded but there are already files saved  | 
                                                        
| 1405 | -                    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { | 
                                                        |
| 1405 | +                    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { | 
                                                        |
| 1406 | 1406 | $field->failed_validation = false;  | 
                                                        
| 1407 | 1407 | unset( $field->validation_message );  | 
                                                        
| 1408 | 1408 | }  | 
                                                        
| 1409 | 1409 | |
| 1410 | 1410 | // validate if multi file upload reached max number of files [maxFiles] => 2  | 
                                                        
| 1411 | -                    if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { | 
                                                        |
| 1411 | +                    if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { | 
                                                        |
| 1412 | 1412 | |
| 1413 | 1413 | $input_name = 'input_' . $field->id;  | 
                                                        
| 1414 | 1414 | //uploaded  | 
                                                        
| 1415 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();  | 
                                                        |
| 1415 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();  | 
                                                        |
| 1416 | 1416 | |
| 1417 | 1417 | //existent  | 
                                                        
| 1418 | 1418 | $entry = $this->get_entry();  | 
                                                        
| 1419 | 1419 | $value = NULL;  | 
                                                        
| 1420 | -                        if( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1420 | +                        if ( isset( $entry[ $field->id ] ) ) { | 
                                                        |
| 1421 | 1421 | $value = json_decode( $entry[ $field->id ], true );  | 
                                                        
| 1422 | 1422 | }  | 
                                                        
| 1423 | 1423 | |
| 1424 | 1424 | // count uploaded files and existent entry files  | 
                                                        
| 1425 | 1425 | $count_files = count( $file_names ) + count( $value );  | 
                                                        
| 1426 | 1426 | |
| 1427 | -                        if( $count_files > $field->maxFiles ) { | 
                                                        |
| 1427 | +                        if ( $count_files > $field->maxFiles ) { | 
                                                        |
| 1428 | 1428 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );  | 
                                                        
| 1429 | 1429 | $field->failed_validation = 1;  | 
                                                        
| 1430 | 1430 | $gv_valid = false;  | 
                                                        
| 1431 | 1431 | |
| 1432 | 1432 | // in case of error make sure the newest upload files are removed from the upload input  | 
                                                        
| 1433 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;  | 
                                                        |
| 1433 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;  | 
                                                        |
| 1434 | 1434 | }  | 
                                                        
| 1435 | 1435 | |
| 1436 | 1436 | }  | 
                                                        
@@ -1441,7 +1441,7 @@ discard block  | 
                                                    ||
| 1441 | 1441 | }  | 
                                                        
| 1442 | 1442 | |
| 1443 | 1443 | // This field has failed validation.  | 
                                                        
| 1444 | -            if( !empty( $field->failed_validation ) ) { | 
                                                        |
| 1444 | +            if ( ! empty( $field->failed_validation ) ) { | 
                                                        |
| 1445 | 1445 | |
| 1446 | 1446 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) );  | 
                                                        
| 1447 | 1447 | |
@@ -1459,32 +1459,32 @@ discard block  | 
                                                    ||
| 1459 | 1459 | }  | 
                                                        
| 1460 | 1460 | |
| 1461 | 1461 | // You can't continue inside a switch, so we do it after.  | 
                                                        
| 1462 | -                if( empty( $field->failed_validation ) ) { | 
                                                        |
| 1462 | +                if ( empty( $field->failed_validation ) ) { | 
                                                        |
| 1463 | 1463 | continue;  | 
                                                        
| 1464 | 1464 | }  | 
                                                        
| 1465 | 1465 | |
| 1466 | 1466 | // checks if the No Duplicates option is not validating entry against itself, since  | 
                                                        
| 1467 | 1467 | // we're editing a stored entry, it would also assume it's a duplicate.  | 
                                                        
| 1468 | -                if( !empty( $field->noDuplicates ) ) { | 
                                                        |
| 1468 | +                if ( ! empty( $field->noDuplicates ) ) { | 
                                                        |
| 1469 | 1469 | |
| 1470 | 1470 | $entry = $this->get_entry();  | 
                                                        
| 1471 | 1471 | |
| 1472 | 1472 | // If the value of the entry is the same as the stored value  | 
                                                        
| 1473 | 1473 | // Then we can assume it's not a duplicate, it's the same.  | 
                                                        
| 1474 | -                    if( !empty( $entry ) && $value == $entry[ $field->id ] ) { | 
                                                        |
| 1474 | +                    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { | 
                                                        |
| 1475 | 1475 | //if value submitted was not changed, then don't validate  | 
                                                        
| 1476 | 1476 | $field->failed_validation = false;  | 
                                                        
| 1477 | 1477 | |
| 1478 | 1478 | unset( $field->validation_message );  | 
                                                        
| 1479 | 1479 | |
| 1480 | -                        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); | 
                                                        |
| 1480 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry );  | 
                                                        |
| 1481 | 1481 | |
| 1482 | 1482 | continue;  | 
                                                        
| 1483 | 1483 | }  | 
                                                        
| 1484 | 1484 | }  | 
                                                        
| 1485 | 1485 | |
| 1486 | 1486 | // if here then probably we are facing the validation 'At least one field must be filled out'  | 
                                                        
| 1487 | -                if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) { | 
                                                        |
| 1487 | +                if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { | 
                                                        |
| 1488 | 1488 | unset( $field->validation_message );  | 
                                                        
| 1489 | 1489 | $field->validation_message = false;  | 
                                                        
| 1490 | 1490 | continue;  | 
                                                        
@@ -1496,12 +1496,12 @@ discard block  | 
                                                    ||
| 1496 | 1496 | |
| 1497 | 1497 | }  | 
                                                        
| 1498 | 1498 | |
| 1499 | - $validation_results['is_valid'] = $gv_valid;  | 
                                                        |
| 1499 | + $validation_results[ 'is_valid' ] = $gv_valid;  | 
                                                        |
| 1500 | 1500 | |
| 1501 | -        do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); | 
                                                        |
| 1501 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results );  | 
                                                        |
| 1502 | 1502 | |
| 1503 | 1503 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form )  | 
                                                        
| 1504 | - $this->form_after_validation = $validation_results['form'];  | 
                                                        |
| 1504 | + $this->form_after_validation = $validation_results[ 'form' ];  | 
                                                        |
| 1505 | 1505 | |
| 1506 | 1506 | return $validation_results;  | 
                                                        
| 1507 | 1507 | }  | 
                                                        
@@ -1514,7 +1514,7 @@ discard block  | 
                                                    ||
| 1514 | 1514 | */  | 
                                                        
| 1515 | 1515 |      public function get_entry() { | 
                                                        
| 1516 | 1516 | |
| 1517 | -        if( empty( $this->entry ) ) { | 
                                                        |
| 1517 | +        if ( empty( $this->entry ) ) { | 
                                                        |
| 1518 | 1518 | // Get the database value of the entry that's being edited  | 
                                                        
| 1519 | 1519 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );  | 
                                                        
| 1520 | 1520 | }  | 
                                                        
@@ -1541,10 +1541,10 @@ discard block  | 
                                                    ||
| 1541 | 1541 | $properties = GravityView_View_Data::getInstance()->get_fields( $view_id );  | 
                                                        
| 1542 | 1542 | |
| 1543 | 1543 | // If edit tab not yet configured, show all fields  | 
                                                        
| 1544 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;  | 
                                                        |
| 1544 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;  | 
                                                        |
| 1545 | 1545 | |
| 1546 | 1546 | // Hide fields depending on admin settings  | 
                                                        
| 1547 | - $fields = $this->filter_fields( $form['fields'], $edit_fields );  | 
                                                        |
| 1547 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );  | 
                                                        |
| 1548 | 1548 | |
| 1549 | 1549 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.  | 
                                                        
| 1550 | 1550 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );  | 
                                                        
@@ -1576,7 +1576,7 @@ discard block  | 
                                                    ||
| 1576 | 1576 | */  | 
                                                        
| 1577 | 1577 |      private function filter_fields( $fields, $configured_fields ) { | 
                                                        
| 1578 | 1578 | |
| 1579 | -        if( empty( $fields ) || !is_array( $fields ) ) { | 
                                                        |
| 1579 | +        if ( empty( $fields ) || ! is_array( $fields ) ) { | 
                                                        |
| 1580 | 1580 | return $fields;  | 
                                                        
| 1581 | 1581 | }  | 
                                                        
| 1582 | 1582 | |
@@ -1593,13 +1593,13 @@ discard block  | 
                                                    ||
| 1593 | 1593 | */  | 
                                                        
| 1594 | 1594 | $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) );  | 
                                                        
| 1595 | 1595 | |
| 1596 | -	    if( $hide_product_fields ) { | 
                                                        |
| 1597 | - $field_type_blacklist[] = 'option';  | 
                                                        |
| 1598 | - $field_type_blacklist[] = 'quantity';  | 
                                                        |
| 1599 | - $field_type_blacklist[] = 'product';  | 
                                                        |
| 1600 | - $field_type_blacklist[] = 'total';  | 
                                                        |
| 1601 | - $field_type_blacklist[] = 'shipping';  | 
                                                        |
| 1602 | - $field_type_blacklist[] = 'calculation';  | 
                                                        |
| 1596 | +	    if ( $hide_product_fields ) { | 
                                                        |
| 1597 | + $field_type_blacklist[ ] = 'option';  | 
                                                        |
| 1598 | + $field_type_blacklist[ ] = 'quantity';  | 
                                                        |
| 1599 | + $field_type_blacklist[ ] = 'product';  | 
                                                        |
| 1600 | + $field_type_blacklist[ ] = 'total';  | 
                                                        |
| 1601 | + $field_type_blacklist[ ] = 'shipping';  | 
                                                        |
| 1602 | + $field_type_blacklist[ ] = 'calculation';  | 
                                                        |
| 1603 | 1603 | }  | 
                                                        
| 1604 | 1604 | |
| 1605 | 1605 | // First, remove blacklist or calculation fields  | 
                                                        
@@ -1607,24 +1607,24 @@ discard block  | 
                                                    ||
| 1607 | 1607 | |
| 1608 | 1608 | // Remove the fields that have calculation properties and keep them to be used later  | 
                                                        
| 1609 | 1609 | // @since 1.16.2  | 
                                                        
| 1610 | -            if( $field->has_calculation() ) { | 
                                                        |
| 1611 | - $this->fields_with_calculation[] = $field;  | 
                                                        |
| 1610 | +            if ( $field->has_calculation() ) { | 
                                                        |
| 1611 | + $this->fields_with_calculation[ ] = $field;  | 
                                                        |
| 1612 | 1612 | // don't remove the calculation fields on form render.  | 
                                                        
| 1613 | 1613 | }  | 
                                                        
| 1614 | 1614 | |
| 1615 | 1615 | // process total field after all fields have been saved  | 
                                                        
| 1616 | 1616 |              if ( $field->type == 'total' ) { | 
                                                        
| 1617 | - $this->total_fields[] = $field;  | 
                                                        |
| 1617 | + $this->total_fields[ ] = $field;  | 
                                                        |
| 1618 | 1618 | unset( $fields[ $key ] );  | 
                                                        
| 1619 | 1619 | }  | 
                                                        
| 1620 | 1620 | |
| 1621 | -            if( in_array( $field->type, $field_type_blacklist ) ) { | 
                                                        |
| 1621 | +            if ( in_array( $field->type, $field_type_blacklist ) ) { | 
                                                        |
| 1622 | 1622 | unset( $fields[ $key ] );  | 
                                                        
| 1623 | 1623 | }  | 
                                                        
| 1624 | 1624 | }  | 
                                                        
| 1625 | 1625 | |
| 1626 | 1626 | // The Edit tab has not been configured, so we return all fields by default.  | 
                                                        
| 1627 | -        if( empty( $configured_fields ) ) { | 
                                                        |
| 1627 | +        if ( empty( $configured_fields ) ) { | 
                                                        |
| 1628 | 1628 | return $fields;  | 
                                                        
| 1629 | 1629 | }  | 
                                                        
| 1630 | 1630 | |
@@ -1634,8 +1634,8 @@ discard block  | 
                                                    ||
| 1634 | 1634 | /** @var GF_Field $field */  | 
                                                        
| 1635 | 1635 |  	        foreach ( $fields as $field ) { | 
                                                        
| 1636 | 1636 | |
| 1637 | -                if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { | 
                                                        |
| 1638 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field );  | 
                                                        |
| 1637 | +                if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { | 
                                                        |
| 1638 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );  | 
                                                        |
| 1639 | 1639 | break;  | 
                                                        
| 1640 | 1640 | }  | 
                                                        
| 1641 | 1641 | |
@@ -1658,14 +1658,14 @@ discard block  | 
                                                    ||
| 1658 | 1658 | |
| 1659 | 1659 | $return_field = $field;  | 
                                                        
| 1660 | 1660 | |
| 1661 | -        if( empty( $field_setting['show_label'] ) ) { | 
                                                        |
| 1661 | +        if ( empty( $field_setting[ 'show_label' ] ) ) { | 
                                                        |
| 1662 | 1662 | $return_field->label = '';  | 
                                                        
| 1663 | -        } elseif ( !empty( $field_setting['custom_label'] ) ) { | 
                                                        |
| 1664 | - $return_field->label = $field_setting['custom_label'];  | 
                                                        |
| 1663 | +        } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { | 
                                                        |
| 1664 | + $return_field->label = $field_setting[ 'custom_label' ];  | 
                                                        |
| 1665 | 1665 | }  | 
                                                        
| 1666 | 1666 | |
| 1667 | -        if( !empty( $field_setting['custom_class'] ) ) { | 
                                                        |
| 1668 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );  | 
                                                        |
| 1667 | +        if ( ! empty( $field_setting[ 'custom_class' ] ) ) { | 
                                                        |
| 1668 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );  | 
                                                        |
| 1669 | 1669 | }  | 
                                                        
| 1670 | 1670 | |
| 1671 | 1671 | /**  | 
                                                        
@@ -1703,16 +1703,16 @@ discard block  | 
                                                    ||
| 1703 | 1703 | */  | 
                                                        
| 1704 | 1704 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );  | 
                                                        
| 1705 | 1705 | |
| 1706 | -	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { | 
                                                        |
| 1707 | -            foreach( $fields as $k => $field ) { | 
                                                        |
| 1708 | -                if( $field->adminOnly ) { | 
                                                        |
| 1706 | +	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { | 
                                                        |
| 1707 | +            foreach ( $fields as $k => $field ) { | 
                                                        |
| 1708 | +                if ( $field->adminOnly ) { | 
                                                        |
| 1709 | 1709 | unset( $fields[ $k ] );  | 
                                                        
| 1710 | 1710 | }  | 
                                                        
| 1711 | 1711 | }  | 
                                                        
| 1712 | 1712 | return $fields;  | 
                                                        
| 1713 | 1713 | }  | 
                                                        
| 1714 | 1714 | |
| 1715 | -	    foreach( $fields as &$field ) { | 
                                                        |
| 1715 | +	    foreach ( $fields as &$field ) { | 
                                                        |
| 1716 | 1716 | $field->adminOnly = false;  | 
                                                        
| 1717 | 1717 | }  | 
                                                        
| 1718 | 1718 | |
@@ -1736,22 +1736,22 @@ discard block  | 
                                                    ||
| 1736 | 1736 | */  | 
                                                        
| 1737 | 1737 |      function prefill_conditional_logic( $form ) { | 
                                                        
| 1738 | 1738 | |
| 1739 | -        if( ! GFFormDisplay::has_conditional_logic( $form ) ) { | 
                                                        |
| 1739 | +        if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { | 
                                                        |
| 1740 | 1740 | return $form;  | 
                                                        
| 1741 | 1741 | }  | 
                                                        
| 1742 | 1742 | |
| 1743 | 1743 | // Have Conditional Logic pre-fill fields as if the data were default values  | 
                                                        
| 1744 | 1744 | /** @var GF_Field $field */  | 
                                                        
| 1745 | -        foreach ( $form['fields'] as &$field ) { | 
                                                        |
| 1745 | +        foreach ( $form[ 'fields' ] as &$field ) { | 
                                                        |
| 1746 | 1746 | |
| 1747 | -            if( 'checkbox' === $field->type ) { | 
                                                        |
| 1747 | +            if ( 'checkbox' === $field->type ) { | 
                                                        |
| 1748 | 1748 |                  foreach ( $field->get_entry_inputs() as $key => $input ) { | 
                                                        
| 1749 | - $input_id = $input['id'];  | 
                                                        |
| 1749 | + $input_id = $input[ 'id' ];  | 
                                                        |
| 1750 | 1750 | $choice = $field->choices[ $key ];  | 
                                                        
| 1751 | 1751 | $value = rgar( $this->entry, $input_id );  | 
                                                        
| 1752 | 1752 | $match = RGFormsModel::choice_value_match( $field, $choice, $value );  | 
                                                        
| 1753 | -                    if( $match ) { | 
                                                        |
| 1754 | - $field->choices[ $key ]['isSelected'] = true;  | 
                                                        |
| 1753 | +                    if ( $match ) { | 
                                                        |
| 1754 | + $field->choices[ $key ][ 'isSelected' ] = true;  | 
                                                        |
| 1755 | 1755 | }  | 
                                                        
| 1756 | 1756 | }  | 
                                                        
| 1757 | 1757 |              } else { | 
                                                        
@@ -1759,15 +1759,15 @@ discard block  | 
                                                    ||
| 1759 | 1759 | // We need to run through each field to set the default values  | 
                                                        
| 1760 | 1760 |                  foreach ( $this->entry as $field_id => $field_value ) { | 
                                                        
| 1761 | 1761 | |
| 1762 | -                    if( floatval( $field_id ) === floatval( $field->id ) ) { | 
                                                        |
| 1762 | +                    if ( floatval( $field_id ) === floatval( $field->id ) ) { | 
                                                        |
| 1763 | 1763 | |
| 1764 | -                        if( 'list' === $field->type ) { | 
                                                        |
| 1764 | +                        if ( 'list' === $field->type ) { | 
                                                        |
| 1765 | 1765 | $list_rows = maybe_unserialize( $field_value );  | 
                                                        
| 1766 | 1766 | |
| 1767 | 1767 | $list_field_value = array();  | 
                                                        
| 1768 | -                            foreach ( (array) $list_rows as $row ) { | 
                                                        |
| 1769 | -                                foreach ( (array) $row as $column ) { | 
                                                        |
| 1770 | - $list_field_value[] = $column;  | 
                                                        |
| 1768 | +                            foreach ( (array)$list_rows as $row ) { | 
                                                        |
| 1769 | +                                foreach ( (array)$row as $column ) { | 
                                                        |
| 1770 | + $list_field_value[ ] = $column;  | 
                                                        |
| 1771 | 1771 | }  | 
                                                        
| 1772 | 1772 | }  | 
                                                        
| 1773 | 1773 | |
@@ -1802,16 +1802,16 @@ discard block  | 
                                                    ||
| 1802 | 1802 | */  | 
                                                        
| 1803 | 1803 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );  | 
                                                        
| 1804 | 1804 | |
| 1805 | -        if( $use_conditional_logic ) { | 
                                                        |
| 1805 | +        if ( $use_conditional_logic ) { | 
                                                        |
| 1806 | 1806 | return $form;  | 
                                                        
| 1807 | 1807 | }  | 
                                                        
| 1808 | 1808 | |
| 1809 | -        foreach( $form['fields'] as &$field ) { | 
                                                        |
| 1809 | +        foreach ( $form[ 'fields' ] as &$field ) { | 
                                                        |
| 1810 | 1810 | /* @var GF_Field $field */  | 
                                                        
| 1811 | 1811 | $field->conditionalLogic = null;  | 
                                                        
| 1812 | 1812 | }  | 
                                                        
| 1813 | 1813 | |
| 1814 | - unset( $form['button']['conditionalLogic'] );  | 
                                                        |
| 1814 | + unset( $form[ 'button' ][ 'conditionalLogic' ] );  | 
                                                        |
| 1815 | 1815 | |
| 1816 | 1816 | return $form;  | 
                                                        
| 1817 | 1817 | |
@@ -1828,7 +1828,7 @@ discard block  | 
                                                    ||
| 1828 | 1828 | */  | 
                                                        
| 1829 | 1829 |      public function manage_conditional_logic( $has_conditional_logic, $form ) { | 
                                                        
| 1830 | 1830 | |
| 1831 | -        if( ! $this->is_edit_entry() ) { | 
                                                        |
| 1831 | +        if ( ! $this->is_edit_entry() ) { | 
                                                        |
| 1832 | 1832 | return $has_conditional_logic;  | 
                                                        
| 1833 | 1833 | }  | 
                                                        
| 1834 | 1834 | |
@@ -1860,44 +1860,44 @@ discard block  | 
                                                    ||
| 1860 | 1860 | * 2. There are two entries embedded using oEmbed  | 
                                                        
| 1861 | 1861 | * 3. One of the entries has just been saved  | 
                                                        
| 1862 | 1862 | */  | 
                                                        
| 1863 | -        if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { | 
                                                        |
| 1863 | +        if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { | 
                                                        |
| 1864 | 1864 | |
| 1865 | 1865 | $error = true;  | 
                                                        
| 1866 | 1866 | |
| 1867 | 1867 | }  | 
                                                        
| 1868 | 1868 | |
| 1869 | -        if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { | 
                                                        |
| 1869 | +        if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { | 
                                                        |
| 1870 | 1870 | |
| 1871 | 1871 | $error = true;  | 
                                                        
| 1872 | 1872 | |
| 1873 | -        } elseif( ! $this->verify_nonce() ) { | 
                                                        |
| 1873 | +        } elseif ( ! $this->verify_nonce() ) { | 
                                                        |
| 1874 | 1874 | |
| 1875 | 1875 | /**  | 
                                                        
| 1876 | 1876 | * If the Entry is embedded, there may be two entries on the same page.  | 
                                                        
| 1877 | 1877 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error.  | 
                                                        
| 1878 | 1878 | */  | 
                                                        
| 1879 | -            if( GravityView_oEmbed::getInstance()->get_entry_id() ) { | 
                                                        |
| 1879 | +            if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { | 
                                                        |
| 1880 | 1880 | $error = true;  | 
                                                        
| 1881 | 1881 |              } else { | 
                                                        
| 1882 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');  | 
                                                        |
| 1882 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );  | 
                                                        |
| 1883 | 1883 | }  | 
                                                        
| 1884 | 1884 | |
| 1885 | 1885 | }  | 
                                                        
| 1886 | 1886 | |
| 1887 | -        if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { | 
                                                        |
| 1888 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview');  | 
                                                        |
| 1887 | +        if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { | 
                                                        |
| 1888 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' );  | 
                                                        |
| 1889 | 1889 | }  | 
                                                        
| 1890 | 1890 | |
| 1891 | -        if( $this->entry['status'] === 'trash' ) { | 
                                                        |
| 1892 | -            $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); | 
                                                        |
| 1891 | +        if ( $this->entry[ 'status' ] === 'trash' ) { | 
                                                        |
| 1892 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );  | 
                                                        |
| 1893 | 1893 | }  | 
                                                        
| 1894 | 1894 | |
| 1895 | 1895 | // No errors; everything's fine here!  | 
                                                        
| 1896 | -        if( empty( $error ) ) { | 
                                                        |
| 1896 | +        if ( empty( $error ) ) { | 
                                                        |
| 1897 | 1897 | return true;  | 
                                                        
| 1898 | 1898 | }  | 
                                                        
| 1899 | 1899 | |
| 1900 | -        if( $echo && $error !== true ) { | 
                                                        |
| 1900 | +        if ( $echo && $error !== true ) { | 
                                                        |
| 1901 | 1901 | |
| 1902 | 1902 | $error = esc_html( $error );  | 
                                                        
| 1903 | 1903 | |
@@ -1905,13 +1905,13 @@ discard block  | 
                                                    ||
| 1905 | 1905 | * @since 1.9  | 
                                                        
| 1906 | 1906 | */  | 
                                                        
| 1907 | 1907 |  	        if ( ! empty( $this->entry ) ) { | 
                                                        
| 1908 | -		        $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;" ) ); | 
                                                        |
| 1908 | + $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;" ) );  | 
                                                        |
| 1909 | 1909 | }  | 
                                                        
| 1910 | 1910 | |
| 1911 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');  | 
                                                        |
| 1911 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );  | 
                                                        |
| 1912 | 1912 | }  | 
                                                        
| 1913 | 1913 | |
| 1914 | -        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); | 
                                                        |
| 1914 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error );  | 
                                                        |
| 1915 | 1915 | |
| 1916 | 1916 | return false;  | 
                                                        
| 1917 | 1917 | }  | 
                                                        
@@ -1928,20 +1928,20 @@ discard block  | 
                                                    ||
| 1928 | 1928 | |
| 1929 | 1929 | $error = NULL;  | 
                                                        
| 1930 | 1930 | |
| 1931 | -        if( ! $this->check_user_cap_edit_field( $field ) ) { | 
                                                        |
| 1932 | - $error = __( 'You do not have permission to edit this field.', 'gravityview');  | 
                                                        |
| 1931 | +        if ( ! $this->check_user_cap_edit_field( $field ) ) { | 
                                                        |
| 1932 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' );  | 
                                                        |
| 1933 | 1933 | }  | 
                                                        
| 1934 | 1934 | |
| 1935 | 1935 | // No errors; everything's fine here!  | 
                                                        
| 1936 | -        if( empty( $error ) ) { | 
                                                        |
| 1936 | +        if ( empty( $error ) ) { | 
                                                        |
| 1937 | 1937 | return true;  | 
                                                        
| 1938 | 1938 | }  | 
                                                        
| 1939 | 1939 | |
| 1940 | -        if( $echo ) { | 
                                                        |
| 1941 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');  | 
                                                        |
| 1940 | +        if ( $echo ) { | 
                                                        |
| 1941 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );  | 
                                                        |
| 1942 | 1942 | }  | 
                                                        
| 1943 | 1943 | |
| 1944 | -        do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); | 
                                                        |
| 1944 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error );  | 
                                                        |
| 1945 | 1945 | |
| 1946 | 1946 | return false;  | 
                                                        
| 1947 | 1947 | |
@@ -1959,15 +1959,15 @@ discard block  | 
                                                    ||
| 1959 | 1959 |      private function check_user_cap_edit_field( $field ) { | 
                                                        
| 1960 | 1960 | |
| 1961 | 1961 | // If they can edit any entries (as defined in Gravity Forms), we're good.  | 
                                                        
| 1962 | -        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { | 
                                                        |
| 1962 | +        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { | 
                                                        |
| 1963 | 1963 | return true;  | 
                                                        
| 1964 | 1964 | }  | 
                                                        
| 1965 | 1965 | |
| 1966 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;  | 
                                                        |
| 1966 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;  | 
                                                        |
| 1967 | 1967 | |
| 1968 | 1968 | // If the field has custom editing capaibilities set, check those  | 
                                                        
| 1969 | -        if( $field_cap ) { | 
                                                        |
| 1970 | - return GVCommon::has_cap( $field['allow_edit_cap'] );  | 
                                                        |
| 1969 | +        if ( $field_cap ) { | 
                                                        |
| 1970 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );  | 
                                                        |
| 1971 | 1971 | }  | 
                                                        
| 1972 | 1972 | |
| 1973 | 1973 | return false;  | 
                                                        
@@ -1981,17 +1981,17 @@ discard block  | 
                                                    ||
| 1981 | 1981 |      public function verify_nonce() { | 
                                                        
| 1982 | 1982 | |
| 1983 | 1983 | // Verify form submitted for editing single  | 
                                                        
| 1984 | -        if( $this->is_edit_entry_submission() ) { | 
                                                        |
| 1984 | +        if ( $this->is_edit_entry_submission() ) { | 
                                                        |
| 1985 | 1985 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );  | 
                                                        
| 1986 | 1986 | }  | 
                                                        
| 1987 | 1987 | |
| 1988 | 1988 | // Verify  | 
                                                        
| 1989 | -        else if( ! $this->is_edit_entry() ) { | 
                                                        |
| 1989 | +        else if ( ! $this->is_edit_entry() ) { | 
                                                        |
| 1990 | 1990 | $valid = false;  | 
                                                        
| 1991 | 1991 | }  | 
                                                        
| 1992 | 1992 | |
| 1993 | 1993 |          else { | 
                                                        
| 1994 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );  | 
                                                        |
| 1994 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );  | 
                                                        |
| 1995 | 1995 | }  | 
                                                        
| 1996 | 1996 | |
| 1997 | 1997 | /**  |