Completed
Push — master ( 02cc92...6df54b )
by Stephanie
02:42
created
classes/helpers/FrmListHelper.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -264,6 +264,9 @@  discard block
 block discarded – undo
264 264
 <?php
265 265
 	}
266 266
 
267
+	/**
268
+	 * @param string $param_name
269
+	 */
267 270
 	private function hidden_search_inputs( $param_name ) {
268 271
 		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
269 272
 			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />';
@@ -402,6 +405,9 @@  discard block
 block discarded – undo
402 405
 		return $action;
403 406
 	}
404 407
 
408
+	/**
409
+	 * @param string $action_name
410
+	 */
405 411
 	private static function get_bulk_action( $action_name ) {
406 412
 		$action = false;
407 413
 		$action_param = self::get_param( array( 'param' => $action_name, 'sanitize' => 'sanitize_text_field' ) );
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 			return $this->get_pagenum();
210 210
 		}
211 211
 
212
-		if ( isset( $this->_pagination_args[ $key ] ) ) {
213
-			return $this->_pagination_args[ $key ];
212
+		if ( isset( $this->_pagination_args[$key] ) ) {
213
+			return $this->_pagination_args[$key];
214 214
 		}
215 215
 	}
216 216
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	private function hidden_search_inputs( $param_name ) {
268
-		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
269
-			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />';
268
+		if ( ! empty( $_REQUEST[$param_name] ) ) {
269
+			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />';
270 270
 		}
271 271
 	}
272 272
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 		echo "<ul class='subsubsub'>\n";
311 311
 		foreach ( $views as $class => $view ) {
312
-			$views[ $class ] = "\t<li class='$class'>$view";
312
+			$views[$class] = "\t<li class='$class'>$view";
313 313
 		}
314 314
 		echo implode( " |</li>\n", $views ) . "</li>\n";
315 315
 		echo '</ul>';
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 
432 432
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
433 433
 		foreach ( $actions as $action => $link ) {
434
-			++$i;
434
+			++ $i;
435 435
 			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
436 436
 			$out .= "<span class='$action'>$link$sep</span>";
437 437
 		}
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 
703 703
 		// If the primary column doesn't exist fall back to the
704 704
 		// first non-checkbox column.
705
-		if ( ! isset( $columns[ $default ] ) ) {
705
+		if ( ! isset( $columns[$default] ) ) {
706 706
 			$default = FrmListHelper::get_default_primary_column_name();
707 707
 		}
708 708
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 		 */
717 717
 		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
718 718
 
719
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
719
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
720 720
 			$column = $default;
721 721
 		}
722 722
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			// In 4.3, we added a fourth argument for primary column.
739 739
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
740 740
 			foreach ( $this->_column_headers as $key => $value ) {
741
-				$column_headers[ $key ] = $value;
741
+				$column_headers[$key] = $value;
742 742
 			}
743 743
 
744 744
 			return $column_headers;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 				$data[1] = false;
773 773
 			}
774 774
 
775
-			$sortable[ $id ] = $data;
775
+			$sortable[$id] = $data;
776 776
 		}
777 777
 
778 778
 		$primary = $this->get_primary_column_name();
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 			foreach ( $columns as $name => $c ) {
796 796
 				if ( ! in_array( $name, $hidden ) ) {
797 797
 					$hidden[] = $name;
798
-					$remove--;
798
+					$remove --;
799 799
 					if ( $remove <= 0 ) {
800 800
 						break;
801 801
 					}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 			static $cb_counter = 1;
851 851
 			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
852 852
 				. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
853
-			$cb_counter++;
853
+			$cb_counter ++;
854 854
 		}
855 855
 
856 856
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -870,8 +870,8 @@  discard block
 block discarded – undo
870 870
 				$class[] = 'column-primary';
871 871
 			}
872 872
 
873
-			if ( isset( $sortable[ $column_key ] ) ) {
874
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
873
+			if ( isset( $sortable[$column_key] ) ) {
874
+				list( $orderby, $desc_first ) = $sortable[$column_key];
875 875
 
876 876
 				if ( $current_orderby == $orderby ) {
877 877
 					$order = 'asc' == $current_order ? 'desc' : 'asc';
Please login to merge, or discard this patch.
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -23,40 +23,40 @@  discard block
 block discarded – undo
23 23
 		$order   = self::get_param( array( 'param' => 'order', 'default'  => 'ASC' ) );
24 24
 		$start   = self::get_param( array( 'param' => 'start', 'default' => ( ( $page - 1 ) * $per_page ) ) );
25 25
 
26
-        $s_query = array();
27
-        $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
26
+		$s_query = array();
27
+		$s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
28 28
 		switch ( $this->status ) {
29
-		    case 'template':
30
-                $s_query['is_template'] = 1;
31
-                $s_query['status !'] = 'trash';
32
-		        break;
33
-		    case 'draft':
34
-                $s_query['is_template'] = 0;
35
-                $s_query['status'] = 'draft';
36
-		        break;
37
-		    case 'trash':
38
-                $s_query['status'] = 'trash';
39
-		        break;
40
-		    default:
41
-                $s_query['is_template'] = 0;
42
-                $s_query['status !'] = 'trash';
43
-		        break;
29
+			case 'template':
30
+				$s_query['is_template'] = 1;
31
+				$s_query['status !'] = 'trash';
32
+				break;
33
+			case 'draft':
34
+				$s_query['is_template'] = 0;
35
+				$s_query['status'] = 'draft';
36
+				break;
37
+			case 'trash':
38
+				$s_query['status'] = 'trash';
39
+				break;
40
+			default:
41
+				$s_query['is_template'] = 0;
42
+				$s_query['status !'] = 'trash';
43
+				break;
44 44
 		}
45 45
 
46 46
 		$s = FrmAppHelper::get_simple_request( array( 'param' => 's', 'sanitize' => 'sanitize_text_field' ) );
47
-	    if ( $s != '' ) {
48
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
49
-		    $search_terms = array_map('trim', $matches[0]);
50
-	        foreach ( (array) $search_terms as $term ) {
51
-                $s_query[] = array(
52
-                    'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
53
-                );
54
-	            unset($term);
55
-            }
56
-	    }
47
+		if ( $s != '' ) {
48
+			preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
49
+			$search_terms = array_map('trim', $matches[0]);
50
+			foreach ( (array) $search_terms as $term ) {
51
+				$s_query[] = array(
52
+					'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
53
+				);
54
+				unset($term);
55
+			}
56
+		}
57 57
 
58 58
 		$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
59
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
59
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
60 60
 
61 61
 		$this->set_pagination_args( array(
62 62
 			'total_items' => $total_items,
@@ -65,69 +65,69 @@  discard block
 block discarded – undo
65 65
 	}
66 66
 
67 67
 	public function no_items() {
68
-	    if ( 'template' == $this->status ) {
69
-            _e( 'No Templates Found.', 'formidable' ) ?>
68
+		if ( 'template' == $this->status ) {
69
+			_e( 'No Templates Found.', 'formidable' ) ?>
70 70
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
71 71
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
72 72
                 <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
73 73
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
74 74
             </ol>
75 75
 <?php   } else {
76
-            _e( 'No Forms Found.', 'formidable' ) ?>
76
+			_e( 'No Forms Found.', 'formidable' ) ?>
77 77
             <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a>
78 78
 <?php   }
79 79
 	}
80 80
 
81 81
 	public function get_bulk_actions() {
82
-	    $actions = array();
82
+		$actions = array();
83 83
 
84 84
 		if ( in_array( $this->status, array( '', 'published' ) ) ) {
85
-	        $actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
86
-	    }
87
-
88
-	    if ( 'trash' == $this->status ) {
89
-	        if ( current_user_can('frm_edit_forms') ) {
90
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
91
-	        }
92
-
93
-	        if ( current_user_can('frm_delete_forms') ) {
94
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
95
-	        }
96
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
97
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
98
-	    } else if ( current_user_can('frm_delete_forms') ) {
99
-	        $actions['bulk_delete'] = __( 'Delete');
100
-	    }
101
-
102
-        return $actions;
103
-    }
85
+			$actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
86
+		}
87
+
88
+		if ( 'trash' == $this->status ) {
89
+			if ( current_user_can('frm_edit_forms') ) {
90
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
91
+			}
92
+
93
+			if ( current_user_can('frm_delete_forms') ) {
94
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
95
+			}
96
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
97
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
98
+		} else if ( current_user_can('frm_delete_forms') ) {
99
+			$actions['bulk_delete'] = __( 'Delete');
100
+		}
101
+
102
+		return $actions;
103
+	}
104 104
 
105 105
 	public function extra_tablenav( $which ) {
106
-        if ( 'top' != $which ) {
107
-            return;
108
-        }
106
+		if ( 'top' != $which ) {
107
+			return;
108
+		}
109 109
 
110
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
110
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
111 111
 ?>
112 112
             <div class="alignleft actions frm_visible_overflow">
113 113
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
114 114
             </div>
115 115
 <?php
116
-            return;
117
-        }
116
+			return;
117
+		}
118 118
 
119
-        if ( 'template' != $this->status ) {
120
-            return;
121
-        }
119
+		if ( 'template' != $this->status ) {
120
+			return;
121
+		}
122 122
 
123 123
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
124 124
 		$forms = FrmForm::get_published_forms( $where );
125 125
 
126
-        $base = admin_url('admin.php?page=formidable&form_type=template');
127
-        $args = array(
128
-            'frm_action'    => 'duplicate',
129
-            'template'      => true,
130
-        );
126
+		$base = admin_url('admin.php?page=formidable&form_type=template');
127
+		$args = array(
128
+			'frm_action'    => 'duplicate',
129
+			'template'      => true,
130
+		);
131 131
 
132 132
 ?>
133 133
     <div class="alignleft actions frm_visible_overflow">
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
         <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a>
136 136
 		<ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop">
137 137
 		<?php
138
-        if ( empty( $forms ) ) { ?>
138
+		if ( empty( $forms ) ) { ?>
139 139
             <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li>
140 140
         <?php
141
-        } else {
142
-            foreach ( $forms as $form ) {
143
-		        $args['id'] = $form->id; ?>
141
+		} else {
142
+			foreach ( $forms as $form ) {
143
+				$args['id'] = $form->id; ?>
144 144
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
145 145
 			<?php
146
-			    unset($form);
146
+				unset($form);
147 147
 			}
148
-        }
149
-        ?>
148
+		}
149
+		?>
150 150
 		</ul>
151 151
 	</div>
152 152
 	</div>
@@ -156,30 +156,30 @@  discard block
 block discarded – undo
156 156
 	public function get_views() {
157 157
 
158 158
 		$statuses = array(
159
-		    'published' => __( 'My Forms', 'formidable' ),
160
-		    'template'  => __( 'Templates', 'formidable' ),
161
-		    'draft'     => __( 'Drafts', 'formidable' ),
162
-		    'trash'     => __( 'Trash', 'formidable' ),
159
+			'published' => __( 'My Forms', 'formidable' ),
160
+			'template'  => __( 'Templates', 'formidable' ),
161
+			'draft'     => __( 'Drafts', 'formidable' ),
162
+			'trash'     => __( 'Trash', 'formidable' ),
163 163
 		);
164 164
 
165
-	    $links = array();
166
-	    $counts = FrmForm::get_count();
165
+		$links = array();
166
+		$counts = FrmForm::get_count();
167 167
 		$form_type = self::get_param( array( 'param' => 'form_type', 'default' => 'published' ) );
168 168
 
169
-	    foreach ( $statuses as $status => $name ) {
169
+		foreach ( $statuses as $status => $name ) {
170 170
 
171
-	        if ( $status == $form_type ) {
172
-    			$class = ' class="current"';
173
-    		} else {
174
-    		    $class = '';
175
-    		}
171
+			if ( $status == $form_type ) {
172
+				$class = ' class="current"';
173
+			} else {
174
+				$class = '';
175
+			}
176 176
 
177
-    		if ( $counts->{$status} || 'published' == $status ) {
177
+			if ( $counts->{$status} || 'published' == $status ) {
178 178
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
179
-		    }
179
+			}
180 180
 
181
-		    unset($status, $name);
182
-	    }
181
+			unset($status, $name);
182
+		}
183 183
 
184 184
 		return $links;
185 185
 	}
@@ -195,16 +195,16 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 
197 197
 	public function single_row( $item, $style = '' ) {
198
-	    global $frm_vars, $mode;
198
+		global $frm_vars, $mode;
199 199
 
200 200
 		// Set up the hover actions for this user
201 201
 		$actions = array();
202 202
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
203 203
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
204 204
 
205
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
205
+		$this->get_actions($actions, $item, $edit_link, $duplicate_link);
206 206
 
207
-        $action_links = $this->row_actions( $actions );
207
+		$action_links = $this->row_actions( $actions );
208 208
 
209 209
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
210 210
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 
214 214
 		list( $columns, $hidden ) = $this->get_column_info();
215 215
 
216
-        $format = 'Y/m/d';
217
-        if ( 'list' != $mode ) {
218
-            $format .= ' \<\b\r \/\> g:i:s a';
216
+		$format = 'Y/m/d';
217
+		if ( 'list' != $mode ) {
218
+			$format .= ' \<\b\r \/\> g:i:s a';
219 219
 		}
220 220
 
221 221
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 			$style = '';
225 225
 			if ( in_array( $column_name, $hidden ) ) {
226
-                $class .= ' frm_hidden';
226
+				$class .= ' frm_hidden';
227 227
 			}
228 228
 
229 229
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -236,41 +236,41 @@  discard block
 block discarded – undo
236 236
 					break;
237 237
 				case 'id':
238 238
 				case 'form_key':
239
-				    $val = $item->{$column_name};
240
-				    break;
239
+					$val = $item->{$column_name};
240
+					break;
241 241
 				case 'name':
242
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
243
-			        $val .= $action_links;
242
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
243
+					$val .= $action_links;
244 244
 
245
-				    break;
245
+					break;
246 246
 				case 'created_at':
247
-				    $date = date($format, strtotime($item->created_at));
247
+					$date = date($format, strtotime($item->created_at));
248 248
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
249 249
 					break;
250 250
 				case 'shortcode':
251 251
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
252
-				    if ( 'excerpt' == $mode ) {
252
+					if ( 'excerpt' == $mode ) {
253 253
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
254
-				    }
255
-			        break;
256
-			    case 'entries':
254
+					}
255
+					break;
256
+				case 'entries':
257 257
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
258 258
 						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
259
-			        } else {
260
-			            $text = FrmEntry::getRecordCount($item->id);
259
+					} else {
260
+						$text = FrmEntry::getRecordCount($item->id);
261 261
 						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
262
-                        unset($text);
263
-                    }
264
-			        break;
265
-                case 'type':
266
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
267
-                    break;
262
+						unset($text);
263
+					}
264
+					break;
265
+				case 'type':
266
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
267
+					break;
268 268
 			}
269 269
 
270 270
 			if ( isset($val) ) {
271
-			    $r .= "<td $attributes>";
272
-			    $r .= $val;
273
-			    $r .= '</td>';
271
+				$r .= "<td $attributes>";
272
+				$r .= $val;
273
+				$r .= '</td>';
274 274
 			}
275 275
 			unset($val);
276 276
 		}
@@ -279,38 +279,38 @@  discard block
 block discarded – undo
279 279
 		return $r;
280 280
 	}
281 281
 
282
-    /**
283
-     * @param string $edit_link
284
-     * @param string $duplicate_link
285
-     */
286
-    private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
282
+	/**
283
+	 * @param string $edit_link
284
+	 * @param string $duplicate_link
285
+	 */
286
+	private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
287 287
 		if ( 'trash' == $this->status ) {
288 288
 			if ( current_user_can('frm_edit_forms') ) {
289 289
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
290 290
 			}
291 291
 
292
-		    if ( current_user_can('frm_delete_forms') ) {
292
+			if ( current_user_can('frm_delete_forms') ) {
293 293
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
294 294
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
295
-    		}
296
-            return;
295
+			}
296
+			return;
297 297
 		}
298 298
 
299 299
 		if ( current_user_can('frm_edit_forms') ) {
300
-            if ( ! $item->is_template || ! $item->default_template ) {
300
+			if ( ! $item->is_template || ! $item->default_template ) {
301 301
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
302
-            }
302
+			}
303 303
 
304
-		    if ( $item->is_template ) {
304
+			if ( $item->is_template ) {
305 305
 				$actions['frm_duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
306
-            } else {
306
+			} else {
307 307
 				$actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
308 308
 
309
-    		    if ( FrmAppHelper::pro_is_installed() ) {
309
+				if ( FrmAppHelper::pro_is_installed() ) {
310 310
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
311
-        	    }
312
-        	}
313
-        }
311
+				}
312
+			}
313
+		}
314 314
 
315 315
 		$actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
316 316
 		if ( empty( $actions['trash'] ) ) {
@@ -319,52 +319,52 @@  discard block
 block discarded – undo
319 319
 		}
320 320
 
321 321
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
322
-    }
322
+	}
323 323
 
324
-    /**
325
-     * @param string $edit_link
326
-     */
324
+	/**
325
+	 * @param string $edit_link
326
+	 */
327 327
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
328
-        $form_name = $item->name;
329
-        if ( trim($form_name) == '' ) {
330
-            $form_name = __( '(no title)');
331
-        }
328
+		$form_name = $item->name;
329
+		if ( trim($form_name) == '' ) {
330
+			$form_name = __( '(no title)');
331
+		}
332 332
 		$form_name = FrmAppHelper::kses( $form_name );
333 333
 		if ( 'excerpt' != $mode ) {
334 334
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
335 335
 		}
336 336
 
337
-        $val = '<strong>';
338
-        if ( 'trash' == $this->status ) {
339
-            $val .= $form_name;
340
-        } else {
337
+		$val = '<strong>';
338
+		if ( 'trash' == $this->status ) {
339
+			$val .= $form_name;
340
+		} else {
341 341
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
342
-        }
342
+		}
343 343
 
344
-        $this->add_draft_label( $item, $val );
345
-        $val .= '</strong>';
344
+		$this->add_draft_label( $item, $val );
345
+		$val .= '</strong>';
346 346
 
347
-        $this->add_form_description( $item, $val );
347
+		$this->add_form_description( $item, $val );
348 348
 
349
-        return $val;
350
-    }
349
+		return $val;
350
+	}
351 351
 
352
-    /**
353
-     * @param string $val
354
-     */
355
-    private function add_draft_label( $item, &$val ) {
356
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
352
+	/**
353
+	 * @param string $val
354
+	 */
355
+	private function add_draft_label( $item, &$val ) {
356
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
357 357
 			$val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
358
-        }
359
-    }
360
-
361
-    /**
362
-     * @param string $val
363
-     */
364
-    private function add_form_description( $item, &$val ) {
365
-        global $mode;
366
-        if ( 'excerpt' == $mode ) {
367
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
368
-        }
369
-    }
358
+		}
359
+	}
360
+
361
+	/**
362
+	 * @param string $val
363
+	 */
364
+	private function add_form_description( $item, &$val ) {
365
+		global $mode;
366
+		if ( 'excerpt' == $mode ) {
367
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
368
+		}
369
+	}
370 370
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 
46 46
 		$s = FrmAppHelper::get_simple_request( array( 'param' => 's', 'sanitize' => 'sanitize_text_field' ) );
47 47
 	    if ( $s != '' ) {
48
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
49
-		    $search_terms = array_map('trim', $matches[0]);
48
+	        preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
49
+		    $search_terms = array_map( 'trim', $matches[0] );
50 50
 	        foreach ( (array) $search_terms as $term ) {
51 51
                 $s_query[] = array(
52 52
                     'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
53 53
                 );
54
-	            unset($term);
54
+	            unset( $term );
55 55
             }
56 56
 	    }
57 57
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             _e( 'No Templates Found.', 'formidable' ) ?>
70 70
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
71 71
 			<ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
72
-                <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
72
+                <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li>
73 73
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
74 74
             </ol>
75 75
 <?php   } else {
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 	    }
87 87
 
88 88
 	    if ( 'trash' == $this->status ) {
89
-	        if ( current_user_can('frm_edit_forms') ) {
89
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
90 90
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
91 91
 	        }
92 92
 
93
-	        if ( current_user_can('frm_delete_forms') ) {
93
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
94 94
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
95 95
 	        }
96
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
96
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
97 97
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
98
-	    } else if ( current_user_can('frm_delete_forms') ) {
99
-	        $actions['bulk_delete'] = __( 'Delete');
98
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
99
+	        $actions['bulk_delete'] = __( 'Delete' );
100 100
 	    }
101 101
 
102 102
         return $actions;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             return;
108 108
         }
109 109
 
110
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
110
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
111 111
 ?>
112 112
             <div class="alignleft actions frm_visible_overflow">
113 113
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
124 124
 		$forms = FrmForm::get_published_forms( $where );
125 125
 
126
-        $base = admin_url('admin.php?page=formidable&form_type=template');
126
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
127 127
         $args = array(
128 128
             'frm_action'    => 'duplicate',
129 129
             'template'      => true,
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		        $args['id'] = $form->id; ?>
144 144
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
145 145
 			<?php
146
-			    unset($form);
146
+			    unset( $form );
147 147
 			}
148 148
         }
149 149
         ?>
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
     		}
176 176
 
177 177
     		if ( $counts->{$status} || 'published' == $status ) {
178
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
178
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
179 179
 		    }
180 180
 
181
-		    unset($status, $name);
181
+		    unset( $status, $name );
182 182
 	    }
183 183
 
184 184
 		return $links;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		$edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
203 203
 		$duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
204 204
 
205
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
205
+        $this->get_actions( $actions, $item, $edit_link, $duplicate_link );
206 206
 
207 207
         $action_links = $this->row_actions( $actions );
208 208
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 				    break;
246 246
 				case 'created_at':
247
-				    $date = date($format, strtotime($item->created_at));
247
+				    $date = date( $format, strtotime( $item->created_at ) );
248 248
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
249 249
 					break;
250 250
 				case 'shortcode':
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 			        break;
256 256
 			    case 'entries':
257 257
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
258
-						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
258
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Saving entries is disabled for this form', 'formidable' ) . '"></i>';
259 259
 			        } else {
260
-			            $text = FrmEntry::getRecordCount($item->id);
261
-						$val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
262
-                        unset($text);
260
+			            $text = FrmEntry::getRecordCount( $item->id );
261
+						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
262
+                        unset( $text );
263 263
                     }
264 264
 			        break;
265 265
                 case 'type':
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
                     break;
268 268
 			}
269 269
 
270
-			if ( isset($val) ) {
270
+			if ( isset( $val ) ) {
271 271
 			    $r .= "<td $attributes>";
272 272
 			    $r .= $val;
273 273
 			    $r .= '</td>';
274 274
 			}
275
-			unset($val);
275
+			unset( $val );
276 276
 		}
277 277
 		$r .= '</tr>';
278 278
 
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
      */
286 286
     private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
287 287
 		if ( 'trash' == $this->status ) {
288
-			if ( current_user_can('frm_edit_forms') ) {
288
+			if ( current_user_can( 'frm_edit_forms' ) ) {
289 289
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
290 290
 			}
291 291
 
292
-		    if ( current_user_can('frm_delete_forms') ) {
292
+		    if ( current_user_can( 'frm_delete_forms' ) ) {
293 293
 				$trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id );
294 294
 				$actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
295 295
     		}
296 296
             return;
297 297
 		}
298 298
 
299
-		if ( current_user_can('frm_edit_forms') ) {
299
+		if ( current_user_can( 'frm_edit_forms' ) ) {
300 300
             if ( ! $item->is_template || ! $item->default_template ) {
301 301
 				$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
302 302
             }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 			unset( $actions['trash'] );
319 319
 		}
320 320
 
321
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
321
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
322 322
     }
323 323
 
324 324
     /**
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
      */
327 327
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
328 328
         $form_name = $item->name;
329
-        if ( trim($form_name) == '' ) {
330
-            $form_name = __( '(no title)');
329
+        if ( trim( $form_name ) == '' ) {
330
+            $form_name = __( '(no title)' );
331 331
         }
332 332
 		$form_name = FrmAppHelper::kses( $form_name );
333 333
 		if ( 'excerpt' != $mode ) {
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
     private function add_form_description( $item, &$val ) {
365 365
         global $mode;
366 366
         if ( 'excerpt' == $mode ) {
367
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
367
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
368 368
         }
369 369
     }
370 370
 }
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 2 patches
Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -19,38 +19,38 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public static function get_direct_link( $key, $form = false ) {
21 21
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
22
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
23
-
24
-        return $target_url;
25
-    }
26
-
27
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
28
-        $defaults = array(
29
-            'blank'     => true,
30
-            'field_id'  => false,
31
-            'onchange'  => false,
32
-            'exclude'   => false,
33
-            'class'     => '',
22
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
23
+
24
+		return $target_url;
25
+	}
26
+
27
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
28
+		$defaults = array(
29
+			'blank'     => true,
30
+			'field_id'  => false,
31
+			'onchange'  => false,
32
+			'exclude'   => false,
33
+			'class'     => '',
34 34
 			'inc_children' => 'exclude',
35
-        );
36
-        $args = wp_parse_args( $args, $defaults );
35
+		);
36
+		$args = wp_parse_args( $args, $defaults );
37 37
 
38
-        if ( ! $args['field_id'] ) {
39
-            $args['field_id'] = $field_name;
40
-        }
38
+		if ( ! $args['field_id'] ) {
39
+			$args['field_id'] = $field_name;
40
+		}
41 41
 
42 42
 		$query = array();
43
-        if ( $args['exclude'] ) {
43
+		if ( $args['exclude'] ) {
44 44
 			$query['id !'] = $args['exclude'];
45
-        }
45
+		}
46 46
 
47
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
47
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
48 48
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
49 49
 		$add_html = array();
50 50
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
51 51
 		self::add_html_attr( $args['class'], 'class', $add_html );
52 52
 
53
-        ?>
53
+		?>
54 54
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
55 55
 		<?php if ( $args['blank'] ) { ?>
56 56
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		<?php } ?>
63 63
         </select>
64 64
         <?php
65
-    }
65
+	}
66 66
 
67 67
 	/**
68 68
 	 * @param string $class
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		}
78 78
 	}
79 79
 
80
-    public static function form_switcher() {
80
+	public static function form_switcher() {
81 81
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
82 82
 		$forms = FrmForm::get_published_forms( $where );
83 83
 
@@ -86,32 +86,32 @@  discard block
 block discarded – undo
86 86
 			unset( $args['form'] );
87 87
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
88 88
 			unset( $args['id'] );
89
-        }
89
+		}
90 90
 
91 91
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
92 92
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
93
-            $args['frm_action'] = 'list';
94
-            $args['form'] = 0;
93
+			$args['frm_action'] = 'list';
94
+			$args['form'] = 0;
95 95
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
96
-            $args['frm_action'] = 'edit';
96
+			$args['frm_action'] = 'edit';
97 97
 		} else if ( isset( $_GET['post'] ) ) {
98
-            $args['form'] = 0;
99
-            $base = admin_url('edit.php?post_type=frm_display');
100
-        }
98
+			$args['form'] = 0;
99
+			$base = admin_url('edit.php?post_type=frm_display');
100
+		}
101 101
 
102
-        ?>
102
+		?>
103 103
 		<li class="dropdown last" id="frm_bs_dropdown">
104 104
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
105 105
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
106 106
 			<?php
107 107
 			foreach ( $forms as $form ) {
108 108
 				if ( isset( $args['id'] ) ) {
109
-			        $args['id'] = $form->id;
109
+					$args['id'] = $form->id;
110 110
 				}
111
-			    if ( isset( $args['form'] ) ) {
112
-			        $args['form'] = $form->id;
111
+				if ( isset( $args['form'] ) ) {
112
+					$args['form'] = $form->id;
113 113
 				}
114
-                ?>
114
+				?>
115 115
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
116 116
 			<?php
117 117
 				unset( $form );
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 			</ul>
120 120
 		</li>
121 121
         <?php
122
-    }
122
+	}
123 123
 
124 124
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
125
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
126
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
127
-    }
125
+		echo ($sort_col == $col) ? 'sorted' : 'sortable';
126
+		echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
127
+	}
128 128
 
129 129
 	/**
130 130
 	 * Get the invalid form error message
@@ -148,104 +148,104 @@  discard block
 block discarded – undo
148 148
 		return $message;
149 149
 	}
150 150
 
151
-    /**
152
-     * Used when a form is created
153
-     */
154
-    public static function setup_new_vars( $values = array() ) {
155
-        global $wpdb;
151
+	/**
152
+	 * Used when a form is created
153
+	 */
154
+	public static function setup_new_vars( $values = array() ) {
155
+		global $wpdb;
156 156
 
157
-        if ( ! empty( $values ) ) {
158
-            $post_values = $values;
159
-        } else {
160
-            $values = array();
161
-            $post_values = isset($_POST) ? $_POST : array();
162
-        }
157
+		if ( ! empty( $values ) ) {
158
+			$post_values = $values;
159
+		} else {
160
+			$values = array();
161
+			$post_values = isset($_POST) ? $_POST : array();
162
+		}
163 163
 
164 164
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
165 165
 			if ( ! isset( $values[ $var ] ) ) {
166 166
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
167
-            }
168
-        }
167
+			}
168
+		}
169 169
 
170
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
170
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
171 171
 
172 172
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
173
-            if ( ! isset( $values[ $var ] ) ) {
173
+			if ( ! isset( $values[ $var ] ) ) {
174 174
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
175
-            }
176
-        }
175
+			}
176
+		}
177 177
 
178
-        if ( ! isset( $values['form_key'] ) ) {
178
+		if ( ! isset( $values['form_key'] ) ) {
179 179
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
180
-        }
180
+		}
181 181
 
182 182
 		$values = self::fill_default_opts( $values, false, $post_values );
183 183
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
184 184
 
185
-        return apply_filters('frm_setup_new_form_vars', $values);
186
-    }
185
+		return apply_filters('frm_setup_new_form_vars', $values);
186
+	}
187 187
 
188
-    /**
189
-     * Used when editing a form
190
-     */
191
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
188
+	/**
189
+	 * Used when editing a form
190
+	 */
191
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
192 192
 		if ( empty( $post_values ) ) {
193 193
 			$post_values = stripslashes_deep( $_POST );
194 194
 		}
195 195
 
196
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
197
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
198
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
199
-        $values['status'] = $record->status;
196
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
197
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
198
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
199
+		$values['status'] = $record->status;
200 200
 
201
-        $values = self::fill_default_opts($values, $record, $post_values);
201
+		$values = self::fill_default_opts($values, $record, $post_values);
202 202
 
203
-        return apply_filters('frm_setup_edit_form_vars', $values);
204
-    }
203
+		return apply_filters('frm_setup_edit_form_vars', $values);
204
+	}
205 205
 
206 206
 	public static function fill_default_opts( $values, $record, $post_values ) {
207 207
 
208
-        $defaults = self::get_default_opts();
208
+		$defaults = self::get_default_opts();
209 209
 		foreach ( $defaults as $var => $default ) {
210
-            if ( is_array($default) ) {
211
-                if ( ! isset( $values[ $var ] ) ) {
210
+			if ( is_array($default) ) {
211
+				if ( ! isset( $values[ $var ] ) ) {
212 212
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
213
-                }
213
+				}
214 214
 
215
-                foreach ( $default as $k => $v ) {
215
+				foreach ( $default as $k => $v ) {
216 216
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
217 217
 
218
-                    if ( is_array( $v ) ) {
219
-                        foreach ( $v as $k1 => $v1 ) {
218
+					if ( is_array( $v ) ) {
219
+						foreach ( $v as $k1 => $v1 ) {
220 220
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
221
-                            unset( $k1, $v1 );
222
-                        }
223
-                    }
221
+							unset( $k1, $v1 );
222
+						}
223
+					}
224 224
 
225
-                    unset($k, $v);
226
-                }
227
-            } else {
225
+					unset($k, $v);
226
+				}
227
+			} else {
228 228
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
229
-            }
229
+			}
230 230
 
231
-            unset($var, $default);
232
-        }
231
+			unset($var, $default);
232
+		}
233 233
 
234
-        return $values;
235
-    }
234
+		return $values;
235
+	}
236 236
 
237
-    public static function get_default_opts() {
238
-        $frm_settings = FrmAppHelper::get_settings();
237
+	public static function get_default_opts() {
238
+		$frm_settings = FrmAppHelper::get_settings();
239 239
 
240
-        return array(
241
-            'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
242
-            'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
243
-            'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
244
-            'before_html' => self::get_default_html('before'),
245
-            'after_html' => '',
246
-            'submit_html' => self::get_default_html('submit'),
247
-        );
248
-    }
240
+		return array(
241
+			'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
242
+			'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
243
+			'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
244
+			'before_html' => self::get_default_html('before'),
245
+			'after_html' => '',
246
+			'submit_html' => self::get_default_html('submit'),
247
+		);
248
+	}
249 249
 
250 250
 	/**
251 251
 	 * @param array $options
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 		}
261 261
 	}
262 262
 
263
-    /**
264
-     * @param string $loc
265
-     */
263
+	/**
264
+	 * @param string $loc
265
+	 */
266 266
 	public static function get_default_html( $loc ) {
267 267
 		if ( $loc == 'submit' ) {
268
-            $draft_link = self::get_draft_link();
269
-            $default_html = <<<SUBMIT_HTML
268
+			$draft_link = self::get_draft_link();
269
+			$default_html = <<<SUBMIT_HTML
270 270
 <div class="frm_submit">
271 271
 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
272 272
 <button class="frm_button_submit" type="submit"  [button_action]>[button_label]</button>
@@ -274,22 +274,22 @@  discard block
 block discarded – undo
274 274
 </div>
275 275
 SUBMIT_HTML;
276 276
 		} else if ( $loc == 'before' ) {
277
-            $default_html = <<<BEFORE_HTML
277
+			$default_html = <<<BEFORE_HTML
278 278
 <legend class="frm_hidden">[form_name]</legend>
279 279
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
280 280
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
281 281
 BEFORE_HTML;
282 282
 		} else {
283
-            $default_html = '';
284
-        }
283
+			$default_html = '';
284
+		}
285 285
 
286
-        return $default_html;
287
-    }
286
+		return $default_html;
287
+	}
288 288
 
289
-    public static function get_draft_link() {
290
-        $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
291
-        return $link;
292
-    }
289
+	public static function get_draft_link() {
290
+		$link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
291
+		return $link;
292
+	}
293 293
 
294 294
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
295 295
 		$button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 		echo $button_parts[1];
317 317
 	}
318 318
 
319
-    /**
320
-     * Automatically add end section fields if they don't exist (2.0 migration)
321
-     * @since 2.0
322
-     *
323
-     * @param boolean $reset_fields
324
-     */
325
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
319
+	/**
320
+	 * Automatically add end section fields if they don't exist (2.0 migration)
321
+	 * @since 2.0
322
+	 *
323
+	 * @param boolean $reset_fields
324
+	 */
325
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
326 326
 		if ( empty( $fields ) ) {
327 327
 			return;
328 328
 		}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		$prev_order = false;
333 333
 		$add_order = 0;
334 334
 		$last_field = false;
335
-        foreach ( $fields as $field ) {
335
+		foreach ( $fields as $field ) {
336 336
 			if ( $prev_order === $field->field_order ) {
337 337
 				$add_order++;
338 338
 			}
@@ -343,48 +343,48 @@  discard block
 block discarded – undo
343 343
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
344 344
 			}
345 345
 
346
-            switch ( $field->type ) {
347
-                case 'divider':
348
-                    // create an end section if open
346
+			switch ( $field->type ) {
347
+				case 'divider':
348
+					// create an end section if open
349 349
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
350 350
 
351
-                    // mark it open for the next end section
352
-                    $open = true;
353
-                break;
354
-                case 'break';
351
+					// mark it open for the next end section
352
+					$open = true;
353
+				break;
354
+				case 'break';
355 355
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
356
-                break;
357
-                case 'end_divider':
358
-                    if ( ! $open ) {
359
-                        // the section isn't open, so this is an extra field that needs to be removed
360
-                        FrmField::destroy( $field->id );
361
-                        $reset_fields = true;
362
-                    }
363
-
364
-                    // There is already an end section here, so there is no need to create one
365
-                    $open = false;
366
-            }
356
+				break;
357
+				case 'end_divider':
358
+					if ( ! $open ) {
359
+						// the section isn't open, so this is an extra field that needs to be removed
360
+						FrmField::destroy( $field->id );
361
+						$reset_fields = true;
362
+					}
363
+
364
+					// There is already an end section here, so there is no need to create one
365
+					$open = false;
366
+			}
367 367
 			$prev_order = $field->field_order;
368 368
 
369 369
 			$last_field = $field;
370 370
 			unset( $field );
371
-        }
371
+		}
372 372
 
373 373
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
374
-    }
374
+	}
375 375
 
376 376
 	/**
377 377
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
378 378
 	 * Fix any ordering that may be messed up
379 379
 	 */
380 380
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
381
-        if ( ! $open ) {
382
-            return;
383
-        }
381
+		if ( ! $open ) {
382
+			return;
383
+		}
384 384
 
385 385
 		$end_section_values['field_order'] = $field->field_order + 1;
386 386
 
387
-        FrmField::create( $end_section_values );
387
+		FrmField::create( $end_section_values );
388 388
 
389 389
 		if ( $move == 'move' ) {
390 390
 			// bump the order of current field unless we're at the end of the form
@@ -392,39 +392,39 @@  discard block
 block discarded – undo
392 392
 		}
393 393
 
394 394
 		$add_order += 2;
395
-        $open = false;
396
-        $reset_fields = true;
397
-    }
395
+		$open = false;
396
+		$reset_fields = true;
397
+	}
398 398
 
399
-    public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
399
+	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
400 400
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
401
-            if ( $code == 'form_name' ) {
402
-                $replace_with = $form->name;
403
-            } else if ( $code == 'form_description' ) {
404
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
405
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
406
-                $replace_with = FrmAppHelper::simple_get( 'entry' );
407
-            } else {
408
-                $replace_with = '';
409
-            }
401
+			if ( $code == 'form_name' ) {
402
+				$replace_with = $form->name;
403
+			} else if ( $code == 'form_description' ) {
404
+				$replace_with = FrmAppHelper::use_wpautop($form->description);
405
+			} else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
406
+				$replace_with = FrmAppHelper::simple_get( 'entry' );
407
+			} else {
408
+				$replace_with = '';
409
+			}
410 410
 
411
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
412
-        }
411
+			FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
412
+		}
413 413
 
414
-        //replace [form_key]
415
-        $html = str_replace('[form_key]', $form->form_key, $html);
414
+		//replace [form_key]
415
+		$html = str_replace('[form_key]', $form->form_key, $html);
416 416
 
417
-        //replace [frmurl]
418
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
417
+		//replace [frmurl]
418
+		$html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
419 419
 
420 420
 		if ( strpos( $html, '[button_label]' ) ) {
421 421
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
422 422
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
423 423
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
424 424
 			$html = str_replace( '[button_label]', $submit_label, $html );
425
-        }
425
+		}
426 426
 
427
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
427
+		$html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
428 428
 
429 429
 		if ( strpos( $html, '[if back_button]' ) ) {
430 430
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -438,17 +438,17 @@  discard block
 block discarded – undo
438 438
 			$html = do_shortcode( $html );
439 439
 		}
440 440
 
441
-        return $html;
442
-    }
441
+		return $html;
442
+	}
443 443
 
444 444
 	public static function submit_button_label( $submit ) {
445
-        if ( ! $submit || empty($submit) ) {
446
-            $frm_settings = FrmAppHelper::get_settings();
447
-            $submit = $frm_settings->submit_value;
448
-        }
445
+		if ( ! $submit || empty($submit) ) {
446
+			$frm_settings = FrmAppHelper::get_settings();
447
+			$submit = $frm_settings->submit_value;
448
+		}
449 449
 
450
-        return $submit;
451
-    }
450
+		return $submit;
451
+	}
452 452
 
453 453
 	/**
454 454
 	 * If the Formidable styling isn't being loaded,
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 	}
466 466
 
467 467
 	public static function get_form_style_class( $form = false ) {
468
-        $style = self::get_form_style($form);
469
-        $class = ' with_frm_style';
470
-
471
-        if ( empty($style) ) {
472
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
473
-                return $class;
474
-            } else {
475
-                return;
476
-            }
477
-        }
478
-
479
-        //If submit button needs to be inline or centered
480
-        if ( is_object($form) ) {
468
+		$style = self::get_form_style($form);
469
+		$class = ' with_frm_style';
470
+
471
+		if ( empty($style) ) {
472
+			if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
473
+				return $class;
474
+			} else {
475
+				return;
476
+			}
477
+		}
478
+
479
+		//If submit button needs to be inline or centered
480
+		if ( is_object($form) ) {
481 481
 			$form = $form->options;
482 482
 		}
483 483
 
@@ -489,17 +489,17 @@  discard block
 block discarded – undo
489 489
 			$class .= ' frm_center_submit';
490 490
 		}
491 491
 
492
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
492
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
493 493
 
494
-        return $class;
495
-    }
494
+		return $class;
495
+	}
496 496
 
497
-    /**
498
-     * @param string|boolean $form
499
-     *
500
-     * @return string
501
-     */
502
-    public static function get_form_style( $form ) {
497
+	/**
498
+	 * @param string|boolean $form
499
+	 *
500
+	 * @return string
501
+	 */
502
+	public static function get_form_style( $form ) {
503 503
 		$style = 1;
504 504
 		if ( empty( $form ) || 'default' == 'form' ) {
505 505
 			return $style;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
520 520
 
521 521
 		return $style;
522
-    }
522
+	}
523 523
 
524 524
 	/**
525 525
 	 * Display the validation error messages when an entry is submitted
@@ -581,74 +581,74 @@  discard block
 block discarded – undo
581 581
 	}
582 582
 
583 583
 	public static function get_scroll_js( $form_id ) {
584
-        ?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
585
-    }
584
+		?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
585
+	}
586 586
 
587 587
 	public static function edit_form_link( $form_id ) {
588
-        if ( is_object($form_id) ) {
589
-            $form = $form_id;
590
-            $name = $form->name;
591
-            $form_id = $form->id;
592
-        } else {
593
-            $name = FrmForm::getName($form_id);
594
-        }
595
-
596
-        if ( $form_id ) {
588
+		if ( is_object($form_id) ) {
589
+			$form = $form_id;
590
+			$name = $form->name;
591
+			$form_id = $form->id;
592
+		} else {
593
+			$name = FrmForm::getName($form_id);
594
+		}
595
+
596
+		if ( $form_id ) {
597 597
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
598
-	    } else {
599
-	        $val = '';
600
-	    }
598
+		} else {
599
+			$val = '';
600
+		}
601 601
 
602
-	    return $val;
602
+		return $val;
603 603
 	}
604 604
 
605 605
 	public static function delete_trash_link( $id, $status, $length = 'long' ) {
606
-        $link = '';
607
-        $labels = array(
608
-            'restore' => array(
609
-                'long'  => __( 'Restore from Trash', 'formidable' ),
610
-                'short' => __( 'Restore', 'formidable' ),
611
-            ),
612
-            'trash' => array(
613
-                'long'  => __( 'Move to Trash', 'formidable' ),
614
-                'short' => __( 'Trash', 'formidable' ),
615
-            ),
616
-            'delete' => array(
617
-                'long'  => __( 'Delete Permanently', 'formidable' ),
618
-                'short' => __( 'Delete', 'formidable' ),
619
-            ),
620
-        );
606
+		$link = '';
607
+		$labels = array(
608
+			'restore' => array(
609
+				'long'  => __( 'Restore from Trash', 'formidable' ),
610
+				'short' => __( 'Restore', 'formidable' ),
611
+			),
612
+			'trash' => array(
613
+				'long'  => __( 'Move to Trash', 'formidable' ),
614
+				'short' => __( 'Trash', 'formidable' ),
615
+			),
616
+			'delete' => array(
617
+				'long'  => __( 'Delete Permanently', 'formidable' ),
618
+				'short' => __( 'Delete', 'formidable' ),
619
+			),
620
+		);
621 621
 
622 622
 		$current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) );
623 623
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
624
-        if ( 'trash' == $status ) {
624
+		if ( 'trash' == $status ) {
625 625
 			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
626
-        } else if ( current_user_can('frm_delete_forms') ) {
627
-            if ( EMPTY_TRASH_DAYS ) {
626
+		} else if ( current_user_can('frm_delete_forms') ) {
627
+			if ( EMPTY_TRASH_DAYS ) {
628 628
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
629
-            } else {
629
+			} else {
630 630
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
631
-            }
632
-        }
631
+			}
632
+		}
633 633
 
634
-        return $link;
635
-    }
634
+		return $link;
635
+	}
636 636
 
637 637
 	public static function status_nice_name( $status ) {
638
-        $nice_names = array(
639
-            'draft'     => __( 'Draft', 'formidable' ),
640
-            'trash'     => __( 'Trash', 'formidable' ),
641
-            'publish'   => __( 'Published', 'formidable' ),
642
-        );
643
-
644
-        if ( ! in_array($status, array_keys($nice_names)) ) {
645
-            $status = 'publish';
646
-        }
638
+		$nice_names = array(
639
+			'draft'     => __( 'Draft', 'formidable' ),
640
+			'trash'     => __( 'Trash', 'formidable' ),
641
+			'publish'   => __( 'Published', 'formidable' ),
642
+		);
643
+
644
+		if ( ! in_array($status, array_keys($nice_names)) ) {
645
+			$status = 'publish';
646
+		}
647 647
 
648 648
 		$name = $nice_names[ $status ];
649 649
 
650
-        return $name;
651
-    }
650
+		return $name;
651
+	}
652 652
 
653 653
 	public static function get_params() {
654 654
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public static function get_direct_link( $key, $form = false ) {
21 21
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
22
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
22
+        $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
23 23
 
24 24
         return $target_url;
25 25
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 			$query['id !'] = $args['exclude'];
45 45
         }
46 46
 
47
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
47
+        $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
48 48
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
49 49
 		$add_html = array();
50 50
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		<?php } ?>
58 58
 		<?php foreach ( $forms as $form ) { ?>
59 59
 			<option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php
60
-				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ;
60
+				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' );
61 61
 			?></option>
62 62
 		<?php } ?>
63 63
         </select>
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public static function add_html_attr( $class, $param, &$add_html ) {
75 75
 		if ( ! empty( $class ) ) {
76
-			$add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
76
+			$add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
77 77
 		}
78 78
 	}
79 79
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$args = array( 'id' => 0, 'form' => 0 );
85 85
 		if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
86 86
 			unset( $args['form'] );
87
-		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
87
+		} else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
88 88
 			unset( $args['id'] );
89 89
         }
90 90
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
93 93
             $args['frm_action'] = 'list';
94 94
             $args['form'] = 0;
95
-		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
95
+		} else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
96 96
             $args['frm_action'] = 'edit';
97 97
 		} else if ( isset( $_GET['post'] ) ) {
98 98
             $args['form'] = 0;
99
-            $base = admin_url('edit.php?post_type=frm_display');
99
+            $base = admin_url( 'edit.php?post_type=frm_display' );
100 100
         }
101 101
 
102 102
         ?>
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			        $args['form'] = $form->id;
113 113
 				}
114 114
                 ?>
115
-				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
115
+				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
116 116
 			<?php
117 117
 				unset( $form );
118 118
 			} ?>
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
     }
123 123
 
124 124
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
125
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
126
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
125
+        echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
126
+        echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc';
127 127
     }
128 128
 
129 129
 	/**
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
             $post_values = $values;
159 159
         } else {
160 160
             $values = array();
161
-            $post_values = isset($_POST) ? $_POST : array();
161
+            $post_values = isset( $_POST ) ? $_POST : array();
162 162
         }
163 163
 
164 164
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
165
-			if ( ! isset( $values[ $var ] ) ) {
166
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
165
+			if ( ! isset( $values[$var] ) ) {
166
+				$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
167 167
             }
168 168
         }
169 169
 
170
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
170
+        $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
171 171
 
172 172
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
173
-            if ( ! isset( $values[ $var ] ) ) {
174
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
173
+            if ( ! isset( $values[$var] ) ) {
174
+				$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
175 175
             }
176 176
         }
177 177
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		$values = self::fill_default_opts( $values, false, $post_values );
183 183
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
184 184
 
185
-        return apply_filters('frm_setup_new_form_vars', $values);
185
+        return apply_filters( 'frm_setup_new_form_vars', $values );
186 186
     }
187 187
 
188 188
     /**
@@ -193,42 +193,42 @@  discard block
 block discarded – undo
193 193
 			$post_values = stripslashes_deep( $_POST );
194 194
 		}
195 195
 
196
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
197
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
198
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
196
+        $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
197
+        $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
198
+        $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
199 199
         $values['status'] = $record->status;
200 200
 
201
-        $values = self::fill_default_opts($values, $record, $post_values);
201
+        $values = self::fill_default_opts( $values, $record, $post_values );
202 202
 
203
-        return apply_filters('frm_setup_edit_form_vars', $values);
203
+        return apply_filters( 'frm_setup_edit_form_vars', $values );
204 204
     }
205 205
 
206 206
 	public static function fill_default_opts( $values, $record, $post_values ) {
207 207
 
208 208
         $defaults = self::get_default_opts();
209 209
 		foreach ( $defaults as $var => $default ) {
210
-            if ( is_array($default) ) {
211
-                if ( ! isset( $values[ $var ] ) ) {
212
-					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
210
+            if ( is_array( $default ) ) {
211
+                if ( ! isset( $values[$var] ) ) {
212
+					$values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array();
213 213
                 }
214 214
 
215 215
                 foreach ( $default as $k => $v ) {
216
-					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
216
+					$values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v );
217 217
 
218 218
                     if ( is_array( $v ) ) {
219 219
                         foreach ( $v as $k1 => $v1 ) {
220
-							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
220
+							$values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 );
221 221
                             unset( $k1, $v1 );
222 222
                         }
223 223
                     }
224 224
 
225
-                    unset($k, $v);
225
+                    unset( $k, $v );
226 226
                 }
227 227
             } else {
228
-				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
228
+				$values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default );
229 229
             }
230 230
 
231
-            unset($var, $default);
231
+            unset( $var, $default );
232 232
         }
233 233
 
234 234
         return $values;
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
             'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
242 242
             'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
243 243
             'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
244
-            'before_html' => self::get_default_html('before'),
244
+            'before_html' => self::get_default_html( 'before' ),
245 245
             'after_html' => '',
246
-            'submit_html' => self::get_default_html('submit'),
246
+            'submit_html' => self::get_default_html( 'submit' ),
247 247
         );
248 248
     }
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	public static function fill_form_options( &$options, $values ) {
256 256
 		$defaults = self::get_default_opts();
257 257
 		foreach ( $defaults as $var => $default ) {
258
-			$options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
258
+			$options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default;
259 259
 			unset( $var, $default );
260 260
 		}
261 261
 	}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 		$last_field = false;
335 335
         foreach ( $fields as $field ) {
336 336
 			if ( $prev_order === $field->field_order ) {
337
-				$add_order++;
337
+				$add_order ++;
338 338
 			}
339 339
 
340 340
 			if ( $add_order ) {
@@ -401,21 +401,21 @@  discard block
 block discarded – undo
401 401
             if ( $code == 'form_name' ) {
402 402
                 $replace_with = $form->name;
403 403
             } else if ( $code == 'form_description' ) {
404
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
405
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
404
+                $replace_with = FrmAppHelper::use_wpautop( $form->description );
405
+            } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
406 406
                 $replace_with = FrmAppHelper::simple_get( 'entry' );
407 407
             } else {
408 408
                 $replace_with = '';
409 409
             }
410 410
 
411
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
411
+            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
412 412
         }
413 413
 
414 414
         //replace [form_key]
415
-        $html = str_replace('[form_key]', $form->form_key, $html);
415
+        $html = str_replace( '[form_key]', $form->form_key, $html );
416 416
 
417 417
         //replace [frmurl]
418
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
418
+        $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
419 419
 
420 420
 		if ( strpos( $html, '[button_label]' ) ) {
421 421
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 			$html = str_replace( '[button_label]', $submit_label, $html );
425 425
         }
426 426
 
427
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
427
+        $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
428 428
 
429 429
 		if ( strpos( $html, '[if back_button]' ) ) {
430 430
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
     }
443 443
 
444 444
 	public static function submit_button_label( $submit ) {
445
-        if ( ! $submit || empty($submit) ) {
445
+        if ( ! $submit || empty( $submit ) ) {
446 446
             $frm_settings = FrmAppHelper::get_settings();
447 447
             $submit = $frm_settings->submit_value;
448 448
         }
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 	}
466 466
 
467 467
 	public static function get_form_style_class( $form = false ) {
468
-        $style = self::get_form_style($form);
468
+        $style = self::get_form_style( $form );
469 469
         $class = ' with_frm_style';
470 470
 
471
-        if ( empty($style) ) {
472
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
471
+        if ( empty( $style ) ) {
472
+            if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
473 473
                 return $class;
474 474
             } else {
475 475
                 return;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         }
478 478
 
479 479
         //If submit button needs to be inline or centered
480
-        if ( is_object($form) ) {
480
+        if ( is_object( $form ) ) {
481 481
 			$form = $form->options;
482 482
 		}
483 483
 
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 			$class .= ' frm_center_submit';
490 490
 		}
491 491
 
492
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
492
+        $class = apply_filters( 'frm_add_form_style_class', $class, $style );
493 493
 
494 494
         return $class;
495 495
     }
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
     }
586 586
 
587 587
 	public static function edit_form_link( $form_id ) {
588
-        if ( is_object($form_id) ) {
588
+        if ( is_object( $form_id ) ) {
589 589
             $form = $form_id;
590 590
             $name = $form->name;
591 591
             $form_id = $form->id;
592 592
         } else {
593
-            $name = FrmForm::getName($form_id);
593
+            $name = FrmForm::getName( $form_id );
594 594
         }
595 595
 
596 596
         if ( $form_id ) {
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 		$current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type' ) );
623 623
 		$base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
624 624
         if ( 'trash' == $status ) {
625
-			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
626
-        } else if ( current_user_can('frm_delete_forms') ) {
625
+			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>';
626
+        } else if ( current_user_can( 'frm_delete_forms' ) ) {
627 627
             if ( EMPTY_TRASH_DAYS ) {
628
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
628
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>';
629 629
             } else {
630
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
630
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>';
631 631
             }
632 632
         }
633 633
 
@@ -641,11 +641,11 @@  discard block
 block discarded – undo
641 641
             'publish'   => __( 'Published', 'formidable' ),
642 642
         );
643 643
 
644
-        if ( ! in_array($status, array_keys($nice_names)) ) {
644
+        if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
645 645
             $status = 'publish';
646 646
         }
647 647
 
648
-		$name = $nice_names[ $status ];
648
+		$name = $nice_names[$status];
649 649
 
650 650
         return $name;
651 651
     }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $per_page;
9
+		global $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12
-        $form_id = $this->params['form'];
12
+		$form_id = $this->params['form'];
13 13
 
14 14
 		$s_query = array();
15 15
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 		$limit = FrmDb::esc_limit( $start . ',' . $per_page );
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
 		$s = self::get_param( array( 'param' => 's', 'sanitize' => 'sanitize_text_field' ) );
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62 62
 
63 63
 		$form_id = $this->params['form'];
64 64
 		$form = $this->params['form'];
65 65
 
66
-        if ( $form_id ) {
67
-            $form = FrmForm::getOne($form_id);
68
-        }
69
-        $colspan = $this->get_column_count();
66
+		if ( $form_id ) {
67
+			$form = FrmForm::getOne($form_id);
68
+		}
69
+		$colspan = $this->get_column_count();
70 70
 
71 71
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
72 72
 	}
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets the name of the primary column in the Entries screen
90
-	*
91
-	* @since 2.0.14
92
-	*
93
-	* @return string $primary_column
94
-	*/
89
+	 * Gets the name of the primary column in the Entries screen
90
+	 *
91
+	 * @since 2.0.14
92
+	 *
93
+	 * @return string $primary_column
94
+	 */
95 95
 	protected function get_primary_column_name() {
96 96
 		$columns = get_column_headers( $this->screen );
97 97
 		$hidden = get_hidden_columns( $this->screen );
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 		$this->get_actions( $actions, $item, $view_link );
117 117
 
118
-        $action_links = $this->row_actions( $actions );
118
+		$action_links = $this->row_actions( $actions );
119 119
 
120 120
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
121 121
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$r = "<tr id='item-action-{$item->id}'$style>";
124 124
 
125 125
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
126
-        $action_col = false;
126
+		$action_col = false;
127 127
 
128 128
 		foreach ( $columns as $column_name => $column_display_name ) {
129 129
 			$class = $column_name . ' column-' . $column_name;
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 			if ( in_array( $column_name, $hidden ) ) {
136 136
 				$class .= ' frm_hidden';
137 137
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
138
-			    $action_col = $column_name;
139
-            }
138
+				$action_col = $column_name;
139
+			}
140 140
 
141 141
 			$attributes = 'class="' . esc_attr( $class ) . '"';
142 142
 			unset($class);
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 					$val = $this->column_value( $item );
155 155
 				}
156 156
 
157
-			    $r .= "<td $attributes>";
157
+				$r .= "<td $attributes>";
158 158
 				if ( $column_name == $action_col ) {
159 159
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
160 160
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
161
-			        $r .= $action_links;
161
+					$r .= $action_links;
162 162
 				} else {
163
-			        $r .= $val;
164
-			    }
165
-			    $r .= '</td>';
163
+					$r .= $val;
164
+				}
165
+				$r .= '</td>';
166 166
 			}
167 167
 			unset($val);
168 168
 		}
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
 		return $val;
216 216
 	}
217 217
 
218
-    /**
219
-     * @param string $view_link
220
-     */
221
-    private function get_actions( &$actions, $item, $view_link ) {
218
+	/**
219
+	 * @param string $view_link
220
+	 */
221
+	private function get_actions( &$actions, $item, $view_link ) {
222 222
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
223 223
 
224
-        if ( current_user_can('frm_delete_entries') ) {
224
+		if ( current_user_can('frm_delete_entries') ) {
225 225
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
226 226
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
227
-	    }
227
+		}
228 228
 
229
-        $actions = apply_filters('frm_row_actions', $actions, $item);
230
-    }
229
+		$actions = apply_filters('frm_row_actions', $actions, $item);
230
+	}
231 231
 
232 232
 	private function get_column_value( $item, &$val ) {
233 233
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 		$limit = FrmDb::esc_limit( $start . ',' . $per_page );
47 47
 		$this->items = FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
48
-        $total_items = FrmEntry::getRecordCount($s_query);
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
 		$s = self::get_param( array( 'param' => 's', 'sanitize' => 'sanitize_text_field' ) );
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		$form = $this->params['form'];
65 65
 
66 66
         if ( $form_id ) {
67
-            $form = FrmForm::getOne($form_id);
67
+            $form = FrmForm::getOne( $form_id );
68 68
         }
69 69
         $colspan = $this->get_column_count();
70 70
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$r = "<tr id='item-action-{$item->id}'$style>";
124 124
 
125
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
125
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
126 126
         $action_col = false;
127 127
 
128 128
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             }
140 140
 
141 141
 			$attributes = 'class="' . esc_attr( $class ) . '"';
142
-			unset($class);
142
+			unset( $class );
143 143
 			$attributes .= ' data-colname="' . $column_display_name . '"';
144 144
 
145 145
 			$form_id = $this->params['form'] ? $this->params['form'] : 0;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			    }
165 165
 			    $r .= '</td>';
166 166
 			}
167
-			unset($val);
167
+			unset( $val );
168 168
 		}
169 169
 		$r .= '</tr>';
170 170
 
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
     private function get_actions( &$actions, $item, $view_link ) {
222 222
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
223 223
 
224
-        if ( current_user_can('frm_delete_entries') ) {
224
+        if ( current_user_can( 'frm_delete_entries' ) ) {
225 225
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
226 226
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>';
227 227
 	    }
228 228
 
229
-        $actions = apply_filters('frm_row_actions', $actions, $item);
229
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
230 230
     }
231 231
 
232 232
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/models/FrmDb.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmDb {
4
-    public $fields;
5
-    public $forms;
6
-    public $entries;
7
-    public $entry_metas;
8
-
9
-    public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
12
-        }
4
+	public $fields;
5
+	public $forms;
6
+	public $entries;
7
+	public $entry_metas;
8
+
9
+	public function __construct() {
10
+		if ( ! defined('ABSPATH') ) {
11
+			die('You are not allowed to call this page directly.');
12
+		}
13 13
 
14 14
 		_deprecated_function( __METHOD__, '2.05.06', 'FrmMigrate' );
15
-        global $wpdb;
16
-        $this->fields         = $wpdb->prefix . 'frm_fields';
17
-        $this->forms          = $wpdb->prefix . 'frm_forms';
18
-        $this->entries        = $wpdb->prefix . 'frm_items';
19
-        $this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
20
-    }
21
-
22
-    /**
23
-     * Change array into format $wpdb->prepare can use
15
+		global $wpdb;
16
+		$this->fields         = $wpdb->prefix . 'frm_fields';
17
+		$this->forms          = $wpdb->prefix . 'frm_forms';
18
+		$this->entries        = $wpdb->prefix . 'frm_items';
19
+		$this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
20
+	}
21
+
22
+	/**
23
+	 * Change array into format $wpdb->prepare can use
24 24
 	 *
25 25
 	 * @param array $args
26 26
 	 * @param string $starts_with
27
-     */
28
-    public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
29
-        if ( empty($args) ) {
27
+	 */
28
+	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
29
+		if ( empty($args) ) {
30 30
 			// add an arg to prevent prepare from failing
31 31
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
32 32
 			return;
33
-        }
33
+		}
34 34
 
35 35
 		$where = '';
36 36
 		$values = array();
@@ -41,64 +41,64 @@  discard block
 block discarded – undo
41 41
 		}
42 42
 
43 43
 		$args = compact( 'where', 'values' );
44
-    }
44
+	}
45 45
 
46
-    /**
46
+	/**
47 47
 	 * @param array $args
48
-     * @param string $base_where
49
-     * @param string $where
48
+	 * @param string $base_where
49
+	 * @param string $where
50 50
 	 * @param array $values
51
-     */
52
-    public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
53
-        $condition = ' AND';
54
-        if ( isset( $args['or'] ) ) {
55
-            $condition = ' OR';
56
-            unset( $args['or'] );
57
-        }
58
-
59
-        foreach ( $args as $key => $value ) {
60
-            $where .= empty( $where ) ? $base_where : $condition;
61
-            $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
62
-            if ( is_numeric( $key ) || $array_inc_null ) {
63
-                $where .= ' ( ';
64
-                $nested_where = '';
65
-                if ( $array_inc_null ) {
66
-                    foreach ( $value as $val ) {
67
-                        self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
68
-                    }
69
-                } else {
70
-                    self::parse_where_from_array( $value, '', $nested_where, $values );
71
-                }
72
-                $where .= $nested_where;
73
-                $where .= ' ) ';
74
-            } else {
75
-                self::interpret_array_to_sql( $key, $value, $where, $values );
76
-            }
77
-        }
78
-    }
79
-
80
-    /**
81
-     * @param string $key
51
+	 */
52
+	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
53
+		$condition = ' AND';
54
+		if ( isset( $args['or'] ) ) {
55
+			$condition = ' OR';
56
+			unset( $args['or'] );
57
+		}
58
+
59
+		foreach ( $args as $key => $value ) {
60
+			$where .= empty( $where ) ? $base_where : $condition;
61
+			$array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
62
+			if ( is_numeric( $key ) || $array_inc_null ) {
63
+				$where .= ' ( ';
64
+				$nested_where = '';
65
+				if ( $array_inc_null ) {
66
+					foreach ( $value as $val ) {
67
+						self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
68
+					}
69
+				} else {
70
+					self::parse_where_from_array( $value, '', $nested_where, $values );
71
+				}
72
+				$where .= $nested_where;
73
+				$where .= ' ) ';
74
+			} else {
75
+				self::interpret_array_to_sql( $key, $value, $where, $values );
76
+			}
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * @param string $key
82 82
 	 * @param string|array $value
83
-     * @param string $where
83
+	 * @param string $where
84 84
 	 * @param array $values
85
-     */
86
-    private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
85
+	 */
86
+	private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
87 87
 		$key = trim( $key );
88 88
 
89 89
 		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
90
-            $k = explode(' ', $key);
91
-            $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
92
-            $values[] = '%Y-%m-%d %H:%i:%s';
93
-        } else {
90
+			$k = explode(' ', $key);
91
+			$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
92
+			$values[] = '%Y-%m-%d %H:%i:%s';
93
+		} else {
94 94
 			$where .= ' ' . $key;
95
-        }
95
+		}
96 96
 
97 97
 		$lowercase_key = explode( ' ', strtolower( $key ) );
98 98
 		$lowercase_key = end( $lowercase_key );
99 99
 
100
-        if ( is_array( $value ) ) {
101
-            // translate array of values to "in"
100
+		if ( is_array( $value ) ) {
101
+			// translate array of values to "in"
102 102
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
103 103
 				$where = preg_replace('/' . $key . '$/', '', $where);
104 104
 				$where .= '(';
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				$where .= ' in (' . self::prepare_array_values( $value, '%s' ) . ')';
117 117
 				$values = array_merge( $values, $value );
118 118
 			}
119
-        } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
119
+		} else if ( strpos( $lowercase_key, 'like' ) !== false ) {
120 120
 			/**
121 121
 			 * Allow string to start or end with the value
122 122
 			 * If the key is like% then skip the first % for starts with
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 			$where .= ' %s';
137 137
 			$values[] = $start . self::esc_like( $value ) . $end;
138 138
 
139
-        } else if ( $value === null ) {
140
-            $where .= ' IS NULL';
141
-        } else {
139
+		} else if ( $value === null ) {
140
+			$where .= ' IS NULL';
141
+		} else {
142 142
 			// allow a - to prevent = from being added
143 143
 			if ( substr( $key, -1 ) == '-' ) {
144 144
 				$where = rtrim( $where, '-' );
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 
149 149
 			self::add_query_placeholder( $key, $value, $where );
150 150
 
151
-            $values[] = $value;
152
-        }
153
-    }
151
+			$values[] = $value;
152
+		}
153
+	}
154 154
 
155 155
 	/**
156 156
 	 * Add %d, or %s to query
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @param int|string $value
161 161
 	 * @param string $where
162 162
 	 */
163
-    private static function add_query_placeholder( $key, $value, &$where ) {
163
+	private static function add_query_placeholder( $key, $value, &$where ) {
164 164
 		if ( is_numeric( $value ) && ( strpos( $key, 'meta_value' ) === false || strpos( $key, '+0' ) !== false ) ) {
165 165
 			$where .= '%d';
166 166
 		} else {
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
 		}
169 169
 	}
170 170
 
171
-    /**
172
-     * @param string $table
171
+	/**
172
+	 * @param string $table
173 173
 	 * @param array $where
174 174
 	 * @param array $args
175 175
 	 * @return int
176
-     */
177
-    public static function get_count( $table, $where = array(), $args = array() ) {
178
-        $count = self::get_var( $table, $where, 'COUNT(*)', $args );
179
-        return $count;
180
-    }
176
+	 */
177
+	public static function get_count( $table, $where = array(), $args = array() ) {
178
+		$count = self::get_var( $table, $where, 'COUNT(*)', $args );
179
+		return $count;
180
+	}
181 181
 
182 182
 	/**
183 183
 	 * @param string $table
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 	 * @param string $type
189 189
 	 * @return array|null|string|object
190 190
 	 */
191
-    public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
192
-        $group = '';
193
-        self::get_group_and_table_name( $table, $group );
191
+	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
192
+		$group = '';
193
+		self::get_group_and_table_name( $table, $group );
194 194
 		self::convert_options_to_array( $args, '', $limit );
195 195
 
196 196
 		$query = self::generate_query_string_from_pieces( $field, $table, $where, $args );
197 197
 
198 198
 		$cache_key = self::generate_cache_key( $where, $args, $field, $type );
199 199
 		$results = self::check_cache( $cache_key, $group, $query, 'get_' . $type );
200
-        return $results;
201
-    }
200
+		return $results;
201
+	}
202 202
 
203 203
 	/**
204 204
 	 * Generate a cache key from the where query, field, type, and other arguments
@@ -224,44 +224,44 @@  discard block
 block discarded – undo
224 224
 		return $cache_key;
225 225
 	}
226 226
 
227
-    /**
228
-     * @param string $table
229
-     * @param array $where
227
+	/**
228
+	 * @param string $table
229
+	 * @param array $where
230 230
 	 * @param string $field
231 231
 	 * @param array $args
232 232
 	 * @param string $limit
233 233
 	 * @return mixed
234
-     */
235
-    public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
236
-        return self::get_var( $table, $where, $field, $args, $limit, 'col' );
237
-    }
238
-
239
-    /**
240
-     * @since 2.0
241
-     * @param string $table
234
+	 */
235
+	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
236
+		return self::get_var( $table, $where, $field, $args, $limit, 'col' );
237
+	}
238
+
239
+	/**
240
+	 * @since 2.0
241
+	 * @param string $table
242 242
 	 * @param array $where
243 243
 	 * @param string $fields
244 244
 	 * @param array $args
245 245
 	 * @return mixed
246
-     */
247
-    public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
248
-        $args['limit'] = 1;
249
-        return self::get_var( $table, $where, $fields, $args, '', 'row' );
250
-    }
251
-
252
-    /**
253
-     * Prepare a key/value array before DB call
246
+	 */
247
+	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
248
+		$args['limit'] = 1;
249
+		return self::get_var( $table, $where, $fields, $args, '', 'row' );
250
+	}
251
+
252
+	/**
253
+	 * Prepare a key/value array before DB call
254 254
 	 *
255
-     * @since 2.0
256
-     * @param string $table
255
+	 * @since 2.0
256
+	 * @param string $table
257 257
 	 * @param array $where
258 258
 	 * @param string $fields
259 259
 	 * @param array $args
260 260
 	 * @return mixed
261
-     */
262
-    public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
263
-        return self::get_var( $table, $where, $fields, $args, '', 'results' );
264
-    }
261
+	 */
262
+	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
263
+		return self::get_var( $table, $where, $fields, $args, '', 'results' );
264
+	}
265 265
 
266 266
 	/**
267 267
 	 * Check for like, not like, in, not in, =, !=, >, <, <=, >=
@@ -298,56 +298,56 @@  discard block
 block discarded – undo
298 298
 		return '';
299 299
 	}
300 300
 
301
-    /**
302
-     * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
303
-     * Also add the wpdb->prefix to the table if it's missing
304
-     *
305
-     * @param string $table
306
-     * @param string $group
307
-     */
308
-    private static function get_group_and_table_name( &$table, &$group ) {
301
+	/**
302
+	 * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
303
+	 * Also add the wpdb->prefix to the table if it's missing
304
+	 *
305
+	 * @param string $table
306
+	 * @param string $group
307
+	 */
308
+	private static function get_group_and_table_name( &$table, &$group ) {
309 309
 		global $wpdb, $wpmuBaseTablePrefix;
310 310
 
311
-        $table_parts = explode(' ', $table);
312
-        $group = reset($table_parts);
313
-        $group = str_replace( $wpdb->prefix, '', $group );
311
+		$table_parts = explode(' ', $table);
312
+		$group = reset($table_parts);
313
+		$group = str_replace( $wpdb->prefix, '', $group );
314 314
 
315 315
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
316 316
 		$group = str_replace( $prefix, '', $group );
317 317
 
318
-        if ( $group == $table ) {
319
-            $table = $wpdb->prefix . $table;
320
-        }
318
+		if ( $group == $table ) {
319
+			$table = $wpdb->prefix . $table;
320
+		}
321 321
 
322 322
 		// switch to singular group name
323 323
 		$group = rtrim( $group, 's' );
324
-    }
324
+	}
325 325
 
326
-    private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
327
-        if ( ! is_array($args) ) {
326
+	private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
327
+		if ( ! is_array($args) ) {
328 328
 			$args = array( 'order_by' => $args );
329
-        }
329
+		}
330 330
 
331
-        if ( ! empty( $order_by ) ) {
332
-            $args['order_by'] = $order_by;
333
-        }
331
+		if ( ! empty( $order_by ) ) {
332
+			$args['order_by'] = $order_by;
333
+		}
334 334
 
335
-        if ( ! empty( $limit ) ) {
336
-            $args['limit'] = $limit;
337
-        }
335
+		if ( ! empty( $limit ) ) {
336
+			$args['limit'] = $limit;
337
+		}
338 338
 
339
-        $temp_args = $args;
340
-        foreach ( $temp_args as $k => $v ) {
341
-            if ( $v == '' ) {
339
+		$temp_args = $args;
340
+		foreach ( $temp_args as $k => $v ) {
341
+			if ( $v == '' ) {
342 342
 				unset( $args[ $k ] );
343
-                continue;
344
-            }
343
+				continue;
344
+			}
345 345
 
346
-            $db_name = strtoupper( str_replace( '_', ' ', $k ) );
347
-            if ( strpos( $v, $db_name ) === false ) {
346
+			$db_name = strtoupper( str_replace( '_', ' ', $k ) );
347
+			if ( strpos( $v, $db_name ) === false ) {
348 348
 				$args[ $k ] = $db_name . ' ' . $v;
349
-            }
350
-        }
349
+			}
350
+		}
351 351
 
352 352
 		// Make sure LIMIT is the last argument
353 353
 		if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) {
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 			unset( $args['limit'] );
356 356
 			$args['limit'] = $temp_limit;
357 357
 		}
358
-    }
358
+	}
359 359
 
360 360
 	/**
361 361
 	 * Get the associative array results for the given columns, table, and where query
@@ -427,25 +427,25 @@  discard block
 block discarded – undo
427 427
 		}
428 428
 	}
429 429
 
430
-    /**
431
-     * Added for < WP 4.0 compatability
432
-     *
433
-     * @since 2.05.06
434
-     *
435
-     * @param string $term The value to escape
436
-     * @return string The escaped value
437
-     */
430
+	/**
431
+	 * Added for < WP 4.0 compatability
432
+	 *
433
+	 * @since 2.05.06
434
+	 *
435
+	 * @param string $term The value to escape
436
+	 * @return string The escaped value
437
+	 */
438 438
 	public static function esc_like( $term ) {
439
-        global $wpdb;
440
-        if ( method_exists( $wpdb, 'esc_like' ) ) {
439
+		global $wpdb;
440
+		if ( method_exists( $wpdb, 'esc_like' ) ) {
441 441
 			// WP 4.0
442
-            $term = $wpdb->esc_like( $term );
443
-        } else {
444
-            $term = like_escape( $term );
445
-        }
442
+			$term = $wpdb->esc_like( $term );
443
+		} else {
444
+			$term = like_escape( $term );
445
+		}
446 446
 
447
-        return $term;
448
-    }
447
+		return $term;
448
+	}
449 449
 
450 450
 	/**
451 451
 	 * @since 2.05.06
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
 		return ' LIMIT ' . $limit;
521 521
 	}
522 522
 
523
-    /**
524
-     * Get an array of values ready to go through $wpdb->prepare
525
-     * @since 2.05.06
526
-     */
523
+	/**
524
+	 * Get an array of values ready to go through $wpdb->prepare
525
+	 * @since 2.05.06
526
+	 */
527 527
 	public static function prepare_array_values( $array, $type = '%s' ) {
528 528
 		$placeholders = array_fill( 0, count( $array ), $type );
529 529
 		return implode( ', ', $placeholders );
@@ -594,17 +594,17 @@  discard block
 block discarded – undo
594 594
 		return $post;
595 595
 	}
596 596
 
597
-    /**
598
-     * Check cache before fetching values and saving to cache
599
-     *
600
-     * @since 2.05.06
601
-     *
602
-     * @param string $cache_key The unique name for this cache
603
-     * @param string $group The name of the cache group
604
-     * @param string $query If blank, don't run a db call
605
-     * @param string $type The wpdb function to use with this query
606
-     * @return mixed $results The cache or query results
607
-     */
597
+	/**
598
+	 * Check cache before fetching values and saving to cache
599
+	 *
600
+	 * @since 2.05.06
601
+	 *
602
+	 * @param string $cache_key The unique name for this cache
603
+	 * @param string $group The name of the cache group
604
+	 * @param string $query If blank, don't run a db call
605
+	 * @param string $type The wpdb function to use with this query
606
+	 * @return mixed $results The cache or query results
607
+	 */
608 608
 	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
609 609
 		$results = wp_cache_get( $cache_key, $group );
610 610
 		if ( ! FrmAppHelper::is_empty_value( $results, false ) || empty( $query ) ) {
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
 		wp_cache_delete( $cache_key, $group );
669 669
 	}
670 670
 
671
-    /**
672
-     * Delete all caching in a single group
673
-     *
674
-     * @since 2.05.06
675
-     *
676
-     * @param string $group The name of the cache group
677
-     */
671
+	/**
672
+	 * Delete all caching in a single group
673
+	 *
674
+	 * @since 2.05.06
675
+	 *
676
+	 * @param string $group The name of the cache group
677
+	 */
678 678
 	public static function cache_delete_group( $group ) {
679 679
 		$cached_keys = self::get_group_cached_keys( $group );
680 680
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     public $entry_metas;
8 8
 
9 9
     public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
10
+        if ( ! defined( 'ABSPATH' ) ) {
11
+            die( 'You are not allowed to call this page directly.' );
12 12
         }
13 13
 
14 14
 		_deprecated_function( __METHOD__, '2.05.06', 'FrmMigrate' );
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param string $starts_with
27 27
      */
28 28
     public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
29
-        if ( empty($args) ) {
29
+        if ( empty( $args ) ) {
30 30
 			// add an arg to prevent prepare from failing
31 31
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
32 32
 			return;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$key = trim( $key );
88 88
 
89 89
 		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
90
-            $k = explode(' ', $key);
90
+            $k = explode( ' ', $key );
91 91
             $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
92 92
             $values[] = '%Y-%m-%d %H:%i:%s';
93 93
         } else {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         if ( is_array( $value ) ) {
101 101
             // translate array of values to "in"
102 102
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
103
-				$where = preg_replace('/' . $key . '$/', '', $where);
103
+				$where = preg_replace( '/' . $key . '$/', '', $where );
104 104
 				$where .= '(';
105 105
 				$start = true;
106 106
 				foreach ( $value as $v ) {
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		);
286 286
 
287 287
 		$where_is = strtolower( $where_is );
288
-		if ( isset( $switch_to[ $where_is ] ) ) {
289
-			return ' ' . $switch_to[ $where_is ];
288
+		if ( isset( $switch_to[$where_is] ) ) {
289
+			return ' ' . $switch_to[$where_is];
290 290
 		}
291 291
 
292 292
 		// > and < need a little more work since we don't want them switched to >= and <=
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
     private static function get_group_and_table_name( &$table, &$group ) {
309 309
 		global $wpdb, $wpmuBaseTablePrefix;
310 310
 
311
-        $table_parts = explode(' ', $table);
312
-        $group = reset($table_parts);
311
+        $table_parts = explode( ' ', $table );
312
+        $group = reset( $table_parts );
313 313
         $group = str_replace( $wpdb->prefix, '', $group );
314 314
 
315 315
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     }
325 325
 
326 326
     private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
327
-        if ( ! is_array($args) ) {
327
+        if ( ! is_array( $args ) ) {
328 328
 			$args = array( 'order_by' => $args );
329 329
         }
330 330
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
         $temp_args = $args;
340 340
         foreach ( $temp_args as $k => $v ) {
341 341
             if ( $v == '' ) {
342
-				unset( $args[ $k ] );
342
+				unset( $args[$k] );
343 343
                 continue;
344 344
             }
345 345
 
346 346
             $db_name = strtoupper( str_replace( '_', ' ', $k ) );
347 347
             if ( strpos( $v, $db_name ) === false ) {
348
-				$args[ $k ] = $db_name . ' ' . $v;
348
+				$args[$k] = $db_name . ' ' . $v;
349 349
             }
350 350
         }
351 351
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
 		$query = self::generate_query_string_from_pieces( $columns, $table, $where );
374 374
 
375
-		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) );
375
+		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) );
376 376
 		$results = self::check_cache( $cache_key, $group, $query, 'get_associative_results' );
377 377
 
378 378
 		return $results;
@@ -416,13 +416,13 @@  discard block
 block discarded – undo
416 416
 	private static function esc_query_args( &$args ) {
417 417
 		foreach ( $args as $param => $value ) {
418 418
 			if ( $param == 'order_by' ) {
419
-				$args[ $param ] = self::esc_order( $value );
419
+				$args[$param] = self::esc_order( $value );
420 420
 			} elseif ( $param == 'limit' ) {
421
-				$args[ $param ] = self::esc_limit( $value );
421
+				$args[$param] = self::esc_limit( $value );
422 422
 			}
423 423
 
424
-			if ( $args[ $param ] == '' ) {
425
-				unset( $args[ $param ] );
424
+			if ( $args[$param] == '' ) {
425
+				unset( $args[$param] );
426 426
 			}
427 427
 		}
428 428
 	}
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 		$limit = explode( ',', trim( $limit ) );
513 513
 		foreach ( $limit as $k => $l ) {
514 514
 			if ( is_numeric( $l ) ) {
515
-				$limit[ $k ] = $l;
515
+				$limit[$k] = $l;
516 516
 			}
517 517
 		}
518 518
 
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 	 */
644 644
 	public static function add_key_to_group_cache( $key, $group ) {
645 645
 		$cached = self::get_group_cached_keys( $group );
646
-		$cached[ $key ] = $key;
646
+		$cached[$key] = $key;
647 647
 		wp_cache_set( 'cached_keys', $cached, $group, 300 );
648 648
 	}
649 649
 
Please login to merge, or discard this patch.
classes/controllers/FrmFormsController.php 2 patches
Indentation   +502 added lines, -502 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,35 +24,35 @@  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() {
28
-        wp_enqueue_script('formidable-editinplace');
27
+	public static function head() {
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
-    public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
38
-    }
35
+	public static function register_widgets() {
36
+		require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
+		register_widget('FrmShowForm');
38
+	}
39 39
 
40
-    public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
40
+	public static function list_form() {
41
+		FrmAppHelper::permission_check('frm_view_forms');
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+		$errors = self::process_bulk_form_actions( array());
45
+		$errors = apply_filters('frm_admin_list_form_action', $errors);
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48
-    }
48
+	}
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+		FrmAppHelper::permission_check('frm_edit_forms');
52 52
 
53
-        global $frm_vars;
53
+		global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
55
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56 56
 		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
57 57
 
58 58
 		if ( $action == 'create' ) {
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
64
-            $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
63
+			$values = FrmFormsHelper::setup_new_vars($values);
64
+			$id = FrmForm::create( $values );
65
+			$form = FrmForm::getOne($id);
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
69 69
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
70 70
 
71
-            $values['id'] = $id;
71
+			$values['id'] = $id;
72 72
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
73
-        }
74
-    }
73
+		}
74
+	}
75 75
 
76 76
 	/**
77 77
 	 * Create the default email action
@@ -80,87 +80,87 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param object $form
82 82
 	 */
83
-    private static function create_default_email_action( $form ) {
84
-    	$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
83
+	private static function create_default_email_action( $form ) {
84
+		$create_email = apply_filters( 'frm_create_default_email_action', true, $form );
85 85
 
86
-	    if ( $create_email ) {
87
-		    $action_control = FrmFormActionsController::get_form_actions( 'email' );
88
-		    $action_control->create( $form->id );
89
-	    }
90
-    }
86
+		if ( $create_email ) {
87
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
88
+			$action_control->create( $form->id );
89
+		}
90
+	}
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+		FrmAppHelper::permission_check('frm_edit_forms');
94 94
 
95
-        global $frm_vars;
96
-        if ( empty( $values ) ) {
97
-            $values = $_POST;
98
-        }
95
+		global $frm_vars;
96
+		if ( empty( $values ) ) {
97
+			$values = $_POST;
98
+		}
99 99
 
100
-        //Set radio button and checkbox meta equal to "other" value
101
-        if ( FrmAppHelper::pro_is_installed() ) {
102
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
103
-        }
100
+		//Set radio button and checkbox meta equal to "other" value
101
+		if ( FrmAppHelper::pro_is_installed() ) {
102
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
103
+		}
104 104
 
105 105
 		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107
-        if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
-            $frm_settings = FrmAppHelper::get_settings();
109
-            $errors = array( 'form' => $frm_settings->admin_permission );
110
-        } else {
111
-            $errors = FrmForm::validate($values);
112
-        }
107
+		if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108
+			$frm_settings = FrmAppHelper::get_settings();
109
+			$errors = array( 'form' => $frm_settings->admin_permission );
110
+		} else {
111
+			$errors = FrmForm::validate($values);
112
+		}
113 113
 
114
-        if ( count($errors) > 0 ) {
115
-            $hide_preview = true;
114
+		if ( count($errors) > 0 ) {
115
+			$hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117
-            $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
117
+			$form = FrmForm::getOne( $id );
118
+			$fields = FrmField::get_all_for_form($id);
119 119
 
120
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
120
+			$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
121 121
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
122 122
 
123 123
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
124
-        } else {
125
-            FrmForm::update( $id, $values, true );
124
+		} else {
125
+			FrmForm::update( $id, $values, true );
126 126
 			$url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id );
127 127
 			die( FrmAppHelper::js_redirect( $url ) );
128
-        }
129
-    }
128
+		}
129
+	}
130 130
 
131
-    public static function edit( $values = false ) {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
131
+	public static function edit( $values = false ) {
132
+		FrmAppHelper::permission_check('frm_edit_forms');
133 133
 
134 134
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135
-        return self::get_edit_vars($id);
136
-    }
135
+		return self::get_edit_vars($id);
136
+	}
137 137
 
138
-    public static function settings( $id = false, $message = '' ) {
139
-        FrmAppHelper::permission_check('frm_edit_forms');
138
+	public static function settings( $id = false, $message = '' ) {
139
+		FrmAppHelper::permission_check('frm_edit_forms');
140 140
 
141
-        if ( ! $id || ! is_numeric($id) ) {
141
+		if ( ! $id || ! is_numeric($id) ) {
142 142
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143
-        }
143
+		}
144 144
 		return self::get_settings_vars( $id, array(), $message );
145
-    }
145
+	}
146 146
 
147
-    public static function update_settings() {
148
-        FrmAppHelper::permission_check('frm_edit_forms');
147
+	public static function update_settings() {
148
+		FrmAppHelper::permission_check('frm_edit_forms');
149 149
 
150 150
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
151 151
 
152
-        $errors = FrmForm::validate($_POST);
153
-        if ( count($errors) > 0 ) {
154
-            return self::get_settings_vars($id, $errors);
155
-        }
152
+		$errors = FrmForm::validate($_POST);
153
+		if ( count($errors) > 0 ) {
154
+			return self::get_settings_vars($id, $errors);
155
+		}
156 156
 
157
-        do_action('frm_before_update_form_settings', $id);
157
+		do_action('frm_before_update_form_settings', $id);
158 158
 
159 159
 		FrmForm::update( $id, $_POST );
160 160
 
161
-        $message = __( 'Settings Successfully Updated', 'formidable' );
161
+		$message = __( 'Settings Successfully Updated', 'formidable' );
162 162
 		return self::get_settings_vars( $id, array(), $message );
163
-    }
163
+	}
164 164
 
165 165
 	public static function edit_key() {
166 166
 		$values = self::edit_in_place_value( 'form_key' );
@@ -190,43 +190,43 @@  discard block
 block discarded – undo
190 190
 
191 191
 	public static function update( $values = array() ) {
192 192
 		if ( empty( $values ) ) {
193
-            $values = $_POST;
194
-        }
193
+			$values = $_POST;
194
+		}
195 195
 
196
-        //Set radio button and checkbox meta equal to "other" value
197
-        if ( FrmAppHelper::pro_is_installed() ) {
198
-            $values = FrmProEntry::mod_other_vals( $values, 'back' );
199
-        }
196
+		//Set radio button and checkbox meta equal to "other" value
197
+		if ( FrmAppHelper::pro_is_installed() ) {
198
+			$values = FrmProEntry::mod_other_vals( $values, 'back' );
199
+		}
200 200
 
201
-        $errors = FrmForm::validate( $values );
202
-        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
-        if ( $permission_error !== false ) {
204
-            $errors['form'] = $permission_error;
205
-        }
201
+		$errors = FrmForm::validate( $values );
202
+		$permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
203
+		if ( $permission_error !== false ) {
204
+			$errors['form'] = $permission_error;
205
+		}
206 206
 
207 207
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
208 208
 
209 209
 		if ( count( $errors ) > 0 ) {
210
-            return self::get_edit_vars( $id, $errors );
210
+			return self::get_edit_vars( $id, $errors );
211 211
 		} else {
212
-            FrmForm::update( $id, $values );
213
-            $message = __( 'Form was Successfully Updated', 'formidable' );
214
-            if ( defined( 'DOING_AJAX' ) ) {
212
+			FrmForm::update( $id, $values );
213
+			$message = __( 'Form was Successfully Updated', 'formidable' );
214
+			if ( defined( 'DOING_AJAX' ) ) {
215 215
 				wp_die( $message );
216
-            }
216
+			}
217 217
 			return self::get_edit_vars( $id, array(), $message );
218
-        }
219
-    }
218
+		}
219
+	}
220 220
 
221
-    public static function bulk_create_template( $ids ) {
222
-        FrmAppHelper::permission_check( 'frm_edit_forms' );
221
+	public static function bulk_create_template( $ids ) {
222
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
223 223
 
224
-        foreach ( $ids as $id ) {
225
-            FrmForm::duplicate( $id, true, true );
226
-        }
224
+		foreach ( $ids as $id ) {
225
+			FrmForm::duplicate( $id, true, true );
226
+		}
227 227
 
228
-        return __( 'Form template was Successfully Created', 'formidable' );
229
-    }
228
+		return __( 'Form template was Successfully Created', 'formidable' );
229
+	}
230 230
 
231 231
 	/**
232 232
 	 * Redirect to the url for creating from a template
@@ -248,45 +248,45 @@  discard block
 block discarded – undo
248 248
 		wp_die();
249 249
 	}
250 250
 
251
-    public static function duplicate() {
252
-        FrmAppHelper::permission_check('frm_edit_forms');
251
+	public static function duplicate() {
252
+		FrmAppHelper::permission_check('frm_edit_forms');
253 253
 
254 254
 		$params = FrmForm::list_page_params();
255
-        $form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257
-        if ( $form ) {
255
+		$form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
+		$message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257
+		if ( $form ) {
258 258
 			return self::get_edit_vars( $form, array(), $message, true );
259
-        } else {
260
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
261
-        }
262
-    }
259
+		} else {
260
+			return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
261
+		}
262
+	}
263 263
 
264
-    public static function page_preview() {
264
+	public static function page_preview() {
265 265
 		$params = FrmForm::list_page_params();
266
-        if ( ! $params['form'] ) {
267
-            return;
268
-        }
269
-
270
-        $form = FrmForm::getOne( $params['form'] );
271
-        if ( ! $form ) {
272
-            return;
273
-        }
274
-        return self::show_form( $form->id, '', true, true );
275
-    }
276
-
277
-    public static function preview() {
278
-        do_action( 'frm_wp' );
279
-
280
-        global $frm_vars;
281
-        $frm_vars['preview'] = true;
282
-
283
-        if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284
-            global $wp;
285
-            $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
266
+		if ( ! $params['form'] ) {
267
+			return;
268
+		}
269
+
270
+		$form = FrmForm::getOne( $params['form'] );
271
+		if ( ! $form ) {
272
+			return;
273
+		}
274
+		return self::show_form( $form->id, '', true, true );
275
+	}
276
+
277
+	public static function preview() {
278
+		do_action( 'frm_wp' );
279
+
280
+		global $frm_vars;
281
+		$frm_vars['preview'] = true;
282
+
283
+		if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
284
+			global $wp;
285
+			$root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
286 286
 			include_once( $root . '/wp-config.php' );
287
-            $wp->init();
288
-            $wp->register_globals();
289
-        }
287
+			$wp->init();
288
+			$wp->register_globals();
289
+		}
290 290
 
291 291
 		header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
292 292
 
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
 		$form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
299 299
 		if ( empty( $form ) ) {
300 300
 			$form = FrmForm::getAll( array(), '', 1 );
301
-        }
301
+		}
302 302
 
303 303
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' );
304
-        wp_die();
305
-    }
304
+		wp_die();
305
+	}
306 306
 
307 307
 	public static function register_pro_scripts() {
308 308
 		_deprecated_function( __FUNCTION__, '2.03', 'FrmProEntriesController::register_scripts' );
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
 		}
312 312
 	}
313 313
 
314
-    public static function untrash() {
314
+	public static function untrash() {
315 315
 		self::change_form_status( 'untrash' );
316
-    }
316
+	}
317 317
 
318 318
 	public static function bulk_untrash( $ids ) {
319
-        FrmAppHelper::permission_check('frm_edit_forms');
319
+		FrmAppHelper::permission_check('frm_edit_forms');
320 320
 
321
-        $count = FrmForm::set_status( $ids, 'published' );
321
+		$count = FrmForm::set_status( $ids, 'published' );
322 322
 
323
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324
-        return $message;
325
-    }
323
+		$message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324
+		return $message;
325
+	}
326 326
 
327
-    public static function trash() {
327
+	public static function trash() {
328 328
 		self::change_form_status( 'trash' );
329
-    }
329
+	}
330 330
 
331 331
 	/**
332 332
 	 * @param string $status
@@ -365,68 +365,68 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 	public static function bulk_trash( $ids ) {
368
-        FrmAppHelper::permission_check('frm_delete_forms');
368
+		FrmAppHelper::permission_check('frm_delete_forms');
369 369
 
370
-        $count = 0;
371
-        foreach ( $ids as $id ) {
372
-            if ( FrmForm::trash( $id ) ) {
373
-                $count++;
374
-            }
375
-        }
370
+		$count = 0;
371
+		foreach ( $ids as $id ) {
372
+			if ( FrmForm::trash( $id ) ) {
373
+				$count++;
374
+			}
375
+		}
376 376
 
377 377
 		$current_page = FrmAppHelper::get_simple_request( array( 'param' => 'form_type', 'type' => 'request' ) );
378 378
 		$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=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' );
379 379
 
380
-        return $message;
381
-    }
380
+		return $message;
381
+	}
382 382
 
383
-    public static function destroy() {
384
-        FrmAppHelper::permission_check('frm_delete_forms');
383
+	public static function destroy() {
384
+		FrmAppHelper::permission_check('frm_delete_forms');
385 385
 
386 386
 		$params = FrmForm::list_page_params();
387 387
 
388
-        //check nonce url
389
-        check_admin_referer('destroy_form_' . $params['id']);
388
+		//check nonce url
389
+		check_admin_referer('destroy_form_' . $params['id']);
390 390
 
391
-        $count = 0;
392
-        if ( FrmForm::destroy( $params['id'] ) ) {
393
-            $count++;
394
-        }
391
+		$count = 0;
392
+		if ( FrmForm::destroy( $params['id'] ) ) {
393
+			$count++;
394
+		}
395 395
 
396
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
396
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
397 397
 
398 398
 		self::display_forms_list( $params, $message );
399
-    }
399
+	}
400 400
 
401 401
 	public static function bulk_destroy( $ids ) {
402
-        FrmAppHelper::permission_check('frm_delete_forms');
402
+		FrmAppHelper::permission_check('frm_delete_forms');
403 403
 
404
-        $count = 0;
405
-        foreach ( $ids as $id ) {
406
-            $d = FrmForm::destroy( $id );
407
-            if ( $d ) {
408
-                $count++;
409
-            }
410
-        }
404
+		$count = 0;
405
+		foreach ( $ids as $id ) {
406
+			$d = FrmForm::destroy( $id );
407
+			if ( $d ) {
408
+				$count++;
409
+			}
410
+		}
411 411
 
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
413 413
 
414
-        return $message;
415
-    }
414
+		return $message;
415
+	}
416 416
 
417
-    private static function delete_all() {
418
-        //check nonce url
419
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
420
-        if ( $permission_error !== false ) {
417
+	private static function delete_all() {
418
+		//check nonce url
419
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
420
+		if ( $permission_error !== false ) {
421 421
 			self::display_forms_list( array(), '', array( $permission_error ) );
422
-            return;
423
-        }
422
+			return;
423
+		}
424 424
 
425 425
 		$count = FrmForm::scheduled_delete( time() );
426
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
426
+		$message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
427 427
 
428 428
 		self::display_forms_list( array(), $message );
429
-    }
429
+	}
430 430
 
431 431
 	public static function scheduled_delete( $delete_timestamp = '' ) {
432 432
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' );
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 
436 436
 	/**
437
-	* Inserts Formidable button
438
-	* Hook exists since 2.5.0
439
-	*
440
-	* @since 2.0.15
441
-	*/
437
+	 * Inserts Formidable button
438
+	 * Hook exists since 2.5.0
439
+	 *
440
+	 * @since 2.0.15
441
+	 */
442 442
 	public static function insert_form_button() {
443 443
 		if ( current_user_can('frm_view_forms') ) {
444 444
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -449,49 +449,49 @@  discard block
 block discarded – undo
449 449
 		}
450 450
 	}
451 451
 
452
-    public static function insert_form_popup() {
452
+	public static function insert_form_popup() {
453 453
 		$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
454 454
 		if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
455
-            return;
456
-        }
455
+			return;
456
+		}
457 457
 
458
-        FrmAppHelper::load_admin_wide_js();
458
+		FrmAppHelper::load_admin_wide_js();
459 459
 
460
-        $shortcodes = array(
460
+		$shortcodes = array(
461 461
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
462
-        );
462
+		);
463 463
 
464
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
464
+		$shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
465 465
 
466 466
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
467
-    }
467
+	}
468 468
 
469
-    public static function get_shortcode_opts() {
469
+	public static function get_shortcode_opts() {
470 470
 		FrmAppHelper::permission_check('frm_view_forms');
471
-        check_ajax_referer( 'frm_ajax', 'nonce' );
471
+		check_ajax_referer( 'frm_ajax', 'nonce' );
472 472
 
473 473
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
474
-        if ( empty($shortcode) ) {
475
-            wp_die();
476
-        }
474
+		if ( empty($shortcode) ) {
475
+			wp_die();
476
+		}
477 477
 
478 478
 		echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">';
479 479
 		echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />';
480 480
 
481
-        $form_id = '';
482
-        $opts = array();
481
+		$form_id = '';
482
+		$opts = array();
483 483
 		switch ( $shortcode ) {
484
-            case 'formidable':
485
-                $opts = array(
484
+			case 'formidable':
485
+				$opts = array(
486 486
 					'form_id'       => 'id',
487
-                    //'key' => ',
487
+					//'key' => ',
488 488
 					'title'         => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ),
489 489
 					'description'   => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ),
490 490
 					'minimize'      => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ),
491
-                );
492
-            break;
493
-        }
494
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
491
+				);
492
+			break;
493
+		}
494
+		$opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
495 495
 
496 496
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
497 497
 			// allow other shortcodes to use the required form id option
@@ -501,61 +501,61 @@  discard block
 block discarded – undo
501 501
 
502 502
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' );
503 503
 
504
-        echo '</div>';
504
+		echo '</div>';
505 505
 
506
-        wp_die();
507
-    }
506
+		wp_die();
507
+	}
508 508
 
509 509
 	public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) {
510
-        FrmAppHelper::permission_check( 'frm_view_forms' );
510
+		FrmAppHelper::permission_check( 'frm_view_forms' );
511 511
 		if ( ! empty( $deprecated_errors ) ) {
512 512
 			$errors = $deprecated_errors;
513 513
 			_deprecated_argument( 'errors', '2.0.8' );
514 514
 		}
515 515
 
516
-        global $wpdb, $frm_vars;
516
+		global $wpdb, $frm_vars;
517 517
 
518 518
 		if ( empty( $params ) ) {
519 519
 			$params = FrmForm::list_page_params();
520
-        }
520
+		}
521 521
 
522
-        $wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
522
+		$wp_list_table = new FrmFormsListHelper( compact( 'params' ) );
523 523
 
524
-        $pagenum = $wp_list_table->get_pagenum();
524
+		$pagenum = $wp_list_table->get_pagenum();
525 525
 
526
-        $wp_list_table->prepare_items();
526
+		$wp_list_table->prepare_items();
527 527
 
528
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
529
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
528
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
529
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
530 530
 			wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
531
-            die();
532
-        }
531
+			die();
532
+		}
533 533
 
534 534
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' );
535
-    }
535
+	}
536 536
 
537 537
 	public static function get_columns( $columns ) {
538
-	    $columns['cb'] = '<input type="checkbox" />';
539
-	    $columns['id'] = 'ID';
538
+		$columns['cb'] = '<input type="checkbox" />';
539
+		$columns['id'] = 'ID';
540 540
 
541 541
 		$type = FrmAppHelper::get_simple_request( array( 'param' => 'form_type', 'type' => 'request', 'default' => 'published' ) );
542 542
 
543
-        if ( 'template' == $type ) {
544
-            $columns['name']        = __( 'Template Name', 'formidable' );
545
-            $columns['type']        = __( 'Type', 'formidable' );
546
-            $columns['form_key']    = __( 'Key', 'formidable' );
547
-        } else {
548
-            $columns['name']        = __( 'Form Title', 'formidable' );
549
-            $columns['entries']     = __( 'Entries', 'formidable' );
550
-            $columns['form_key']    = __( 'Key', 'formidable' );
551
-            $columns['shortcode']   = __( 'Shortcodes', 'formidable' );
552
-        }
543
+		if ( 'template' == $type ) {
544
+			$columns['name']        = __( 'Template Name', 'formidable' );
545
+			$columns['type']        = __( 'Type', 'formidable' );
546
+			$columns['form_key']    = __( 'Key', 'formidable' );
547
+		} else {
548
+			$columns['name']        = __( 'Form Title', 'formidable' );
549
+			$columns['entries']     = __( 'Entries', 'formidable' );
550
+			$columns['form_key']    = __( 'Key', 'formidable' );
551
+			$columns['shortcode']   = __( 'Shortcodes', 'formidable' );
552
+		}
553 553
 
554
-        $columns['created_at'] = __( 'Date', 'formidable' );
554
+		$columns['created_at'] = __( 'Date', 'formidable' );
555 555
 
556 556
 		add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) );
557 557
 
558
-        return $columns;
558
+		return $columns;
559 559
 	}
560 560
 
561 561
 	public static function get_sortable_columns() {
@@ -580,83 +580,83 @@  discard block
 block discarded – undo
580 580
 	}
581 581
 
582 582
 	public static function save_per_page( $save, $option, $value ) {
583
-        if ( $option == 'formidable_page_formidable_per_page' ) {
584
-            $save = (int) $value;
585
-        }
586
-        return $save;
587
-    }
583
+		if ( $option == 'formidable_page_formidable_per_page' ) {
584
+			$save = (int) $value;
585
+		}
586
+		return $save;
587
+	}
588 588
 
589 589
 	private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
590
-        global $frm_vars;
590
+		global $frm_vars;
591 591
 
592
-        $form = FrmForm::getOne( $id );
593
-        if ( ! $form ) {
594
-            wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
595
-        }
592
+		$form = FrmForm::getOne( $id );
593
+		if ( ! $form ) {
594
+			wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) );
595
+		}
596 596
 
597
-        if ( $form->parent_form_id ) {
597
+		if ( $form->parent_form_id ) {
598 598
 			wp_die( sprintf( __( '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>' ));
599
-        }
599
+		}
600 600
 
601 601
 		$frm_field_selection = FrmField::field_selection();
602
-        $fields = FrmField::get_all_for_form($form->id);
602
+		$fields = FrmField::get_all_for_form($form->id);
603 603
 
604
-        // Automatically add end section fields if they don't exist (2.0 migration)
605
-        $reset_fields = false;
606
-        FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
604
+		// Automatically add end section fields if they don't exist (2.0 migration)
605
+		$reset_fields = false;
606
+		FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields );
607 607
 
608
-        if ( $reset_fields ) {
609
-            $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
610
-        }
608
+		if ( $reset_fields ) {
609
+			$fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
610
+		}
611 611
 
612
-        unset($end_section_values, $last_order, $open, $reset_fields);
612
+		unset($end_section_values, $last_order, $open, $reset_fields);
613 613
 
614 614
 		$args = array( 'parent_form_id' => $form->id );
615
-        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
615
+		$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
616 616
 
617
-        $edit_message = __( 'Form was Successfully Updated', 'formidable' );
618
-        if ( $form->is_template && $message == $edit_message ) {
619
-            $message = __( 'Template was Successfully Updated', 'formidable' );
620
-        }
617
+		$edit_message = __( 'Form was Successfully Updated', 'formidable' );
618
+		if ( $form->is_template && $message == $edit_message ) {
619
+			$message = __( 'Template was Successfully Updated', 'formidable' );
620
+		}
621 621
 
622 622
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
623 623
 
624
-        if ( $form->default_template ) {
625
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
626
-        } else if ( defined('DOING_AJAX') ) {
627
-            wp_die();
628
-        } else if ( $create_link ) {
624
+		if ( $form->default_template ) {
625
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
626
+		} else if ( defined('DOING_AJAX') ) {
627
+			wp_die();
628
+		} else if ( $create_link ) {
629 629
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
630
-        } else {
630
+		} else {
631 631
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' );
632
-        }
633
-    }
632
+		}
633
+	}
634 634
 
635 635
 	public static function get_settings_vars( $id, $errors = array(), $message = '' ) {
636 636
 		FrmAppHelper::permission_check( 'frm_edit_forms' );
637 637
 
638
-        global $frm_vars;
638
+		global $frm_vars;
639 639
 
640
-        $form = FrmForm::getOne( $id );
640
+		$form = FrmForm::getOne( $id );
641 641
 
642
-        $fields = FrmField::get_all_for_form($id);
643
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
642
+		$fields = FrmField::get_all_for_form($id);
643
+		$values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
644 644
 
645
-        if ( isset($values['default_template']) && $values['default_template'] ) {
646
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
647
-        }
645
+		if ( isset($values['default_template']) && $values['default_template'] ) {
646
+			wp_die(__( 'That template cannot be edited', 'formidable' ));
647
+		}
648 648
 
649 649
 		self::clean_submit_html( $values );
650 650
 
651
-        $action_controls = FrmFormActionsController::get_form_actions();
651
+		$action_controls = FrmFormActionsController::get_form_actions();
652 652
 
653
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
654
-        $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
653
+		$sections = apply_filters('frm_add_form_settings_section', array(), $values);
654
+		$pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
655 655
 
656
-        $styles = apply_filters('frm_get_style_opts', array());
656
+		$styles = apply_filters('frm_get_style_opts', array());
657 657
 
658 658
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
659
-    }
659
+	}
660 660
 
661 661
 	/**
662 662
 	 * Replace old Submit Button href with new href to avoid errors in Chrome
@@ -671,11 +671,11 @@  discard block
 block discarded – undo
671 671
 		}
672 672
 	}
673 673
 
674
-    public static function mb_tags_box( $form_id, $class = '' ) {
675
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
676
-        $linked_forms = array();
677
-        $col = 'one';
678
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
674
+	public static function mb_tags_box( $form_id, $class = '' ) {
675
+		$fields = FrmField::get_all_for_form($form_id, '', 'include');
676
+		$linked_forms = array();
677
+		$col = 'one';
678
+		$settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
679 679
 
680 680
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
681 681
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 		$entry_shortcodes = self::get_shortcode_helpers( $settings_tab );
684 684
 
685 685
 		include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' );
686
-    }
686
+	}
687 687
 
688 688
 	/**
689 689
 	 * Get an array of the options to display in the advanced tab
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 			''          => '',
725 725
 			'siteurl'   => __( 'Site URL', 'formidable' ),
726 726
 			'sitename'  => __( 'Site Name', 'formidable' ),
727
-        );
727
+		);
728 728
 
729 729
 		if ( ! FrmAppHelper::pro_is_installed() ) {
730 730
 			unset( $entry_shortcodes['post_id'] );
@@ -752,39 +752,39 @@  discard block
 block discarded – undo
752 752
 		return $entry_shortcodes;
753 753
 	}
754 754
 
755
-    // Insert the form class setting into the form
755
+	// Insert the form class setting into the form
756 756
 	public static function form_classes( $form ) {
757
-        if ( isset($form->options['form_class']) ) {
757
+		if ( isset($form->options['form_class']) ) {
758 758
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
759
-        }
760
-    }
759
+		}
760
+	}
761 761
 
762
-    public static function get_email_html() {
762
+	public static function get_email_html() {
763 763
 		FrmAppHelper::permission_check('frm_view_forms');
764
-        check_ajax_referer( 'frm_ajax', 'nonce' );
764
+		check_ajax_referer( 'frm_ajax', 'nonce' );
765 765
 		echo FrmEntriesController::show_entry_shortcode( array(
766 766
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
767
-	        'default_email' => true,
767
+			'default_email' => true,
768 768
 			'plain_text'    => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ),
769
-	    ) );
770
-	    wp_die();
769
+		) );
770
+		wp_die();
771 771
 	}
772 772
 
773
-    public static function filter_content( $content, $form, $entry = false ) {
773
+	public static function filter_content( $content, $form, $entry = false ) {
774 774
 		self::get_entry_by_param( $entry );
775
-        if ( ! $entry ) {
776
-            return $content;
777
-        }
775
+		if ( ! $entry ) {
776
+			return $content;
777
+		}
778 778
 
779
-        if ( is_object( $form ) ) {
780
-            $form = $form->id;
781
-        }
779
+		if ( is_object( $form ) ) {
780
+			$form = $form->id;
781
+		}
782 782
 
783
-        $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
784
-        $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
783
+		$shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form );
784
+		$content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes );
785 785
 
786
-        return $content;
787
-    }
786
+		return $content;
787
+	}
788 788
 
789 789
 	private static function get_entry_by_param( &$entry ) {
790 790
 		if ( ! $entry || ! is_object( $entry ) ) {
@@ -796,207 +796,207 @@  discard block
 block discarded – undo
796 796
 		}
797 797
 	}
798 798
 
799
-    public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
800
-        return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
801
-    }
799
+	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
800
+		return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
801
+	}
802 802
 
803
-    public static function process_bulk_form_actions( $errors ) {
804
-        if ( ! $_REQUEST ) {
805
-            return $errors;
806
-        }
803
+	public static function process_bulk_form_actions( $errors ) {
804
+		if ( ! $_REQUEST ) {
805
+			return $errors;
806
+		}
807 807
 
808 808
 		$bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
809
-        if ( $bulkaction == -1 ) {
809
+		if ( $bulkaction == -1 ) {
810 810
 			$bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
811
-        }
811
+		}
812 812
 
813
-        if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
814
-            FrmAppHelper::remove_get_action();
813
+		if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) {
814
+			FrmAppHelper::remove_get_action();
815 815
 
816
-            $bulkaction = str_replace( 'bulk_', '', $bulkaction );
817
-        }
816
+			$bulkaction = str_replace( 'bulk_', '', $bulkaction );
817
+		}
818 818
 
819 819
 		$ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
820
-        if ( empty( $ids ) ) {
821
-            $errors[] = __( 'No forms were specified', 'formidable' );
822
-            return $errors;
823
-        }
824
-
825
-        $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
826
-        if ( $permission_error !== false ) {
827
-            $errors[] = $permission_error;
828
-            return $errors;
829
-        }
830
-
831
-        if ( ! is_array( $ids ) ) {
832
-            $ids = explode( ',', $ids );
833
-        }
834
-
835
-        switch ( $bulkaction ) {
836
-            case 'delete':
837
-                $message = self::bulk_destroy( $ids );
838
-            break;
839
-            case 'trash':
840
-                $message = self::bulk_trash( $ids );
841
-            break;
842
-            case 'untrash':
843
-                $message = self::bulk_untrash( $ids );
844
-            break;
845
-            case 'create_template':
846
-                $message = self::bulk_create_template( $ids );
847
-            break;
848
-        }
849
-
850
-        if ( isset( $message ) && ! empty( $message ) ) {
820
+		if ( empty( $ids ) ) {
821
+			$errors[] = __( 'No forms were specified', 'formidable' );
822
+			return $errors;
823
+		}
824
+
825
+		$permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
826
+		if ( $permission_error !== false ) {
827
+			$errors[] = $permission_error;
828
+			return $errors;
829
+		}
830
+
831
+		if ( ! is_array( $ids ) ) {
832
+			$ids = explode( ',', $ids );
833
+		}
834
+
835
+		switch ( $bulkaction ) {
836
+			case 'delete':
837
+				$message = self::bulk_destroy( $ids );
838
+			break;
839
+			case 'trash':
840
+				$message = self::bulk_trash( $ids );
841
+			break;
842
+			case 'untrash':
843
+				$message = self::bulk_untrash( $ids );
844
+			break;
845
+			case 'create_template':
846
+				$message = self::bulk_create_template( $ids );
847
+			break;
848
+		}
849
+
850
+		if ( isset( $message ) && ! empty( $message ) ) {
851 851
 			echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>';
852
-        }
852
+		}
853 853
 
854
-        return $errors;
855
-    }
854
+		return $errors;
855
+	}
856 856
 
857
-    public static function add_default_templates( $path, $default = true, $template = true ) {
858
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
857
+	public static function add_default_templates( $path, $default = true, $template = true ) {
858
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
859 859
 
860
-        $path = untrailingslashit(trim($path));
860
+		$path = untrailingslashit(trim($path));
861 861
 		$templates = glob( $path . '/*.php' );
862 862
 
863 863
 		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
864 864
 			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
865 865
 			$template_query = array( 'form_key' => $filename );
866
-            if ( $template ) {
867
-                $template_query['is_template'] = 1;
868
-            }
869
-            if ( $default ) {
870
-                $template_query['default_template'] = 1;
871
-            }
866
+			if ( $template ) {
867
+				$template_query['is_template'] = 1;
868
+			}
869
+			if ( $default ) {
870
+				$template_query['default_template'] = 1;
871
+			}
872 872
 			$form = FrmForm::getAll( $template_query, '', 1 );
873 873
 
874
-            $values = FrmFormsHelper::setup_new_vars();
875
-            $values['form_key'] = $filename;
876
-            $values['is_template'] = $template;
877
-            $values['status'] = 'published';
878
-            if ( $default ) {
879
-                $values['default_template'] = 1;
880
-            }
881
-
882
-            include( $templates[ $i ] );
883
-
884
-            //get updated form
885
-            if ( isset($form) && ! empty($form) ) {
886
-                $old_id = $form->id;
887
-                $form = FrmForm::getOne($form->id);
888
-            } else {
889
-                $old_id = false;
874
+			$values = FrmFormsHelper::setup_new_vars();
875
+			$values['form_key'] = $filename;
876
+			$values['is_template'] = $template;
877
+			$values['status'] = 'published';
878
+			if ( $default ) {
879
+				$values['default_template'] = 1;
880
+			}
881
+
882
+			include( $templates[ $i ] );
883
+
884
+			//get updated form
885
+			if ( isset($form) && ! empty($form) ) {
886
+				$old_id = $form->id;
887
+				$form = FrmForm::getOne($form->id);
888
+			} else {
889
+				$old_id = false;
890 890
 				$form = FrmForm::getAll( $template_query, '', 1 );
891
-            }
891
+			}
892 892
 
893
-            if ( $form ) {
893
+			if ( $form ) {
894 894
 				do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) );
895
-            }
896
-        }
897
-    }
895
+			}
896
+		}
897
+	}
898 898
 
899
-    public static function route() {
900
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
901
-        $vars = array();
899
+	public static function route() {
900
+		$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
901
+		$vars = array();
902 902
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
903 903
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
904 904
 
905
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
906
-            $json_vars = json_decode($json_vars, true);
907
-            if ( empty($json_vars) ) {
908
-                // json decoding failed so we should return an error message
905
+			$json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
906
+			$json_vars = json_decode($json_vars, true);
907
+			if ( empty($json_vars) ) {
908
+				// json decoding failed so we should return an error message
909 909
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
910
-                if ( 'edit' == $action ) {
911
-                    $action = 'update';
912
-                }
913
-
914
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
915
-            } else {
916
-                $vars = FrmAppHelper::json_to_array($json_vars);
917
-                $action = $vars[ $action ];
910
+				if ( 'edit' == $action ) {
911
+					$action = 'update';
912
+				}
913
+
914
+				add_filter('frm_validate_form', 'FrmFormsController::json_error');
915
+			} else {
916
+				$vars = FrmAppHelper::json_to_array($json_vars);
917
+				$action = $vars[ $action ];
918 918
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
919 919
 				$_REQUEST = array_merge( $_REQUEST, $vars );
920 920
 				$_POST = array_merge( $_POST, $_REQUEST );
921
-            }
922
-        } else {
921
+			}
922
+		} else {
923 923
 			$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
924
-    		if ( isset( $_REQUEST['delete_all'] ) ) {
925
-                // override the action for this page
926
-    			$action = 'delete_all';
927
-            }
928
-        }
924
+			if ( isset( $_REQUEST['delete_all'] ) ) {
925
+				// override the action for this page
926
+				$action = 'delete_all';
927
+			}
928
+		}
929 929
 
930 930
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
931
-        FrmAppHelper::trigger_hook_load( 'form' );
932
-
933
-        switch ( $action ) {
934
-            case 'new':
935
-                return self::new_form($vars);
936
-            case 'create':
937
-            case 'edit':
938
-            case 'update':
939
-            case 'duplicate':
940
-            case 'trash':
941
-            case 'untrash':
942
-            case 'destroy':
943
-            case 'delete_all':
944
-            case 'settings':
945
-            case 'update_settings':
931
+		FrmAppHelper::trigger_hook_load( 'form' );
932
+
933
+		switch ( $action ) {
934
+			case 'new':
935
+				return self::new_form($vars);
936
+			case 'create':
937
+			case 'edit':
938
+			case 'update':
939
+			case 'duplicate':
940
+			case 'trash':
941
+			case 'untrash':
942
+			case 'destroy':
943
+			case 'delete_all':
944
+			case 'settings':
945
+			case 'update_settings':
946 946
 				return self::$action( $vars );
947
-            default:
947
+			default:
948 948
 				do_action( 'frm_form_action_' . $action );
949 949
 				if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
950
-                    return;
951
-                }
950
+					return;
951
+				}
952 952
 
953 953
 				$action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
954
-                if ( $action == -1 ) {
954
+				if ( $action == -1 ) {
955 955
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
956
-                }
956
+				}
957 957
 
958
-                if ( strpos($action, 'bulk_') === 0 ) {
959
-                    FrmAppHelper::remove_get_action();
960
-                    return self::list_form();
961
-                }
958
+				if ( strpos($action, 'bulk_') === 0 ) {
959
+					FrmAppHelper::remove_get_action();
960
+					return self::list_form();
961
+				}
962 962
 
963
-                return self::display_forms_list();
964
-        }
965
-    }
963
+				return self::display_forms_list();
964
+		}
965
+	}
966 966
 
967
-    public static function json_error( $errors ) {
968
-        $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
969
-        return $errors;
970
-    }
967
+	public static function json_error( $errors ) {
968
+		$errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
969
+		return $errors;
970
+	}
971 971
 
972 972
 
973
-    /* FRONT-END FORMS */
974
-    public static function admin_bar_css() {
973
+	/* FRONT-END FORMS */
974
+	public static function admin_bar_css() {
975 975
 		if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
976
-            return;
977
-        }
976
+			return;
977
+		}
978 978
 
979 979
 		add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' );
980 980
 		FrmAppHelper::load_font_style();
981 981
 	}
982 982
 
983 983
 	public static function admin_bar_configure() {
984
-        global $frm_vars;
985
-        if ( empty($frm_vars['forms_loaded']) ) {
986
-            return;
987
-        }
988
-
989
-        $actions = array();
990
-        foreach ( $frm_vars['forms_loaded'] as $form ) {
991
-            if ( is_object($form) ) {
992
-                $actions[ $form->id ] = $form->name;
993
-            }
994
-            unset($form);
995
-        }
996
-
997
-        if ( empty($actions) ) {
998
-            return;
999
-        }
984
+		global $frm_vars;
985
+		if ( empty($frm_vars['forms_loaded']) ) {
986
+			return;
987
+		}
988
+
989
+		$actions = array();
990
+		foreach ( $frm_vars['forms_loaded'] as $form ) {
991
+			if ( is_object($form) ) {
992
+				$actions[ $form->id ] = $form->name;
993
+			}
994
+			unset($form);
995
+		}
996
+
997
+		if ( empty($actions) ) {
998
+			return;
999
+		}
1000 1000
 
1001 1001
 		self::add_menu_to_admin_bar();
1002 1002
 		self::add_forms_to_admin_bar( $actions );
@@ -1037,48 +1037,48 @@  discard block
 block discarded – undo
1037 1037
 		}
1038 1038
 	}
1039 1039
 
1040
-    //formidable shortcode
1040
+	//formidable shortcode
1041 1041
 	public static function get_form_shortcode( $atts ) {
1042
-        global $frm_vars;
1043
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1044
-            $sc = '[formidable';
1042
+		global $frm_vars;
1043
+		if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1044
+			$sc = '[formidable';
1045 1045
 			if ( ! empty( $atts ) ) {
1046 1046
 				foreach ( $atts as $k => $v ) {
1047 1047
 					$sc .= ' ' . $k . '="' . esc_attr( $v ) . '"';
1048 1048
 				}
1049 1049
 			}
1050 1050
 			return $sc . ']';
1051
-        }
1052
-
1053
-        $shortcode_atts = shortcode_atts( array(
1054
-            'id' => '', 'key' => '', 'title' => false, 'description' => false,
1055
-            'readonly' => false, 'entry_id' => false, 'fields' => array(),
1056
-            'exclude_fields' => array(), 'minimize' => false,
1057
-        ), $atts);
1058
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1059
-
1060
-        return self::show_form(
1061
-            $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1062
-            $shortcode_atts['description'], $atts
1063
-        );
1064
-    }
1065
-
1066
-    public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1067
-        if ( empty( $id ) ) {
1068
-            $id = $key;
1069
-        }
1070
-
1071
-        $form = self::maybe_get_form_to_show( $id );
1072
-        if ( ! $form ) {
1073
-            return __( 'Please select a valid form', 'formidable' );
1074
-        }
1051
+		}
1052
+
1053
+		$shortcode_atts = shortcode_atts( array(
1054
+			'id' => '', 'key' => '', 'title' => false, 'description' => false,
1055
+			'readonly' => false, 'entry_id' => false, 'fields' => array(),
1056
+			'exclude_fields' => array(), 'minimize' => false,
1057
+		), $atts);
1058
+		do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1059
+
1060
+		return self::show_form(
1061
+			$shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
1062
+			$shortcode_atts['description'], $atts
1063
+		);
1064
+	}
1065
+
1066
+	public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
1067
+		if ( empty( $id ) ) {
1068
+			$id = $key;
1069
+		}
1070
+
1071
+		$form = self::maybe_get_form_to_show( $id );
1072
+		if ( ! $form ) {
1073
+			return __( 'Please select a valid form', 'formidable' );
1074
+		}
1075 1075
 
1076 1076
 		add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' );
1077
-        FrmAppHelper::trigger_hook_load( 'form', $form );
1077
+		FrmAppHelper::trigger_hook_load( 'form', $form );
1078 1078
 
1079
-        $form = apply_filters( 'frm_pre_display_form', $form );
1079
+		$form = apply_filters( 'frm_pre_display_form', $form );
1080 1080
 
1081
-        $frm_settings = FrmAppHelper::get_settings();
1081
+		$frm_settings = FrmAppHelper::get_settings();
1082 1082
 
1083 1083
 		if ( self::is_viewable_draft_form( $form ) ) {
1084 1084
 			// don't show a draft form on a page
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		}
1100 1100
 
1101 1101
 		return $form;
1102
-    }
1102
+	}
1103 1103
 
1104 1104
 	private static function maybe_get_form_to_show( $id ) {
1105 1105
 		$form = false;
@@ -1128,19 +1128,19 @@  discard block
 block discarded – undo
1128 1128
 		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'] );
1129 1129
 	}
1130 1130
 
1131
-    public static function get_form( $form, $title, $description, $atts = array() ) {
1132
-        ob_start();
1131
+	public static function get_form( $form, $title, $description, $atts = array() ) {
1132
+		ob_start();
1133 1133
 
1134
-        self::get_form_contents( $form, $title, $description, $atts );
1134
+		self::get_form_contents( $form, $title, $description, $atts );
1135 1135
 		self::enqueue_scripts( FrmForm::get_params( $form ) );
1136 1136
 
1137
-        $contents = ob_get_contents();
1138
-        ob_end_clean();
1137
+		$contents = ob_get_contents();
1138
+		ob_end_clean();
1139 1139
 
1140 1140
 		self::maybe_minimize_form( $atts, $contents );
1141 1141
 
1142
-        return $contents;
1143
-    }
1142
+		return $contents;
1143
+	}
1144 1144
 
1145 1145
 	public static function enqueue_scripts( $params ) {
1146 1146
 		do_action( 'frm_enqueue_form_scripts', $params );
@@ -1336,10 +1336,10 @@  discard block
 block discarded – undo
1336 1336
 	}
1337 1337
 
1338 1338
 	public static function defer_script_loading( $tag, $handle ) {
1339
-	    if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1340
-	        $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1339
+		if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
1340
+			$tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
1341 1341
 		}
1342
-	    return $tag;
1342
+		return $tag;
1343 1343
 	}
1344 1344
 
1345 1345
 	public static function footer_js( $location = 'footer' ) {
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 		if ( ! FrmAppHelper::pro_is_installed() ) {
8 8
 			$menu_label .= ' (Lite)';
9 9
 		}
10
-		add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
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
     }
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 			return;
19 19
 		}
20 20
 
21
-		add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
21
+		add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
22 22
 
23
-		add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
-		add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
23
+		add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
24
+		add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
25 25
 	}
26 26
 
27 27
     public static function head() {
28
-        wp_enqueue_script('formidable-editinplace');
28
+        wp_enqueue_script( 'formidable-editinplace' );
29 29
 
30 30
         if ( wp_is_mobile() ) {
31 31
     		wp_enqueue_script( 'jquery-touch-punch' );
@@ -33,36 +33,36 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     public static function register_widgets() {
36
-        require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php');
37
-        register_widget('FrmShowForm');
36
+        require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' );
37
+        register_widget( 'FrmShowForm' );
38 38
     }
39 39
 
40 40
     public static function list_form() {
41
-        FrmAppHelper::permission_check('frm_view_forms');
41
+        FrmAppHelper::permission_check( 'frm_view_forms' );
42 42
 
43 43
 		$params = FrmForm::list_page_params();
44
-        $errors = self::process_bulk_form_actions( array());
45
-        $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+        $errors = self::process_bulk_form_actions( array() );
45
+        $errors = apply_filters( 'frm_admin_list_form_action', $errors );
46 46
 
47 47
 		return self::display_forms_list( $params, '', $errors );
48 48
     }
49 49
 
50 50
 	public static function new_form( $values = array() ) {
51
-        FrmAppHelper::permission_check('frm_edit_forms');
51
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
52 52
 
53 53
         global $frm_vars;
54 54
 
55
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
56
-		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ];
55
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
56
+		$action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action];
57 57
 
58 58
 		if ( $action == 'create' ) {
59
-			self::create($values);
59
+			self::create( $values );
60 60
 			return;
61 61
 		} else if ( $action == 'new' ) {
62 62
 			$frm_field_selection = FrmField::field_selection();
63
-            $values = FrmFormsHelper::setup_new_vars($values);
63
+            $values = FrmFormsHelper::setup_new_vars( $values );
64 64
             $id = FrmForm::create( $values );
65
-            $form = FrmForm::getOne($id);
65
+            $form = FrmForm::getOne( $id );
66 66
 
67 67
 			self::create_default_email_action( $form );
68 68
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     }
91 91
 
92 92
 	public static function create( $values = array() ) {
93
-        FrmAppHelper::permission_check('frm_edit_forms');
93
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
94 94
 
95 95
         global $frm_vars;
96 96
         if ( empty( $values ) ) {
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
             $values = FrmProEntry::mod_other_vals( $values, 'back' );
103 103
         }
104 104
 
105
-		$id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
105
+		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
106 106
 
107 107
         if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
108 108
             $frm_settings = FrmAppHelper::get_settings();
109 109
             $errors = array( 'form' => $frm_settings->admin_permission );
110 110
         } else {
111
-            $errors = FrmForm::validate($values);
111
+            $errors = FrmForm::validate( $values );
112 112
         }
113 113
 
114
-        if ( count($errors) > 0 ) {
114
+        if ( count( $errors ) > 0 ) {
115 115
             $hide_preview = true;
116 116
 			$frm_field_selection = FrmField::field_selection();
117 117
             $form = FrmForm::getOne( $id );
118
-            $fields = FrmField::get_all_for_form($id);
118
+            $fields = FrmField::get_all_for_form( $id );
119 119
 
120
-            $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
120
+            $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
121 121
 			$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
122 122
 
123 123
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -129,32 +129,32 @@  discard block
 block discarded – undo
129 129
     }
130 130
 
131 131
     public static function edit( $values = false ) {
132
-        FrmAppHelper::permission_check('frm_edit_forms');
132
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
133 133
 
134 134
 		$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
135
-        return self::get_edit_vars($id);
135
+        return self::get_edit_vars( $id );
136 136
     }
137 137
 
138 138
     public static function settings( $id = false, $message = '' ) {
139
-        FrmAppHelper::permission_check('frm_edit_forms');
139
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
140 140
 
141
-        if ( ! $id || ! is_numeric($id) ) {
141
+        if ( ! $id || ! is_numeric( $id ) ) {
142 142
 			$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
143 143
         }
144 144
 		return self::get_settings_vars( $id, array(), $message );
145 145
     }
146 146
 
147 147
     public static function update_settings() {
148
-        FrmAppHelper::permission_check('frm_edit_forms');
148
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
149 149
 
150 150
 		$id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
151 151
 
152
-        $errors = FrmForm::validate($_POST);
153
-        if ( count($errors) > 0 ) {
154
-            return self::get_settings_vars($id, $errors);
152
+        $errors = FrmForm::validate( $_POST );
153
+        if ( count( $errors ) > 0 ) {
154
+            return self::get_settings_vars( $id, $errors );
155 155
         }
156 156
 
157
-        do_action('frm_before_update_form_settings', $id);
157
+        do_action( 'frm_before_update_form_settings', $id );
158 158
 
159 159
 		FrmForm::update( $id, $_POST );
160 160
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 	private static function edit_in_place_value( $field ) {
178 178
 		check_ajax_referer( 'frm_ajax', 'nonce' );
179
-		FrmAppHelper::permission_check('frm_edit_forms', 'hide');
179
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
180 180
 
181 181
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
182 182
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' );
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @since 2.0
235 235
 	 */
236 236
 	public static function _create_from_template() {
237
-		FrmAppHelper::permission_check('frm_edit_forms');
237
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
238 238
 		check_ajax_referer( 'frm_ajax', 'nonce' );
239 239
 
240 240
 		$current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' );
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
     public static function duplicate() {
252
-        FrmAppHelper::permission_check('frm_edit_forms');
252
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
253 253
 
254 254
 		$params = FrmForm::list_page_params();
255 255
         $form = FrmForm::duplicate( $params['id'], $params['template'], true );
256
-        $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
256
+        $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' );
257 257
         if ( $form ) {
258 258
 			return self::get_edit_vars( $form, array(), $message, true );
259 259
         } else {
260
-            return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' ));
260
+            return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) );
261 261
         }
262 262
     }
263 263
 
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
     }
317 317
 
318 318
 	public static function bulk_untrash( $ids ) {
319
-        FrmAppHelper::permission_check('frm_edit_forms');
319
+        FrmAppHelper::permission_check( 'frm_edit_forms' );
320 320
 
321 321
         $count = FrmForm::set_status( $ids, 'published' );
322 322
 
323
-        $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
323
+        $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 );
324 324
         return $message;
325 325
     }
326 326
 
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 			'trash'   => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ),
340 340
 		);
341 341
 
342
-		if ( ! isset( $available_status[ $status ] ) ) {
342
+		if ( ! isset( $available_status[$status] ) ) {
343 343
 			return;
344 344
 		}
345 345
 
346
-		FrmAppHelper::permission_check( $available_status[ $status ]['permission'] );
346
+		FrmAppHelper::permission_check( $available_status[$status]['permission'] );
347 347
 
348 348
 		$params = FrmForm::list_page_params();
349 349
 
@@ -351,26 +351,26 @@  discard block
 block discarded – undo
351 351
 		check_admin_referer( $status . '_form_' . $params['id'] );
352 352
 
353 353
 		$count = 0;
354
-		if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
355
-			$count++;
354
+		if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) {
355
+			$count ++;
356 356
 		}
357 357
 
358 358
 		$form_type = FrmAppHelper::get_simple_request( array( 'param' => 'form_type', 'type' => 'request' ) );
359
-		$available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
359
+		$available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count );
360 360
 		$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>' );
361 361
 
362
-		$message = $available_status[ $status ]['message'];
362
+		$message = $available_status[$status]['message'];
363 363
 
364 364
 		self::display_forms_list( $params, $message );
365 365
 	}
366 366
 
367 367
 	public static function bulk_trash( $ids ) {
368
-        FrmAppHelper::permission_check('frm_delete_forms');
368
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
369 369
 
370 370
         $count = 0;
371 371
         foreach ( $ids as $id ) {
372 372
             if ( FrmForm::trash( $id ) ) {
373
-                $count++;
373
+                $count ++;
374 374
             }
375 375
         }
376 376
 
@@ -381,49 +381,49 @@  discard block
 block discarded – undo
381 381
     }
382 382
 
383 383
     public static function destroy() {
384
-        FrmAppHelper::permission_check('frm_delete_forms');
384
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
385 385
 
386 386
 		$params = FrmForm::list_page_params();
387 387
 
388 388
         //check nonce url
389
-        check_admin_referer('destroy_form_' . $params['id']);
389
+        check_admin_referer( 'destroy_form_' . $params['id'] );
390 390
 
391 391
         $count = 0;
392 392
         if ( FrmForm::destroy( $params['id'] ) ) {
393
-            $count++;
393
+            $count ++;
394 394
         }
395 395
 
396
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
396
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
397 397
 
398 398
 		self::display_forms_list( $params, $message );
399 399
     }
400 400
 
401 401
 	public static function bulk_destroy( $ids ) {
402
-        FrmAppHelper::permission_check('frm_delete_forms');
402
+        FrmAppHelper::permission_check( 'frm_delete_forms' );
403 403
 
404 404
         $count = 0;
405 405
         foreach ( $ids as $id ) {
406 406
             $d = FrmForm::destroy( $id );
407 407
             if ( $d ) {
408
-                $count++;
408
+                $count ++;
409 409
             }
410 410
         }
411 411
 
412
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
412
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
413 413
 
414 414
         return $message;
415 415
     }
416 416
 
417 417
     private static function delete_all() {
418 418
         //check nonce url
419
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
419
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
420 420
         if ( $permission_error !== false ) {
421 421
 			self::display_forms_list( array(), '', array( $permission_error ) );
422 422
             return;
423 423
         }
424 424
 
425 425
 		$count = FrmForm::scheduled_delete( time() );
426
-        $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
426
+        $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count );
427 427
 
428 428
 		self::display_forms_list( array(), $message );
429 429
     }
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	* @since 2.0.15
441 441
 	*/
442 442
 	public static function insert_form_button() {
443
-		if ( current_user_can('frm_view_forms') ) {
443
+		if ( current_user_can( 'frm_view_forms' ) ) {
444 444
 			$menu_name = FrmAppHelper::get_menu_name();
445 445
 			$content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">
446 446
 				<span class="frm-buttons-icon wp-media-buttons-icon"></span> ' .
@@ -461,17 +461,17 @@  discard block
 block discarded – undo
461 461
 			'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ),
462 462
         );
463 463
 
464
-        $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes);
464
+        $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes );
465 465
 
466 466
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' );
467 467
     }
468 468
 
469 469
     public static function get_shortcode_opts() {
470
-		FrmAppHelper::permission_check('frm_view_forms');
470
+		FrmAppHelper::permission_check( 'frm_view_forms' );
471 471
         check_ajax_referer( 'frm_ajax', 'nonce' );
472 472
 
473 473
 		$shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
474
-        if ( empty($shortcode) ) {
474
+        if ( empty( $shortcode ) ) {
475 475
             wp_die();
476 476
         }
477 477
 
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
                 );
492 492
             break;
493 493
         }
494
-        $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
494
+        $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
495 495
 
496 496
 		if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
497 497
 			// allow other shortcodes to use the required form id option
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
         }
596 596
 
597 597
         if ( $form->parent_form_id ) {
598
-			wp_die( sprintf( __( '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>' ));
598
+			wp_die( sprintf( __( '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>' ) );
599 599
         }
600 600
 
601 601
 		$frm_field_selection = FrmField::field_selection();
602
-        $fields = FrmField::get_all_for_form($form->id);
602
+        $fields = FrmField::get_all_for_form( $form->id );
603 603
 
604 604
         // Automatically add end section fields if they don't exist (2.0 migration)
605 605
         $reset_fields = false;
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
             $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' );
610 610
         }
611 611
 
612
-        unset($end_section_values, $last_order, $open, $reset_fields);
612
+        unset( $end_section_values, $last_order, $open, $reset_fields );
613 613
 
614 614
 		$args = array( 'parent_form_id' => $form->id );
615 615
         $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args );
@@ -622,8 +622,8 @@  discard block
 block discarded – undo
622 622
 		$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
623 623
 
624 624
         if ( $form->default_template ) {
625
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
626
-        } else if ( defined('DOING_AJAX') ) {
625
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
626
+        } else if ( defined( 'DOING_AJAX' ) ) {
627 627
             wp_die();
628 628
         } else if ( $create_link ) {
629 629
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
@@ -639,21 +639,21 @@  discard block
 block discarded – undo
639 639
 
640 640
         $form = FrmForm::getOne( $id );
641 641
 
642
-        $fields = FrmField::get_all_for_form($id);
643
-        $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true);
642
+        $fields = FrmField::get_all_for_form( $id );
643
+        $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
644 644
 
645
-        if ( isset($values['default_template']) && $values['default_template'] ) {
646
-            wp_die(__( 'That template cannot be edited', 'formidable' ));
645
+        if ( isset( $values['default_template'] ) && $values['default_template'] ) {
646
+            wp_die( __( 'That template cannot be edited', 'formidable' ) );
647 647
         }
648 648
 
649 649
 		self::clean_submit_html( $values );
650 650
 
651 651
         $action_controls = FrmFormActionsController::get_form_actions();
652 652
 
653
-        $sections = apply_filters('frm_add_form_settings_section', array(), $values);
653
+        $sections = apply_filters( 'frm_add_form_settings_section', array(), $values );
654 654
         $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"';
655 655
 
656
-        $styles = apply_filters('frm_get_style_opts', array());
656
+        $styles = apply_filters( 'frm_get_style_opts', array() );
657 657
 
658 658
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' );
659 659
     }
@@ -672,10 +672,10 @@  discard block
 block discarded – undo
672 672
 	}
673 673
 
674 674
     public static function mb_tags_box( $form_id, $class = '' ) {
675
-        $fields = FrmField::get_all_for_form($form_id, '', 'include');
675
+        $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
676 676
         $linked_forms = array();
677 677
         $col = 'one';
678
-        $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false;
678
+        $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false;
679 679
 
680 680
 		$cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() );
681 681
 		$adv_shortcodes = self::get_advanced_shortcodes();
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
 
755 755
     // Insert the form class setting into the form
756 756
 	public static function form_classes( $form ) {
757
-        if ( isset($form->options['form_class']) ) {
757
+        if ( isset( $form->options['form_class'] ) ) {
758 758
 			echo esc_attr( sanitize_text_field( $form->options['form_class'] ) );
759 759
         }
760 760
     }
761 761
 
762 762
     public static function get_email_html() {
763
-		FrmAppHelper::permission_check('frm_view_forms');
763
+		FrmAppHelper::permission_check( 'frm_view_forms' );
764 764
         check_ajax_referer( 'frm_ajax', 'nonce' );
765 765
 		echo FrmEntriesController::show_entry_shortcode( array(
766 766
 			'form_id'       => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ),
@@ -857,11 +857,11 @@  discard block
 block discarded – undo
857 857
     public static function add_default_templates( $path, $default = true, $template = true ) {
858 858
         _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' );
859 859
 
860
-        $path = untrailingslashit(trim($path));
860
+        $path = untrailingslashit( trim( $path ) );
861 861
 		$templates = glob( $path . '/*.php' );
862 862
 
863
-		for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) {
864
-			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) );
863
+		for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) {
864
+			$filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) );
865 865
 			$template_query = array( 'form_key' => $filename );
866 866
             if ( $template ) {
867 867
                 $template_query['is_template'] = 1;
@@ -879,12 +879,12 @@  discard block
 block discarded – undo
879 879
                 $values['default_template'] = 1;
880 880
             }
881 881
 
882
-            include( $templates[ $i ] );
882
+            include( $templates[$i] );
883 883
 
884 884
             //get updated form
885
-            if ( isset($form) && ! empty($form) ) {
885
+            if ( isset( $form ) && ! empty( $form ) ) {
886 886
                 $old_id = $form->id;
887
-                $form = FrmForm::getOne($form->id);
887
+                $form = FrmForm::getOne( $form->id );
888 888
             } else {
889 889
                 $old_id = false;
890 890
 				$form = FrmForm::getAll( $template_query, '', 1 );
@@ -897,24 +897,24 @@  discard block
 block discarded – undo
897 897
     }
898 898
 
899 899
     public static function route() {
900
-        $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
900
+        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
901 901
         $vars = array();
902 902
 		if ( isset( $_POST['frm_compact_fields'] ) ) {
903 903
 			FrmAppHelper::permission_check( 'frm_edit_forms' );
904 904
 
905
-            $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('&quot;', '\\\"', $_POST['frm_compact_fields'] ))));
906
-            $json_vars = json_decode($json_vars, true);
907
-            if ( empty($json_vars) ) {
905
+            $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '&quot;', '\\\"', $_POST['frm_compact_fields'] ) ) ) );
906
+            $json_vars = json_decode( $json_vars, true );
907
+            if ( empty( $json_vars ) ) {
908 908
                 // json decoding failed so we should return an error message
909 909
 				$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
910 910
                 if ( 'edit' == $action ) {
911 911
                     $action = 'update';
912 912
                 }
913 913
 
914
-                add_filter('frm_validate_form', 'FrmFormsController::json_error');
914
+                add_filter( 'frm_validate_form', 'FrmFormsController::json_error' );
915 915
             } else {
916
-                $vars = FrmAppHelper::json_to_array($json_vars);
917
-                $action = $vars[ $action ];
916
+                $vars = FrmAppHelper::json_to_array( $json_vars );
917
+                $action = $vars[$action];
918 918
 				unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] );
919 919
 				$_REQUEST = array_merge( $_REQUEST, $vars );
920 920
 				$_POST = array_merge( $_POST, $_REQUEST );
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 
933 933
         switch ( $action ) {
934 934
             case 'new':
935
-                return self::new_form($vars);
935
+                return self::new_form( $vars );
936 936
             case 'create':
937 937
             case 'edit':
938 938
             case 'update':
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 					$action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
956 956
                 }
957 957
 
958
-                if ( strpos($action, 'bulk_') === 0 ) {
958
+                if ( strpos( $action, 'bulk_' ) === 0 ) {
959 959
                     FrmAppHelper::remove_get_action();
960 960
                     return self::list_form();
961 961
                 }
@@ -982,19 +982,19 @@  discard block
 block discarded – undo
982 982
 
983 983
 	public static function admin_bar_configure() {
984 984
         global $frm_vars;
985
-        if ( empty($frm_vars['forms_loaded']) ) {
985
+        if ( empty( $frm_vars['forms_loaded'] ) ) {
986 986
             return;
987 987
         }
988 988
 
989 989
         $actions = array();
990 990
         foreach ( $frm_vars['forms_loaded'] as $form ) {
991
-            if ( is_object($form) ) {
992
-                $actions[ $form->id ] = $form->name;
991
+            if ( is_object( $form ) ) {
992
+                $actions[$form->id] = $form->name;
993 993
             }
994
-            unset($form);
994
+            unset( $form );
995 995
         }
996 996
 
997
-        if ( empty($actions) ) {
997
+        if ( empty( $actions ) ) {
998 998
             return;
999 999
         }
1000 1000
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
     //formidable shortcode
1041 1041
 	public static function get_form_shortcode( $atts ) {
1042 1042
         global $frm_vars;
1043
-        if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) {
1043
+        if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
1044 1044
             $sc = '[formidable';
1045 1045
 			if ( ! empty( $atts ) ) {
1046 1046
 				foreach ( $atts as $k => $v ) {
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
             'id' => '', 'key' => '', 'title' => false, 'description' => false,
1055 1055
             'readonly' => false, 'entry_id' => false, 'fields' => array(),
1056 1056
             'exclude_fields' => array(), 'minimize' => false,
1057
-        ), $atts);
1058
-        do_action('formidable_shortcode_atts', $shortcode_atts, $atts);
1057
+        ), $atts );
1058
+        do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts );
1059 1059
 
1060 1060
         return self::show_form(
1061 1061
             $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'],
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 	private static function get_saved_errors( $form, $params ) {
1191 1191
 		global $frm_vars;
1192 1192
 
1193
-		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) {
1194
-			$errors = $frm_vars['created_entries'][ $form->id ]['errors'];
1193
+		if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) {
1194
+			$errors = $frm_vars['created_entries'][$form->id]['errors'];
1195 1195
 		} else {
1196 1196
 			$errors = array();
1197 1197
 		}
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 	 */
1204 1204
 	public static function just_created_entry( $form_id ) {
1205 1205
 		global $frm_vars;
1206
-		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;
1206
+		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;
1207 1207
 	}
1208 1208
 
1209 1209
 	/**
Please login to merge, or discard this patch.