Completed
Push — master ( 67ab10...dbf55d )
by Stephanie
03:13
created
classes/helpers/FrmAppHelper.php 1 patch
Indentation   +557 added lines, -557 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public static $plug_version = '3.04.01';
15 15
 
16
-    /**
17
-     * @since 1.07.02
18
-     *
19
-     * @param none
20
-     * @return string The version of this plugin
21
-     */
22
-    public static function plugin_version() {
23
-        return self::$plug_version;
24
-    }
16
+	/**
17
+	 * @since 1.07.02
18
+	 *
19
+	 * @param none
20
+	 * @return string The version of this plugin
21
+	 */
22
+	public static function plugin_version() {
23
+		return self::$plug_version;
24
+	}
25 25
 
26 26
 	public static function plugin_folder() {
27 27
 		return basename( self::plugin_path() );
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 		return dirname( dirname( dirname( __FILE__ ) ) );
32 32
 	}
33 33
 
34
-    public static function plugin_url() {
35
-        //prevously FRM_URL constant
34
+	public static function plugin_url() {
35
+		//prevously FRM_URL constant
36 36
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
37
-    }
37
+	}
38 38
 
39 39
 	public static function relative_plugin_url() {
40 40
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
41 41
 	}
42 42
 
43
-    /**
44
-     * @return string Site URL
45
-     */
46
-    public static function site_url() {
47
-        return site_url();
48
-    }
49
-
50
-    /**
51
-     * Get the name of this site
52
-     * Used for [sitename] shortcode
53
-     *
54
-     * @since 2.0
55
-     * @return string
56
-     */
43
+	/**
44
+	 * @return string Site URL
45
+	 */
46
+	public static function site_url() {
47
+		return site_url();
48
+	}
49
+
50
+	/**
51
+	 * Get the name of this site
52
+	 * Used for [sitename] shortcode
53
+	 *
54
+	 * @since 2.0
55
+	 * @return string
56
+	 */
57 57
 	public static function site_name() {
58 58
 		return get_option( 'blogname' );
59 59
 	}
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
72 72
 	}
73 73
 
74
-    /**
75
-     * Get the Formidable settings
76
-     *
77
-     * @since 2.0
78
-     *
79
-     * @param None
80
-     * @return FrmSettings $frm_setings
81
-     */
74
+	/**
75
+	 * Get the Formidable settings
76
+	 *
77
+	 * @since 2.0
78
+	 *
79
+	 * @param None
80
+	 * @return FrmSettings $frm_setings
81
+	 */
82 82
 	public static function get_settings() {
83 83
 		global $frm_settings;
84 84
 		if ( empty( $frm_settings ) ) {
@@ -119,50 +119,50 @@  discard block
 block discarded – undo
119 119
 		return $is_formidable;
120 120
 	}
121 121
 
122
-    /**
123
-     * Check for certain page in Formidable settings
124
-     *
125
-     * @since 2.0
126
-     *
127
-     * @param string $page The name of the page to check
128
-     * @return boolean
129
-     */
122
+	/**
123
+	 * Check for certain page in Formidable settings
124
+	 *
125
+	 * @since 2.0
126
+	 *
127
+	 * @param string $page The name of the page to check
128
+	 * @return boolean
129
+	 */
130 130
 	public static function is_admin_page( $page = 'formidable' ) {
131
-        global $pagenow;
131
+		global $pagenow;
132 132
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
133
-        if ( $pagenow ) {
133
+		if ( $pagenow ) {
134 134
 			// allow this to be true during ajax load i.e. ajax form builder loading
135 135
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
136
-        }
136
+		}
137 137
 
138 138
 		return is_admin() && $get_page == $page;
139
-    }
140
-
141
-    /**
142
-     * Check for the form preview page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_preview_page() {
150
-        global $pagenow;
139
+	}
140
+
141
+	/**
142
+	 * Check for the form preview page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_preview_page() {
150
+		global $pagenow;
151 151
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
152 152
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
153
-    }
154
-
155
-    /**
156
-     * Check for ajax except the form preview page
157
-     *
158
-     * @since 2.0
159
-     *
160
-     * @param None
161
-     * @return boolean
162
-     */
163
-    public static function doing_ajax() {
164
-        return self::wp_doing_ajax() && ! self::is_preview_page();
165
-    }
153
+	}
154
+
155
+	/**
156
+	 * Check for ajax except the form preview page
157
+	 *
158
+	 * @since 2.0
159
+	 *
160
+	 * @param None
161
+	 * @return boolean
162
+	 */
163
+	public static function doing_ajax() {
164
+		return self::wp_doing_ajax() && ! self::is_preview_page();
165
+	}
166 166
 
167 167
 	public static function js_suffix() {
168 168
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -189,81 +189,81 @@  discard block
 block discarded – undo
189 189
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
190 190
 	}
191 191
 
192
-    /**
193
-     * Check if on an admin page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function is_admin() {
201
-        return is_admin() && ! self::wp_doing_ajax();
202
-    }
203
-
204
-    /**
205
-     * Check if value contains blank value or empty array
206
-     *
207
-     * @since 2.0
208
-     * @param mixed $value - value to check
192
+	/**
193
+	 * Check if on an admin page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function is_admin() {
201
+		return is_admin() && ! self::wp_doing_ajax();
202
+	}
203
+
204
+	/**
205
+	 * Check if value contains blank value or empty array
206
+	 *
207
+	 * @since 2.0
208
+	 * @param mixed $value - value to check
209 209
 	 * @param string
210
-     * @return boolean
211
-     */
212
-    public static function is_empty_value( $value, $empty = '' ) {
213
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
-    }
215
-
216
-    public static function is_not_empty_value( $value, $empty = '' ) {
217
-        return ! self::is_empty_value( $value, $empty );
218
-    }
219
-
220
-    /**
221
-     * Get any value from the $_SERVER
222
-     *
223
-     * @since 2.0
224
-     * @param string $value
225
-     * @return string
226
-     */
210
+	 * @return boolean
211
+	 */
212
+	public static function is_empty_value( $value, $empty = '' ) {
213
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
+	}
215
+
216
+	public static function is_not_empty_value( $value, $empty = '' ) {
217
+		return ! self::is_empty_value( $value, $empty );
218
+	}
219
+
220
+	/**
221
+	 * Get any value from the $_SERVER
222
+	 *
223
+	 * @since 2.0
224
+	 * @param string $value
225
+	 * @return string
226
+	 */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
-    }
230
-
231
-    /**
232
-     * Check for the IP address in several places
233
-     * Used by [ip] shortcode
234
-     *
235
-     * @return string The IP address of the current user
236
-     */
237
-    public static function get_ip_address() {
228
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
+	}
230
+
231
+	/**
232
+	 * Check for the IP address in several places
233
+	 * Used by [ip] shortcode
234
+	 *
235
+	 * @return string The IP address of the current user
236
+	 */
237
+	public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
241
-                continue;
242
-            }
240
+			if ( ! isset( $_SERVER[ $key ] ) ) {
241
+				continue;
242
+			}
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
244
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245 245
 				$ip = trim( $ip ); // just to be safe
246 246
 
247 247
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248
-                    return sanitize_text_field( $ip );
249
-                }
250
-            }
251
-        }
248
+					return sanitize_text_field( $ip );
249
+				}
250
+			}
251
+		}
252 252
 
253 253
 		return sanitize_text_field( $ip );
254
-    }
254
+	}
255 255
 
256
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
256
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257 257
 		if ( strpos( $param, '[' ) ) {
258 258
 			$params = explode( '[', $param );
259
-            $param = $params[0];
260
-        }
259
+			$param = $params[0];
260
+		}
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
-            }
263
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
+			}
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
269 269
 			$value = self::get_simple_request(
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 			}
288 288
 		}
289 289
 
290
-        return $value;
291
-    }
290
+		return $value;
291
+	}
292 292
 
293 293
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
294 294
 		return self::get_simple_request(
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 	}
357 357
 
358 358
 	/**
359
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
360
-	*
361
-	* @since 2.0.8
362
-	* @param string $value
363
-	* @return string $value
364
-	*/
359
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
360
+	 *
361
+	 * @since 2.0.8
362
+	 * @param string $value
363
+	 * @return string $value
364
+	 */
365 365
 	public static function preserve_backslashes( $value ) {
366 366
 		// If backslashes have already been added, don't add them again
367 367
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 		}
384 384
 	}
385 385
 
386
-    public static function sanitize_request( $sanitize_method, &$values ) {
387
-        $temp_values = $values;
388
-        foreach ( $temp_values as $k => $val ) {
389
-            if ( isset( $sanitize_method[ $k ] ) ) {
386
+	public static function sanitize_request( $sanitize_method, &$values ) {
387
+		$temp_values = $values;
388
+		foreach ( $temp_values as $k => $val ) {
389
+			if ( isset( $sanitize_method[ $k ] ) ) {
390 390
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
391
-            }
392
-        }
393
-    }
391
+			}
392
+		}
393
+	}
394 394
 
395 395
 	/**
396 396
 	 * @deprecated 3.01
@@ -516,39 +516,39 @@  discard block
 block discarded – undo
516 516
 		);
517 517
 	}
518 518
 
519
-    /**
520
-     * Used when switching the action for a bulk action
521
-     * @since 2.0
522
-     */
519
+	/**
520
+	 * Used when switching the action for a bulk action
521
+	 * @since 2.0
522
+	 */
523 523
 	public static function remove_get_action() {
524 524
 		if ( ! isset( $_GET ) ) {
525 525
 			return;
526 526
 		}
527 527
 
528
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
529
-        if ( ! empty( $new_action ) ) {
528
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
529
+		if ( ! empty( $new_action ) ) {
530 530
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
531
-        }
532
-    }
531
+		}
532
+	}
533 533
 
534
-    /**
535
-     * Check the WP query for a parameter
536
-     *
537
-     * @since 2.0
538
-     * @return string|array
539
-     */
540
-    public static function get_query_var( $value, $param ) {
541
-        if ( $value != '' ) {
542
-            return $value;
543
-        }
534
+	/**
535
+	 * Check the WP query for a parameter
536
+	 *
537
+	 * @since 2.0
538
+	 * @return string|array
539
+	 */
540
+	public static function get_query_var( $value, $param ) {
541
+		if ( $value != '' ) {
542
+			return $value;
543
+		}
544 544
 
545
-        global $wp_query;
546
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
547
-            $value = $wp_query->query_vars[ $param ];
548
-        }
545
+		global $wp_query;
546
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
547
+			$value = $wp_query->query_vars[ $param ];
548
+		}
549 549
 
550
-        return $value;
551
-    }
550
+		return $value;
551
+	}
552 552
 
553 553
 	/**
554 554
 	 * @since 3.0
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 		}
571 571
 	}
572 572
 
573
-    /**
574
-     * @param string $type
575
-     */
576
-    public static function trigger_hook_load( $type, $object = null ) {
577
-        // only load the form hooks once
573
+	/**
574
+	 * @param string $type
575
+	 */
576
+	public static function trigger_hook_load( $type, $object = null ) {
577
+		// only load the form hooks once
578 578
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
579
-        if ( ! $hooks_loaded ) {
579
+		if ( ! $hooks_loaded ) {
580 580
 			do_action( 'frm_load_' . $type . '_hooks' );
581
-        }
582
-    }
581
+		}
582
+	}
583 583
 
584 584
 	/**
585 585
 	 * Save all front-end js scripts into a single file
@@ -604,29 +604,29 @@  discard block
 block discarded – undo
604 604
 		$new_file->combine_files( $files );
605 605
 	}
606 606
 
607
-    /**
608
-     * Check a value from a shortcode to see if true or false.
609
-     * True when value is 1, true, 'true', 'yes'
610
-     *
611
-     * @since 1.07.10
612
-     *
613
-     * @param string $value The value to compare
614
-     * @return boolean True or False
615
-     */
607
+	/**
608
+	 * Check a value from a shortcode to see if true or false.
609
+	 * True when value is 1, true, 'true', 'yes'
610
+	 *
611
+	 * @since 1.07.10
612
+	 *
613
+	 * @param string $value The value to compare
614
+	 * @return boolean True or False
615
+	 */
616 616
 	public static function is_true( $value ) {
617
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
618
-    }
617
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
618
+	}
619 619
 
620
-    /**
621
-     * Used to filter shortcode in text widgets
620
+	/**
621
+	 * Used to filter shortcode in text widgets
622 622
 	 *
623 623
 	 * @deprecated 2.5.4
624 624
 	 * @codeCoverageIgnore
625
-     */
626
-    public static function widget_text_filter_callback( $matches ) {
625
+	 */
626
+	public static function widget_text_filter_callback( $matches ) {
627 627
 		_deprecated_function( __METHOD__, '2.5.4' );
628
-        return do_shortcode( $matches[0] );
629
-    }
628
+		return do_shortcode( $matches[0] );
629
+	}
630 630
 
631 631
 	public static function get_pages() {
632 632
 		$query = array(
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
 		return get_posts( $query );
640 640
 	}
641 641
 
642
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
643
-        $pages = self::get_pages();
642
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
643
+		$pages = self::get_pages();
644 644
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
645
-    ?>
645
+	?>
646 646
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
647 647
             <option value=""> </option>
648 648
             <?php foreach ( $pages as $page ) { ?>
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
             <?php } ?>
653 653
         </select>
654 654
     <?php
655
-    }
655
+	}
656 656
 
657 657
 	public static function post_edit_link( $post_id ) {
658 658
 		$post = get_post( $post_id );
659
-        if ( $post ) {
659
+		if ( $post ) {
660 660
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
661 661
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
662
-        }
663
-        return '';
664
-    }
662
+		}
663
+		return '';
664
+	}
665 665
 
666 666
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
667 667
 		?>
@@ -672,73 +672,73 @@  discard block
 block discarded – undo
672 672
 	}
673 673
 
674 674
 	public static function roles_options( $capability ) {
675
-        global $frm_vars;
675
+		global $frm_vars;
676 676
 		if ( isset( $frm_vars['editable_roles'] ) ) {
677
-            $editable_roles = $frm_vars['editable_roles'];
678
-        } else {
679
-            $editable_roles = get_editable_roles();
680
-            $frm_vars['editable_roles'] = $editable_roles;
681
-        }
677
+			$editable_roles = $frm_vars['editable_roles'];
678
+		} else {
679
+			$editable_roles = get_editable_roles();
680
+			$frm_vars['editable_roles'] = $editable_roles;
681
+		}
682 682
 
683
-        foreach ( $editable_roles as $role => $details ) {
683
+		foreach ( $editable_roles as $role => $details ) {
684 684
 			$name = translate_user_role( $details['name'] );
685 685
 			?>
686 686
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
687 687
 <?php
688 688
 			unset( $role, $details );
689
-        }
690
-    }
689
+		}
690
+	}
691 691
 
692 692
 	public static function frm_capabilities( $type = 'auto' ) {
693
-        $cap = array(
694
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
695
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
696
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
697
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
698
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
699
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
700
-        );
693
+		$cap = array(
694
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
695
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
696
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
697
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
698
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
699
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
700
+		);
701 701
 
702 702
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
703
-            return $cap;
704
-        }
703
+			return $cap;
704
+		}
705 705
 
706
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
707
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
708
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
709
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
706
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
707
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
708
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
709
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
710 710
 
711
-        return $cap;
712
-    }
711
+		return $cap;
712
+	}
713 713
 
714 714
 	public static function user_has_permission( $needed_role ) {
715
-        if ( $needed_role == '-1' ) {
716
-            return false;
715
+		if ( $needed_role == '-1' ) {
716
+			return false;
717 717
 		}
718 718
 
719
-        // $needed_role will be equal to blank if "Logged-in users" is selected
720
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
721
-            return true;
722
-        }
719
+		// $needed_role will be equal to blank if "Logged-in users" is selected
720
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
721
+			return true;
722
+		}
723 723
 
724
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
725
-        foreach ( $roles as $role ) {
724
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
725
+		foreach ( $roles as $role ) {
726 726
 			if ( current_user_can( $role ) ) {
727
-        		return true;
727
+				return true;
728 728
 			}
729
-        	if ( $role == $needed_role ) {
730
-        		break;
729
+			if ( $role == $needed_role ) {
730
+				break;
731 731
 			}
732
-        }
733
-        return false;
734
-    }
735
-
736
-    /**
737
-     * Make sure administrators can see Formidable menu
738
-     *
739
-     * @since 2.0
740
-     */
741
-    public static function maybe_add_permissions() {
732
+		}
733
+		return false;
734
+	}
735
+
736
+	/**
737
+	 * Make sure administrators can see Formidable menu
738
+	 *
739
+	 * @since 2.0
740
+	 */
741
+	public static function maybe_add_permissions() {
742 742
 		self::force_capability( 'frm_view_entries' );
743 743
 
744 744
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -747,12 +747,12 @@  discard block
 block discarded – undo
747 747
 
748 748
 		$user_id = get_current_user_id();
749 749
 		$user = new WP_User( $user_id );
750
-        $frm_roles = self::frm_capabilities();
751
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
750
+		$frm_roles = self::frm_capabilities();
751
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
752 752
 			$user->add_cap( $frm_role );
753 753
 			unset( $frm_role, $frm_role_description );
754
-        }
755
-    }
754
+		}
755
+	}
756 756
 
757 757
 	/**
758 758
 	 * Make sure admins have permission to see the menu items
@@ -768,28 +768,28 @@  discard block
 block discarded – undo
768 768
 		}
769 769
 	}
770 770
 
771
-    /**
772
-     * Check if the user has permision for action.
773
-     * Return permission message and stop the action if no permission
774
-     * @since 2.0
775
-     * @param string $permission
776
-     */
771
+	/**
772
+	 * Check if the user has permision for action.
773
+	 * Return permission message and stop the action if no permission
774
+	 * @since 2.0
775
+	 * @param string $permission
776
+	 */
777 777
 	public static function permission_check( $permission, $show_message = 'show' ) {
778 778
 		$permission_error = self::permission_nonce_error( $permission );
779
-        if ( $permission_error !== false ) {
780
-            if ( 'hide' == $show_message ) {
781
-                $permission_error = '';
782
-            }
779
+		if ( $permission_error !== false ) {
780
+			if ( 'hide' == $show_message ) {
781
+				$permission_error = '';
782
+			}
783 783
 			wp_die( esc_html( $permission_error ) );
784
-        }
785
-    }
786
-
787
-    /**
788
-     * Check user permission and nonce
789
-     * @since 2.0
790
-     * @param string $permission
791
-     * @return false|string The permission message or false if allowed
792
-     */
784
+		}
785
+	}
786
+
787
+	/**
788
+	 * Check user permission and nonce
789
+	 * @since 2.0
790
+	 * @param string $permission
791
+	 * @return false|string The permission message or false if allowed
792
+	 */
793 793
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
794 794
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
795 795
 			$frm_settings = self::get_settings();
@@ -798,22 +798,22 @@  discard block
 block discarded – undo
798 798
 
799 799
 		$error = false;
800 800
 		if ( empty( $nonce_name ) ) {
801
-            return $error;
802
-        }
801
+			return $error;
802
+		}
803 803
 
804
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
805
-            $frm_settings = self::get_settings();
806
-            $error = $frm_settings->admin_permission;
807
-        }
804
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
805
+			$frm_settings = self::get_settings();
806
+			$error = $frm_settings->admin_permission;
807
+		}
808 808
 
809
-        return $error;
810
-    }
809
+		return $error;
810
+	}
811 811
 
812
-    public static function checked( $values, $current ) {
812
+	public static function checked( $values, $current ) {
813 813
 		if ( self::check_selected( $values, $current ) ) {
814
-            echo ' checked="checked"';
814
+			echo ' checked="checked"';
815 815
 		}
816
-    }
816
+	}
817 817
 
818 818
 	public static function check_selected( $values, $current ) {
819 819
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -851,24 +851,24 @@  discard block
 block discarded – undo
851 851
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
852 852
 	}
853 853
 
854
-    /**
855
-     * Flatten a multi-dimensional array
856
-     */
854
+	/**
855
+	 * Flatten a multi-dimensional array
856
+	 */
857 857
 	public static function array_flatten( $array, $keys = 'keep' ) {
858
-        $return = array();
859
-        foreach ( $array as $key => $value ) {
858
+		$return = array();
859
+		foreach ( $array as $key => $value ) {
860 860
 			if ( is_array( $value ) ) {
861 861
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
862
-            } else {
862
+			} else {
863 863
 				if ( $keys == 'keep' ) {
864 864
 					$return[ $key ] = $value;
865 865
 				} else {
866 866
 					$return[] = $value;
867 867
 				}
868
-            }
869
-        }
870
-        return $return;
871
-    }
868
+			}
869
+		}
870
+		return $return;
871
+	}
872 872
 
873 873
 	public static function esc_textarea( $text, $is_rich_text = false ) {
874 874
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -879,10 +879,10 @@  discard block
 block discarded – undo
879 879
 		return apply_filters( 'esc_textarea', $safe_text, $text );
880 880
 	}
881 881
 
882
-    /**
883
-     * Add auto paragraphs to text areas
884
-     * @since 2.0
885
-     */
882
+	/**
883
+	 * Add auto paragraphs to text areas
884
+	 * @since 2.0
885
+	 */
886 886
 	public static function use_wpautop( $content ) {
887 887
 		if ( apply_filters( 'frm_use_wpautop', true ) ) {
888 888
 			$content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -891,26 +891,26 @@  discard block
 block discarded – undo
891 891
 	}
892 892
 
893 893
 	public static function replace_quotes( $val ) {
894
-        //Replace double quotes
894
+		//Replace double quotes
895 895
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
896
-        //Replace single quotes
897
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
898
-        return $val;
899
-    }
900
-
901
-    /**
902
-     * @since 2.0
903
-     * @return string The base Google APIS url for the current version of jQuery UI
904
-     */
905
-    public static function jquery_ui_base_url() {
896
+		//Replace single quotes
897
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
898
+		return $val;
899
+	}
900
+
901
+	/**
902
+	 * @since 2.0
903
+	 * @return string The base Google APIS url for the current version of jQuery UI
904
+	 */
905
+	public static function jquery_ui_base_url() {
906 906
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
907 907
 		$url = apply_filters( 'frm_jquery_ui_base_url', $url );
908
-        return $url;
909
-    }
908
+		return $url;
909
+	}
910 910
 
911
-    /**
912
-     * @param string $handle
913
-     */
911
+	/**
912
+	 * @param string $handle
913
+	 */
914 914
 	public static function script_version( $handle, $default = 0 ) {
915 915
 		global $wp_scripts;
916 916
 		if ( ! $wp_scripts ) {
@@ -932,12 +932,12 @@  discard block
 block discarded – undo
932 932
 
933 933
 	public static function js_redirect( $url ) {
934 934
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
935
-    }
935
+	}
936 936
 
937 937
 	public static function get_user_id_param( $user_id ) {
938 938
 		if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
939
-            return $user_id;
940
-        }
939
+			return $user_id;
940
+		}
941 941
 
942 942
 		$user_id = sanitize_text_field( $user_id );
943 943
 		if ( $user_id == 'current' ) {
@@ -949,14 +949,14 @@  discard block
 block discarded – undo
949 949
 				$user = get_user_by( 'login', $user_id );
950 950
 			}
951 951
 
952
-            if ( $user ) {
953
-                $user_id = $user->ID;
954
-            }
952
+			if ( $user ) {
953
+				$user_id = $user->ID;
954
+			}
955 955
 			unset( $user );
956
-        }
956
+		}
957 957
 
958
-        return $user_id;
959
-    }
958
+		return $user_id;
959
+	}
960 960
 
961 961
 	public static function get_file_contents( $filename, $atts = array() ) {
962 962
 		if ( ! is_file( $filename ) ) {
@@ -971,28 +971,28 @@  discard block
 block discarded – undo
971 971
 		return $contents;
972 972
 	}
973 973
 
974
-    /**
975
-     * @param string $table_name
976
-     * @param string $column
974
+	/**
975
+	 * @param string $table_name
976
+	 * @param string $column
977 977
 	 * @param int $id
978 978
 	 * @param int $num_chars
979
-     */
980
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
981
-        $key = '';
979
+	 */
980
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
981
+		$key = '';
982 982
 
983
-        if ( ! empty( $name ) ) {
983
+		if ( ! empty( $name ) ) {
984 984
 			$key = sanitize_key( $name );
985
-        }
985
+		}
986 986
 
987 987
 		if ( empty( $key ) ) {
988 988
 			$max_slug_value = pow( 36, $num_chars );
989
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
989
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
990 990
 			$key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
991
-        }
991
+		}
992 992
 
993 993
 		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
994 994
 			$key = $key . 'a';
995
-        }
995
+		}
996 996
 
997 997
 		$key_check = FrmDb::get_var(
998 998
 			$table_name,
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		);
1005 1005
 
1006 1006
 		if ( $key_check || is_numeric( $key_check ) ) {
1007
-            $suffix = 2;
1007
+			$suffix = 2;
1008 1008
 			do {
1009 1009
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1010 1010
 				$key_check = FrmDb::get_var(
@@ -1018,19 +1018,19 @@  discard block
 block discarded – undo
1018 1018
 				$suffix++;
1019 1019
 			} while ( $key_check || is_numeric( $key_check ) );
1020 1020
 			$key = $alt_post_name;
1021
-        }
1022
-        return $key;
1023
-    }
1024
-
1025
-    /**
1026
-     * Editing a Form or Entry
1027
-     * @param string $table
1028
-     * @return bool|array
1029
-     */
1030
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1031
-        if ( ! $record ) {
1032
-            return false;
1033
-        }
1021
+		}
1022
+		return $key;
1023
+	}
1024
+
1025
+	/**
1026
+	 * Editing a Form or Entry
1027
+	 * @param string $table
1028
+	 * @return bool|array
1029
+	 */
1030
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1031
+		if ( ! $record ) {
1032
+			return false;
1033
+		}
1034 1034
 
1035 1035
 		if ( empty( $post_values ) ) {
1036 1036
 			$post_values = stripslashes_deep( $_POST );
@@ -1053,14 +1053,14 @@  discard block
 block discarded – undo
1053 1053
 
1054 1054
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1055 1055
 
1056
-        if ( $table == 'entries' ) {
1057
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1058
-        } else if ( $table == 'forms' ) {
1059
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1060
-        }
1056
+		if ( $table == 'entries' ) {
1057
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1058
+		} else if ( $table == 'forms' ) {
1059
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1060
+		}
1061 1061
 
1062
-        return $values;
1063
-    }
1062
+		return $values;
1063
+	}
1064 1064
 
1065 1065
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1066 1066
 		if ( ! empty( $fields ) ) {
@@ -1073,15 +1073,15 @@  discard block
 block discarded – undo
1073 1073
 	}
1074 1074
 
1075 1075
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1076
-        $post_values = $args['post_values'];
1076
+		$post_values = $args['post_values'];
1077 1077
 
1078
-        if ( $args['default'] ) {
1079
-            $meta_value = $field->default_value;
1080
-        } else {
1078
+		if ( $args['default'] ) {
1079
+			$meta_value = $field->default_value;
1080
+		} else {
1081 1081
 			if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1082 1082
 				if ( ! isset( $field->field_options['custom_field'] ) ) {
1083
-                    $field->field_options['custom_field'] = '';
1084
-                }
1083
+					$field->field_options['custom_field'] = '';
1084
+				}
1085 1085
 				$meta_value = FrmProEntryMetaHelper::get_post_value(
1086 1086
 					$record->post_id,
1087 1087
 					$field->field_options['post_field'],
@@ -1093,31 +1093,31 @@  discard block
 block discarded – undo
1093 1093
 						'field' => $field,
1094 1094
 					)
1095 1095
 				);
1096
-            } else {
1096
+			} else {
1097 1097
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1098
-            }
1099
-        }
1098
+			}
1099
+		}
1100 1100
 
1101 1101
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1102
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1102
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1103 1103
 
1104 1104
 		$field_array = self::start_field_array( $field );
1105 1105
 		$field_array['value'] = $new_value;
1106 1106
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1107 1107
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1108 1108
 
1109
-        $args['field_type'] = $field_type;
1109
+		$args['field_type'] = $field_type;
1110 1110
 
1111 1111
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1112 1112
 
1113 1113
 		if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1114
-            $field_array['unique_msg'] = '';
1115
-        }
1114
+			$field_array['unique_msg'] = '';
1115
+		}
1116 1116
 
1117
-        $field_array = array_merge( $field->field_options, $field_array );
1117
+		$field_array = array_merge( $field->field_options, $field_array );
1118 1118
 
1119
-        $values['fields'][ $field->id ] = $field_array;
1120
-    }
1119
+		$values['fields'][ $field->id ] = $field_array;
1120
+	}
1121 1121
 
1122 1122
 	/**
1123 1123
 	 * @since 3.0
@@ -1138,20 +1138,20 @@  discard block
 block discarded – undo
1138 1138
 		);
1139 1139
 	}
1140 1140
 
1141
-    /**
1142
-     * @param string $table
1143
-     */
1141
+	/**
1142
+	 * @param string $table
1143
+	 */
1144 1144
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1145
-        if ( $table == 'entries' ) {
1146
-            $form = $record->form_id;
1145
+		if ( $table == 'entries' ) {
1146
+			$form = $record->form_id;
1147 1147
 			FrmForm::maybe_get_form( $form );
1148
-        } else {
1149
-            $form = $record;
1150
-        }
1148
+		} else {
1149
+			$form = $record;
1150
+		}
1151 1151
 
1152
-        if ( ! $form ) {
1153
-            return;
1154
-        }
1152
+		if ( ! $form ) {
1153
+			return;
1154
+		}
1155 1155
 
1156 1156
 		$values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1157 1157
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
@@ -1160,26 +1160,26 @@  discard block
 block discarded – undo
1160 1160
 			return;
1161 1161
 		}
1162 1162
 
1163
-        foreach ( $form->options as $opt => $value ) {
1164
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1165
-        }
1163
+		foreach ( $form->options as $opt => $value ) {
1164
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1165
+		}
1166 1166
 
1167 1167
 		self::fill_form_defaults( $post_values, $values );
1168
-    }
1168
+	}
1169 1169
 
1170
-    /**
1171
-     * Set to POST value or default
1172
-     */
1170
+	/**
1171
+	 * Set to POST value or default
1172
+	 */
1173 1173
 	private static function fill_form_defaults( $post_values, array &$values ) {
1174
-        $form_defaults = FrmFormsHelper::get_default_opts();
1174
+		$form_defaults = FrmFormsHelper::get_default_opts();
1175 1175
 
1176
-        foreach ( $form_defaults as $opt => $default ) {
1177
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1176
+		foreach ( $form_defaults as $opt => $default ) {
1177
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1178 1178
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1179
-            }
1179
+			}
1180 1180
 
1181 1181
 			unset( $opt, $default );
1182
-        }
1182
+		}
1183 1183
 
1184 1184
 		if ( ! isset( $values['custom_style'] ) ) {
1185 1185
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1188,10 +1188,10 @@  discard block
 block discarded – undo
1188 1188
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1189 1189
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1190 1190
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1191
-            }
1191
+			}
1192 1192
 			unset( $h );
1193
-        }
1194
-    }
1193
+		}
1194
+	}
1195 1195
 
1196 1196
 	/**
1197 1197
 	 * @since 2.2.10
@@ -1214,33 +1214,33 @@  discard block
 block discarded – undo
1214 1214
 		if ( $possible_email_field ) {
1215 1215
 			$class .= 'show_frm_not_email_to';
1216 1216
 		}
1217
-    ?>
1217
+	?>
1218 1218
 <li>
1219 1219
 	<a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a>
1220 1220
 	<a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a>
1221 1221
 	<a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a>
1222 1222
 </li>
1223 1223
     <?php
1224
-    }
1224
+	}
1225 1225
 
1226 1226
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1227
-        if ( is_array( $str ) ) {
1228
-            return '';
1227
+		if ( is_array( $str ) ) {
1228
+			return '';
1229 1229
 		}
1230 1230
 
1231
-        $length = (int) $length;
1231
+		$length = (int) $length;
1232 1232
 		$str = wp_strip_all_tags( $str );
1233 1233
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1234 1234
 
1235 1235
 		if ( $length == 0 ) {
1236
-            return '';
1237
-        } else if ( $length <= 10 ) {
1236
+			return '';
1237
+		} else if ( $length <= 10 ) {
1238 1238
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1239 1239
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1240
-        }
1240
+		}
1241 1241
 
1242
-        $sub = '';
1243
-        $len = 0;
1242
+		$sub = '';
1243
+		$len = 0;
1244 1244
 
1245 1245
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1246 1246
 
@@ -1248,21 +1248,21 @@  discard block
 block discarded – undo
1248 1248
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1249 1249
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1250 1250
 			if ( $total_len > $length && str_word_count( $sub ) ) {
1251
-                break;
1252
-            }
1251
+				break;
1252
+			}
1253 1253
 
1254
-            $sub .= $part;
1254
+			$sub .= $part;
1255 1255
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1256 1256
 
1257 1257
 			if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1258
-                break;
1259
-            }
1258
+				break;
1259
+			}
1260 1260
 
1261 1261
 			unset( $total_len, $word );
1262
-        }
1262
+		}
1263 1263
 
1264 1264
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1265
-    }
1265
+	}
1266 1266
 
1267 1267
 	public static function mb_function( $function_names, $args ) {
1268 1268
 		$mb_function_name = $function_names[0];
@@ -1275,17 +1275,17 @@  discard block
 block discarded – undo
1275 1275
 
1276 1276
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1277 1277
 		if ( empty( $date ) ) {
1278
-            return $date;
1279
-        }
1278
+			return $date;
1279
+		}
1280 1280
 
1281 1281
 		if ( empty( $date_format ) ) {
1282 1282
 			$date_format = get_option( 'date_format' );
1283 1283
 		}
1284 1284
 
1285 1285
 		if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1286
-            $frmpro_settings = new FrmProSettings();
1286
+			$frmpro_settings = new FrmProSettings();
1287 1287
 			$date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1288
-        }
1288
+		}
1289 1289
 
1290 1290
 		$formatted = self::get_localized_date( $date_format, $date );
1291 1291
 
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 			$formatted .= self::add_time_to_date( $time_format, $date );
1295 1295
 		}
1296 1296
 
1297
-        return $formatted;
1298
-    }
1297
+		return $formatted;
1298
+	}
1299 1299
 
1300 1300
 	private static function add_time_to_date( $time_format, $date ) {
1301 1301
 		if ( empty( $time_format ) ) {
@@ -1377,32 +1377,32 @@  discard block
 block discarded – undo
1377 1377
 		);
1378 1378
 	}
1379 1379
 
1380
-    // Pagination Methods
1380
+	// Pagination Methods
1381 1381
 
1382
-    /**
1383
-     * @param integer $current_p
1384
-     */
1382
+	/**
1383
+	 * @param integer $current_p
1384
+	 */
1385 1385
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1386 1386
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1387 1387
 	}
1388 1388
 
1389
-    /**
1390
-     * @param integer $current_p
1391
-     */
1392
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1393
-        if ( $current_p == 1 ) {
1394
-            return 1;
1395
-        } else {
1396
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1397
-        }
1398
-    }
1389
+	/**
1390
+	 * @param integer $current_p
1391
+	 */
1392
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1393
+		if ( $current_p == 1 ) {
1394
+			return 1;
1395
+		} else {
1396
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1397
+		}
1398
+	}
1399 1399
 
1400 1400
 	/**
1401 1401
 	 * @return array
1402 1402
 	 */
1403 1403
 	public static function json_to_array( $json_vars ) {
1404
-        $vars = array();
1405
-        foreach ( $json_vars as $jv ) {
1404
+		$vars = array();
1405
+		foreach ( $json_vars as $jv ) {
1406 1406
 			$jv_name = explode( '[', $jv['name'] );
1407 1407
 			$last = count( $jv_name ) - 1;
1408 1408
 			foreach ( $jv_name as $p => $n ) {
@@ -1419,77 +1419,77 @@  discard block
 block discarded – undo
1419 1419
 					$l3 = $name;
1420 1420
 				}
1421 1421
 
1422
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1422
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1423 1423
 
1424
-                switch ( $p ) {
1425
-                    case 0:
1426
-                        $l1 = $name;
1427
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1424
+				switch ( $p ) {
1425
+					case 0:
1426
+						$l1 = $name;
1427
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1428 1428
 						break;
1429 1429
 
1430
-                    case 1:
1431
-                        $l2 = $name;
1432
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1430
+					case 1:
1431
+						$l2 = $name;
1432
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1433 1433
 						break;
1434 1434
 
1435
-                    case 2:
1436
-                        $l3 = $name;
1437
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1435
+					case 2:
1436
+						$l3 = $name;
1437
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1438 1438
 						break;
1439 1439
 
1440
-                    case 3:
1441
-                        $l4 = $name;
1442
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1443
-                }
1440
+					case 3:
1441
+						$l4 = $name;
1442
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1443
+				}
1444 1444
 
1445 1445
 				unset( $this_val, $n );
1446
-            }
1446
+			}
1447 1447
 
1448 1448
 			unset( $last, $jv );
1449
-        }
1450
-
1451
-        return $vars;
1452
-    }
1453
-
1454
-    /**
1455
-     * @param string $name
1456
-     * @param string $l1
1457
-     */
1458
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1459
-        if ( $name == '' ) {
1460
-            $vars[] = $val;
1461
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1462
-            $vars[ $l1 ] = $val;
1463
-        }
1464
-    }
1449
+		}
1450
+
1451
+		return $vars;
1452
+	}
1453
+
1454
+	/**
1455
+	 * @param string $name
1456
+	 * @param string $l1
1457
+	 */
1458
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1459
+		if ( $name == '' ) {
1460
+			$vars[] = $val;
1461
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1462
+			$vars[ $l1 ] = $val;
1463
+		}
1464
+	}
1465 1465
 
1466 1466
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1467
-        $tooltips = array(
1468
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1469
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1470
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1471
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1472
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1473
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1474
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1475
-        );
1476
-
1477
-        if ( ! isset( $tooltips[ $name ] ) ) {
1478
-            return;
1479
-        }
1480
-
1481
-        if ( 'open' == $class ) {
1482
-            echo ' frm_help"';
1483
-        } else {
1484
-            echo ' class="frm_help"';
1485
-        }
1467
+		$tooltips = array(
1468
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1469
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1470
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1471
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1472
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1473
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1474
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1475
+		);
1476
+
1477
+		if ( ! isset( $tooltips[ $name ] ) ) {
1478
+			return;
1479
+		}
1480
+
1481
+		if ( 'open' == $class ) {
1482
+			echo ' frm_help"';
1483
+		} else {
1484
+			echo ' class="frm_help"';
1485
+		}
1486 1486
 
1487 1487
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1488 1488
 
1489
-        if ( 'open' != $class ) {
1490
-            echo '"';
1491
-        }
1492
-    }
1489
+		if ( 'open' != $class ) {
1490
+			echo '"';
1491
+		}
1492
+	}
1493 1493
 
1494 1494
 	/**
1495 1495
 	 * Add the current_page class to that page in the form nav
@@ -1505,35 +1505,35 @@  discard block
 block discarded – undo
1505 1505
 		}
1506 1506
 	}
1507 1507
 
1508
-    /**
1509
-     * Prepare and json_encode post content
1510
-     *
1511
-     * @since 2.0
1512
-     *
1513
-     * @param array $post_content
1514
-     * @return string $post_content ( json encoded array )
1515
-     */
1516
-    public static function prepare_and_encode( $post_content ) {
1517
-        //Loop through array to strip slashes and add only the needed ones
1508
+	/**
1509
+	 * Prepare and json_encode post content
1510
+	 *
1511
+	 * @since 2.0
1512
+	 *
1513
+	 * @param array $post_content
1514
+	 * @return string $post_content ( json encoded array )
1515
+	 */
1516
+	public static function prepare_and_encode( $post_content ) {
1517
+		//Loop through array to strip slashes and add only the needed ones
1518 1518
 		foreach ( $post_content as $key => $val ) {
1519 1519
 			// Replace problematic characters (like &quot;)
1520 1520
 			$val = str_replace( '&quot;', '"', $val );
1521 1521
 
1522 1522
 			self::prepare_action_slashes( $val, $key, $post_content );
1523
-            unset( $key, $val );
1524
-        }
1523
+			unset( $key, $val );
1524
+		}
1525 1525
 
1526
-        // json_encode the array
1527
-        $post_content = json_encode( $post_content );
1526
+		// json_encode the array
1527
+		$post_content = json_encode( $post_content );
1528 1528
 
1529
-	    // add extra slashes for \r\n since WP strips them
1529
+		// add extra slashes for \r\n since WP strips them
1530 1530
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1531 1531
 
1532
-        // allow for &quot
1533
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1532
+		// allow for &quot
1533
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1534 1534
 
1535
-        return $post_content;
1536
-    }
1535
+		return $post_content;
1536
+	}
1537 1537
 
1538 1538
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1539 1539
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1556,54 +1556,54 @@  discard block
 block discarded – undo
1556 1556
 
1557 1557
 	public static function maybe_json_decode( $string ) {
1558 1558
 		if ( is_array( $string ) ) {
1559
-            return $string;
1560
-        }
1559
+			return $string;
1560
+		}
1561 1561
 
1562 1562
 		$new_string = json_decode( $string, true );
1563 1563
 		if ( function_exists( 'json_last_error' ) ) {
1564 1564
 			// php 5.3+
1565
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1566
-                $string = $new_string;
1567
-            }
1565
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1566
+				$string = $new_string;
1567
+			}
1568 1568
 		} elseif ( isset( $new_string ) ) {
1569 1569
 			// php < 5.3 fallback
1570
-            $string = $new_string;
1571
-        }
1572
-        return $string;
1573
-    }
1574
-
1575
-    /**
1576
-     * @since 1.07.10
1577
-     *
1578
-     * @param string $post_type The name of the post type that may need to be highlighted
1579
-     * echo The javascript to open and highlight the Formidable menu
1580
-     */
1570
+			$string = $new_string;
1571
+		}
1572
+		return $string;
1573
+	}
1574
+
1575
+	/**
1576
+	 * @since 1.07.10
1577
+	 *
1578
+	 * @param string $post_type The name of the post type that may need to be highlighted
1579
+	 * echo The javascript to open and highlight the Formidable menu
1580
+	 */
1581 1581
 	public static function maybe_highlight_menu( $post_type ) {
1582
-        global $post;
1582
+		global $post;
1583 1583
 
1584 1584
 		if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1585
-            return;
1586
-        }
1585
+			return;
1586
+		}
1587 1587
 
1588 1588
 		if ( is_object( $post ) && $post->post_type != $post_type ) {
1589
-            return;
1590
-        }
1589
+			return;
1590
+		}
1591 1591
 
1592
-        self::load_admin_wide_js();
1593
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1594
-    }
1592
+		self::load_admin_wide_js();
1593
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1594
+	}
1595 1595
 
1596
-    /**
1597
-     * Load the JS file on non-Formidable pages in the admin area
1598
-     * @since 2.0
1599
-     */
1596
+	/**
1597
+	 * Load the JS file on non-Formidable pages in the admin area
1598
+	 * @since 2.0
1599
+	 */
1600 1600
 	public static function load_admin_wide_js( $load = true ) {
1601
-        $version = FrmAppHelper::plugin_version();
1601
+		$version = FrmAppHelper::plugin_version();
1602 1602
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1603 1603
 
1604 1604
 		$global_strings = array(
1605 1605
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1606
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1606
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1607 1607
 			'url'          => FrmAppHelper::plugin_url(),
1608 1608
 			'loading'      => __( 'Loading&hellip;' ),
1609 1609
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 		if ( $load ) {
1614 1614
 			wp_enqueue_script( 'formidable_admin_global' );
1615 1615
 		}
1616
-    }
1616
+	}
1617 1617
 
1618 1618
 	/**
1619 1619
 	 * @since 2.0.9
@@ -1622,9 +1622,9 @@  discard block
 block discarded – undo
1622 1622
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1623 1623
 	}
1624 1624
 
1625
-    /**
1626
-     * @param string $location
1627
-     */
1625
+	/**
1626
+	 * @param string $location
1627
+	 */
1628 1628
 	public static function localize_script( $location ) {
1629 1629
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1630 1630
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1687,27 +1687,27 @@  discard block
 block discarded – undo
1687 1687
 		}
1688 1688
 	}
1689 1689
 
1690
-    /**
1690
+	/**
1691 1691
 	 * echo the message on the plugins listing page
1692
-     * @since 1.07.10
1693
-     *
1694
-     * @param float $min_version The version the add-on requires
1695
-     */
1692
+	 * @since 1.07.10
1693
+	 *
1694
+	 * @param float $min_version The version the add-on requires
1695
+	 */
1696 1696
 	public static function min_version_notice( $min_version ) {
1697
-        $frm_version = self::plugin_version();
1697
+		$frm_version = self::plugin_version();
1698 1698
 
1699
-        // check if Formidable meets minimum requirements
1699
+		// check if Formidable meets minimum requirements
1700 1700
 		if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1701
-            return;
1702
-        }
1701
+			return;
1702
+		}
1703 1703
 
1704 1704
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1705 1705
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1706
-        esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1707
-        '</div></td></tr>';
1708
-    }
1706
+		esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1707
+		'</div></td></tr>';
1708
+	}
1709 1709
 
1710
-    public static function locales( $type = 'date' ) {
1710
+	public static function locales( $type = 'date' ) {
1711 1711
 		$locales = array(
1712 1712
 			'en' => __( 'English', 'formidable' ),
1713 1713
 			''   => __( 'English/Western', 'formidable' ),
@@ -1786,8 +1786,8 @@  discard block
 block discarded – undo
1786 1786
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1787 1787
 		$locales = apply_filters( 'frm_locales', $locales );
1788 1788
 
1789
-        return $locales;
1790
-    }
1789
+		return $locales;
1790
+	}
1791 1791
 
1792 1792
 	/**
1793 1793
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.
classes/views/shared/mb_adv_info.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -56,27 +56,27 @@  discard block
 block discarded – undo
56 56
         <?php esc_html_e( 'Helpers', 'formidable' ) ?>:
57 57
         <ul class="frm_code_list">
58 58
         <?php
59
-        $col = 'one';
59
+		$col = 'one';
60 60
 		foreach ( $entry_shortcodes as $skey => $sname ) {
61 61
 			if ( empty( $skey ) ) {
62
-                 $col = 'one';
63
-                 echo '<li class="clear frm_block"></li>';
64
-                 continue;
65
-            }
62
+				 $col = 'one';
63
+				 echo '<li class="clear frm_block"></li>';
64
+				 continue;
65
+			}
66 66
 
67 67
 			$classes = ( in_array( $skey, array( 'siteurl', 'sitename', 'entry_count' ) ) ) ? 'show_before_content show_after_content' : '';
68 68
 			$classes .= ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : '';
69
-        ?>
69
+		?>
70 70
         <li class="frm_col_<?php echo esc_attr( $col ) ?>">
71 71
 			<a href="javascript:void(0)" class="frmbutton button <?php echo esc_attr( $classes ); ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>">
72 72
 				<?php echo esc_html( $sname ) ?>
73 73
 			</a>
74 74
         </li>
75 75
         <?php
76
-            $col = ( $col == 'one' ) ? 'two' : 'one';
76
+			$col = ( $col == 'one' ) ? 'two' : 'one';
77 77
 			unset( $skey, $sname, $classes );
78
-        }
79
-        ?>
78
+		}
79
+		?>
80 80
         </ul>
81 81
 		<div class="clear"></div>
82 82
 	</div>
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 	    <ul class="frm_code_list frm_full_width">
92 92
 			<?php
93 93
 			if ( ! empty( $fields ) ) {
94
-		        foreach ( $fields as $f ) {
94
+				foreach ( $fields as $f ) {
95 95
 					if ( FrmField::is_no_save_field( $f->type ) || ( $f->type == 'data' && ( ! isset( $f->field_options['data_type'] ) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '' ) ) ) {
96
-                        continue;
97
-                }
98
-            ?>
96
+						continue;
97
+				}
98
+			?>
99 99
                 <li>
100 100
                     <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a>
101 101
 					<a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ); ?>]something[/if <?php echo esc_attr( $f->field_key ); ?>">[if <?php echo FrmAppHelper::truncate( $f->field_key, 10 ); // WPCS: XSS ok. ?>]</a>
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
         <p class="howto"><?php esc_html_e( 'Click a button below to insert sample logic into your view', 'formidable' ) ?></p>
116 116
         <ul class="frm_code_list">
117 117
         <?php
118
-        $col = 'one';
118
+		$col = 'one';
119 119
 		foreach ( $cond_shortcodes as $skey => $sname ) {
120
-	    ?>
120
+		?>
121 121
 	    <li class="frm_col_<?php echo esc_attr( $col ) ?>">
122 122
 			<a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if x <?php echo esc_attr( $skey ); ?>][/if x"><?php echo esc_html( $sname ); ?></a>
123 123
 	    </li>
124 124
 	    <?php
125
-	        $col = ( $col == 'one' ) ? 'two' : 'one';
125
+			$col = ( $col == 'one' ) ? 'two' : 'one';
126 126
 			unset( $skey, $sname );
127
-	    }
128
-        ?>
127
+		}
128
+		?>
129 129
         </ul>
130 130
 	</div>
131 131
 	<?php } ?>
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	        <p class="howto"><?php echo esc_html( $helper['heading'] ); ?></p>
145 145
 	        <ul class="frm_code_list">
146 146
 	        <?php foreach ( $helper['codes'] as $code => $code_label ) {
147
-	        	$code = str_replace( '|user_id|', $uid->id, $code );
147
+				$code = str_replace( '|user_id|', $uid->id, $code );
148 148
 				?>
149 149
 	            <li class="frm_col_<?php echo esc_attr( $col ) ?>">
150 150
 					<a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $code_label ) ? 'frm_help' : ''; ?>" data-code="x <?php echo esc_attr( $code ) ?>" <?php echo is_array( $code_label ) ? 'title="' . esc_attr( $code_label['title'] ) . '"' : ''; ?>>
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	</div>
165 165
 
166 166
     <?php
167
-    if ( $settings_tab ) {
167
+	if ( $settings_tab ) {
168 168
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/mb_html_tab.php' );
169
-    }
170
-    ?>
169
+	}
170
+	?>
171 171
 </div>
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 2 patches
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFormsController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		$menu_label = __( 'Forms', 'formidable' );
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
11 11
 
12 12
 		self::maybe_load_listing_hooks();
13
-    }
13
+	}
14 14
 
15 15
 	public static function maybe_load_listing_hooks() {
16 16
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27
-    public static function head() {
27
+	public static function head() {
28 28
 		wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30
-        if ( wp_is_mobile() ) {
31
-    		wp_enqueue_script( 'jquery-touch-punch' );
32
-    	}
33
-    }
30
+		if ( wp_is_mobile() ) {
31
+			wp_enqueue_script( 'jquery-touch-punch' );
32
+		}
33
+	}
34 34
 
35 35
 	public static function register_widgets() {
36 36
 		require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	public static function new_form( $values = array() ) {
62 62
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
63 63
 
64
-        global $frm_vars;
64
+		global $frm_vars;
65 65
 
66 66
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
67 67
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 		} else if ( $action == 'new' ) {
73 73
 			$frm_field_selection = FrmField::field_selection();
74 74
 			$values = FrmFormsHelper::setup_new_vars( $values );
75
-            $id = FrmForm::create( $values );
75
+			$id = FrmForm::create( $values );
76 76
 			$form = FrmForm::getOne( $id );
77 77
 
78 78
 			self::create_default_email_action( $form );
79 79
 
80 80
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
81 81
 
82
-            $values['id'] = $id;
82
+			$values['id'] = $id;
83 83
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
84
-        }
85
-    }
84
+		}
85
+	}
86 86
 
87 87
 	/**
88 88
 	 * Create the default email action
@@ -91,41 +91,41 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @param object $form
93 93
 	 */
94
-    private static function create_default_email_action( $form ) {
95
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
94
+	private static function create_default_email_action( $form ) {
95
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
96 96
 
97
-	    if ( $create_email ) {
98
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
99
-		    $action_control->create( $form->id );
100
-	    }
101
-    }
97
+		if ( $create_email ) {
98
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
99
+			$action_control->create( $form->id );
100
+		}
101
+	}
102 102
 
103 103
 	public static function create( $values = array() ) {
104 104
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
105 105
 
106
-        global $frm_vars;
107
-        if ( empty( $values ) ) {
108
-            $values = $_POST;
109
-        }
106
+		global $frm_vars;
107
+		if ( empty( $values ) ) {
108
+			$values = $_POST;
109
+		}
110 110
 
111
-        //Set radio button and checkbox meta equal to "other" value
112
-        if ( FrmAppHelper::pro_is_installed() ) {
113
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
114
-        }
111
+		//Set radio button and checkbox meta equal to "other" value
112
+		if ( FrmAppHelper::pro_is_installed() ) {
113
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
114
+		}
115 115
 
116 116
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
117 117
 
118
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
119
-            $frm_settings = FrmAppHelper::get_settings();
120
-            $errors = array( 'form' => $frm_settings->admin_permission );
121
-        } else {
118
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
119
+			$frm_settings = FrmAppHelper::get_settings();
120
+			$errors = array( 'form' => $frm_settings->admin_permission );
121
+		} else {
122 122
 			$errors = FrmForm::validate( $values );
123
-        }
123
+		}
124 124
 
125 125
 		if ( count( $errors ) > 0 ) {
126
-            $hide_preview = true;
126
+			$hide_preview = true;
127 127
 			$frm_field_selection = FrmField::field_selection();
128
-            $form = FrmForm::getOne( $id );
128
+			$form = FrmForm::getOne( $id );
129 129
 			$fields = FrmField::get_all_for_form( $id );
130 130
 
131 131
 			$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true );
@@ -133,30 +133,30 @@  discard block
 block discarded – undo
133 133
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
134 134
 
135 135
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
136
-        } else {
137
-            FrmForm::update( $id, $values, true );
136
+		} else {
137
+			FrmForm::update( $id, $values, true );
138 138
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
139 139
 			die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok.
140
-        }
141
-    }
140
+		}
141
+	}
142 142
 
143
-    public static function edit( $values = false ) {
143
+	public static function edit( $values = false ) {
144 144
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
145 145
 
146 146
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
147 147
 		return self::get_edit_vars( $id );
148
-    }
148
+	}
149 149
 
150
-    public static function settings( $id = false, $message = '' ) {
150
+	public static function settings( $id = false, $message = '' ) {
151 151
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
152 152
 
153 153
 		if ( ! $id || ! is_numeric( $id ) ) {
154 154
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
155
-        }
155
+		}
156 156
 		return self::get_settings_vars( $id, array(), $message );
157
-    }
157
+	}
158 158
 
159
-    public static function update_settings() {
159
+	public static function update_settings() {
160 160
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
161 161
 
162 162
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
@@ -170,39 +170,39 @@  discard block
 block discarded – undo
170 170
 
171 171
 		FrmForm::update( $id, $_POST );
172 172
 
173
-        $message = __( 'Settings Successfully Updated', 'formidable' );
173
+		$message = __( 'Settings Successfully Updated', 'formidable' );
174 174
 		return self::get_settings_vars( $id, array(), $message );
175
-    }
175
+	}
176 176
 
177 177
 	public static function update( $values = array() ) {
178 178
 		if ( empty( $values ) ) {
179
-            $values = $_POST;
180
-        }
179
+			$values = $_POST;
180
+		}
181 181
 
182
-        //Set radio button and checkbox meta equal to "other" value
183
-        if ( FrmAppHelper::pro_is_installed() ) {
184
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
185
-        }
182
+		//Set radio button and checkbox meta equal to "other" value
183
+		if ( FrmAppHelper::pro_is_installed() ) {
184
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
185
+		}
186 186
 
187
-        $errors = FrmForm::validate( $values );
188
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
189
-        if ( $permission_error !== false ) {
190
-            $errors['form'] = $permission_error;
191
-        }
187
+		$errors = FrmForm::validate( $values );
188
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
189
+		if ( $permission_error !== false ) {
190
+			$errors['form'] = $permission_error;
191
+		}
192 192
 
193 193
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
194 194
 
195 195
 		if ( count( $errors ) > 0 ) {
196
-            return self::get_edit_vars( $id, $errors );
196
+			return self::get_edit_vars( $id, $errors );
197 197
 		} else {
198
-            FrmForm::update( $id, $values );
199
-            $message = __( 'Form was Successfully Updated', 'formidable' );
200
-            if ( defined( 'DOING_AJAX' ) ) {
198
+			FrmForm::update( $id, $values );
199
+			$message = __( 'Form was Successfully Updated', 'formidable' );
200
+			if ( defined( 'DOING_AJAX' ) ) {
201 201
 				wp_die( esc_html( $message ) );
202
-            }
202
+			}
203 203
 			return self::get_edit_vars( $id, array(), $message );
204
-        }
205
-    }
204
+		}
205
+	}
206 206
 
207 207
 	/**
208 208
 	 * Redirect to the url for creating from a template
@@ -224,30 +224,30 @@  discard block
 block discarded – undo
224 224
 		wp_die();
225 225
 	}
226 226
 
227
-    public static function duplicate() {
227
+	public static function duplicate() {
228 228
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
229 229
 
230 230
 		$params = FrmForm::list_page_params();
231
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
232
-        $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
233
-        if ( $form ) {
231
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
232
+		$message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
233
+		if ( $form ) {
234 234
 			return self::get_edit_vars( $form, array(), $message, true );
235
-        } else {
235
+		} else {
236 236
 			return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
237
-        }
238
-    }
237
+		}
238
+	}
239 239
 
240
-    public static function page_preview() {
240
+	public static function page_preview() {
241 241
 		$params = FrmForm::list_page_params();
242
-        if ( ! $params['form'] ) {
243
-            return;
244
-        }
242
+		if ( ! $params['form'] ) {
243
+			return;
244
+		}
245 245
 
246
-        $form = FrmForm::getOne( $params['form'] );
246
+		$form = FrmForm::getOne( $params['form'] );
247 247
 		if ( $form ) {
248 248
 			return self::show_form( $form->id, '', true, true );
249 249
 		}
250
-    }
250
+	}
251 251
 
252 252
 	/**
253 253
 	 * @since 3.0
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 		echo self::page_preview(); // WPCS: XSS ok.
257 257
 	}
258 258
 
259
-    public static function preview() {
260
-        do_action( 'frm_wp' );
259
+	public static function preview() {
260
+		do_action( 'frm_wp' );
261 261
 
262
-        global $frm_vars;
263
-        $frm_vars['preview'] = true;
262
+		global $frm_vars;
263
+		$frm_vars['preview'] = true;
264 264
 
265 265
 		self::load_wp();
266 266
 
@@ -374,22 +374,22 @@  discard block
 block discarded – undo
374 374
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
375 375
 	}
376 376
 
377
-    public static function untrash() {
377
+	public static function untrash() {
378 378
 		self::change_form_status( 'untrash' );
379
-    }
379
+	}
380 380
 
381 381
 	public static function bulk_untrash( $ids ) {
382 382
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
383 383
 
384
-        $count = FrmForm::set_status( $ids, 'published' );
384
+		$count = FrmForm::set_status( $ids, 'published' );
385 385
 
386 386
 		$message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
387
-        return $message;
388
-    }
387
+		return $message;
388
+	}
389 389
 
390
-    public static function trash() {
390
+	public static function trash() {
391 391
 		self::change_form_status( 'trash' );
392
-    }
392
+	}
393 393
 
394 394
 	/**
395 395
 	 * @param string $status
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	public static function bulk_trash( $ids ) {
443 443
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
444 444
 
445
-        $count = 0;
446
-        foreach ( $ids as $id ) {
447
-            if ( FrmForm::trash( $id ) ) {
448
-                $count++;
449
-            }
450
-        }
445
+		$count = 0;
446
+		foreach ( $ids as $id ) {
447
+			if ( FrmForm::trash( $id ) ) {
448
+				$count++;
449
+			}
450
+		}
451 451
 
452 452
 		$current_page = FrmAppHelper::get_simple_request(
453 453
 			array(
@@ -462,63 +462,63 @@  discard block
 block discarded – undo
462 462
 			'</a>'
463 463
 		);
464 464
 
465
-        return $message;
466
-    }
465
+		return $message;
466
+	}
467 467
 
468
-    public static function destroy() {
468
+	public static function destroy() {
469 469
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
470 470
 
471 471
 		$params = FrmForm::list_page_params();
472 472
 
473
-        //check nonce url
473
+		//check nonce url
474 474
 		check_admin_referer( 'destroy_form_' . $params['id'] );
475 475
 
476
-        $count = 0;
477
-        if ( FrmForm::destroy( $params['id'] ) ) {
478
-            $count++;
479
-        }
476
+		$count = 0;
477
+		if ( FrmForm::destroy( $params['id'] ) ) {
478
+			$count++;
479
+		}
480 480
 
481 481
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
482 482
 
483 483
 		self::display_forms_list( $params, $message );
484
-    }
484
+	}
485 485
 
486 486
 	public static function bulk_destroy( $ids ) {
487 487
 		FrmAppHelper::permission_check( 'frm_delete_forms' );
488 488
 
489
-        $count = 0;
490
-        foreach ( $ids as $id ) {
491
-            $d = FrmForm::destroy( $id );
492
-            if ( $d ) {
493
-                $count++;
494
-            }
495
-        }
489
+		$count = 0;
490
+		foreach ( $ids as $id ) {
491
+			$d = FrmForm::destroy( $id );
492
+			if ( $d ) {
493
+				$count++;
494
+			}
495
+		}
496 496
 
497 497
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
498 498
 
499
-        return $message;
500
-    }
499
+		return $message;
500
+	}
501 501
 
502
-    private static function delete_all() {
503
-        //check nonce url
502
+	private static function delete_all() {
503
+		//check nonce url
504 504
 		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
505
-        if ( $permission_error !== false ) {
505
+		if ( $permission_error !== false ) {
506 506
 			self::display_forms_list( array(), '', array( $permission_error ) );
507
-            return;
508
-        }
507
+			return;
508
+		}
509 509
 
510 510
 		$count = FrmForm::scheduled_delete( time() );
511 511
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
512 512
 
513 513
 		self::display_forms_list( array(), $message );
514
-    }
514
+	}
515 515
 
516 516
 	/**
517
-	* Inserts Formidable button
518
-	* Hook exists since 2.5.0
519
-	*
520
-	* @since 2.0.15
521
-	*/
517
+	 * Inserts Formidable button
518
+	 * Hook exists since 2.5.0
519
+	 *
520
+	 * @since 2.0.15
521
+	 */
522 522
 	public static function insert_form_button() {
523 523
 		if ( current_user_can( 'frm_view_forms' ) ) {
524 524
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -529,45 +529,45 @@  discard block
 block discarded – undo
529 529
 		}
530 530
 	}
531 531
 
532
-    public static function insert_form_popup() {
532
+	public static function insert_form_popup() {
533 533
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
534 534
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
535
-            return;
536
-        }
535
+			return;
536
+		}
537 537
 
538
-        FrmAppHelper::load_admin_wide_js();
538
+		FrmAppHelper::load_admin_wide_js();
539 539
 
540
-        $shortcodes = array(
540
+		$shortcodes = array(
541 541
 			'formidable' => array(
542 542
 				'name'  => __( 'Form', 'formidable' ),
543 543
 				'label' => __( 'Insert a Form', 'formidable' ),
544 544
 			),
545
-        );
545
+		);
546 546
 
547 547
 		$shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
548 548
 
549 549
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
550
-    }
550
+	}
551 551
 
552
-    public static function get_shortcode_opts() {
552
+	public static function get_shortcode_opts() {
553 553
 		FrmAppHelper::permission_check( 'frm_view_forms' );
554
-        check_ajax_referer( 'frm_ajax', 'nonce' );
554
+		check_ajax_referer( 'frm_ajax', 'nonce' );
555 555
 
556 556
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
557 557
 		if ( empty( $shortcode ) ) {
558
-            wp_die();
559
-        }
558
+			wp_die();
559
+		}
560 560
 
561 561
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
562 562
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
563 563
 
564
-        $form_id = '';
565
-        $opts = array();
564
+		$form_id = '';
565
+		$opts = array();
566 566
 		switch ( $shortcode ) {
567
-            case 'formidable':
568
-                $opts = array(
567
+			case 'formidable':
568
+				$opts = array(
569 569
 					'form_id'       => 'id',
570
-                    //'key' => ',
570
+					//'key' => ',
571 571
 					'title'         => array(
572 572
 						'val'   => 1,
573 573
 						'label' => __( 'Display form title', 'formidable' ),
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 						'val'   => 1,
581 581
 						'label' => __( 'Minimize form HTML', 'formidable' ),
582 582
 					),
583
-                );
584
-        }
583
+				);
584
+		}
585 585
 		$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
586 586
 
587 587
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
@@ -592,38 +592,38 @@  discard block
 block discarded – undo
592 592
 
593 593
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
594 594
 
595
-        echo '</div>';
595
+		echo '</div>';
596 596
 
597
-        wp_die();
598
-    }
597
+		wp_die();
598
+	}
599 599
 
600 600
 	public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
601
-        FrmAppHelper::permission_check( 'frm_view_forms' );
601
+		FrmAppHelper::permission_check( 'frm_view_forms' );
602 602
 
603
-        global $wpdb, $frm_vars;
603
+		global $wpdb, $frm_vars;
604 604
 
605 605
 		if ( empty( $params ) ) {
606 606
 			$params = FrmForm::list_page_params();
607
-        }
607
+		}
608 608
 
609
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
609
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
610 610
 
611
-        $pagenum = $wp_list_table->get_pagenum();
611
+		$pagenum = $wp_list_table->get_pagenum();
612 612
 
613
-        $wp_list_table->prepare_items();
613
+		$wp_list_table->prepare_items();
614 614
 
615
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
616
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
615
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
616
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
617 617
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
618
-            die();
619
-        }
618
+			die();
619
+		}
620 620
 
621 621
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
622
-    }
622
+	}
623 623
 
624 624
 	public static function get_columns( $columns ) {
625
-	    $columns['cb'] = '<input type="checkbox" />';
626
-	    $columns['id'] = 'ID';
625
+		$columns['cb'] = '<input type="checkbox" />';
626
+		$columns['id'] = 'ID';
627 627
 
628 628
 		$type = FrmAppHelper::get_simple_request(
629 629
 			array(
@@ -633,18 +633,18 @@  discard block
 block discarded – undo
633 633
 			)
634 634
 		);
635 635
 
636
-        if ( 'template' == $type ) {
637
-            $columns['name']        = __( 'Template Name', 'formidable' );
638
-            $columns['type']        = __( 'Type', 'formidable' );
639
-            $columns['form_key']    = __( 'Key', 'formidable' );
640
-        } else {
641
-            $columns['name']        = __( 'Form Title', 'formidable' );
642
-            $columns['entries']     = __( 'Entries', 'formidable' );
643
-            $columns['form_key']    = __( 'Key', 'formidable' );
644
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
645
-        }
636
+		if ( 'template' == $type ) {
637
+			$columns['name']        = __( 'Template Name', 'formidable' );
638
+			$columns['type']        = __( 'Type', 'formidable' );
639
+			$columns['form_key']    = __( 'Key', 'formidable' );
640
+		} else {
641
+			$columns['name']        = __( 'Form Title', 'formidable' );
642
+			$columns['entries']     = __( 'Entries', 'formidable' );
643
+			$columns['form_key']    = __( 'Key', 'formidable' );
644
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
645
+		}
646 646
 
647
-        $columns['created_at'] = __( 'Date', 'formidable' );
647
+		$columns['created_at'] = __( 'Date', 'formidable' );
648 648
 
649 649
 		add_screen_option(
650 650
 			'per_page',
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			)
656 656
 		);
657 657
 
658
-        return $columns;
658
+		return $columns;
659 659
 	}
660 660
 
661 661
 	public static function get_sortable_columns() {
@@ -685,34 +685,34 @@  discard block
 block discarded – undo
685 685
 	}
686 686
 
687 687
 	public static function save_per_page( $save, $option, $value ) {
688
-        if ( $option == 'formidable_page_formidable_per_page' ) {
689
-            $save = (int) $value;
690
-        }
691
-        return $save;
692
-    }
688
+		if ( $option == 'formidable_page_formidable_per_page' ) {
689
+			$save = (int) $value;
690
+		}
691
+		return $save;
692
+	}
693 693
 
694 694
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
695
-        global $frm_vars;
695
+		global $frm_vars;
696 696
 
697
-        $form = FrmForm::getOne( $id );
698
-        if ( ! $form ) {
699
-            wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
700
-        }
697
+		$form = FrmForm::getOne( $id );
698
+		if ( ! $form ) {
699
+			wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) );
700
+		}
701 701
 
702
-        if ( $form->parent_form_id ) {
702
+		if ( $form->parent_form_id ) {
703 703
 			wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) );
704
-        }
704
+		}
705 705
 
706 706
 		$frm_field_selection = FrmField::field_selection();
707 707
 		$fields = FrmField::get_all_for_form( $form->id );
708 708
 
709
-        // Automatically add end section fields if they don't exist (2.0 migration)
710
-        $reset_fields = false;
711
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
709
+		// Automatically add end section fields if they don't exist (2.0 migration)
710
+		$reset_fields = false;
711
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
712 712
 
713
-        if ( $reset_fields ) {
714
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
715
-        }
713
+		if ( $reset_fields ) {
714
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
715
+		}
716 716
 
717 717
 		unset( $end_section_values, $last_order, $open, $reset_fields );
718 718
 
@@ -720,30 +720,30 @@  discard block
 block discarded – undo
720 720
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args );
721 721
 		$values['fields'] = $fields;
722 722
 
723
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
724
-        if ( $form->is_template && $message == $edit_message ) {
725
-            $message = __( 'Template was Successfully Updated', 'formidable' );
726
-        }
723
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
724
+		if ( $form->is_template && $message == $edit_message ) {
725
+			$message = __( 'Template was Successfully Updated', 'formidable' );
726
+		}
727 727
 
728 728
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
729 729
 
730
-        if ( $form->default_template ) {
730
+		if ( $form->default_template ) {
731 731
 			wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) );
732 732
 		} elseif ( defined( 'DOING_AJAX' ) ) {
733
-            wp_die();
734
-        } else if ( $create_link ) {
733
+			wp_die();
734
+		} else if ( $create_link ) {
735 735
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
736
-        } else {
736
+		} else {
737 737
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
738
-        }
739
-    }
738
+		}
739
+	}
740 740
 
741 741
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
742 742
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
743 743
 
744
-        global $frm_vars;
744
+		global $frm_vars;
745 745
 
746
-        $form = FrmForm::getOne( $id );
746
+		$form = FrmForm::getOne( $id );
747 747
 
748 748
 		$fields = FrmField::get_all_for_form( $id );
749 749
 		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
@@ -754,17 +754,17 @@  discard block
 block discarded – undo
754 754
 
755 755
 		self::clean_submit_html( $values );
756 756
 
757
-        $action_controls = FrmFormActionsController::get_form_actions();
757
+		$action_controls = FrmFormActionsController::get_form_actions();
758 758
 
759 759
 		$sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
760
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
760
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
761 761
 
762 762
 		$styles = apply_filters( 'frm_get_style_opts', array() );
763 763
 
764 764
 		$first_h3 = 'frm_first_h3';
765 765
 
766 766
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
767
-    }
767
+	}
768 768
 
769 769
 	/**
770 770
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -779,10 +779,10 @@  discard block
 block discarded – undo
779 779
 		}
780 780
 	}
781 781
 
782
-    public static function mb_tags_box( $form_id, $class = '' ) {
782
+	public static function mb_tags_box( $form_id, $class = '' ) {
783 783
 		$fields = FrmField::get_all_for_form( $form_id, '', 'include' );
784
-        $linked_forms = array();
785
-        $col = 'one';
784
+		$linked_forms = array();
785
+		$col = 'one';
786 786
 		$settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
787 787
 
788 788
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 		$advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) );
792 792
 
793 793
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
794
-    }
794
+	}
795 795
 
796 796
 	/**
797 797
 	 * @since 3.04.01
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 			''          => '',
883 883
 			'siteurl'   => __( 'Site URL', 'formidable' ),
884 884
 			'sitename'  => __( 'Site Name', 'formidable' ),
885
-        );
885
+		);
886 886
 
887 887
 		if ( ! FrmAppHelper::pro_is_installed() ) {
888 888
 			unset( $entry_shortcodes['post_id'] );
@@ -931,21 +931,21 @@  discard block
 block discarded – undo
931 931
 		wp_die();
932 932
 	}
933 933
 
934
-    public static function filter_content( $content, $form, $entry = false ) {
934
+	public static function filter_content( $content, $form, $entry = false ) {
935 935
 		self::get_entry_by_param( $entry );
936
-        if ( ! $entry ) {
937
-            return $content;
938
-        }
936
+		if ( ! $entry ) {
937
+			return $content;
938
+		}
939 939
 
940
-        if ( is_object( $form ) ) {
941
-            $form = $form->id;
942
-        }
940
+		if ( is_object( $form ) ) {
941
+			$form = $form->id;
942
+		}
943 943
 
944
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
945
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
944
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
945
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
946 946
 
947
-        return $content;
948
-    }
947
+		return $content;
948
+	}
949 949
 
950 950
 	private static function get_entry_by_param( &$entry ) {
951 951
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -957,66 +957,66 @@  discard block
 block discarded – undo
957 957
 		}
958 958
 	}
959 959
 
960
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
961
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
962
-    }
960
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
961
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
962
+	}
963 963
 
964
-    public static function process_bulk_form_actions( $errors ) {
965
-        if ( ! $_REQUEST ) {
966
-            return $errors;
967
-        }
964
+	public static function process_bulk_form_actions( $errors ) {
965
+		if ( ! $_REQUEST ) {
966
+			return $errors;
967
+		}
968 968
 
969 969
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
970
-        if ( $bulkaction == -1 ) {
970
+		if ( $bulkaction == -1 ) {
971 971
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
972
-        }
972
+		}
973 973
 
974
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
975
-            FrmAppHelper::remove_get_action();
974
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
975
+			FrmAppHelper::remove_get_action();
976 976
 
977
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
978
-        }
977
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
978
+		}
979 979
 
980 980
 		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
981
-        if ( empty( $ids ) ) {
982
-            $errors[] = __( 'No forms were specified', 'formidable' );
983
-            return $errors;
984
-        }
985
-
986
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
987
-        if ( $permission_error !== false ) {
988
-            $errors[] = $permission_error;
989
-            return $errors;
990
-        }
991
-
992
-        if ( ! is_array( $ids ) ) {
993
-            $ids = explode( ',', $ids );
994
-        }
995
-
996
-        switch ( $bulkaction ) {
997
-            case 'delete':
998
-                $message = self::bulk_destroy( $ids );
981
+		if ( empty( $ids ) ) {
982
+			$errors[] = __( 'No forms were specified', 'formidable' );
983
+			return $errors;
984
+		}
985
+
986
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
987
+		if ( $permission_error !== false ) {
988
+			$errors[] = $permission_error;
989
+			return $errors;
990
+		}
991
+
992
+		if ( ! is_array( $ids ) ) {
993
+			$ids = explode( ',', $ids );
994
+		}
995
+
996
+		switch ( $bulkaction ) {
997
+			case 'delete':
998
+				$message = self::bulk_destroy( $ids );
999 999
 				break;
1000
-            case 'trash':
1001
-                $message = self::bulk_trash( $ids );
1000
+			case 'trash':
1001
+				$message = self::bulk_trash( $ids );
1002 1002
 				break;
1003
-            case 'untrash':
1004
-                $message = self::bulk_untrash( $ids );
1005
-        }
1003
+			case 'untrash':
1004
+				$message = self::bulk_untrash( $ids );
1005
+		}
1006 1006
 
1007
-        if ( isset( $message ) && ! empty( $message ) ) {
1007
+		if ( isset( $message ) && ! empty( $message ) ) {
1008 1008
 			echo '<div id="message" class="updated frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; // WPCS: XSS ok.
1009
-        }
1009
+		}
1010 1010
 
1011
-        return $errors;
1012
-    }
1011
+		return $errors;
1012
+	}
1013 1013
 
1014 1014
 	/**
1015 1015
 	 * @deprecated 1.07.05
1016 1016
 	 * @codeCoverageIgnore
1017 1017
 	 */
1018
-    public static function add_default_templates( $path, $default = true, $template = true ) {
1019
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
1018
+	public static function add_default_templates( $path, $default = true, $template = true ) {
1019
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
1020 1020
 
1021 1021
 		$path = untrailingslashit( trim( $path ) );
1022 1022
 		$templates = glob( $path . '/*.php' );
@@ -1024,130 +1024,130 @@  discard block
 block discarded – undo
1024 1024
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
1025 1025
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
1026 1026
 			$template_query = array( 'form_key' => $filename );
1027
-            if ( $template ) {
1028
-                $template_query['is_template'] = 1;
1029
-            }
1030
-            if ( $default ) {
1031
-                $template_query['default_template'] = 1;
1032
-            }
1027
+			if ( $template ) {
1028
+				$template_query['is_template'] = 1;
1029
+			}
1030
+			if ( $default ) {
1031
+				$template_query['default_template'] = 1;
1032
+			}
1033 1033
 			$form = FrmForm::getAll( $template_query, '', 1 );
1034 1034
 
1035
-            $values = FrmFormsHelper::setup_new_vars();
1036
-            $values['form_key'] = $filename;
1037
-            $values['is_template'] = $template;
1038
-            $values['status'] = 'published';
1039
-            if ( $default ) {
1040
-                $values['default_template'] = 1;
1041
-            }
1035
+			$values = FrmFormsHelper::setup_new_vars();
1036
+			$values['form_key'] = $filename;
1037
+			$values['is_template'] = $template;
1038
+			$values['status'] = 'published';
1039
+			if ( $default ) {
1040
+				$values['default_template'] = 1;
1041
+			}
1042 1042
 
1043
-            include( $templates[ $i ] );
1043
+			include( $templates[ $i ] );
1044 1044
 
1045
-            //get updated form
1045
+			//get updated form
1046 1046
 			if ( isset( $form ) && ! empty( $form ) ) {
1047
-                $old_id = $form->id;
1047
+				$old_id = $form->id;
1048 1048
 				$form = FrmForm::getOne( $form->id );
1049
-            } else {
1050
-                $old_id = false;
1049
+			} else {
1050
+				$old_id = false;
1051 1051
 				$form = FrmForm::getAll( $template_query, '', 1 );
1052
-            }
1052
+			}
1053 1053
 
1054
-            if ( $form ) {
1054
+			if ( $form ) {
1055 1055
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
1056
-            }
1057
-        }
1058
-    }
1056
+			}
1057
+		}
1058
+	}
1059 1059
 
1060
-    public static function route() {
1060
+	public static function route() {
1061 1061
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1062
-        $vars = array();
1062
+		$vars = array();
1063 1063
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
1064 1064
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
1065 1065
 
1066 1066
 			$json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
1067 1067
 			$json_vars = json_decode( $json_vars, true );
1068 1068
 			if ( empty( $json_vars ) ) {
1069
-                // json decoding failed so we should return an error message
1069
+				// json decoding failed so we should return an error message
1070 1070
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1071
-                if ( 'edit' == $action ) {
1072
-                    $action = 'update';
1073
-                }
1071
+				if ( 'edit' == $action ) {
1072
+					$action = 'update';
1073
+				}
1074 1074
 
1075 1075
 				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1076
-            } else {
1076
+			} else {
1077 1077
 				$vars = FrmAppHelper::json_to_array( $json_vars );
1078
-                $action = $vars[ $action ];
1078
+				$action = $vars[ $action ];
1079 1079
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1080 1080
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1081 1081
 				$_POST = array_merge( $_POST, $_REQUEST );
1082
-            }
1083
-        } else {
1082
+			}
1083
+		} else {
1084 1084
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
1085
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
1086
-                // override the action for this page
1087
-    			$action = 'delete_all';
1088
-            }
1089
-        }
1085
+			if ( isset( $_REQUEST['delete_all'] ) ) {
1086
+				// override the action for this page
1087
+				$action = 'delete_all';
1088
+			}
1089
+		}
1090 1090
 
1091 1091
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1092
-        FrmAppHelper::trigger_hook_load( 'form' );
1092
+		FrmAppHelper::trigger_hook_load( 'form' );
1093 1093
 
1094
-        switch ( $action ) {
1095
-            case 'new':
1094
+		switch ( $action ) {
1095
+			case 'new':
1096 1096
 				return self::new_form( $vars );
1097
-            case 'create':
1098
-            case 'edit':
1099
-            case 'update':
1100
-            case 'duplicate':
1101
-            case 'trash':
1102
-            case 'untrash':
1103
-            case 'destroy':
1104
-            case 'delete_all':
1105
-            case 'settings':
1106
-            case 'update_settings':
1097
+			case 'create':
1098
+			case 'edit':
1099
+			case 'update':
1100
+			case 'duplicate':
1101
+			case 'trash':
1102
+			case 'untrash':
1103
+			case 'destroy':
1104
+			case 'delete_all':
1105
+			case 'settings':
1106
+			case 'update_settings':
1107 1107
 				return self::$action( $vars );
1108
-            default:
1108
+			default:
1109 1109
 				do_action( 'frm_form_action_' . $action );
1110 1110
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
1111
-                    return;
1112
-                }
1111
+					return;
1112
+				}
1113 1113
 
1114 1114
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
1115
-                if ( $action == -1 ) {
1115
+				if ( $action == -1 ) {
1116 1116
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
1117
-                }
1117
+				}
1118 1118
 
1119 1119
 				if ( strpos( $action, 'bulk_' ) === 0 ) {
1120
-                    FrmAppHelper::remove_get_action();
1121
-                    return self::list_form();
1122
-                }
1120
+					FrmAppHelper::remove_get_action();
1121
+					return self::list_form();
1122
+				}
1123 1123
 
1124
-                return self::display_forms_list();
1125
-        }
1126
-    }
1124
+				return self::display_forms_list();
1125
+		}
1126
+	}
1127 1127
 
1128
-    public static function json_error( $errors ) {
1129
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1130
-        return $errors;
1131
-    }
1128
+	public static function json_error( $errors ) {
1129
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
1130
+		return $errors;
1131
+	}
1132 1132
 
1133 1133
 
1134
-    /* FRONT-END FORMS */
1135
-    public static function admin_bar_css() {
1134
+	/* FRONT-END FORMS */
1135
+	public static function admin_bar_css() {
1136 1136
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
1137
-            return;
1138
-        }
1137
+			return;
1138
+		}
1139 1139
 
1140 1140
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
1141 1141
 		FrmAppHelper::load_font_style();
1142 1142
 	}
1143 1143
 
1144 1144
 	public static function admin_bar_configure() {
1145
-        global $frm_vars;
1145
+		global $frm_vars;
1146 1146
 		if ( empty( $frm_vars['forms_loaded'] ) ) {
1147
-            return;
1148
-        }
1147
+			return;
1148
+		}
1149 1149
 
1150
-        $actions = array();
1150
+		$actions = array();
1151 1151
 		foreach ( $frm_vars['forms_loaded'] as $form ) {
1152 1152
 			if ( is_object( $form ) ) {
1153 1153
 				$actions[ $form->id ] = $form->name;
@@ -1202,18 +1202,18 @@  discard block
 block discarded – undo
1202 1202
 		}
1203 1203
 	}
1204 1204
 
1205
-    //formidable shortcode
1205
+	//formidable shortcode
1206 1206
 	public static function get_form_shortcode( $atts ) {
1207
-        global $frm_vars;
1207
+		global $frm_vars;
1208 1208
 		if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1209
-            $sc = '[formidable';
1209
+			$sc = '[formidable';
1210 1210
 			if ( ! empty( $atts ) ) {
1211 1211
 				foreach ( $atts as $k => $v ) {
1212 1212
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1213 1213
 				}
1214 1214
 			}
1215 1215
 			return $sc . ']';
1216
-        }
1216
+		}
1217 1217
 
1218 1218
 		$shortcode_atts = shortcode_atts(
1219 1219
 			array(
@@ -1231,27 +1231,27 @@  discard block
 block discarded – undo
1231 1231
 		);
1232 1232
 		do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1233 1233
 
1234
-        return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
1235
-    }
1234
+		return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts );
1235
+	}
1236 1236
 
1237
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1238
-        if ( empty( $id ) ) {
1239
-            $id = $key;
1240
-        }
1237
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1238
+		if ( empty( $id ) ) {
1239
+			$id = $key;
1240
+		}
1241 1241
 
1242
-        $form = self::maybe_get_form_to_show( $id );
1243
-        if ( ! $form ) {
1244
-            return __( 'Please select a valid form', 'formidable' );
1245
-        }
1242
+		$form = self::maybe_get_form_to_show( $id );
1243
+		if ( ! $form ) {
1244
+			return __( 'Please select a valid form', 'formidable' );
1245
+		}
1246 1246
 
1247 1247
 		FrmAppController::maybe_update_styles();
1248 1248
 
1249 1249
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1250
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1250
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1251 1251
 
1252
-        $form = apply_filters( 'frm_pre_display_form', $form );
1252
+		$form = apply_filters( 'frm_pre_display_form', $form );
1253 1253
 
1254
-        $frm_settings = FrmAppHelper::get_settings();
1254
+		$frm_settings = FrmAppHelper::get_settings();
1255 1255
 
1256 1256
 		if ( self::is_viewable_draft_form( $form ) ) {
1257 1257
 			// don't show a draft form on a page
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 		}
1274 1274
 
1275 1275
 		return $form;
1276
-    }
1276
+	}
1277 1277
 
1278 1278
 	private static function maybe_get_form_to_show( $id ) {
1279 1279
 		$form = false;
@@ -1302,21 +1302,21 @@  discard block
 block discarded – undo
1302 1302
 		return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] );
1303 1303
 	}
1304 1304
 
1305
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1305
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1306 1306
 		ob_start();
1307 1307
 
1308 1308
 		do_action( 'frm_before_get_form', $atts );
1309 1309
 
1310
-        self::get_form_contents( $form, $title, $description, $atts );
1310
+		self::get_form_contents( $form, $title, $description, $atts );
1311 1311
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1312 1312
 
1313
-        $contents = ob_get_contents();
1314
-        ob_end_clean();
1313
+		$contents = ob_get_contents();
1314
+		ob_end_clean();
1315 1315
 
1316 1316
 		self::maybe_minimize_form( $atts, $contents );
1317 1317
 
1318
-        return $contents;
1319
-    }
1318
+		return $contents;
1319
+	}
1320 1320
 
1321 1321
 	public static function enqueue_scripts( $params ) {
1322 1322
 		do_action( 'frm_enqueue_form_scripts', $params );
@@ -1662,10 +1662,10 @@  discard block
 block discarded – undo
1662 1662
 	}
1663 1663
 
1664 1664
 	public static function defer_script_loading( $tag, $handle ) {
1665
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1666
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1665
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1666
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1667 1667
 		}
1668
-	    return $tag;
1668
+		return $tag;
1669 1669
 	}
1670 1670
 
1671 1671
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         global $frm_vars;
65 65
 
66 66
 		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
67
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
67
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
68 68
 
69 69
 		if ( $action == 'create' ) {
70 70
 			self::create( $values );
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 			),
409 409
 		);
410 410
 
411
-		if ( ! isset( $available_status[ $status ] ) ) {
411
+		if ( ! isset( $available_status[$status] ) ) {
412 412
 			return;
413 413
 		}
414 414
 
415
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
415
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
416 416
 
417 417
 		$params = FrmForm::list_page_params();
418 418
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 		check_admin_referer( $status . '_form_' . $params['id'] );
421 421
 
422 422
 		$count = 0;
423
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
424
-			$count++;
423
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
424
+			$count ++;
425 425
 		}
426 426
 
427 427
 		$form_type = FrmAppHelper::get_simple_request(
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
435 435
 		$available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' );
436 436
 
437
-		$message = $available_status[ $status ]['message'];
437
+		$message = $available_status[$status]['message'];
438 438
 
439 439
 		self::display_forms_list( $params, $message );
440 440
 	}
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $count = 0;
446 446
         foreach ( $ids as $id ) {
447 447
             if ( FrmForm::trash( $id ) ) {
448
-                $count++;
448
+                $count ++;
449 449
             }
450 450
         }
451 451
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
         $count = 0;
477 477
         if ( FrmForm::destroy( $params['id'] ) ) {
478
-            $count++;
478
+            $count ++;
479 479
         }
480 480
 
481 481
 		$message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
         foreach ( $ids as $id ) {
491 491
             $d = FrmForm::destroy( $id );
492 492
             if ( $d ) {
493
-                $count++;
493
+                $count ++;
494 494
             }
495 495
         }
496 496
 
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 		if ( ! empty( $user_fields ) ) {
809 809
 			$user_helpers = array();
810 810
 			foreach ( $user_fields as $uk => $uf ) {
811
-				$user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
811
+				$user_helpers['|user_id| show="' . $uk . '"'] = $uf;
812 812
 				unset( $uk, $uf );
813 813
 			}
814 814
 
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 		$path = untrailingslashit( trim( $path ) );
1022 1022
 		$templates = glob( $path . '/*.php' );
1023 1023
 
1024
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
1025
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
1024
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
1025
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
1026 1026
 			$template_query = array( 'form_key' => $filename );
1027 1027
             if ( $template ) {
1028 1028
                 $template_query['is_template'] = 1;
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
                 $values['default_template'] = 1;
1041 1041
             }
1042 1042
 
1043
-            include( $templates[ $i ] );
1043
+            include( $templates[$i] );
1044 1044
 
1045 1045
             //get updated form
1046 1046
 			if ( isset( $form ) && ! empty( $form ) ) {
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 				add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
1076 1076
             } else {
1077 1077
 				$vars = FrmAppHelper::json_to_array( $json_vars );
1078
-                $action = $vars[ $action ];
1078
+                $action = $vars[$action];
1079 1079
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
1080 1080
 				$_REQUEST = array_merge( $_REQUEST, $vars );
1081 1081
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
         $actions = array();
1151 1151
 		foreach ( $frm_vars['forms_loaded'] as $form ) {
1152 1152
 			if ( is_object( $form ) ) {
1153
-				$actions[ $form->id ] = $form->name;
1153
+				$actions[$form->id] = $form->name;
1154 1154
 			}
1155 1155
 			unset( $form );
1156 1156
 		}
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
 	private static function get_saved_errors( $form, $params ) {
1370 1370
 		global $frm_vars;
1371 1371
 
1372
-		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
1373
-			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
1372
+		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) {
1373
+			$errors = $frm_vars['created_entries'][$form->id]['errors'];
1374 1374
 		} else {
1375 1375
 			$errors = array();
1376 1376
 		}
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 	 */
1383 1383
 	public static function just_created_entry( $form_id ) {
1384 1384
 		global $frm_vars;
1385
-		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0;
1385
+		return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0;
1386 1386
 	}
1387 1387
 
1388 1388
 	/**
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 	 */
1391 1391
 	private static function get_confirmation_method( $atts ) {
1392 1392
 		$opt = 'success_action';
1393
-		$method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message';
1393
+		$method = ( isset( $atts['form']->options[$opt] ) && ! empty( $atts['form']->options[$opt] ) ) ? $atts['form']->options[$opt] : 'message';
1394 1394
 		$method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' );
1395 1395
 
1396 1396
 		if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) {
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	public static function maybe_trigger_redirect( $form, $params, $args ) {
1404 1404
 		if ( ! isset( $params['id'] ) ) {
1405 1405
 			global $frm_vars;
1406
-			$params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
1406
+			$params['id'] = $frm_vars['created_entries'][$form->id]['entry_id'];
1407 1407
 		}
1408 1408
 
1409 1409
 		$conf_method = self::get_confirmation_method(
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 
1446 1446
 		$opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit';
1447 1447
 		$args['success_opt'] = $opt;
1448
-		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) {
1448
+		if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[$opt . '_page_id'] ) ) {
1449 1449
 			self::load_page_after_submit( $args );
1450 1450
 		} elseif ( $args['conf_method'] == 'redirect' ) {
1451 1451
 			self::redirect_after_submit( $args );
@@ -1460,8 +1460,8 @@  discard block
 block discarded – undo
1460 1460
 	private static function load_page_after_submit( $args ) {
1461 1461
 		global $post;
1462 1462
 		$opt = $args['success_opt'];
1463
-		if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
1464
-			$page = get_post( $args['form']->options[ $opt . '_page_id' ] );
1463
+		if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) {
1464
+			$page = get_post( $args['form']->options[$opt . '_page_id'] );
1465 1465
 			$old_post = $post;
1466 1466
 			$post = $page;
1467 1467
 			$content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] );
@@ -1479,11 +1479,11 @@  discard block
 block discarded – undo
1479 1479
 		add_filter( 'frm_use_wpautop', '__return_false' );
1480 1480
 
1481 1481
 		$opt = $args['success_opt'];
1482
-		$success_url = trim( $args['form']->options[ $opt . '_url' ] );
1482
+		$success_url = trim( $args['form']->options[$opt . '_url'] );
1483 1483
 		$success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] );
1484 1484
 		$success_url = do_shortcode( $success_url );
1485 1485
 
1486
-		$success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' );
1486
+		$success_msg = isset( $args['form']->options[$opt . '_msg'] ) ? $args['form']->options[$opt . '_msg'] : __( 'Please wait while you are redirected.', 'formidable' );
1487 1487
 
1488 1488
 		$redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args );
1489 1489
 
Please login to merge, or discard this patch.