Completed
Push — master ( adc45b...f024e3 )
by Jamie
03:50
created
classes/helpers/FrmEntriesListHelper.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 			$join_form_in_query = true;
24 24
 		}
25 25
 
26
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
26
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
27 27
 
28 28
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
29 29
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	    }
32 32
 
33 33
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
34
-        if ( strpos($orderby, 'meta') !== false ) {
34
+        if ( strpos( $orderby, 'meta' ) !== false ) {
35 35
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
36 36
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
37 37
         }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
44 44
 
45 45
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query );
46
-        $total_items = FrmEntry::getRecordCount($s_query);
46
+        $total_items = FrmEntry::getRecordCount( $s_query );
47 47
 
48 48
 		$this->set_pagination_args( array(
49 49
 			'total_items' => $total_items,
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 	public function no_items() {
55 55
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
56
-	    if ( ! empty($s) ) {
56
+	    if ( ! empty( $s ) ) {
57 57
             _e( 'No Entries Found', 'formidable' );
58 58
             return;
59 59
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$form = $this->params['form'];
63 63
 
64 64
         if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
65
+            $form = FrmForm::getOne( $form_id );
66 66
         }
67 67
         $colspan = $this->get_column_count();
68 68
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 		$r = "<tr id='item-action-{$item->id}'$style>";
122 122
 
123
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
123
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
124 124
         $action_col = false;
125 125
 
126 126
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             }
138 138
 
139 139
 			$attributes = 'class="' . esc_attr( $class ) . '"';
140
-			unset($class);
140
+			unset( $class );
141 141
 			$attributes .= ' data-colname="' . $column_display_name . '"';
142 142
 
143 143
 			$form_id = $this->params['form'] ? $this->params['form'] : 0;
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
155 155
 				    break;
156 156
 				case 'name':
157 157
 				case 'description':
158
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
158
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
159 159
 				    break;
160 160
 				case 'created_at':
161 161
 				case 'updated_at':
162
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
162
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
163 163
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
164 164
 					break;
165 165
 				case 'is_draft':
166
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
166
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
167 167
 			        break;
168 168
 				case 'form_id':
169
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
169
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
170 170
     				break;
171 171
 				case 'post_id':
172
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
172
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
173 173
 				    break;
174 174
 				case 'user_id':
175
-				    $user = get_userdata($item->user_id);
175
+				    $user = get_userdata( $item->user_id );
176 176
 				    $val = $user ? $user->user_login : '';
177 177
 				    break;
178 178
 				default:
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 			    }
195 195
 			    $r .= '</td>';
196 196
 			}
197
-			unset($val);
197
+			unset( $val );
198 198
 		}
199 199
 		$r .= '</tr>';
200 200
 
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
     private function get_actions( &$actions, $item, $view_link ) {
208 208
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
209 209
 
210
-        if ( current_user_can('frm_delete_entries') ) {
210
+        if ( current_user_can( 'frm_delete_entries' ) ) {
211 211
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
212 212
 			$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>';
213 213
 	    }
214 214
 
215
-        $actions = apply_filters('frm_row_actions', $actions, $item);
215
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
216 216
     }
217 217
 
218 218
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 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
 		$default_orderby = 'id';
15 15
 		$default_order = 'DESC';
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 
26 26
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
27 27
 
28
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
29
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
30
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
31
-	    }
28
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
29
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
30
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
31
+		}
32 32
 
33
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
34
-        if ( strpos($orderby, 'meta') !== false ) {
35
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
33
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
34
+		if ( strpos($orderby, 'meta') !== false ) {
35
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
36 36
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
37
-        }
37
+		}
38 38
 
39 39
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
40 40
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
41 41
 
42
-        $page = $this->get_pagenum();
42
+		$page = $this->get_pagenum();
43 43
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
44 44
 
45 45
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, $join_form_in_query );
46
-        $total_items = FrmEntry::getRecordCount($s_query);
46
+		$total_items = FrmEntry::getRecordCount($s_query);
47 47
 
48 48
 		$this->set_pagination_args( array(
49 49
 			'total_items' => $total_items,
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	public function no_items() {
55
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
56
-	    if ( ! empty($s) ) {
57
-            _e( 'No Entries Found', 'formidable' );
58
-            return;
59
-        }
55
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
56
+		if ( ! empty($s) ) {
57
+			_e( 'No Entries Found', 'formidable' );
58
+			return;
59
+		}
60 60
 
61 61
 		$form_id = $this->params['form'];
62 62
 		$form = $this->params['form'];
63 63
 
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68 68
 
69 69
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	}
85 85
 
86 86
 	/**
87
-	* Gets the name of the primary column in the Entries screen
88
-	*
89
-	* @since 2.0.14
90
-	*
91
-	* @return string $primary_column
92
-	*/
87
+	 * Gets the name of the primary column in the Entries screen
88
+	 *
89
+	 * @since 2.0.14
90
+	 *
91
+	 * @return string $primary_column
92
+	 */
93 93
 	protected function get_primary_column_name() {
94 94
 		$columns = get_column_headers( $this->screen );
95 95
 		$hidden = get_hidden_columns( $this->screen );
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->get_actions( $actions, $item, $view_link );
115 115
 
116
-        $action_links = $this->row_actions( $actions );
116
+		$action_links = $this->row_actions( $actions );
117 117
 
118 118
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
119 119
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		$r = "<tr id='item-action-{$item->id}'$style>";
122 122
 
123 123
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
124
-        $action_col = false;
124
+		$action_col = false;
125 125
 
126 126
 		foreach ( $columns as $column_name => $column_display_name ) {
127 127
 			$class = $column_name . ' column-' . $column_name;
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 			if ( in_array( $column_name, $hidden ) ) {
134 134
 				$class .= ' frm_hidden';
135 135
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
136
-			    $action_col = $column_name;
137
-            }
136
+				$action_col = $column_name;
137
+			}
138 138
 
139 139
 			$attributes = 'class="' . esc_attr( $class ) . '"';
140 140
 			unset($class);
@@ -152,30 +152,30 @@  discard block
 block discarded – undo
152 152
 				case 'ip':
153 153
 				case 'id':
154 154
 				case 'item_key':
155
-				    $val = $item->{$col_name};
156
-				    break;
155
+					$val = $item->{$col_name};
156
+					break;
157 157
 				case 'name':
158 158
 				case 'description':
159
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
160
-				    break;
159
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
160
+					break;
161 161
 				case 'created_at':
162 162
 				case 'updated_at':
163
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
163
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
164 164
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
165 165
 					break;
166 166
 				case 'is_draft':
167
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
168
-			        break;
167
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
168
+					break;
169 169
 				case 'form_id':
170
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
171
-    				break;
170
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
171
+					break;
172 172
 				case 'post_id':
173
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
174
-				    break;
173
+					$val = FrmAppHelper::post_edit_link($item->post_id);
174
+					break;
175 175
 				case 'user_id':
176
-				    $user = get_userdata($item->user_id);
177
-				    $val = $user ? $user->user_login : '';
178
-				    break;
176
+					$user = get_userdata($item->user_id);
177
+					$val = $user ? $user->user_login : '';
178
+					break;
179 179
 				default:
180 180
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
181 181
 					if ( $val === false ) {
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 			}
186 186
 
187 187
 			if ( $col_name != 'cb' ) {
188
-			    $r .= "<td $attributes>";
188
+				$r .= "<td $attributes>";
189 189
 				if ( $column_name == $action_col ) {
190 190
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
191 191
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
192
-			        $r .= $action_links;
192
+					$r .= $action_links;
193 193
 				} else {
194
-			        $r .= $val;
195
-			    }
196
-			    $r .= '</td>';
194
+					$r .= $val;
195
+				}
196
+				$r .= '</td>';
197 197
 			}
198 198
 			unset($val);
199 199
 		}
@@ -202,19 +202,19 @@  discard block
 block discarded – undo
202 202
 		return $r;
203 203
 	}
204 204
 
205
-    /**
206
-     * @param string $view_link
207
-     */
208
-    private function get_actions( &$actions, $item, $view_link ) {
205
+	/**
206
+	 * @param string $view_link
207
+	 */
208
+	private function get_actions( &$actions, $item, $view_link ) {
209 209
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
210 210
 
211
-        if ( current_user_can('frm_delete_entries') ) {
211
+		if ( current_user_can('frm_delete_entries') ) {
212 212
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
213 213
 			$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>';
214
-	    }
214
+		}
215 215
 
216
-        $actions = apply_filters('frm_row_actions', $actions, $item);
217
-    }
216
+		$actions = apply_filters('frm_row_actions', $actions, $item);
217
+	}
218 218
 
219 219
 	private function get_column_value( $item, &$val ) {
220 220
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
classes/controllers/FrmFieldsController.php 2 patches
Indentation   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -2,129 +2,129 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmFieldsController {
4 4
 
5
-    public static function load_field() {
5
+	public static function load_field() {
6 6
 		FrmAppHelper::permission_check('frm_edit_forms');
7
-        check_ajax_referer( 'frm_ajax', 'nonce' );
7
+		check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9
-        $fields = $_POST['field'];
10
-        if ( empty( $fields ) ) {
11
-            wp_die();
12
-        }
9
+		$fields = $_POST['field'];
10
+		if ( empty( $fields ) ) {
11
+			wp_die();
12
+		}
13 13
 
14
-        $_GET['page'] = 'formidable';
15
-        $fields = stripslashes_deep( $fields );
14
+		$_GET['page'] = 'formidable';
15
+		$fields = stripslashes_deep( $fields );
16 16
 
17
-        $ajax = true;
17
+		$ajax = true;
18 18
 		$values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) );
19
-        $path = FrmAppHelper::plugin_path();
20
-        $field_html = array();
21
-
22
-        foreach ( $fields as $field ) {
23
-            $field = htmlspecialchars_decode( nl2br( $field ) );
24
-            $field = json_decode( $field, true );
25
-            if ( ! isset( $field['id'] ) ) {
26
-                // this field may have already been loaded
27
-                continue;
28
-            }
19
+		$path = FrmAppHelper::plugin_path();
20
+		$field_html = array();
21
+
22
+		foreach ( $fields as $field ) {
23
+			$field = htmlspecialchars_decode( nl2br( $field ) );
24
+			$field = json_decode( $field, true );
25
+			if ( ! isset( $field['id'] ) ) {
26
+				// this field may have already been loaded
27
+				continue;
28
+			}
29 29
 
30
-            $field_id = absint( $field['id'] );
30
+			$field_id = absint( $field['id'] );
31 31
 
32
-            if ( ! isset( $field['value'] ) ) {
33
-                $field['value'] = '';
34
-            }
32
+			if ( ! isset( $field['value'] ) ) {
33
+				$field['value'] = '';
34
+			}
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+			$html_id = FrmFieldsHelper::get_html_id($field);
38 38
 
39
-            ob_start();
39
+			ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
42
-            ob_end_clean();
43
-        }
41
+			$field_html[ $field_id ] = ob_get_contents();
42
+			ob_end_clean();
43
+		}
44 44
 
45
-        unset($path);
45
+		unset($path);
46 46
 
47
-        echo json_encode($field_html);
47
+		echo json_encode($field_html);
48 48
 
49
-        wp_die();
50
-    }
49
+		wp_die();
50
+	}
51 51
 
52 52
 	/**
53 53
 	 * Create a new field with ajax
54 54
 	 */
55
-    public static function create() {
55
+	public static function create() {
56 56
 		FrmAppHelper::permission_check('frm_edit_forms');
57
-        check_ajax_referer( 'frm_ajax', 'nonce' );
57
+		check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
60 60
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
61 61
 
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64
-        // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
64
+		// this hook will allow for multiple fields to be added at once
65
+		do_action('frm_after_field_created', $field, $form_id);
66 66
 
67
-        wp_die();
68
-    }
67
+		wp_die();
68
+	}
69 69
 
70
-    /**
71
-     * Set up and create a new field
72
-     *
73
-     * @param string $field_type
74
-     * @param integer $form_id
75
-     * @return array|bool
76
-     */
70
+	/**
71
+	 * Set up and create a new field
72
+	 *
73
+	 * @param string $field_type
74
+	 * @param integer $form_id
75
+	 * @return array|bool
76
+	 */
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78
-        $values = array();
79
-        if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
-        }
78
+		$values = array();
79
+		if ( FrmAppHelper::pro_is_installed() ) {
80
+			$values['post_type'] = FrmProFormsHelper::post_type($form_id);
81
+		}
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
84
-        $field_values = apply_filters( 'frm_before_field_created', $field_values );
84
+		$field_values = apply_filters( 'frm_before_field_created', $field_values );
85 85
 
86
-        $field_id = FrmField::create( $field_values );
86
+		$field_id = FrmField::create( $field_values );
87 87
 
88
-        if ( ! $field_id ) {
89
-            return false;
90
-        }
88
+		if ( ! $field_id ) {
89
+			return false;
90
+		}
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+		$field = self::include_single_field($field_id, $values, $form_id);
93 93
 
94
-        return $field;
95
-    }
94
+		return $field;
95
+	}
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98 98
 		FrmAppHelper::permission_check('frm_edit_forms');
99
-        check_ajax_referer( 'frm_ajax', 'nonce' );
99
+		check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
102
-            $field = 'name';
103
-        }
101
+		if ( empty($field) ) {
102
+			$field = 'name';
103
+		}
104 104
 
105
-        if ( empty($id) ) {
105
+		if ( empty($id) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108
-        }
108
+		}
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
113
-            // set blank value if there is no content
114
-            $value = '';
115
-        }
112
+		if ( trim(strip_tags($value)) == '' ) {
113
+			// set blank value if there is no content
114
+			$value = '';
115
+		}
116 116
 
117 117
 		FrmField::update( $id, array( $field => $value ) );
118 118
 
119 119
 		do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) );
120 120
 
121 121
 		echo stripslashes( wp_kses_post( $value ) );
122
-        wp_die();
123
-    }
122
+		wp_die();
123
+	}
124 124
 
125
-    public static function update_ajax_option() {
125
+	public static function update_ajax_option() {
126 126
 		FrmAppHelper::permission_check('frm_edit_forms');
127
-        check_ajax_referer( 'frm_ajax', 'nonce' );
127
+		check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
130 130
 		if ( ! $field_id ) {
@@ -139,252 +139,252 @@  discard block
 block discarded – undo
139 139
 			unset($new_val);
140 140
 		}
141 141
 
142
-        FrmField::update( $field_id, array(
143
-            'field_options' => $field->field_options,
142
+		FrmField::update( $field_id, array(
143
+			'field_options' => $field->field_options,
144 144
 			'form_id'		=> $field->form_id,
145
-        ) );
146
-        wp_die();
147
-    }
145
+		) );
146
+		wp_die();
147
+	}
148 148
 
149
-    public static function duplicate() {
149
+	public static function duplicate() {
150 150
 		FrmAppHelper::permission_check('frm_edit_forms');
151
-        check_ajax_referer( 'frm_ajax', 'nonce' );
151
+		check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153
-        global $wpdb;
153
+		global $wpdb;
154 154
 
155 155
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
156 156
 		$form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
157 157
 
158 158
 		$copy_field = FrmField::getOne( $field_id );
159
-        if ( ! $copy_field ) {
160
-            wp_die();
161
-        }
159
+		if ( ! $copy_field ) {
160
+			wp_die();
161
+		}
162 162
 
163 163
 		do_action( 'frm_duplicate_field', $copy_field, $form_id );
164 164
 		do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id );
165 165
 
166 166
 		$values = array();
167
-        FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
167
+		FrmFieldsHelper::fill_field( $values, $copy_field, $form_id );
168 168
 
169 169
 		$field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) );
170 170
 
171
-        $values['field_order'] = $field_count + 1;
171
+		$values['field_order'] = $field_count + 1;
172 172
 
173
-	    $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
173
+		$values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
174 174
 
175 175
 		$field_id = FrmField::create( $values );
176 176
 		if ( ! $field_id ) {
177 177
 			wp_die();
178 178
 		}
179 179
 
180
-        self::include_single_field($field_id, $values);
180
+		self::include_single_field($field_id, $values);
181 181
 
182
-        wp_die();
183
-    }
182
+		wp_die();
183
+	}
184 184
 
185
-    /**
186
-     * Load a single field in the form builder along with all needed variables
187
-     */
188
-    public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
185
+	/**
186
+	 * Load a single field in the form builder along with all needed variables
187
+	 */
188
+	public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
+		$field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
190 190
 		$field_name = 'item_meta[' . $field_id . ']';
191
-        $html_id = FrmFieldsHelper::get_html_id($field);
192
-        $id = $form_id ? $form_id : $field['form_id'];
193
-        if ( $field['type'] == 'html' ) {
194
-            $field['stop_filter'] = true;
195
-        }
191
+		$html_id = FrmFieldsHelper::get_html_id($field);
192
+		$id = $form_id ? $form_id : $field['form_id'];
193
+		if ( $field['type'] == 'html' ) {
194
+			$field['stop_filter'] = true;
195
+		}
196 196
 
197 197
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' );
198 198
 
199
-        return $field;
200
-    }
199
+		return $field;
200
+	}
201 201
 
202
-    public static function destroy() {
202
+	public static function destroy() {
203 203
 		FrmAppHelper::permission_check('frm_edit_forms');
204
-        check_ajax_referer( 'frm_ajax', 'nonce' );
204
+		check_ajax_referer( 'frm_ajax', 'nonce' );
205 205
 
206 206
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
207 207
 		FrmField::destroy( $field_id );
208
-        wp_die();
209
-    }
208
+		wp_die();
209
+	}
210 210
 
211
-    /* Field Options */
211
+	/* Field Options */
212 212
 
213
-    //Add Single Option or Other Option
214
-    public static function add_option() {
213
+	//Add Single Option or Other Option
214
+	public static function add_option() {
215 215
 		FrmAppHelper::permission_check('frm_edit_forms');
216
-        check_ajax_referer( 'frm_ajax', 'nonce' );
216
+		check_ajax_referer( 'frm_ajax', 'nonce' );
217 217
 
218 218
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219 219
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220 220
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' );
221 221
 
222
-        $field = FrmField::getOne($id);
222
+		$field = FrmField::getOne($id);
223 223
 
224
-        if ( 'other' == $opt_type ) {
224
+		if ( 'other' == $opt_type ) {
225 225
 			$opt = __( 'Other', 'formidable' );
226
-            $other_val = '';
227
-            $opt_key = 'other_' . $opt_key;
228
-        } else {
226
+			$other_val = '';
227
+			$opt_key = 'other_' . $opt_key;
228
+		} else {
229 229
 			$opt = __( 'New Option', 'formidable' );
230
-        }
231
-        $field_val = $opt;
230
+		}
231
+		$field_val = $opt;
232 232
 
233
-        $field_data = $field;
233
+		$field_data = $field;
234 234
 		$field = (array) $field;
235 235
 		$field['separate_value'] = isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0;
236 236
 		unset( $field_data );
237 237
 
238 238
 		$field_name = 'item_meta[' . $id . ']';
239 239
 		$html_id = FrmFieldsHelper::get_html_id( $field );
240
-        $checked = '';
240
+		$checked = '';
241 241
 
242
-        if ( 'other' == $opt_type ) {
242
+		if ( 'other' == $opt_type ) {
243 243
 			include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' );
244
-        } else {
244
+		} else {
245 245
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
246
-        }
247
-        wp_die();
248
-    }
246
+		}
247
+		wp_die();
248
+	}
249 249
 
250
-    public static function edit_option() {
250
+	public static function edit_option() {
251 251
 		_deprecated_function( __FUNCTION__, '2.3' );
252
-    }
252
+	}
253 253
 
254
-    public static function delete_option() {
254
+	public static function delete_option() {
255 255
 		_deprecated_function( __FUNCTION__, '2.3' );
256
-    }
256
+	}
257 257
 
258
-    public static function import_choices() {
259
-        FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
258
+	public static function import_choices() {
259
+		FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' );
260 260
 
261 261
 		$field_id = absint( $_REQUEST['field_id'] );
262 262
 
263
-        global $current_screen, $hook_suffix;
263
+		global $current_screen, $hook_suffix;
264 264
 
265
-        // Catch plugins that include admin-header.php before admin.php completes.
266
-        if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
267
-            $hook_suffix = '';
268
-        	set_current_screen();
269
-        }
265
+		// Catch plugins that include admin-header.php before admin.php completes.
266
+		if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) {
267
+			$hook_suffix = '';
268
+			set_current_screen();
269
+		}
270 270
 
271
-        if ( function_exists( 'register_admin_color_schemes' ) ) {
272
-            register_admin_color_schemes();
273
-        }
271
+		if ( function_exists( 'register_admin_color_schemes' ) ) {
272
+			register_admin_color_schemes();
273
+		}
274 274
 
275 275
 		$hook_suffix = '';
276 276
 		$admin_body_class = '';
277 277
 
278
-        if ( get_user_setting( 'mfold' ) == 'f' ) {
279
-        	$admin_body_class .= ' folded';
280
-        }
278
+		if ( get_user_setting( 'mfold' ) == 'f' ) {
279
+			$admin_body_class .= ' folded';
280
+		}
281 281
 
282
-        if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
283
-        	$admin_body_class .= ' admin-bar';
284
-        }
282
+		if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) {
283
+			$admin_body_class .= ' admin-bar';
284
+		}
285 285
 
286
-        if ( is_rtl() ) {
287
-        	$admin_body_class .= ' rtl';
288
-        }
286
+		if ( is_rtl() ) {
287
+			$admin_body_class .= ' rtl';
288
+		}
289 289
 
290
-        $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
291
-        $prepop = array();
292
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
290
+		$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
291
+		$prepop = array();
292
+		FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
293 293
 
294
-        $field = FrmField::getOne($field_id);
294
+		$field = FrmField::getOne($field_id);
295 295
 
296
-        wp_enqueue_script( 'utils' );
296
+		wp_enqueue_script( 'utils' );
297 297
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
298
-        FrmAppHelper::load_admin_wide_js();
298
+		FrmAppHelper::load_admin_wide_js();
299 299
 
300 300
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' );
301
-        wp_die();
302
-    }
301
+		wp_die();
302
+	}
303 303
 
304
-    public static function import_options() {
304
+	public static function import_options() {
305 305
 		FrmAppHelper::permission_check('frm_edit_forms');
306
-        check_ajax_referer( 'frm_ajax', 'nonce' );
306
+		check_ajax_referer( 'frm_ajax', 'nonce' );
307 307
 
308
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
309
-            return;
310
-        }
308
+		if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
309
+			return;
310
+		}
311 311
 
312 312
 		$field_id = absint( $_POST['field_id'] );
313
-        $field = FrmField::getOne($field_id);
313
+		$field = FrmField::getOne($field_id);
314 314
 
315 315
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
316
-            return;
317
-        }
316
+			return;
317
+		}
318 318
 
319
-        $field = FrmFieldsHelper::setup_edit_vars($field);
319
+		$field = FrmFieldsHelper::setup_edit_vars($field);
320 320
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
321 321
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
322 322
 		$opts = array_map( 'trim', $opts );
323 323
 
324
-        if ( $field['separate_value'] ) {
325
-            foreach ( $opts as $opt_key => $opt ) {
326
-                if ( strpos($opt, '|') !== false ) {
327
-                    $vals = explode('|', $opt);
328
-                    if ( $vals[0] != $vals[1] ) {
329
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
330
-                    }
331
-                    unset($vals);
332
-                }
333
-                unset($opt_key, $opt);
334
-            }
335
-        }
336
-
337
-        //Keep other options after bulk update
338
-        if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
339
-            $other_array = array();
340
-            foreach ( $field['options'] as $opt_key => $opt ) {
324
+		if ( $field['separate_value'] ) {
325
+			foreach ( $opts as $opt_key => $opt ) {
326
+				if ( strpos($opt, '|') !== false ) {
327
+					$vals = explode('|', $opt);
328
+					if ( $vals[0] != $vals[1] ) {
329
+						$opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
330
+					}
331
+					unset($vals);
332
+				}
333
+				unset($opt_key, $opt);
334
+			}
335
+		}
336
+
337
+		//Keep other options after bulk update
338
+		if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) {
339
+			$other_array = array();
340
+			foreach ( $field['options'] as $opt_key => $opt ) {
341 341
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
342 342
 					$other_array[ $opt_key ] = $opt;
343 343
 				}
344
-                unset($opt_key, $opt);
345
-            }
346
-            if ( ! empty($other_array) ) {
347
-                $opts = array_merge( $opts, $other_array);
348
-            }
349
-        }
344
+				unset($opt_key, $opt);
345
+			}
346
+			if ( ! empty($other_array) ) {
347
+				$opts = array_merge( $opts, $other_array);
348
+			}
349
+		}
350 350
 
351
-        $field['options'] = $opts;
351
+		$field['options'] = $opts;
352 352
 
353
-        if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
353
+		if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) {
354 354
 			$field_name = 'item_meta[' . $field['id'] . ']';
355 355
 
356 356
 			// Get html_id which will be used in single-option.php
357 357
 			$html_id = FrmFieldsHelper::get_html_id( $field );
358 358
 
359 359
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
360
-        } else {
361
-            FrmFieldsHelper::show_single_option($field);
362
-        }
360
+		} else {
361
+			FrmFieldsHelper::show_single_option($field);
362
+		}
363 363
 
364
-        wp_die();
365
-    }
364
+		wp_die();
365
+	}
366 366
 
367
-    public static function update_order() {
367
+	public static function update_order() {
368 368
 		FrmAppHelper::permission_check('frm_edit_forms');
369
-        check_ajax_referer( 'frm_ajax', 'nonce' );
369
+		check_ajax_referer( 'frm_ajax', 'nonce' );
370 370
 
371 371
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
372 372
 		foreach ( (array) $fields as $position => $item ) {
373 373
 			FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) );
374 374
 		}
375
-        wp_die();
376
-    }
375
+		wp_die();
376
+	}
377 377
 
378 378
 	public static function change_type( $type ) {
379
-        $type_switch = array(
380
-            'scale'     => 'radio',
381
-            '10radio'   => 'radio',
382
-            'rte'       => 'textarea',
383
-            'website'   => 'url',
384
-        );
385
-        if ( isset( $type_switch[ $type ] ) ) {
386
-            $type = $type_switch[ $type ];
387
-        }
379
+		$type_switch = array(
380
+			'scale'     => 'radio',
381
+			'10radio'   => 'radio',
382
+			'rte'       => 'textarea',
383
+			'website'   => 'url',
384
+		);
385
+		if ( isset( $type_switch[ $type ] ) ) {
386
+			$type = $type_switch[ $type ];
387
+		}
388 388
 
389 389
 		$pro_fields = FrmField::pro_field_selection();
390 390
 		$types = array_keys( $pro_fields );
@@ -392,137 +392,137 @@  discard block
 block discarded – undo
392 392
 			$type = 'text';
393 393
 		}
394 394
 
395
-        return $type;
396
-    }
395
+		return $type;
396
+	}
397 397
 
398 398
 	public static function display_field_options( $display ) {
399 399
 		switch ( $display['type'] ) {
400
-            case 'captcha':
401
-                $display['required'] = false;
402
-                $display['invalid'] = true;
403
-                $display['default_blank'] = false;
400
+			case 'captcha':
401
+				$display['required'] = false;
402
+				$display['invalid'] = true;
403
+				$display['default_blank'] = false;
404 404
 				$display['captcha_size'] = true;
405
-            break;
406
-            case 'radio':
407
-                $display['default_blank'] = false;
408
-            break;
409
-            case 'text':
410
-            case 'textarea':
411
-                $display['size'] = true;
412
-                $display['clear_on_focus'] = true;
413
-            break;
414
-            case 'select':
415
-                $display['size'] = true;
416
-            break;
417
-            case 'url':
418
-            case 'website':
419
-            case 'email':
420
-                $display['size'] = true;
421
-                $display['clear_on_focus'] = true;
422
-                $display['invalid'] = true;
423
-        }
424
-
425
-        return $display;
426
-    }
427
-
428
-    public static function input_html( $field, $echo = true ) {
429
-        $class = array(); //$field['type'];
430
-        self::add_input_classes($field, $class);
431
-
432
-        $add_html = array();
433
-        self::add_html_size($field, $add_html);
434
-        self::add_html_length($field, $add_html);
435
-        self::add_html_placeholder($field, $add_html, $class);
405
+			break;
406
+			case 'radio':
407
+				$display['default_blank'] = false;
408
+			break;
409
+			case 'text':
410
+			case 'textarea':
411
+				$display['size'] = true;
412
+				$display['clear_on_focus'] = true;
413
+			break;
414
+			case 'select':
415
+				$display['size'] = true;
416
+			break;
417
+			case 'url':
418
+			case 'website':
419
+			case 'email':
420
+				$display['size'] = true;
421
+				$display['clear_on_focus'] = true;
422
+				$display['invalid'] = true;
423
+		}
424
+
425
+		return $display;
426
+	}
427
+
428
+	public static function input_html( $field, $echo = true ) {
429
+		$class = array(); //$field['type'];
430
+		self::add_input_classes($field, $class);
431
+
432
+		$add_html = array();
433
+		self::add_html_size($field, $add_html);
434
+		self::add_html_length($field, $add_html);
435
+		self::add_html_placeholder($field, $add_html, $class);
436 436
 		self::add_validation_messages( $field, $add_html );
437 437
 
438
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
438
+		$class = apply_filters('frm_field_classes', implode(' ', $class), $field);
439 439
 
440 440
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
441 441
 
442
-        self::add_shortcodes_to_html($field, $add_html);
442
+		self::add_shortcodes_to_html($field, $add_html);
443 443
 
444 444
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
445 445
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
446 446
 
447
-        if ( $echo ) {
448
-            echo $add_html;
449
-        }
447
+		if ( $echo ) {
448
+			echo $add_html;
449
+		}
450 450
 
451
-        return $add_html;
452
-    }
451
+		return $add_html;
452
+	}
453 453
 
454 454
 	private static function add_input_classes( $field, array &$class ) {
455
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
456
-            $class[] = $field['input_class'];
457
-        }
455
+		if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
456
+			$class[] = $field['input_class'];
457
+		}
458 458
 
459
-        if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
460
-            return;
461
-        }
459
+		if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) {
460
+			return;
461
+		}
462 462
 
463
-        if ( isset($field['size']) && $field['size'] > 0 ) {
464
-            $class[] = 'auto_width';
465
-        }
466
-    }
463
+		if ( isset($field['size']) && $field['size'] > 0 ) {
464
+			$class[] = 'auto_width';
465
+		}
466
+	}
467 467
 
468 468
 	private static function add_html_size( $field, array &$add_html ) {
469 469
 		if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) {
470
-            return;
471
-        }
470
+			return;
471
+		}
472 472
 
473
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
474
-            return;
475
-        }
473
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
474
+			return;
475
+		}
476 476
 
477
-        if ( is_numeric($field['size']) ) {
478
-            $field['size'] .= 'px';
479
-        }
477
+		if ( is_numeric($field['size']) ) {
478
+			$field['size'] .= 'px';
479
+		}
480 480
 
481
-        $important = apply_filters('frm_use_important_width', 1, $field);
482
-        // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
481
+		$important = apply_filters('frm_use_important_width', 1, $field);
482
+		// Note: This inline styling must stay since we cannot realistically set a class for every possible field size
483 483
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
484 484
 
485
-        self::add_html_cols($field, $add_html);
486
-    }
485
+		self::add_html_cols($field, $add_html);
486
+	}
487 487
 
488 488
 	private static function add_html_cols( $field, array &$add_html ) {
489 489
 		if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) {
490
-            return;
491
-        }
490
+			return;
491
+		}
492 492
 
493
-        // convert to cols for textareas
494
-        $calc = array(
495
-            ''      => 9,
496
-            'px'    => 9,
497
-            'rem'   => 0.444,
498
-            'em'    => 0.544,
499
-        );
493
+		// convert to cols for textareas
494
+		$calc = array(
495
+			''      => 9,
496
+			'px'    => 9,
497
+			'rem'   => 0.444,
498
+			'em'    => 0.544,
499
+		);
500 500
 
501
-        // include "col" for valid html
502
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
501
+		// include "col" for valid html
502
+		$unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
503 503
 
504
-        if ( ! isset( $calc[ $unit ] ) ) {
505
-            return;
506
-        }
504
+		if ( ! isset( $calc[ $unit ] ) ) {
505
+			return;
506
+		}
507 507
 
508
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
508
+		$size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
509 509
 
510 510
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
511
-    }
511
+	}
512 512
 
513 513
 	private static function add_html_length( $field, array &$add_html ) {
514
-        // check for max setting and if this field accepts maxlength
514
+		// check for max setting and if this field accepts maxlength
515 515
 		if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) {
516
-            return;
517
-        }
516
+			return;
517
+		}
518 518
 
519
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
520
-            // don't load on form builder page
521
-            return;
522
-        }
519
+		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
520
+			// don't load on form builder page
521
+			return;
522
+		}
523 523
 
524 524
 		$add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"';
525
-    }
525
+	}
526 526
 
527 527
 	private static function add_html_placeholder( $field, array &$add_html, array &$class ) {
528 528
 		if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) {
@@ -530,35 +530,35 @@  discard block
 block discarded – undo
530 530
 		}
531 531
 
532 532
 		$default_value_array = is_array( $field['default_value'] );
533
-        if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
533
+		if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
534 534
 			if ( $default_value_array ) {
535 535
 				$field['default_value'] = json_encode( $field['default_value'] );
536 536
 			}
537 537
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"';
538
-            return;
539
-        }
538
+			return;
539
+		}
540 540
 
541 541
 		if ( $default_value_array ) {
542 542
 			// don't include a json placeholder
543 543
 			return;
544 544
 		}
545 545
 
546
-        $frm_settings = FrmAppHelper::get_settings();
546
+		$frm_settings = FrmAppHelper::get_settings();
547 547
 
548 548
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
549
-            // use HMTL5 placeholder with js fallback
549
+			// use HMTL5 placeholder with js fallback
550 550
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
551
-            wp_enqueue_script('jquery-placeholder');
552
-        } else if ( ! $frm_settings->use_html ) {
551
+			wp_enqueue_script('jquery-placeholder');
552
+		} else if ( ! $frm_settings->use_html ) {
553 553
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
554 554
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
555
-            $class[] = 'frm_toggle_default';
555
+			$class[] = 'frm_toggle_default';
556 556
 
557
-            if ( $field['value'] == $field['default_value'] ) {
558
-                $class[] = 'frm_default';
559
-            }
560
-        }
561
-    }
557
+			if ( $field['value'] == $field['default_value'] ) {
558
+				$class[] = 'frm_default';
559
+			}
560
+		}
561
+	}
562 562
 
563 563
 	private static function add_validation_messages( $field, array &$add_html ) {
564 564
 		if ( FrmField::is_required( $field ) ) {
@@ -572,44 +572,44 @@  discard block
 block discarded – undo
572 572
 		}
573 573
 	}
574 574
 
575
-    private static function add_shortcodes_to_html( $field, array &$add_html ) {
576
-        if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
577
-            return;
578
-        }
575
+	private static function add_shortcodes_to_html( $field, array &$add_html ) {
576
+		if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) {
577
+			return;
578
+		}
579 579
 
580
-        foreach ( $field['shortcodes'] as $k => $v ) {
581
-            if ( 'opt' === $k ) {
582
-                continue;
583
-            }
580
+		foreach ( $field['shortcodes'] as $k => $v ) {
581
+			if ( 'opt' === $k ) {
582
+				continue;
583
+			}
584 584
 
585
-            if ( is_numeric($k) && strpos($v, '=') ) {
586
-                $add_html[] = $v;
587
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
585
+			if ( is_numeric($k) && strpos($v, '=') ) {
586
+				$add_html[] = $v;
587
+			} else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
588 588
 				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
589
-            } else {
589
+			} else {
590 590
 				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
591
-            }
592
-
593
-            unset($k, $v);
594
-        }
595
-    }
596
-
597
-    public static function check_value( $opt, $opt_key, $field ) {
598
-        if ( is_array( $opt ) ) {
599
-            if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
600
-                $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
601
-            } else {
602
-                $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
603
-            }
604
-        }
605
-        return $opt;
606
-    }
591
+			}
592
+
593
+			unset($k, $v);
594
+		}
595
+	}
596
+
597
+	public static function check_value( $opt, $opt_key, $field ) {
598
+		if ( is_array( $opt ) ) {
599
+			if ( FrmField::is_option_true( $field, 'separate_value' ) ) {
600
+				$opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
601
+			} else {
602
+				$opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt );
603
+			}
604
+		}
605
+		return $opt;
606
+	}
607 607
 
608 608
 	public static function check_label( $opt ) {
609
-        if ( is_array($opt) ) {
610
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
611
-        }
609
+		if ( is_array($opt) ) {
610
+			$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
611
+		}
612 612
 
613
-        return $opt;
614
-    }
613
+		return $opt;
614
+	}
615 615
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmFieldsController {
4 4
 
5 5
     public static function load_field() {
6
-		FrmAppHelper::permission_check('frm_edit_forms');
6
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
7 7
         check_ajax_referer( 'frm_ajax', 'nonce' );
8 8
 
9 9
         $fields = $_POST['field'];
@@ -34,17 +34,17 @@  discard block
 block discarded – undo
34 34
             }
35 35
 
36 36
 			$field_name = 'item_meta[' . $field_id . ']';
37
-            $html_id = FrmFieldsHelper::get_html_id($field);
37
+            $html_id = FrmFieldsHelper::get_html_id( $field );
38 38
 
39 39
             ob_start();
40 40
 			include( $path . '/classes/views/frm-forms/add_field.php' );
41
-            $field_html[ $field_id ] = ob_get_contents();
41
+            $field_html[$field_id] = ob_get_contents();
42 42
             ob_end_clean();
43 43
         }
44 44
 
45
-        unset($path);
45
+        unset( $path );
46 46
 
47
-        echo json_encode($field_html);
47
+        echo json_encode( $field_html );
48 48
 
49 49
         wp_die();
50 50
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * Create a new field with ajax
54 54
 	 */
55 55
     public static function create() {
56
-		FrmAppHelper::permission_check('frm_edit_forms');
56
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
57 57
         check_ajax_referer( 'frm_ajax', 'nonce' );
58 58
 
59 59
 		$field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$field = self::include_new_field( $field_type, $form_id );
63 63
 
64 64
         // this hook will allow for multiple fields to be added at once
65
-        do_action('frm_after_field_created', $field, $form_id);
65
+        do_action( 'frm_after_field_created', $field, $form_id );
66 66
 
67 67
         wp_die();
68 68
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	public static function include_new_field( $field_type, $form_id ) {
78 78
         $values = array();
79 79
         if ( FrmAppHelper::pro_is_installed() ) {
80
-            $values['post_type'] = FrmProFormsHelper::post_type($form_id);
80
+            $values['post_type'] = FrmProFormsHelper::post_type( $form_id );
81 81
         }
82 82
 
83 83
 		$field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id );
@@ -89,27 +89,27 @@  discard block
 block discarded – undo
89 89
             return false;
90 90
         }
91 91
 
92
-        $field = self::include_single_field($field_id, $values, $form_id);
92
+        $field = self::include_single_field( $field_id, $values, $form_id );
93 93
 
94 94
         return $field;
95 95
     }
96 96
 
97 97
 	public static function edit_name( $field = 'name', $id = '' ) {
98
-		FrmAppHelper::permission_check('frm_edit_forms');
98
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
99 99
         check_ajax_referer( 'frm_ajax', 'nonce' );
100 100
 
101
-        if ( empty($field) ) {
101
+        if ( empty( $field ) ) {
102 102
             $field = 'name';
103 103
         }
104 104
 
105
-        if ( empty($id) ) {
105
+        if ( empty( $id ) ) {
106 106
 			$id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' );
107 107
 			$id = str_replace( 'field_label_', '', $id );
108 108
         }
109 109
 
110 110
 		$value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' );
111 111
 		$value = trim( $value );
112
-        if ( trim(strip_tags($value)) == '' ) {
112
+        if ( trim( strip_tags( $value ) ) == '' ) {
113 113
             // set blank value if there is no content
114 114
             $value = '';
115 115
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     public static function update_ajax_option() {
126
-		FrmAppHelper::permission_check('frm_edit_forms');
126
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
127 127
         check_ajax_referer( 'frm_ajax', 'nonce' );
128 128
 
129 129
 		$field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		if ( isset( $_POST['separate_value'] ) ) {
137 137
 			$new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1;
138 138
 			$field->field_options['separate_value'] = $new_val;
139
-			unset($new_val);
139
+			unset( $new_val );
140 140
 		}
141 141
 
142 142
         FrmField::update( $field_id, array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     }
148 148
 
149 149
     public static function duplicate() {
150
-		FrmAppHelper::permission_check('frm_edit_forms');
150
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
151 151
         check_ajax_referer( 'frm_ajax', 'nonce' );
152 152
 
153 153
         global $wpdb;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 			wp_die();
178 178
 		}
179 179
 
180
-        self::include_single_field($field_id, $values);
180
+        self::include_single_field( $field_id, $values );
181 181
 
182 182
         wp_die();
183 183
     }
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * Load a single field in the form builder along with all needed variables
187 187
      */
188 188
     public static function include_single_field( $field_id, $values, $form_id = 0 ) {
189
-        $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id));
189
+        $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) );
190 190
 		$field_name = 'item_meta[' . $field_id . ']';
191
-        $html_id = FrmFieldsHelper::get_html_id($field);
191
+        $html_id = FrmFieldsHelper::get_html_id( $field );
192 192
         $id = $form_id ? $form_id : $field['form_id'];
193 193
         if ( $field['type'] == 'html' ) {
194 194
             $field['stop_filter'] = true;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     public static function destroy() {
203
-		FrmAppHelper::permission_check('frm_edit_forms');
203
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
204 204
         check_ajax_referer( 'frm_ajax', 'nonce' );
205 205
 
206 206
 		$field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 
213 213
     //Add Single Option or Other Option
214 214
     public static function add_option() {
215
-		FrmAppHelper::permission_check('frm_edit_forms');
215
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
216 216
         check_ajax_referer( 'frm_ajax', 'nonce' );
217 217
 
218 218
 		$id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' );
219 219
 		$opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' );
220 220
 		$opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' );
221 221
 
222
-        $field = FrmField::getOne($id);
222
+        $field = FrmField::getOne( $id );
223 223
 
224 224
         if ( 'other' == $opt_type ) {
225 225
 			$opt = __( 'Other', 'formidable' );
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 
290 290
         $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
291 291
         $prepop = array();
292
-        FrmFieldsHelper::get_bulk_prefilled_opts($prepop);
292
+        FrmFieldsHelper::get_bulk_prefilled_opts( $prepop );
293 293
 
294
-        $field = FrmField::getOne($field_id);
294
+        $field = FrmField::getOne( $field_id );
295 295
 
296 296
         wp_enqueue_script( 'utils' );
297 297
 		wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' );
@@ -302,35 +302,35 @@  discard block
 block discarded – undo
302 302
     }
303 303
 
304 304
     public static function import_options() {
305
-		FrmAppHelper::permission_check('frm_edit_forms');
305
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
306 306
         check_ajax_referer( 'frm_ajax', 'nonce' );
307 307
 
308
-        if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) {
308
+        if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) {
309 309
             return;
310 310
         }
311 311
 
312 312
 		$field_id = absint( $_POST['field_id'] );
313
-        $field = FrmField::getOne($field_id);
313
+        $field = FrmField::getOne( $field_id );
314 314
 
315 315
 		if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) {
316 316
             return;
317 317
         }
318 318
 
319
-        $field = FrmFieldsHelper::setup_edit_vars($field);
319
+        $field = FrmFieldsHelper::setup_edit_vars( $field );
320 320
 		$opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' );
321 321
 		$opts = explode( "\n", rtrim( $opts, "\n" ) );
322 322
 		$opts = array_map( 'trim', $opts );
323 323
 
324 324
         if ( $field['separate_value'] ) {
325 325
             foreach ( $opts as $opt_key => $opt ) {
326
-                if ( strpos($opt, '|') !== false ) {
327
-                    $vals = explode('|', $opt);
326
+                if ( strpos( $opt, '|' ) !== false ) {
327
+                    $vals = explode( '|', $opt );
328 328
                     if ( $vals[0] != $vals[1] ) {
329
-                        $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
329
+                        $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) );
330 330
                     }
331
-                    unset($vals);
331
+                    unset( $vals );
332 332
                 }
333
-                unset($opt_key, $opt);
333
+                unset( $opt_key, $opt );
334 334
             }
335 335
         }
336 336
 
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
             $other_array = array();
340 340
             foreach ( $field['options'] as $opt_key => $opt ) {
341 341
 				if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
342
-					$other_array[ $opt_key ] = $opt;
342
+					$other_array[$opt_key] = $opt;
343 343
 				}
344
-                unset($opt_key, $opt);
344
+                unset( $opt_key, $opt );
345 345
             }
346
-            if ( ! empty($other_array) ) {
347
-                $opts = array_merge( $opts, $other_array);
346
+            if ( ! empty( $other_array ) ) {
347
+                $opts = array_merge( $opts, $other_array );
348 348
             }
349 349
         }
350 350
 
@@ -358,14 +358,14 @@  discard block
 block discarded – undo
358 358
 
359 359
 			require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' );
360 360
         } else {
361
-            FrmFieldsHelper::show_single_option($field);
361
+            FrmFieldsHelper::show_single_option( $field );
362 362
         }
363 363
 
364 364
         wp_die();
365 365
     }
366 366
 
367 367
     public static function update_order() {
368
-		FrmAppHelper::permission_check('frm_edit_forms');
368
+		FrmAppHelper::permission_check( 'frm_edit_forms' );
369 369
         check_ajax_referer( 'frm_ajax', 'nonce' );
370 370
 
371 371
 		$fields = FrmAppHelper::get_post_param( 'frm_field_id' );
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
             'rte'       => 'textarea',
383 383
             'website'   => 'url',
384 384
         );
385
-        if ( isset( $type_switch[ $type ] ) ) {
386
-            $type = $type_switch[ $type ];
385
+        if ( isset( $type_switch[$type] ) ) {
386
+            $type = $type_switch[$type];
387 387
         }
388 388
 
389 389
 		$pro_fields = FrmField::pro_field_selection();
@@ -427,19 +427,19 @@  discard block
 block discarded – undo
427 427
 
428 428
     public static function input_html( $field, $echo = true ) {
429 429
         $class = array(); //$field['type'];
430
-        self::add_input_classes($field, $class);
430
+        self::add_input_classes( $field, $class );
431 431
 
432 432
         $add_html = array();
433
-        self::add_html_size($field, $add_html);
434
-        self::add_html_length($field, $add_html);
435
-        self::add_html_placeholder($field, $add_html, $class);
433
+        self::add_html_size( $field, $add_html );
434
+        self::add_html_length( $field, $add_html );
435
+        self::add_html_placeholder( $field, $add_html, $class );
436 436
 		self::add_validation_messages( $field, $add_html );
437 437
 
438
-        $class = apply_filters('frm_field_classes', implode(' ', $class), $field);
438
+        $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field );
439 439
 
440 440
 		FrmFormsHelper::add_html_attr( $class, 'class', $add_html );
441 441
 
442
-        self::add_shortcodes_to_html($field, $add_html);
442
+        self::add_shortcodes_to_html( $field, $add_html );
443 443
 
444 444
 		$add_html = apply_filters( 'frm_field_extra_html', $add_html, $field );
445 445
 		$add_html = ' ' . implode( ' ', $add_html ) . '  ';
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
     }
453 453
 
454 454
 	private static function add_input_classes( $field, array &$class ) {
455
-        if ( isset($field['input_class']) && ! empty($field['input_class']) ) {
455
+        if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) {
456 456
             $class[] = $field['input_class'];
457 457
         }
458 458
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
             return;
461 461
         }
462 462
 
463
-        if ( isset($field['size']) && $field['size'] > 0 ) {
463
+        if ( isset( $field['size'] ) && $field['size'] > 0 ) {
464 464
             $class[] = 'auto_width';
465 465
         }
466 466
     }
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
             return;
471 471
         }
472 472
 
473
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
473
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
474 474
             return;
475 475
         }
476 476
 
477
-        if ( is_numeric($field['size']) ) {
477
+        if ( is_numeric( $field['size'] ) ) {
478 478
             $field['size'] .= 'px';
479 479
         }
480 480
 
481
-        $important = apply_filters('frm_use_important_width', 1, $field);
481
+        $important = apply_filters( 'frm_use_important_width', 1, $field );
482 482
         // Note: This inline styling must stay since we cannot realistically set a class for every possible field size
483 483
 		$add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"';
484 484
 
485
-        self::add_html_cols($field, $add_html);
485
+        self::add_html_cols( $field, $add_html );
486 486
     }
487 487
 
488 488
 	private static function add_html_cols( $field, array &$add_html ) {
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
         );
500 500
 
501 501
         // include "col" for valid html
502
-        $unit = trim(preg_replace('/[0-9]+/', '', $field['size']));
502
+        $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) );
503 503
 
504
-        if ( ! isset( $calc[ $unit ] ) ) {
504
+        if ( ! isset( $calc[$unit] ) ) {
505 505
             return;
506 506
         }
507 507
 
508
-        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ];
508
+        $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit];
509 509
 
510 510
 		$add_html['cols'] = 'cols="' . absint( $size ) . '"';
511 511
     }
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             return;
517 517
         }
518 518
 
519
-        if ( FrmAppHelper::is_admin_page('formidable' ) ) {
519
+        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
520 520
             // don't load on form builder page
521 521
             return;
522 522
         }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) {
549 549
             // use HMTL5 placeholder with js fallback
550 550
 			$add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"';
551
-            wp_enqueue_script('jquery-placeholder');
551
+            wp_enqueue_script( 'jquery-placeholder' );
552 552
         } else if ( ! $frm_settings->use_html ) {
553 553
 			$val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( '&#039;', "'", esc_attr( $field['default_value'] ) ) ) );
554 554
 			$add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"';
@@ -582,15 +582,15 @@  discard block
 block discarded – undo
582 582
                 continue;
583 583
             }
584 584
 
585
-            if ( is_numeric($k) && strpos($v, '=') ) {
585
+            if ( is_numeric( $k ) && strpos( $v, '=' ) ) {
586 586
                 $add_html[] = $v;
587
-            } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) {
588
-				$add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] );
587
+            } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) {
588
+				$add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] );
589 589
             } else {
590
-				$add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"';
590
+				$add_html[$k] = $k . '="' . esc_attr( $v ) . '"';
591 591
             }
592 592
 
593
-            unset($k, $v);
593
+            unset( $k, $v );
594 594
         }
595 595
     }
596 596
 
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
     }
607 607
 
608 608
 	public static function check_label( $opt ) {
609
-        if ( is_array($opt) ) {
610
-            $opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
609
+        if ( is_array( $opt ) ) {
610
+            $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) );
611 611
         }
612 612
 
613 613
         return $opt;
Please login to merge, or discard this patch.
classes/controllers/FrmEntriesController.php 2 patches
Indentation   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -2,70 +2,70 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmEntriesController {
4 4
 
5
-    public static function menu() {
5
+	public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+		add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
12 12
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
13 13
 			add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
14 14
 			add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
15
-        }
16
-    }
15
+		}
16
+	}
17 17
 
18
-    /* Display in Back End */
19
-    public static function route() {
18
+	/* Display in Back End */
19
+	public static function route() {
20 20
 		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
21 21
 
22
-        switch ( $action ) {
23
-            case 'show':
24
-            case 'destroy':
25
-            case 'destroy_all':
26
-                return self::$action();
22
+		switch ( $action ) {
23
+			case 'show':
24
+			case 'destroy':
25
+			case 'destroy_all':
26
+				return self::$action();
27 27
 
28
-            default:
29
-                do_action( 'frm_entry_action_route', $action );
30
-                if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
-                    return;
32
-                }
28
+			default:
29
+				do_action( 'frm_entry_action_route', $action );
30
+				if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
31
+					return;
32
+				}
33 33
 
34
-                return self::display_list();
35
-        }
36
-    }
34
+				return self::display_list();
35
+		}
36
+	}
37 37
 
38 38
 	public static function contextual_help( $help, $screen_id, $screen ) {
39
-        // Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
-        if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
-            return $help;
42
-        }
39
+		// Only add to certain screens. add_help_tab was introduced in WordPress 3.3
40
+		if ( ! method_exists( $screen, 'add_help_tab' ) ) {
41
+			return $help;
42
+		}
43 43
 
44 44
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
45 45
 		$page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
46 46
 		if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) {
47
-            return $help;
48
-        }
47
+			return $help;
48
+		}
49 49
 
50 50
 		unset( $action, $page );
51 51
 
52
-        $screen->add_help_tab( array(
53
-            'id'      => 'formidable-entries-tab',
54
-            'title'   => __( 'Overview', 'formidable' ),
52
+		$screen->add_help_tab( array(
53
+			'id'      => 'formidable-entries-tab',
54
+			'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+		));
57 57
 
58
-        $screen->set_help_sidebar(
58
+		$screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
60 60
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' .
61 61
 			'<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>'
62
-    	);
62
+		);
63 63
 
64
-        return $help;
65
-    }
64
+		return $help;
65
+	}
66 66
 
67 67
 	public static function manage_columns( $columns ) {
68
-        global $frm_vars;
68
+		global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71 71
 		$columns[ $form_id . '_id' ] = 'ID';
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84 84
 		$columns[ $form_id . '_ip' ] = 'IP';
85 85
 
86
-        $frm_vars['cols'] = $columns;
86
+		$frm_vars['cols'] = $columns;
87 87
 
88 88
 		$action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
89 89
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
90 90
 			add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) );
91
-        }
91
+		}
92 92
 
93
-        return $columns;
94
-    }
93
+		return $columns;
94
+	}
95 95
 
96 96
 	private static function get_columns_for_form( $form_id, &$columns ) {
97 97
 		$form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -135,76 +135,76 @@  discard block
 block discarded – undo
135 135
 		$menu_name = FrmAppHelper::get_menu_name();
136 136
 		$this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden';
137 137
 		if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
138
-            return $check;
139
-        }
138
+			return $check;
139
+		}
140 140
 
141 141
 		if ( empty( $prev_value ) ) {
142 142
 			$prev_value = get_metadata( 'user', $object_id, $meta_key, true );
143 143
 		}
144 144
 
145
-        global $frm_vars;
146
-        //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
145
+		global $frm_vars;
146
+		//add a check so we don't create a loop
147
+		$frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149
-        return $check;
150
-    }
149
+		return $check;
150
+	}
151 151
 
152
-    //add hidden columns back from other forms
152
+	//add hidden columns back from other forms
153 153
 	public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
154 154
 		$menu_name = FrmAppHelper::get_menu_name();
155 155
 		$sanitized = sanitize_title( $menu_name );
156 156
 		$this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden';
157 157
 		if ( $meta_key != $this_page_name ) {
158
-            return;
159
-        }
160
-
161
-        global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
163
-            return; //don't continue if there's no previous value
164
-        }
165
-
166
-        foreach ( $meta_value as $mk => $mv ) {
167
-            //remove blank values
168
-            if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
170
-            }
171
-        }
172
-
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
175
-        $cur_form_prefix = $cur_form_prefix[0];
176
-        $save = false;
177
-
178
-        foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
158
+			return;
159
+		}
160
+
161
+		global $frm_vars;
162
+		if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
163
+			return; //don't continue if there's no previous value
164
+		}
165
+
166
+		foreach ( $meta_value as $mk => $mv ) {
167
+			//remove blank values
168
+			if ( empty( $mv ) ) {
169
+				unset( $meta_value[ $mk ] );
170
+			}
171
+		}
172
+
173
+		$cur_form_prefix = reset($meta_value);
174
+		$cur_form_prefix = explode('_', $cur_form_prefix);
175
+		$cur_form_prefix = $cur_form_prefix[0];
176
+		$save = false;
177
+
178
+		foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
179 179
 			if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
180
-                //don't add blank cols or process included cols
181
-                continue;
182
-            }
180
+				//don't add blank cols or process included cols
181
+				continue;
182
+			}
183 183
 
184 184
 			$form_prefix = explode( '_', $prev_hidden );
185
-            $form_prefix = $form_prefix[0];
186
-            if ( $form_prefix == $cur_form_prefix ) {
187
-                //don't add back columns that are meant to be hidden
188
-                continue;
189
-            }
185
+			$form_prefix = $form_prefix[0];
186
+			if ( $form_prefix == $cur_form_prefix ) {
187
+				//don't add back columns that are meant to be hidden
188
+				continue;
189
+			}
190 190
 
191
-            $meta_value[] = $prev_hidden;
192
-            $save = true;
193
-            unset($form_prefix);
194
-        }
191
+			$meta_value[] = $prev_hidden;
192
+			$save = true;
193
+			unset($form_prefix);
194
+		}
195 195
 
196 196
 		if ( $save ) {
197
-            $user = wp_get_current_user();
197
+			$user = wp_get_current_user();
198 198
 			update_user_option( $user->ID, $this_page_name, $meta_value, true );
199
-        }
200
-    }
199
+		}
200
+	}
201 201
 
202 202
 	public static function save_per_page( $save, $option, $value ) {
203
-        if ( $option == 'formidable_page_formidable_entries_per_page' ) {
204
-            $save = (int) $value;
205
-        }
206
-        return $save;
207
-    }
203
+		if ( $option == 'formidable_page_formidable_entries_per_page' ) {
204
+			$save = (int) $value;
205
+		}
206
+		return $save;
207
+	}
208 208
 
209 209
 	public static function sortable_columns() {
210 210
 		$form_id = FrmForm::get_current_form_id();
@@ -230,46 +230,46 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	public static function hidden_columns( $result ) {
233
-        global $frm_vars;
233
+		global $frm_vars;
234 234
 
235 235
 		$form_id = FrmForm::get_current_form_id();
236 236
 
237
-        $return = false;
238
-        foreach ( (array) $result as $r ) {
239
-            if ( ! empty( $r ) ) {
240
-                $form_prefix = explode( '_', $r );
241
-                $form_prefix = $form_prefix[0];
237
+		$return = false;
238
+		foreach ( (array) $result as $r ) {
239
+			if ( ! empty( $r ) ) {
240
+				$form_prefix = explode( '_', $r );
241
+				$form_prefix = $form_prefix[0];
242 242
 
243
-                if ( (int) $form_prefix == (int) $form_id ) {
244
-                    $return = true;
245
-                    break;
246
-                }
243
+				if ( (int) $form_prefix == (int) $form_id ) {
244
+					$return = true;
245
+					break;
246
+				}
247 247
 
248
-                unset($form_prefix);
249
-            }
250
-        }
248
+				unset($form_prefix);
249
+			}
250
+		}
251 251
 
252
-        if ( $return ) {
252
+		if ( $return ) {
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
257
-        $max_columns = 8;
258
-        if ( $i <= $max_columns ) {
256
+		$i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
257
+		$max_columns = 8;
258
+		if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262
-        global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
265
-        }
262
+		global $frm_vars;
263
+		if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
+			$frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
265
+		}
266 266
 
267 267
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
268 268
 		if ( $has_custom_hidden_columns ) {
269
-            $result = $frm_vars['current_form']->options['hidden_cols'];
270
-        } else {
271
-            $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
269
+			$result = $frm_vars['current_form']->options['hidden_cols'];
270
+		} else {
271
+			$cols = $frm_vars['cols'];
272
+			$cols = array_reverse($cols, true);
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
@@ -277,59 +277,59 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+			$i--;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283
-                if ( $i > $max_columns ) {
283
+				if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286
-                //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
289
-            }
290
-        }
286
+				//remove some columns by default
287
+				$i--;
288
+				unset($col_key, $col);
289
+			}
290
+		}
291 291
 
292
-        return $result;
293
-    }
292
+		return $result;
293
+	}
294 294
 
295 295
 	public static function display_list( $message = '', $errors = array() ) {
296
-        global $wpdb, $frm_vars;
296
+		global $wpdb, $frm_vars;
297 297
 
298 298
 		$form = FrmForm::maybe_get_current_form();
299 299
 		$params = FrmForm::get_admin_params( $form );
300 300
 
301
-        if ( $form ) {
302
-            $params['form'] = $form->id;
303
-            $frm_vars['current_form'] = $form;
301
+		if ( $form ) {
302
+			$params['form'] = $form->id;
303
+			$frm_vars['current_form'] = $form;
304 304
 
305 305
 			self::get_delete_form_time( $form, $errors );
306 306
 		}
307 307
 
308
-        $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
308
+		$table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
309 309
 
310
-        $wp_list_table = new $table_class( array( 'params' => $params ) );
310
+		$wp_list_table = new $table_class( array( 'params' => $params ) );
311 311
 
312
-        $pagenum = $wp_list_table->get_pagenum();
312
+		$pagenum = $wp_list_table->get_pagenum();
313 313
 
314
-        $wp_list_table->prepare_items();
314
+		$wp_list_table->prepare_items();
315 315
 
316
-        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
317
-        if ( $pagenum > $total_pages && $total_pages > 0 ) {
316
+		$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
317
+		if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319
-            if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
321
-            } else {
322
-                wp_redirect( esc_url_raw( $url ) );
323
-            }
324
-            die();
325
-        }
326
-
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
328
-            $message = __( 'Your import is complete', 'formidable' );
329
-        }
319
+			if ( headers_sent() ) {
320
+				echo FrmAppHelper::js_redirect($url);
321
+			} else {
322
+				wp_redirect( esc_url_raw( $url ) );
323
+			}
324
+			die();
325
+		}
326
+
327
+		if ( empty($message) && isset($_GET['import-message']) ) {
328
+			$message = __( 'Your import is complete', 'formidable' );
329
+		}
330 330
 
331 331
 		require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' );
332
-    }
332
+	}
333 333
 
334 334
 	private static function get_delete_form_time( $form, &$errors ) {
335 335
 		if ( 'trash' == $form->status ) {
@@ -339,19 +339,19 @@  discard block
 block discarded – undo
339 339
 		}
340 340
 	}
341 341
 
342
-    /* Back End CRUD */
342
+	/* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+		FrmAppHelper::permission_check('frm_view_entries');
345 345
 
346
-        if ( ! $id ) {
346
+		if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
348 348
 
349
-            if ( ! $id ) {
349
+			if ( ! $id ) {
350 350
 				$id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' );
351
-            }
352
-        }
351
+			}
352
+		}
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+		$entry = FrmEntry::getOne($id, true);
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,110 +359,110 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+		$data = maybe_unserialize($entry->description);
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
366 366
 
367 367
 		$fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
368
-        $to_emails = array();
368
+		$to_emails = array();
369 369
 
370 370
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
371
-    }
371
+	}
372 372
 
373
-    public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
373
+	public static function destroy() {
374
+		FrmAppHelper::permission_check('frm_delete_entries');
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
379
-            //unlink entry from post
380
-            global $wpdb;
378
+		if ( isset($params['keep_post']) && $params['keep_post'] ) {
379
+			//unlink entry from post
380
+			global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
382
-        }
382
+		}
383 383
 
384
-        $message = '';
385
-        if ( FrmEntry::destroy( $params['id'] ) ) {
386
-            $message = __( 'Entry was Successfully Destroyed', 'formidable' );
387
-        }
384
+		$message = '';
385
+		if ( FrmEntry::destroy( $params['id'] ) ) {
386
+			$message = __( 'Entry was Successfully Destroyed', 'formidable' );
387
+		}
388 388
 
389
-        self::display_list( $message );
390
-    }
389
+		self::display_list( $message );
390
+	}
391 391
 
392
-    public static function destroy_all() {
393
-        if ( ! current_user_can( 'frm_delete_entries' ) ) {
394
-            $frm_settings = FrmAppHelper::get_settings();
395
-            wp_die( $frm_settings->admin_permission );
396
-        }
392
+	public static function destroy_all() {
393
+		if ( ! current_user_can( 'frm_delete_entries' ) ) {
394
+			$frm_settings = FrmAppHelper::get_settings();
395
+			wp_die( $frm_settings->admin_permission );
396
+		}
397 397
 
398
-        global $wpdb;
398
+		global $wpdb;
399 399
 		$params = FrmForm::get_admin_params();
400
-        $message = '';
401
-        $errors = array();
402
-        $form_id = (int) $params['form'];
400
+		$message = '';
401
+		$errors = array();
402
+		$form_id = (int) $params['form'];
403 403
 
404
-        if ( $form_id ) {
405
-            $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
404
+		if ( $form_id ) {
405
+			$entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) );
406 406
 			$action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 );
407 407
 
408
-            if ( $action ) {
409
-                // this action takes a while, so only trigger it if there are posts to delete
410
-                foreach ( $entry_ids as $entry_id ) {
411
-                    do_action( 'frm_before_destroy_entry', $entry_id );
412
-                    unset( $entry_id );
413
-                }
414
-            }
415
-
416
-            $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
417
-            $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
418
-            if ( $results ) {
408
+			if ( $action ) {
409
+				// this action takes a while, so only trigger it if there are posts to delete
410
+				foreach ( $entry_ids as $entry_id ) {
411
+					do_action( 'frm_before_destroy_entry', $entry_id );
412
+					unset( $entry_id );
413
+				}
414
+			}
415
+
416
+			$wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) );
417
+			$results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) );
418
+			if ( $results ) {
419 419
 				FrmEntry::clear_cache();
420
-                $message = __( 'Entries were Successfully Destroyed', 'formidable' );
421
-            }
422
-        } else {
423
-            $errors = __( 'No entries were specified', 'formidable' );
424
-        }
425
-
426
-        self::display_list( $message, $errors );
427
-    }
428
-
429
-    public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
430
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
431
-        return FrmFormsController::show_form( $id, $key, $title, $description );
432
-    }
433
-
434
-    public static function get_form( $filename, $form, $title, $description ) {
435
-        _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
436
-        return FrmFormsController::get_form( $form, $title, $description );
437
-    }
438
-
439
-    public static function process_entry( $errors = '', $ajax = false ) {
420
+				$message = __( 'Entries were Successfully Destroyed', 'formidable' );
421
+			}
422
+		} else {
423
+			$errors = __( 'No entries were specified', 'formidable' );
424
+		}
425
+
426
+		self::display_list( $message, $errors );
427
+	}
428
+
429
+	public static function show_form( $id = '', $key = '', $title = false, $description = false ) {
430
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
431
+		return FrmFormsController::show_form( $id, $key, $title, $description );
432
+	}
433
+
434
+	public static function get_form( $filename, $form, $title, $description ) {
435
+		_deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
436
+		return FrmFormsController::get_form( $form, $title, $description );
437
+	}
438
+
439
+	public static function process_entry( $errors = '', $ajax = false ) {
440 440
 		$form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
441 441
 		if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) {
442
-            return;
443
-        }
442
+			return;
443
+		}
444 444
 
445
-        global $frm_vars;
445
+		global $frm_vars;
446 446
 
447 447
 		$form = FrmForm::getOne( $form_id );
448
-        if ( ! $form ) {
449
-            return;
450
-        }
448
+		if ( ! $form ) {
449
+			return;
450
+		}
451 451
 
452 452
 		$params = FrmForm::get_params( $form );
453 453
 
454
-        if ( ! isset( $frm_vars['form_params'] ) ) {
455
-            $frm_vars['form_params'] = array();
456
-        }
454
+		if ( ! isset( $frm_vars['form_params'] ) ) {
455
+			$frm_vars['form_params'] = array();
456
+		}
457 457
 		$frm_vars['form_params'][ $form->id ] = $params;
458 458
 
459 459
 		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
460
-            return;
461
-        }
460
+			return;
461
+		}
462 462
 
463
-        if ( $errors == '' && ! $ajax ) {
463
+		if ( $errors == '' && ! $ajax ) {
464 464
 			$errors = FrmEntryValidate::validate( $_POST );
465
-        }
465
+		}
466 466
 
467 467
 		/**
468 468
 		 * Use this filter to add trigger actions and add errors after
@@ -473,39 +473,39 @@  discard block
 block discarded – undo
473 473
 
474 474
 		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
475 475
 
476
-        if ( empty( $errors ) ) {
476
+		if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478
-            if ( $params['action'] == 'create' ) {
478
+			if ( $params['action'] == 'create' ) {
479 479
 				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480 480
 					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
481
-                }
482
-            }
481
+				}
482
+			}
483 483
 
484
-            do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
484
+			do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
485 485
 			unset( $_POST['frm_skip_cookie'] );
486
-        }
487
-    }
488
-
489
-    public static function delete_entry_before_redirect( $url, $form, $atts ) {
490
-        self::_delete_entry( $atts['id'], $form );
491
-        return $url;
492
-    }
493
-
494
-    //Delete entry if not redirected
495
-    public static function delete_entry_after_save( $atts ) {
496
-        self::_delete_entry( $atts['entry_id'], $atts['form'] );
497
-    }
498
-
499
-    private static function _delete_entry( $entry_id, $form ) {
500
-        if ( ! $form ) {
501
-            return;
502
-        }
503
-
504
-        $form->options = maybe_unserialize( $form->options );
505
-        if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
506
-            FrmEntry::destroy( $entry_id );
507
-        }
508
-    }
486
+		}
487
+	}
488
+
489
+	public static function delete_entry_before_redirect( $url, $form, $atts ) {
490
+		self::_delete_entry( $atts['id'], $form );
491
+		return $url;
492
+	}
493
+
494
+	//Delete entry if not redirected
495
+	public static function delete_entry_after_save( $atts ) {
496
+		self::_delete_entry( $atts['entry_id'], $atts['form'] );
497
+	}
498
+
499
+	private static function _delete_entry( $entry_id, $form ) {
500
+		if ( ! $form ) {
501
+			return;
502
+		}
503
+
504
+		$form->options = maybe_unserialize( $form->options );
505
+		if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
506
+			FrmEntry::destroy( $entry_id );
507
+		}
508
+	}
509 509
 
510 510
 	public static function show_entry_shortcode( $atts ) {
511 511
 		return FrmEntryFormat::show_entry( $atts );
@@ -517,15 +517,15 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	public static function entry_sidebar( $entry ) {
520
-        $data = maybe_unserialize($entry->description);
521
-        $date_format = get_option('date_format');
522
-        $time_format = get_option('time_format');
520
+		$data = maybe_unserialize($entry->description);
521
+		$date_format = get_option('date_format');
522
+		$time_format = get_option('time_format');
523 523
 		if ( isset( $data['browser'] ) ) {
524 524
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
525 525
 		}
526 526
 
527 527
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
528
-    }
528
+	}
529 529
 
530 530
 	/***********************************************************************
531 531
 	 * Deprecated Functions
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
         global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-		$columns[ $form_id . '_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+		$columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
 		if ( $form_id ) {
75 75
 			self::get_columns_for_form( $form_id, $columns );
76 76
 		} else {
77
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
78
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
79
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
80 80
 		}
81 81
 
82
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84
-		$columns[ $form_id . '_ip' ] = 'IP';
82
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
83
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
84
+		$columns[$form_id . '_ip'] = 'IP';
85 85
 
86 86
         $frm_vars['cols'] = $columns;
87 87
 
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 				if ( $sub_form_cols ) {
108 108
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
109 109
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
-							unset( $sub_form_cols[ $k ] );
110
+							unset( $sub_form_cols[$k] );
111 111
 							continue;
112 112
 						}
113
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
-						unset($sub_form_col);
113
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+						unset( $sub_form_col );
115 115
 					}
116 116
 				}
117
-				unset($sub_form_cols);
117
+				unset( $sub_form_cols );
118 118
 			} else {
119 119
 				$col_id = $form_col->field_key;
120 120
 				if ( $form_col->form_id != $form_id ) {
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
125 125
 				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
126 126
 				if ( $has_separate_value && ! $is_post_status ) {
127
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
 				}
129
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
129
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
130 130
 			}
131 131
 		}
132 132
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         global $frm_vars;
146 146
         //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
147
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149 149
         return $check;
150 150
     }
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
         }
160 160
 
161 161
         global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
162
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
163 163
             return; //don't continue if there's no previous value
164 164
         }
165 165
 
166 166
         foreach ( $meta_value as $mk => $mv ) {
167 167
             //remove blank values
168 168
             if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
169
+                unset( $meta_value[$mk] );
170 170
             }
171 171
         }
172 172
 
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
173
+        $cur_form_prefix = reset( $meta_value );
174
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
175 175
         $cur_form_prefix = $cur_form_prefix[0];
176 176
         $save = false;
177 177
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
             $meta_value[] = $prev_hidden;
192 192
             $save = true;
193
-            unset($form_prefix);
193
+            unset( $form_prefix );
194 194
         }
195 195
 
196 196
 		if ( $save ) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		foreach ( $fields as $field ) {
223 223
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
224 224
 				// Can't sort on checkboxes because they are stored serialized, or post fields
225
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
225
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
226 226
 			}
227 227
 		}
228 228
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     break;
246 246
                 }
247 247
 
248
-                unset($form_prefix);
248
+                unset( $form_prefix );
249 249
             }
250 250
         }
251 251
 
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
256
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
257 257
         $max_columns = 8;
258 258
         if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262 262
         global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
263
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
264
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
265 265
         }
266 266
 
267 267
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
@@ -269,23 +269,23 @@  discard block
 block discarded – undo
269 269
             $result = $frm_vars['current_form']->options['hidden_cols'];
270 270
         } else {
271 271
             $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
272
+            $cols = array_reverse( $cols, true );
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
276
-				$i--;
276
+				$i --;
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+            $i --;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283 283
                 if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286 286
                 //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
287
+                $i --;
288
+                unset( $col_key, $col );
289 289
             }
290 290
         }
291 291
 
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319 319
             if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
320
+                echo FrmAppHelper::js_redirect( $url );
321 321
             } else {
322 322
                 wp_redirect( esc_url_raw( $url ) );
323 323
             }
324 324
             die();
325 325
         }
326 326
 
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
327
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
328 328
             $message = __( 'Your import is complete', 'formidable' );
329 329
         }
330 330
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     /* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+        FrmAppHelper::permission_check( 'frm_view_entries' );
345 345
 
346 346
         if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+        $entry = FrmEntry::getOne( $id, true );
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+        $data = maybe_unserialize( $entry->description );
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
     }
372 372
 
373 373
     public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
374
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
378
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
379 379
             //unlink entry from post
380 380
             global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
         if ( ! isset( $frm_vars['form_params'] ) ) {
455 455
             $frm_vars['form_params'] = array();
456 456
         }
457
-		$frm_vars['form_params'][ $form->id ] = $params;
457
+		$frm_vars['form_params'][$form->id] = $params;
458 458
 
459
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
459
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
460 460
             return;
461 461
         }
462 462
 
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 		 */
472 472
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
473 473
 
474
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
474
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
475 475
 
476 476
         if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478 478
             if ( $params['action'] == 'create' ) {
479
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
479
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
480
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
481 481
                 }
482 482
             }
483 483
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	public static function entry_sidebar( $entry ) {
520
-        $data = maybe_unserialize($entry->description);
521
-        $date_format = get_option('date_format');
522
-        $time_format = get_option('time_format');
520
+        $data = maybe_unserialize( $entry->description );
521
+        $date_format = get_option( 'date_format' );
522
+        $time_format = get_option( 'time_format' );
523 523
 		if ( isset( $data['browser'] ) ) {
524 524
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
525 525
 		}
Please login to merge, or discard this patch.
classes/models/FrmEntryFormat.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -196,9 +196,9 @@
 block discarded – undo
196 196
 	}
197 197
 
198 198
 	/**
199
-	* Flatten multi-dimensional array for multi-file upload fields
200
-	* @since 2.0.9
201
-	*/
199
+	 * Flatten multi-dimensional array for multi-file upload fields
200
+	 * @since 2.0.9
201
+	 */
202 202
 	public static function flatten_multi_file_upload( $field, &$val ) {
203 203
 		if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) {
204 204
 			$val = FrmAppHelper::array_flatten( $val );
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			if ( ! self::skip_field( $atts, $f ) ) {
53 53
 				self::fill_entry_values( $atts, $f, $values );
54 54
 			}
55
-			unset($f);
55
+			unset( $f );
56 56
 		}
57 57
 
58 58
 		self::fill_entry_user_info( $atts, $values );
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			'type'  => $f->type,
122 122
 		);
123 123
 
124
-		$values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
124
+		$values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
125 125
 	}
126 126
 
127 127
 	public static function fill_entry_values( $atts, $f, array &$values ) {
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
 		self::prepare_field_output( $atts, $val );
154 154
 
155 155
 		if ( $atts['format'] != 'text' ) {
156
-			$values[ $f->field_key ] = $val;
156
+			$values[$f->field_key] = $val;
157 157
 			if ( $atts['entry'] && $f->type != 'textarea' ) {
158
-				$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
158
+				$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
159 159
 				if ( $prev_val != $val ) {
160
-					$values[ $f->field_key . '-value' ] = $prev_val;
160
+					$values[$f->field_key . '-value'] = $prev_val;
161 161
 				}
162 162
 			}
163 163
 		} else {
164
-			$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
164
+			$values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
165 165
 		}
166 166
 	}
167 167
 
168 168
 	private static function fill_missing_fields( $atts, &$values ) {
169
-		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
169
+		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) {
170 170
 			// In case include_blank is set
171
-			$atts['entry']->metas[ $atts['field']->id ] = '';
171
+			$atts['entry']->metas[$atts['field']->id] = '';
172 172
 			$atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
173 173
 			self::fill_values_from_entry( $atts, $values );
174 174
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	private static function get_field_value( $atts, &$val ) {
182 182
 		$f = $atts['field'];
183 183
 		if ( $atts['entry'] ) {
184
-			$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
184
+			$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
185 185
 			$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
186 186
 
187 187
 			//This filter applies to the default-message shortcode and frm-show-entry shortcode only
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			return;
253 253
 		}
254 254
 
255
-		$data  = self::get_entry_description_data( $atts );
255
+		$data = self::get_entry_description_data( $atts );
256 256
 
257 257
 		if ( $atts['default_email'] ) {
258 258
 			$atts['entry']->ip = '[ip]';
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
340 340
 
341 341
 		// see how many we have
342
-		$i = count($matches['browser']);
342
+		$i = count( $matches['browser'] );
343 343
 
344 344
 		if ( $i > 1 ) {
345 345
 			//we will have two since we are not using 'other' argument yet
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		self::convert_entry_to_content( $values, $atts, $content );
368 368
 
369 369
 		if ( 'text' == $atts['format'] ) {
370
-			$content = implode('', $content);
370
+			$content = implode( '', $content );
371 371
 		}
372 372
 
373 373
 		if ( $atts['clickable'] ) {
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 
421 421
 		// merge defaults, global settings, and shortcode options
422 422
 		foreach ( $default_settings as $key => $setting ) {
423
-			if ( $atts[ $key ] != '' ) {
423
+			if ( $atts[$key] != '' ) {
424 424
 				continue;
425 425
 			}
426 426
 
427
-			$atts[ $key ] = $setting;
427
+			$atts[$key] = $setting;
428 428
 			unset( $key, $setting );
429 429
 		}
430 430
 	}
Please login to merge, or discard this patch.
classes/models/FrmEmail.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			'entry'     => $this->entry,
96 96
 			'form'      => $this->form,
97 97
 		);
98
-		$to     = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
98
+		$to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
99 99
 
100 100
 		$this->to = array_unique( (array) $to );
101 101
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @return array
434 434
 	 */
435 435
 	private function package_header() {
436
-		$header   = array();
436
+		$header = array();
437 437
 
438 438
 		if ( ! empty( $this->cc ) ) {
439 439
 			$header[] = 'CC: ' . implode( ',', $this->cc );
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 					$name = trim( str_replace( $email, '', $val ) );
547 547
 				} else {
548 548
 					// If user enters a name without an email
549
-					unset( $recipients[ $key ] );
549
+					unset( $recipients[$key] );
550 550
 					continue;
551 551
 				}
552 552
 			}
553 553
 
554
-			$recipients[ $key ] = $name . ' <' . $email . '>';
554
+			$recipients[$key] = $name . ' <' . $email . '>';
555 555
 		}
556 556
 
557 557
 		return $recipients;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 				) );
669 669
 
670 670
 				// Remove phone number from to addresses
671
-				unset( $this->to[ $key ] );
671
+				unset( $this->to[$key] );
672 672
 			}
673 673
 		}
674 674
 	}
Please login to merge, or discard this patch.
classes/models/FrmEntryMeta.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -281,6 +281,7 @@
 block discarded – undo
281 281
      * @param string|array $where
282 282
      * @param string $order_by
283 283
      * @param string $limit
284
+     * @param boolean $unique
284 285
      */
285 286
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
286 287
         global $wpdb;
Please login to merge, or discard this patch.
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -5,25 +5,25 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntryMeta {
7 7
 
8
-    /**
9
-     * @param string $meta_key
10
-     */
8
+	/**
9
+	 * @param string $meta_key
10
+	 */
11 11
 	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
12
-        global $wpdb;
12
+		global $wpdb;
13 13
 
14
-        if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
-            // don't save blank fields
16
-            return 0;
17
-        }
14
+		if ( FrmAppHelper::is_empty_value( $meta_value ) ) {
15
+			// don't save blank fields
16
+			return 0;
17
+		}
18 18
 
19
-        $new_values = array(
19
+		$new_values = array(
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21
-            'item_id'       => $entry_id,
22
-            'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
24
-        );
21
+			'item_id'       => $entry_id,
22
+			'field_id'      => $field_id,
23
+			'created_at'    => current_time('mysql', 1),
24
+		);
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+		$new_values = apply_filters('frm_add_entry_meta', $new_values);
27 27
 
28 28
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
29 29
 
@@ -34,40 +34,40 @@  discard block
 block discarded – undo
34 34
 			$id = 0;
35 35
 		}
36 36
 
37
-        return $id;
38
-    }
37
+		return $id;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $meta_key
42
-     */
40
+	/**
41
+	 * @param string $meta_key
42
+	 */
43 43
 	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) {
44
-        if ( ! $field_id ) {
45
-            return false;
46
-        }
44
+		if ( ! $field_id ) {
45
+			return false;
46
+		}
47 47
 
48
-        global $wpdb;
48
+		global $wpdb;
49 49
 
50 50
 		$values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51 51
 		$where_values = $values;
52
-        $values['meta_value'] = $meta_value;
53
-        $values = apply_filters('frm_update_entry_meta', $values);
52
+		$values['meta_value'] = $meta_value;
53
+		$values = apply_filters('frm_update_entry_meta', $values);
54 54
 		if ( is_array($values['meta_value']) ) {
55 55
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
56 56
 		}
57
-        $meta_value = maybe_serialize($values['meta_value']);
57
+		$meta_value = maybe_serialize($values['meta_value']);
58 58
 
59
-        wp_cache_delete( $entry_id, 'frm_entry');
59
+		wp_cache_delete( $entry_id, 'frm_entry');
60 60
 		self::clear_cache();
61 61
 
62 62
 		return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
63
-    }
63
+	}
64 64
 
65 65
 	public static function update_entry_metas( $entry_id, $values ) {
66
-        global $wpdb;
66
+		global $wpdb;
67 67
 
68 68
 		$prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' );
69 69
 
70
-        foreach ( $values as $field_id => $meta_value ) {
70
+		foreach ( $values as $field_id => $meta_value ) {
71 71
 			$field = false;
72 72
 			if ( ! empty( $field_id ) ) {
73 73
 				$field = FrmField::getOne( $field_id );
@@ -91,39 +91,39 @@  discard block
 block discarded – undo
91 91
 			}
92 92
 		}
93 93
 
94
-        if ( empty($prev_values) ) {
95
-            return;
96
-        }
94
+		if ( empty($prev_values) ) {
95
+			return;
96
+		}
97 97
 
98
-        $prev_values = array_diff($prev_values, array_keys($values));
98
+		$prev_values = array_diff($prev_values, array_keys($values));
99 99
 
100
-        if ( empty($prev_values) ) {
101
-            return;
102
-        }
100
+		if ( empty($prev_values) ) {
101
+			return;
102
+		}
103 103
 
104 104
 		// prepare the query
105 105
 		$where = array( 'item_id' => $entry_id, 'field_id' => $prev_values );
106 106
 		FrmDb::get_where_clause_and_values( $where );
107 107
 
108
-        // Delete any leftovers
109
-        $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
108
+		// Delete any leftovers
109
+		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) );
110 110
 		self::clear_cache();
111
-    }
111
+	}
112 112
 
113 113
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
114
-        $metas = self::get_entry_meta_info($old_id);
115
-        foreach ( $metas as $meta ) {
116
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
117
-            unset($meta);
118
-        }
114
+		$metas = self::get_entry_meta_info($old_id);
115
+		foreach ( $metas as $meta ) {
116
+			self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
117
+			unset($meta);
118
+		}
119 119
 		self::clear_cache();
120
-    }
120
+	}
121 121
 
122 122
 	public static function delete_entry_meta( $entry_id, $field_id ) {
123
-        global $wpdb;
123
+		global $wpdb;
124 124
 		self::clear_cache();
125
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
126
-    }
125
+		return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
126
+	}
127 127
 
128 128
 	/**
129 129
 	 * Clear entry meta caching
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	}
149 149
 
150 150
 	public static function get_entry_meta_by_field( $entry_id, $field_id ) {
151
-        global $wpdb;
151
+		global $wpdb;
152 152
 
153 153
 		if ( is_object( $entry_id ) ) {
154 154
 			$entry = $entry_id;
@@ -161,130 +161,130 @@  discard block
 block discarded – undo
161 161
 
162 162
 		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
163 163
 			$result = $cached->metas[ $field_id ];
164
-            return stripslashes_deep($result);
165
-        }
164
+			return stripslashes_deep($result);
165
+		}
166 166
 
167 167
 		$get_table = $wpdb->prefix . 'frm_item_metas';
168 168
 		$query = array( 'item_id' => $entry_id );
169
-        if ( is_numeric($field_id) ) {
169
+		if ( is_numeric($field_id) ) {
170 170
 			$query['field_id'] = $field_id;
171
-        } else {
171
+		} else {
172 172
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
173 173
 			$query['fi.field_key'] = $field_id;
174
-        }
174
+		}
175 175
 
176 176
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
177
-        $result = maybe_unserialize($result);
178
-        $result = stripslashes_deep($result);
177
+		$result = maybe_unserialize($result);
178
+		$result = stripslashes_deep($result);
179 179
 
180
-        return $result;
181
-    }
180
+		return $result;
181
+	}
182 182
 
183
-    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
183
+	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) {
184 184
 		$defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false );
185
-        $args = wp_parse_args( $args, $defaults );
185
+		$args = wp_parse_args( $args, $defaults );
186 186
 
187
-        $query = array();
188
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
189
-        $query = implode(' ', $query);
187
+		$query = array();
188
+		self::meta_field_query($field_id, $order, $limit, $args, $query);
189
+		$query = implode(' ', $query);
190 190
 
191 191
 		$cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
192
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
192
+		$values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
193 193
 
194
-        if ( ! $args['stripslashes'] ) {
195
-            return $values;
196
-        }
194
+		if ( ! $args['stripslashes'] ) {
195
+			return $values;
196
+		}
197 197
 
198 198
 		foreach ( $values as $k => $v ) {
199 199
 			$values[ $k ] = maybe_unserialize( $v );
200
-            unset($k, $v);
201
-        }
200
+			unset($k, $v);
201
+		}
202 202
 
203
-        return stripslashes_deep($values);
204
-    }
203
+		return stripslashes_deep($values);
204
+	}
205 205
 
206
-    /**
207
-     * @param string $order
208
-     * @param string $limit
209
-     */
206
+	/**
207
+	 * @param string $order
208
+	 * @param string $limit
209
+	 */
210 210
 	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) {
211
-        global $wpdb;
212
-        $query[] = 'SELECT';
213
-        $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
211
+		global $wpdb;
212
+		$query[] = 'SELECT';
213
+		$query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value';
214 214
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em ';
215 215
 
216
-        if ( ! $args['is_draft'] ) {
216
+		if ( ! $args['is_draft'] ) {
217 217
 			$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
218
-        }
218
+		}
219 219
 
220
-        if ( is_numeric($field_id) ) {
221
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
222
-        } else {
220
+		if ( is_numeric($field_id) ) {
221
+			$query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
222
+		} else {
223 223
 			$query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
224
-        }
224
+		}
225 225
 
226
-        if ( ! $args['is_draft'] ) {
227
-            $query[] = 'AND e.is_draft=0';
228
-        }
226
+		if ( ! $args['is_draft'] ) {
227
+			$query[] = 'AND e.is_draft=0';
228
+		}
229 229
 
230
-        if ( $args['value'] ) {
231
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
232
-        }
233
-        $query[] = $order . $limit;
234
-    }
230
+		if ( $args['value'] ) {
231
+			$query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
232
+		}
233
+		$query[] = $order . $limit;
234
+	}
235 235
 
236 236
 	public static function get_entry_meta_info( $entry_id ) {
237 237
 		return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) );
238
-    }
238
+	}
239 239
 
240 240
 	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) {
241
-        global $wpdb;
242
-        $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
241
+		global $wpdb;
242
+		$query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
243 243
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
244 244
 			FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
245
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
245
+			FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
246 246
 
247 247
 		$cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
248
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
248
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
249 249
 
250
-        if ( ! $results || ! $stripslashes ) {
251
-            return $results;
252
-        }
250
+		if ( ! $results || ! $stripslashes ) {
251
+			return $results;
252
+		}
253 253
 
254
-        foreach ( $results as $k => $result ) {
254
+		foreach ( $results as $k => $result ) {
255 255
 			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
256
-            unset($k, $result);
257
-        }
256
+			unset($k, $result);
257
+		}
258 258
 
259
-        return $results;
260
-    }
259
+		return $results;
260
+	}
261 261
 
262
-    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
262
+	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) {
263 263
 		$defaults = array(
264 264
 			'is_draft' => false,
265 265
 			'user_id'  => '',
266 266
 			'group_by' => '',
267 267
 		);
268
-        $args = wp_parse_args($args, $defaults);
268
+		$args = wp_parse_args($args, $defaults);
269 269
 
270
-        $query = array();
271
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
272
-        $query = implode(' ', $query);
270
+		$query = array();
271
+		self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
272
+		$query = implode(' ', $query);
273 273
 
274 274
 		$cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
275
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
275
+		$results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
276 276
 
277
-        return $results;
278
-    }
277
+		return $results;
278
+	}
279 279
 
280
-    /**
281
-     * @param string|array $where
282
-     * @param string $order_by
283
-     * @param string $limit
284
-     */
280
+	/**
281
+	 * @param string|array $where
282
+	 * @param string $order_by
283
+	 * @param string $limit
284
+	 */
285 285
 	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) {
286
-        global $wpdb;
287
-        $query[] = 'SELECT';
286
+		global $wpdb;
287
+		$query[] = 'SELECT';
288 288
 
289 289
 		$defaults = array( 'return_parent_id' => false );
290 290
 		$args = array_merge( $defaults, $args );
@@ -298,89 +298,89 @@  discard block
 block discarded – undo
298 298
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
299 299
 
300 300
 		$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
301
-        if ( is_array($where) ) {
302
-            if ( ! $args['is_draft'] ) {
303
-                $where['e.is_draft'] = 0;
304
-            } else if ( $args['is_draft'] == 1 ) {
305
-                $where['e.is_draft'] = 1;
306
-            }
307
-
308
-            if ( ! empty($args['user_id']) ) {
309
-                $where['e.user_id'] = $args['user_id'];
310
-            }
311
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
301
+		if ( is_array($where) ) {
302
+			if ( ! $args['is_draft'] ) {
303
+				$where['e.is_draft'] = 0;
304
+			} else if ( $args['is_draft'] == 1 ) {
305
+				$where['e.is_draft'] = 1;
306
+			}
307
+
308
+			if ( ! empty($args['user_id']) ) {
309
+				$where['e.user_id'] = $args['user_id'];
310
+			}
311
+			$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
312 312
 
313 313
 			if ( $args['group_by'] ) {
314 314
 				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
315 315
 			}
316
-            return;
317
-        }
316
+			return;
317
+		}
318 318
 
319 319
 		$draft_where = '';
320 320
 		$user_where = '';
321
-        if ( ! $args['is_draft'] ) {
321
+		if ( ! $args['is_draft'] ) {
322 322
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 );
323
-        } else if ( $args['is_draft'] == 1 ) {
323
+		} else if ( $args['is_draft'] == 1 ) {
324 324
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
325
-        }
325
+		}
326 326
 
327
-        if ( ! empty($args['user_id']) ) {
328
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
329
-        }
327
+		if ( ! empty($args['user_id']) ) {
328
+			$user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
329
+		}
330 330
 
331
-        if ( strpos($where, ' GROUP BY ') ) {
332
-            // don't inject WHERE filtering after GROUP BY
333
-            $parts = explode(' GROUP BY ', $where);
334
-            $where = $parts[0];
335
-            $where .= $draft_where . $user_where;
331
+		if ( strpos($where, ' GROUP BY ') ) {
332
+			// don't inject WHERE filtering after GROUP BY
333
+			$parts = explode(' GROUP BY ', $where);
334
+			$where = $parts[0];
335
+			$where .= $draft_where . $user_where;
336 336
 			$where .= ' GROUP BY ' . $parts[1];
337
-        } else {
338
-            $where .= $draft_where . $user_where;
339
-        }
337
+		} else {
338
+			$where .= $draft_where . $user_where;
339
+		}
340 340
 
341 341
 		// The query has already been prepared
342 342
 		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
343
-    }
343
+	}
344 344
 
345
-    public static function search_entry_metas( $search, $field_id = '', $operator ) {
345
+	public static function search_entry_metas( $search, $field_id = '', $operator ) {
346 346
 		$cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
347
-        $results = wp_cache_get($cache_key, 'frm_entry');
348
-        if ( false !== $results ) {
349
-            return $results;
350
-        }
347
+		$results = wp_cache_get($cache_key, 'frm_entry');
348
+		if ( false !== $results ) {
349
+			return $results;
350
+		}
351 351
 
352
-        global $wpdb;
352
+		global $wpdb;
353 353
 		if ( is_array( $search ) ) {
354
-            $where = '';
354
+			$where = '';
355 355
 			foreach ( $search as $field => $value ) {
356 356
 				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) {
357
-                    continue;
358
-                }
357
+					continue;
358
+				}
359 359
 
360
-                switch ( $field ) {
361
-                    case 'year':
360
+				switch ( $field ) {
361
+					case 'year':
362 362
 						$value = '%' . $value;
363
-                    break;
364
-                    case 'month':
365
-                        $value .= '%';
366
-                    break;
367
-                    case 'day':
363
+					break;
364
+					case 'month':
365
+						$value .= '%';
366
+					break;
367
+					case 'day':
368 368
 						$value = '%' . $value . '%';
369
-                }
369
+				}
370 370
 				$where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value );
371
-            }
372
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
371
+			}
372
+			$where .= $wpdb->prepare(' field_id=%d', $field_id);
373 373
 			$query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
374
-        } else {
374
+		} else {
375 375
 			if ( $operator == 'LIKE' ) {
376
-                $search = '%' . $search . '%';
376
+				$search = '%' . $search . '%';
377 377
 			}
378
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
379
-        }
378
+			$query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
379
+		}
380 380
 
381
-        $results = $wpdb->get_col($query, 0);
381
+		$results = $wpdb->get_col($query, 0);
382 382
 		FrmAppHelper::set_cache( $cache_key, $results, 'frm_entry' );
383 383
 
384
-        return $results;
385
-    }
384
+		return $results;
385
+	}
386 386
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 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
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 			'meta_value'    => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ),
21 21
             'item_id'       => $entry_id,
22 22
             'field_id'      => $field_id,
23
-            'created_at'    => current_time('mysql', 1),
23
+            'created_at'    => current_time( 'mysql', 1 ),
24 24
         );
25 25
 
26
-        $new_values = apply_filters('frm_add_entry_meta', $new_values);
26
+        $new_values = apply_filters( 'frm_add_entry_meta', $new_values );
27 27
 
28 28
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values );
29 29
 
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 		$values = array( 'item_id' => $entry_id, 'field_id' => $field_id );
51 51
 		$where_values = $values;
52 52
         $values['meta_value'] = $meta_value;
53
-        $values = apply_filters('frm_update_entry_meta', $values);
54
-		if ( is_array($values['meta_value']) ) {
53
+        $values = apply_filters( 'frm_update_entry_meta', $values );
54
+		if ( is_array( $values['meta_value'] ) ) {
55 55
 			$values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' );
56 56
 		}
57
-        $meta_value = maybe_serialize($values['meta_value']);
57
+        $meta_value = maybe_serialize( $values['meta_value'] );
58 58
 
59
-        wp_cache_delete( $entry_id, 'frm_entry');
59
+        wp_cache_delete( $entry_id, 'frm_entry' );
60 60
 		self::clear_cache();
61 61
 
62 62
 		return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values );
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 			// set the value for the file upload field and add new tags (in Pro version)
77 77
 			$meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id, compact( 'field' ) );
78 78
 
79
-			if ( $prev_values && in_array($field_id, $prev_values) ) {
79
+			if ( $prev_values && in_array( $field_id, $prev_values ) ) {
80 80
 
81 81
 				if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) {
82 82
 					// remove blank fields
83
-					unset( $values[ $field_id ] );
83
+					unset( $values[$field_id] );
84 84
 				} else {
85 85
 					// if value exists, then update it
86 86
 					self::update_entry_meta( $entry_id, $field_id, '', $meta_value );
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 			}
92 92
 		}
93 93
 
94
-        if ( empty($prev_values) ) {
94
+        if ( empty( $prev_values ) ) {
95 95
             return;
96 96
         }
97 97
 
98
-        $prev_values = array_diff($prev_values, array_keys($values));
98
+        $prev_values = array_diff( $prev_values, array_keys( $values ) );
99 99
 
100
-        if ( empty($prev_values) ) {
100
+        if ( empty( $prev_values ) ) {
101 101
             return;
102 102
         }
103 103
 
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
     }
112 112
 
113 113
 	public static function duplicate_entry_metas( $old_id, $new_id ) {
114
-        $metas = self::get_entry_meta_info($old_id);
114
+        $metas = self::get_entry_meta_info( $old_id );
115 115
         foreach ( $metas as $meta ) {
116
-            self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value);
117
-            unset($meta);
116
+            self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value );
117
+            unset( $meta );
118 118
         }
119 119
 		self::clear_cache();
120 120
     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	public static function delete_entry_meta( $entry_id, $field_id ) {
123 123
         global $wpdb;
124 124
 		self::clear_cache();
125
-        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id));
125
+        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) );
126 126
     }
127 127
 
128 128
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public static function get_meta_value( $entry, $field_id ) {
143 143
 		if ( isset( $entry->metas ) ) {
144
-			return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false;
144
+			return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false;
145 145
 		} else {
146 146
 			return self::get_entry_meta_by_field( $entry->id, $field_id );
147 147
 		}
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 			$cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' );
160 160
 		}
161 161
 
162
-		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) {
163
-			$result = $cached->metas[ $field_id ];
164
-            return stripslashes_deep($result);
162
+		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) {
163
+			$result = $cached->metas[$field_id];
164
+            return stripslashes_deep( $result );
165 165
         }
166 166
 
167 167
 		$get_table = $wpdb->prefix . 'frm_item_metas';
168 168
 		$query = array( 'item_id' => $entry_id );
169
-        if ( is_numeric($field_id) ) {
169
+        if ( is_numeric( $field_id ) ) {
170 170
 			$query['field_id'] = $field_id;
171 171
         } else {
172 172
 			$get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
         }
175 175
 
176 176
 		$result = FrmDb::get_var( $get_table, $query, 'meta_value' );
177
-        $result = maybe_unserialize($result);
178
-        $result = stripslashes_deep($result);
177
+        $result = maybe_unserialize( $result );
178
+        $result = stripslashes_deep( $result );
179 179
 
180 180
         return $result;
181 181
     }
@@ -185,22 +185,22 @@  discard block
 block discarded – undo
185 185
         $args = wp_parse_args( $args, $defaults );
186 186
 
187 187
         $query = array();
188
-        self::meta_field_query($field_id, $order, $limit, $args, $query);
189
-        $query = implode(' ', $query);
188
+        self::meta_field_query( $field_id, $order, $limit, $args, $query );
189
+        $query = implode( ' ', $query );
190 190
 
191 191
 		$cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args );
192
-        $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col');
192
+        $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' );
193 193
 
194 194
         if ( ! $args['stripslashes'] ) {
195 195
             return $values;
196 196
         }
197 197
 
198 198
 		foreach ( $values as $k => $v ) {
199
-			$values[ $k ] = maybe_unserialize( $v );
200
-            unset($k, $v);
199
+			$values[$k] = maybe_unserialize( $v );
200
+            unset( $k, $v );
201 201
         }
202 202
 
203
-        return stripslashes_deep($values);
203
+        return stripslashes_deep( $values );
204 204
     }
205 205
 
206 206
     /**
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 			$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)';
218 218
         }
219 219
 
220
-        if ( is_numeric($field_id) ) {
221
-            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id);
220
+        if ( is_numeric( $field_id ) ) {
221
+            $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id );
222 222
         } else {
223 223
 			$query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id );
224 224
         }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         }
229 229
 
230 230
         if ( $args['value'] ) {
231
-            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']);
231
+            $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] );
232 232
         }
233 233
         $query[] = $order . $limit;
234 234
     }
@@ -242,18 +242,18 @@  discard block
 block discarded – undo
242 242
         $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key,
243 243
             fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options
244 244
 			FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' .
245
-            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
245
+            FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
246 246
 
247 247
 		$cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit;
248
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results'));
248
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) );
249 249
 
250 250
         if ( ! $results || ! $stripslashes ) {
251 251
             return $results;
252 252
         }
253 253
 
254 254
         foreach ( $results as $k => $result ) {
255
-			$results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
256
-            unset($k, $result);
255
+			$results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) );
256
+            unset( $k, $result );
257 257
         }
258 258
 
259 259
         return $results;
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 			'user_id'  => '',
266 266
 			'group_by' => '',
267 267
 		);
268
-        $args = wp_parse_args($args, $defaults);
268
+        $args = wp_parse_args( $args, $defaults );
269 269
 
270 270
         $query = array();
271
-        self::get_ids_query($where, $order_by, $limit, $unique, $args, $query );
272
-        $query = implode(' ', $query);
271
+        self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query );
272
+        $query = implode( ' ', $query );
273 273
 
274 274
 		$cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args );
275
-        $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col'));
275
+        $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) );
276 276
 
277 277
         return $results;
278 278
     }
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
 		$query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id';
299 299
 
300 300
 		$query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)';
301
-        if ( is_array($where) ) {
301
+        if ( is_array( $where ) ) {
302 302
             if ( ! $args['is_draft'] ) {
303 303
                 $where['e.is_draft'] = 0;
304 304
             } else if ( $args['is_draft'] == 1 ) {
305 305
                 $where['e.is_draft'] = 1;
306 306
             }
307 307
 
308
-            if ( ! empty($args['user_id']) ) {
308
+            if ( ! empty( $args['user_id'] ) ) {
309 309
                 $where['e.user_id'] = $args['user_id'];
310 310
             }
311
-            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
311
+            $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
312 312
 
313 313
 			if ( $args['group_by'] ) {
314 314
 				$query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] );
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 			$draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 );
325 325
         }
326 326
 
327
-        if ( ! empty($args['user_id']) ) {
328
-            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']);
327
+        if ( ! empty( $args['user_id'] ) ) {
328
+            $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] );
329 329
         }
330 330
 
331
-        if ( strpos($where, ' GROUP BY ') ) {
331
+        if ( strpos( $where, ' GROUP BY ' ) ) {
332 332
             // don't inject WHERE filtering after GROUP BY
333
-            $parts = explode(' GROUP BY ', $where);
333
+            $parts = explode( ' GROUP BY ', $where );
334 334
             $where = $parts[0];
335 335
             $where .= $draft_where . $user_where;
336 336
 			$where .= ' GROUP BY ' . $parts[1];
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
         }
340 340
 
341 341
 		// The query has already been prepared
342
-		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit;
342
+		$query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
343 343
     }
344 344
 
345 345
     public static function search_entry_metas( $search, $field_id = '', $operator ) {
346 346
 		$cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator;
347
-        $results = wp_cache_get($cache_key, 'frm_entry');
347
+        $results = wp_cache_get( $cache_key, 'frm_entry' );
348 348
         if ( false !== $results ) {
349 349
             return $results;
350 350
         }
@@ -367,18 +367,18 @@  discard block
 block discarded – undo
367 367
                     case 'day':
368 368
 						$value = '%' . $value . '%';
369 369
                 }
370
-				$where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value );
370
+				$where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value );
371 371
             }
372
-            $where .= $wpdb->prepare(' field_id=%d', $field_id);
372
+            $where .= $wpdb->prepare( ' field_id=%d', $field_id );
373 373
 			$query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where );
374 374
         } else {
375 375
 			if ( $operator == 'LIKE' ) {
376 376
                 $search = '%' . $search . '%';
377 377
 			}
378
-            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id);
378
+            $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id );
379 379
         }
380 380
 
381
-        $results = $wpdb->get_col($query, 0);
381
+        $results = $wpdb->get_col( $query, 0 );
382 382
 		FrmAppHelper::set_cache( $cache_key, $results, 'frm_entry' );
383 383
 
384 384
         return $results;
Please login to merge, or discard this patch.
classes/models/FrmFieldOption.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -31,6 +31,10 @@
 block discarded – undo
31 31
 	 */
32 32
 	protected $option_label = '';
33 33
 
34
+	/**
35
+	 * @param string $option_key
36
+	 * @param string $option
37
+	 */
34 38
 	public function __construct( $option_key, $option, $args = array() ) {
35 39
 		$this->option_key = $option_key;
36 40
 		$this->option = $option;
Please login to merge, or discard this patch.
classes/models/FrmFieldValueSelector.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
 	/**
76 76
 	 * FrmFieldValueSelector constructor
77 77
 	 *
78
-	 * @param int|string $field_id
78
+	 * @param integer $field_id
79 79
 	 */
80 80
 	public function __construct( $field_id, $args ) {
81 81
 		$this->set_html_name( $args );
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -1,262 +1,262 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
3
+	die('You are not allowed to call this page directly.');
4 4
 }
5 5
 
6 6
 class FrmForm {
7 7
 
8
-    /**
9
-     * @return int|boolean id on success or false on failure
10
-     */
11
-    public static function create( $values ) {
12
-        global $wpdb;
8
+	/**
9
+	 * @return int|boolean id on success or false on failure
10
+	 */
11
+	public static function create( $values ) {
12
+		global $wpdb;
13 13
 
14
-        $new_values = array(
14
+		$new_values = array(
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16
-            'name'          => $values['name'],
17
-            'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
16
+			'name'          => $values['name'],
17
+			'description'   => $values['description'],
18
+			'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
+			'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
+			'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
-        );
22
+			'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
+			'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
+			'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
25
+		);
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
+		$options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
35
+		$new_values['options'] = serialize($options);
36 36
 
37
-        //if(isset($values['id']) && is_numeric($values['id']))
38
-        //    $new_values['id'] = $values['id'];
37
+		//if(isset($values['id']) && is_numeric($values['id']))
38
+		//    $new_values['id'] = $values['id'];
39 39
 
40 40
 		$wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
41 41
 
42
-        $id = $wpdb->insert_id;
42
+		$id = $wpdb->insert_id;
43 43
 
44 44
 		// Clear form caching
45 45
 		self::clear_form_cache();
46 46
 
47
-        return $id;
48
-    }
47
+		return $id;
48
+	}
49 49
 
50
-    /**
51
-     * @return int|boolean ID on success or false on failure
52
-     */
53
-    public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
-        global $wpdb;
50
+	/**
51
+	 * @return int|boolean ID on success or false on failure
52
+	 */
53
+	public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) {
54
+		global $wpdb;
55 55
 
56
-        $values = self::getOne( $id, $blog_id );
57
-        if ( ! $values ) {
58
-            return false;
59
-        }
56
+		$values = self::getOne( $id, $blog_id );
57
+		if ( ! $values ) {
58
+			return false;
59
+		}
60 60
 
61
-        $new_key = $copy_keys ? $values->form_key : '';
61
+		$new_key = $copy_keys ? $values->form_key : '';
62 62
 
63
-        $new_values = array(
63
+		$new_values = array(
64 64
 			'form_key'      => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ),
65
-            'name'          => $values->name,
66
-            'description'   => $values->description,
67
-            'status'        => $template ? 'published' : 'draft',
68
-            'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
-            'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
71
-            'is_template'   => $template ? 1 : 0,
72
-        );
73
-
74
-        if ( $blog_id ) {
75
-            $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
78
-            $new_options['copy'] = false;
79
-            $new_values['options'] = $new_options;
80
-        } else {
81
-            $new_values['options'] = $values->options;
82
-        }
83
-
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
86
-        }
65
+			'name'          => $values->name,
66
+			'description'   => $values->description,
67
+			'status'        => $template ? 'published' : 'draft',
68
+			'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69
+			'editable'      => $values->editable ? $values->editable : 0,
70
+			'created_at'    => current_time('mysql', 1),
71
+			'is_template'   => $template ? 1 : 0,
72
+		);
73
+
74
+		if ( $blog_id ) {
75
+			$new_values['status'] = 'published';
76
+			$new_options = maybe_unserialize($values->options);
77
+			$new_options['email_to'] = get_option('admin_email');
78
+			$new_options['copy'] = false;
79
+			$new_values['options'] = $new_options;
80
+		} else {
81
+			$new_values['options'] = $values->options;
82
+		}
83
+
84
+		if ( is_array($new_values['options']) ) {
85
+			$new_values['options'] = serialize($new_values['options']);
86
+		}
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
89 89
 
90
-        if ( $query_results ) {
90
+		if ( $query_results ) {
91 91
 			// Clear form caching
92 92
 			self::clear_form_cache();
93 93
 
94
-            $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
94
+			$form_id = $wpdb->insert_id;
95
+			FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
96 96
 
97
-            // update form settings after fields are created
97
+			// update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
99
-            return $form_id;
100
-        }
99
+			return $form_id;
100
+		}
101 101
 
102
-        return false;
103
-    }
102
+		return false;
103
+	}
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
107 107
 		$values['options'] = $new_opts;
108 108
 
109
-        if ( isset($new_opts['success_msg']) ) {
110
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
111
-        }
109
+		if ( isset($new_opts['success_msg']) ) {
110
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
111
+		}
112 112
 
113
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
114 114
 
115
-        if ( $new_opts != $values['options'] ) {
116
-            global $wpdb;
115
+		if ( $new_opts != $values['options'] ) {
116
+			global $wpdb;
117 117
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
118
-        }
119
-    }
118
+		}
119
+	}
120 120
 
121
-    /**
122
-     * @return int|boolean
123
-     */
124
-    public static function update( $id, $values, $create_link = false ) {
125
-        global $wpdb;
121
+	/**
122
+	 * @return int|boolean
123
+	 */
124
+	public static function update( $id, $values, $create_link = false ) {
125
+		global $wpdb;
126 126
 
127
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
-            $values['status'] = 'published';
129
-        }
127
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
128
+			$values['status'] = 'published';
129
+		}
130 130
 
131
-        if ( isset($values['form_key']) ) {
131
+		if ( isset($values['form_key']) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133
-        }
133
+		}
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137
-        $new_values = self::set_update_options( array(), $values);
137
+		$new_values = self::set_update_options( array(), $values);
138 138
 
139
-        foreach ( $values as $value_key => $value ) {
139
+		foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141 141
 				$new_values[ $value_key ] = $value;
142
-            }
143
-        }
142
+			}
143
+		}
144 144
 
145
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
-            $new_values['status'] = $values['new_status'];
147
-        }
145
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
146
+			$new_values['status'] = $values['new_status'];
147
+		}
148 148
 
149
-        if ( ! empty( $new_values ) ) {
149
+		if ( ! empty( $new_values ) ) {
150 150
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
151
-            if ( $query_results ) {
151
+			if ( $query_results ) {
152 152
 				self::clear_form_cache();
153
-            }
154
-        } else {
155
-            $query_results = true;
156
-        }
157
-        unset($new_values);
153
+			}
154
+		} else {
155
+			$query_results = true;
156
+		}
157
+		unset($new_values);
158 158
 
159
-        $values = self::update_fields($id, $values);
159
+		$values = self::update_fields($id, $values);
160 160
 
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
163 163
 
164
-        return $query_results;
165
-    }
164
+		return $query_results;
165
+	}
166 166
 
167
-    /**
168
-     * @return array
169
-     */
167
+	/**
168
+	 * @return array
169
+	 */
170 170
 	public static function set_update_options( $new_values, $values ) {
171
-        if ( ! isset($values['options']) ) {
172
-            return $new_values;
173
-        }
171
+		if ( ! isset($values['options']) ) {
172
+			return $new_values;
173
+		}
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
177 177
 
178
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
178
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
182 182
 
183
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
184
-        $new_values['options'] = serialize($options);
183
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
184
+		$new_values['options'] = serialize($options);
185 185
 
186
-        return $new_values;
187
-    }
186
+		return $new_values;
187
+	}
188 188
 
189 189
 
190
-    /**
191
-     * @return array
192
-     */
190
+	/**
191
+	 * @return array
192
+	 */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195
-        if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
196
-            return $values;
197
-        }
195
+		if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
196
+			return $values;
197
+		}
198 198
 
199
-        $all_fields = FrmField::get_all_for_form($id);
200
-        if ( empty($all_fields) ) {
201
-            return $values;
202
-        }
199
+		$all_fields = FrmField::get_all_for_form($id);
200
+		if ( empty($all_fields) ) {
201
+			return $values;
202
+		}
203 203
 
204
-        if ( ! isset($values['item_meta']) ) {
205
-            $values['item_meta'] = array();
206
-        }
204
+		if ( ! isset($values['item_meta']) ) {
205
+			$values['item_meta'] = array();
206
+		}
207 207
 
208
-        $field_array = array();
209
-        $existing_keys = array_keys($values['item_meta']);
210
-        foreach ( $all_fields as $fid ) {
211
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
208
+		$field_array = array();
209
+		$existing_keys = array_keys($values['item_meta']);
210
+		foreach ( $all_fields as $fid ) {
211
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
212 212
 				$values['item_meta'][ $fid->id ] = '';
213
-            }
213
+			}
214 214
 			$field_array[ $fid->id ] = $fid;
215
-        }
216
-        unset($all_fields);
215
+		}
216
+		unset($all_fields);
217 217
 
218
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
219 219
 			if ( isset( $field_array[ $field_id ] ) ) {
220 220
 				$field = $field_array[ $field_id ];
221
-            } else {
222
-                $field = FrmField::getOne($field_id);
223
-            }
221
+			} else {
222
+				$field = FrmField::getOne($field_id);
223
+			}
224 224
 
225
-            if ( ! $field ) {
226
-                continue;
227
-            }
225
+			if ( ! $field ) {
226
+				continue;
227
+			}
228 228
 
229 229
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
230 230
 			if ( $is_settings_page ) {
231
-                //updating the settings page
231
+				//updating the settings page
232 232
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
233 233
 					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
234
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
234
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
235 235
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
236
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237
-                    $prev_opts = $field->field_options;
238
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
239
-                    if ( $prev_opts != $field->field_options ) {
236
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237
+					$prev_opts = $field->field_options;
238
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
239
+					if ( $prev_opts != $field->field_options ) {
240 240
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
241
-                    }
242
-                    unset($prev_opts);
243
-                }
244
-            }
241
+					}
242
+					unset($prev_opts);
243
+				}
244
+			}
245 245
 
246 246
 			if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) {
247
-                continue;
248
-            }
247
+				continue;
248
+			}
249 249
 
250
-            //updating the form
250
+			//updating the form
251 251
 			$update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true );
252 252
 			unset( $update_options['custom_html'] ); // don't check for POST html
253 253
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
254 254
 
255 255
 			foreach ( $update_options as $opt => $default ) {
256 256
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
257
-            }
257
+			}
258 258
 
259
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
260 260
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
261 261
 
262 262
 			$new_field = array(
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 
269 269
 			FrmField::update( $field_id, $new_field );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
272
-        }
271
+			FrmField::delete_form_transient($field->form_id);
272
+		}
273 273
 		self::clear_form_cache();
274 274
 
275
-        return $values;
276
-    }
275
+		return $values;
276
+	}
277 277
 
278 278
 	private static function prepare_field_update_values( $field, $values, &$new_field ) {
279 279
 		$field_cols = array(
@@ -286,113 +286,113 @@  discard block
 block discarded – undo
286 286
 		}
287 287
 	}
288 288
 
289
-    /**
290
-     * @param string $status
291
-     * @return int|boolean
292
-     */
289
+	/**
290
+	 * @param string $status
291
+	 * @return int|boolean
292
+	 */
293 293
 	public static function set_status( $id, $status ) {
294
-        if ( 'trash' == $status ) {
295
-            return self::trash($id);
296
-        }
294
+		if ( 'trash' == $status ) {
295
+			return self::trash($id);
296
+		}
297 297
 
298 298
 		$statuses  = array( 'published', 'draft', 'trash' );
299
-        if ( ! in_array( $status, $statuses ) ) {
300
-            return false;
301
-        }
299
+		if ( ! in_array( $status, $statuses ) ) {
300
+			return false;
301
+		}
302 302
 
303
-        global $wpdb;
303
+		global $wpdb;
304 304
 
305
-        if ( is_array($id) ) {
305
+		if ( is_array($id) ) {
306 306
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
307 307
 			FrmDb::get_where_clause_and_values( $where );
308 308
 			array_unshift( $where['values'], $status );
309 309
 
310 310
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
311
-        } else {
311
+		} else {
312 312
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
313 313
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
314
-        }
314
+		}
315 315
 
316
-        if ( $query_results ) {
316
+		if ( $query_results ) {
317 317
 			self::clear_form_cache();
318
-        }
318
+		}
319 319
 
320
-        return $query_results;
321
-    }
320
+		return $query_results;
321
+	}
322 322
 
323
-    /**
324
-     * @return int|boolean
325
-     */
323
+	/**
324
+	 * @return int|boolean
325
+	 */
326 326
 	public static function trash( $id ) {
327
-        if ( ! EMPTY_TRASH_DAYS ) {
328
-            return self::destroy( $id );
329
-        }
327
+		if ( ! EMPTY_TRASH_DAYS ) {
328
+			return self::destroy( $id );
329
+		}
330 330
 
331
-        $form = self::getOne($id);
332
-        if ( ! $form ) {
333
-            return false;
334
-        }
331
+		$form = self::getOne($id);
332
+		if ( ! $form ) {
333
+			return false;
334
+		}
335 335
 
336
-        $options = $form->options;
337
-        $options['trash_time'] = time();
336
+		$options = $form->options;
337
+		$options['trash_time'] = time();
338 338
 
339
-        global $wpdb;
340
-        $query_results = $wpdb->update(
339
+		global $wpdb;
340
+		$query_results = $wpdb->update(
341 341
 			$wpdb->prefix . 'frm_forms',
342 342
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
343 343
 			array( 'id' => $id )
344
-        );
344
+		);
345 345
 
346
-        $wpdb->update(
346
+		$wpdb->update(
347 347
 			$wpdb->prefix . 'frm_forms',
348 348
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
349 349
 			array( 'parent_form_id' => $id )
350
-        );
350
+		);
351 351
 
352
-        if ( $query_results ) {
352
+		if ( $query_results ) {
353 353
 			self::clear_form_cache();
354
-        }
354
+		}
355 355
 
356
-        return $query_results;
357
-    }
356
+		return $query_results;
357
+	}
358 358
 
359
-    /**
360
-     * @return int|boolean
361
-     */
359
+	/**
360
+	 * @return int|boolean
361
+	 */
362 362
 	public static function destroy( $id ) {
363
-        global $wpdb;
363
+		global $wpdb;
364 364
 
365
-        $form = self::getOne($id);
366
-        if ( ! $form ) {
367
-            return false;
368
-        }
365
+		$form = self::getOne($id);
366
+		if ( ! $form ) {
367
+			return false;
368
+		}
369 369
 		$id = $form->id;
370 370
 
371
-        // Disconnect the entries from this form
371
+		// Disconnect the entries from this form
372 372
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
373
-        foreach ( $entries as $entry_id ) {
374
-            FrmEntry::destroy($entry_id);
375
-            unset($entry_id);
376
-        }
373
+		foreach ( $entries as $entry_id ) {
374
+			FrmEntry::destroy($entry_id);
375
+			unset($entry_id);
376
+		}
377 377
 
378
-        // Disconnect the fields from this form
378
+		// Disconnect the fields from this form
379 379
 		$wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) );
380 380
 
381 381
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
382
-        if ( $query_results ) {
383
-            // Delete all form actions linked to this form
384
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
385
-            $action_control->destroy($id, 'all');
382
+		if ( $query_results ) {
383
+			// Delete all form actions linked to this form
384
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
385
+			$action_control->destroy($id, 'all');
386 386
 
387 387
 			// Clear form caching
388 388
 			self::clear_form_cache();
389 389
 
390 390
 			do_action( 'frm_destroy_form', $id );
391 391
 			do_action( 'frm_destroy_form_' . $id );
392
-        }
392
+		}
393 393
 
394
-        return $query_results;
395
-    }
394
+		return $query_results;
395
+	}
396 396
 
397 397
 	/**
398 398
 	 * Delete trashed forms based on how long they have been trashed
@@ -424,47 +424,47 @@  discard block
 block discarded – undo
424 424
 		return $count;
425 425
 	}
426 426
 
427
-    /**
428
-     * @return string form name
429
-     */
430
-    public static function getName( $id ) {
431
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
432
-        if ( $form ) {
433
-            $r = stripslashes($form->name);
434
-            return $r;
435
-        }
436
-
437
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
438
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
439
-        $r = stripslashes($r);
440
-
441
-        return $r;
442
-    }
443
-
444
-    /**
445
-     * @param string $key
446
-     * @return int form id
447
-     */
427
+	/**
428
+	 * @return string form name
429
+	 */
430
+	public static function getName( $id ) {
431
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
432
+		if ( $form ) {
433
+			$r = stripslashes($form->name);
434
+			return $r;
435
+		}
436
+
437
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
438
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
439
+		$r = stripslashes($r);
440
+
441
+		return $r;
442
+	}
443
+
444
+	/**
445
+	 * @param string $key
446
+	 * @return int form id
447
+	 */
448 448
 	public static function getIdByKey( $key ) {
449
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
450
-        return $id;
451
-    }
452
-
453
-    /**
454
-     * @param int $id
455
-     * @return string form key
456
-     */
449
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
450
+		return $id;
451
+	}
452
+
453
+	/**
454
+	 * @param int $id
455
+	 * @return string form key
456
+	 */
457 457
 	public static function getKeyById( $id ) {
458
-        $id = (int) $id;
459
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
460
-        if ( $cache ) {
461
-            return $cache->form_key;
462
-        }
458
+		$id = (int) $id;
459
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
460
+		if ( $cache ) {
461
+			return $cache->form_key;
462
+		}
463 463
 
464
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
464
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
465 465
 
466
-        return $key;
467
-    }
466
+		return $key;
467
+	}
468 468
 
469 469
 	/**
470 470
 	 * If $form is numeric, get the form object
@@ -477,47 +477,47 @@  discard block
 block discarded – undo
477 477
 		}
478 478
 	}
479 479
 
480
-    /**
481
-     * @return object form
482
-     */
483
-    public static function getOne( $id, $blog_id = false ) {
484
-        global $wpdb;
480
+	/**
481
+	 * @return object form
482
+	 */
483
+	public static function getOne( $id, $blog_id = false ) {
484
+		global $wpdb;
485 485
 
486
-        if ( $blog_id && is_multisite() ) {
487
-            global $wpmuBaseTablePrefix;
486
+		if ( $blog_id && is_multisite() ) {
487
+			global $wpmuBaseTablePrefix;
488 488
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
489 489
 
490 490
 			$table_name = $prefix . 'frm_forms';
491
-        } else {
491
+		} else {
492 492
 			$table_name = $wpdb->prefix . 'frm_forms';
493
-            $cache = wp_cache_get($id, 'frm_form');
494
-            if ( $cache ) {
495
-                if ( isset($cache->options) ) {
496
-                    $cache->options = maybe_unserialize($cache->options);
497
-                }
493
+			$cache = wp_cache_get($id, 'frm_form');
494
+			if ( $cache ) {
495
+				if ( isset($cache->options) ) {
496
+					$cache->options = maybe_unserialize($cache->options);
497
+				}
498 498
 
499
-                return stripslashes_deep($cache);
500
-            }
501
-        }
499
+				return stripslashes_deep($cache);
500
+			}
501
+		}
502 502
 
503
-        if ( is_numeric($id) ) {
504
-            $where = array( 'id' => $id );
505
-        } else {
506
-            $where = array( 'form_key' => $id );
507
-        }
503
+		if ( is_numeric($id) ) {
504
+			$where = array( 'id' => $id );
505
+		} else {
506
+			$where = array( 'form_key' => $id );
507
+		}
508 508
 
509
-        $results = FrmDb::get_row( $table_name, $where );
509
+		$results = FrmDb::get_row( $table_name, $where );
510 510
 
511
-        if ( isset($results->options) ) {
511
+		if ( isset($results->options) ) {
512 512
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
513
-            $results->options = maybe_unserialize($results->options);
514
-        }
515
-        return stripslashes_deep($results);
516
-    }
517
-
518
-    /**
519
-     * @return object|array of objects
520
-     */
513
+			$results->options = maybe_unserialize($results->options);
514
+		}
515
+		return stripslashes_deep($results);
516
+	}
517
+
518
+	/**
519
+	 * @return object|array of objects
520
+	 */
521 521
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
522 522
 		if ( is_array( $where ) && ! empty( $where ) ) {
523 523
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 			$results = reset( $results );
542 542
 		}
543 543
 
544
-        return stripslashes_deep($results);
545
-    }
544
+		return stripslashes_deep($results);
545
+	}
546 546
 
547 547
 	/**
548 548
 	 * Get all published forms
@@ -560,47 +560,47 @@  discard block
 block discarded – undo
560 560
 		return $forms;
561 561
 	}
562 562
 
563
-    /**
564
-     * @return int count of forms
565
-     */
566
-    public static function get_count() {
567
-    	global $wpdb;
563
+	/**
564
+	 * @return int count of forms
565
+	 */
566
+	public static function get_count() {
567
+		global $wpdb;
568 568
 
569
-    	$cache_key = 'frm_form_counts';
569
+		$cache_key = 'frm_form_counts';
570 570
 
571
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
572
-    	if ( false !== $counts ) {
573
-    	    return $counts;
574
-    	}
571
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
572
+		if ( false !== $counts ) {
573
+			return $counts;
574
+		}
575 575
 
576
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
576
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
577 577
 
578 578
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
579
-    	$counts = array_fill_keys( $statuses, 0 );
579
+		$counts = array_fill_keys( $statuses, 0 );
580 580
 
581
-    	foreach ( $results as $row ) {
582
-            if ( 'trash' != $row->status ) {
583
-    	        if ( $row->is_template ) {
581
+		foreach ( $results as $row ) {
582
+			if ( 'trash' != $row->status ) {
583
+				if ( $row->is_template ) {
584 584
 					$counts['template']++;
585
-    	        } else {
585
+				} else {
586 586
 					$counts['published']++;
587
-    	        }
588
-    	    } else {
587
+				}
588
+			} else {
589 589
 				$counts['trash']++;
590
-        	}
590
+			}
591 591
 
592
-    	    if ( 'draft' == $row->status ) {
592
+			if ( 'draft' == $row->status ) {
593 593
 				$counts['draft']++;
594
-    	    }
594
+			}
595 595
 
596
-    		unset($row);
597
-    	}
596
+			unset($row);
597
+		}
598 598
 
599
-    	$counts = (object) $counts;
599
+		$counts = (object) $counts;
600 600
 		FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' );
601 601
 
602
-    	return $counts;
603
-    }
602
+		return $counts;
603
+	}
604 604
 
605 605
 	/**
606 606
 	 * Clear form caching
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 		FrmAppHelper::cache_delete_group( 'frm_form' );
614 614
 	}
615 615
 
616
-    /**
617
-     * @return array of errors
618
-     */
616
+	/**
617
+	 * @return array of errors
618
+	 */
619 619
 	public static function validate( $values ) {
620
-        $errors = array();
620
+		$errors = array();
621 621
 
622
-        return apply_filters('frm_validate_form', $errors, $values);
623
-    }
622
+		return apply_filters('frm_validate_form', $errors, $values);
623
+	}
624 624
 
625 625
 	public static function get_params( $form = null ) {
626 626
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
3
-    die('You are not allowed to call this page directly.');
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+    die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
6 6
 class FrmForm {
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 			'form_key'      => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ),
16 16
             'name'          => $values['name'],
17 17
             'description'   => $values['description'],
18
-            'status'        => isset($values['status']) ? $values['status'] : 'draft',
19
-            'logged_in'     => isset($values['logged_in']) ? $values['logged_in'] : 0,
20
-            'is_template'   => isset($values['is_template']) ? (int) $values['is_template'] : 0,
18
+            'status'        => isset( $values['status'] ) ? $values['status'] : 'draft',
19
+            'logged_in'     => isset( $values['logged_in'] ) ? $values['logged_in'] : 0,
20
+            'is_template'   => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
21 21
 			'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
22
-            'editable'      => isset($values['editable']) ? (int) $values['editable'] : 0,
23
-            'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0,
24
-            'created_at'    => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1),
22
+            'editable'      => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
23
+            'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
24
+            'created_at'    => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
25 25
         );
26 26
 
27 27
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
28 28
 		FrmFormsHelper::fill_form_options( $options, $values );
29 29
 
30
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
31
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
32
-        $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
30
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
31
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
32
+        $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
33 33
 
34
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
35
-        $new_values['options'] = serialize($options);
34
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
35
+        $new_values['options'] = serialize( $options );
36 36
 
37 37
         //if(isset($values['id']) && is_numeric($values['id']))
38 38
         //    $new_values['id'] = $values['id'];
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             'status'        => $template ? 'published' : 'draft',
68 68
             'logged_in'     => $values->logged_in ? $values->logged_in : 0,
69 69
             'editable'      => $values->editable ? $values->editable : 0,
70
-            'created_at'    => current_time('mysql', 1),
70
+            'created_at'    => current_time( 'mysql', 1 ),
71 71
             'is_template'   => $template ? 1 : 0,
72 72
         );
73 73
 
74 74
         if ( $blog_id ) {
75 75
             $new_values['status'] = 'published';
76
-            $new_options = maybe_unserialize($values->options);
77
-            $new_options['email_to'] = get_option('admin_email');
76
+            $new_options = maybe_unserialize( $values->options );
77
+            $new_options['email_to'] = get_option( 'admin_email' );
78 78
             $new_options['copy'] = false;
79 79
             $new_values['options'] = $new_options;
80 80
         } else {
81 81
             $new_values['options'] = $values->options;
82 82
         }
83 83
 
84
-        if ( is_array($new_values['options']) ) {
85
-            $new_values['options'] = serialize($new_values['options']);
84
+        if ( is_array( $new_values['options'] ) ) {
85
+            $new_values['options'] = serialize( $new_values['options'] );
86 86
         }
87 87
 
88 88
 		$query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values );
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			self::clear_form_cache();
93 93
 
94 94
             $form_id = $wpdb->insert_id;
95
-            FrmField::duplicate($id, $form_id, $copy_keys, $blog_id);
95
+            FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id );
96 96
 
97 97
             // update form settings after fields are created
98 98
 			do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) );
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		$new_opts = maybe_unserialize( $values['options'] );
107 107
 		$values['options'] = $new_opts;
108 108
 
109
-        if ( isset($new_opts['success_msg']) ) {
110
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
109
+        if ( isset( $new_opts['success_msg'] ) ) {
110
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
111 111
         }
112 112
 
113
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
114 114
 
115 115
         if ( $new_opts != $values['options'] ) {
116 116
             global $wpdb;
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
             $values['status'] = 'published';
129 129
         }
130 130
 
131
-        if ( isset($values['form_key']) ) {
131
+        if ( isset( $values['form_key'] ) ) {
132 132
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
133 133
         }
134 134
 
135 135
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
136 136
 
137
-        $new_values = self::set_update_options( array(), $values);
137
+        $new_values = self::set_update_options( array(), $values );
138 138
 
139 139
         foreach ( $values as $value_key => $value ) {
140 140
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
141
-				$new_values[ $value_key ] = $value;
141
+				$new_values[$value_key] = $value;
142 142
             }
143 143
         }
144 144
 
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         } else {
155 155
             $query_results = true;
156 156
         }
157
-        unset($new_values);
157
+        unset( $new_values );
158 158
 
159
-        $values = self::update_fields($id, $values);
159
+        $values = self::update_fields( $id, $values );
160 160
 
161 161
 		do_action( 'frm_update_form', $id, $values );
162 162
 		do_action( 'frm_update_form_' . $id, $values );
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
      * @return array
169 169
      */
170 170
 	public static function set_update_options( $new_values, $values ) {
171
-        if ( ! isset($values['options']) ) {
171
+        if ( ! isset( $values['options'] ) ) {
172 172
             return $new_values;
173 173
         }
174 174
 
175 175
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
176 176
 		FrmFormsHelper::fill_form_options( $options, $values );
177 177
 
178
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
179
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
180
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
181
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
178
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
179
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
180
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
181
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
182 182
 
183
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
184
-        $new_values['options'] = serialize($options);
183
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
184
+        $new_values['options'] = serialize( $options );
185 185
 
186 186
         return $new_values;
187 187
     }
@@ -192,54 +192,54 @@  discard block
 block discarded – undo
192 192
      */
193 193
 	public static function update_fields( $id, $values ) {
194 194
 
195
-        if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+        if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
196 196
             return $values;
197 197
         }
198 198
 
199
-        $all_fields = FrmField::get_all_for_form($id);
200
-        if ( empty($all_fields) ) {
199
+        $all_fields = FrmField::get_all_for_form( $id );
200
+        if ( empty( $all_fields ) ) {
201 201
             return $values;
202 202
         }
203 203
 
204
-        if ( ! isset($values['item_meta']) ) {
204
+        if ( ! isset( $values['item_meta'] ) ) {
205 205
             $values['item_meta'] = array();
206 206
         }
207 207
 
208 208
         $field_array = array();
209
-        $existing_keys = array_keys($values['item_meta']);
209
+        $existing_keys = array_keys( $values['item_meta'] );
210 210
         foreach ( $all_fields as $fid ) {
211
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
212
-				$values['item_meta'][ $fid->id ] = '';
211
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
212
+				$values['item_meta'][$fid->id] = '';
213 213
             }
214
-			$field_array[ $fid->id ] = $fid;
214
+			$field_array[$fid->id] = $fid;
215 215
         }
216
-        unset($all_fields);
216
+        unset( $all_fields );
217 217
 
218 218
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
219
-			if ( isset( $field_array[ $field_id ] ) ) {
220
-				$field = $field_array[ $field_id ];
219
+			if ( isset( $field_array[$field_id] ) ) {
220
+				$field = $field_array[$field_id];
221 221
             } else {
222
-                $field = FrmField::getOne($field_id);
222
+                $field = FrmField::getOne( $field_id );
223 223
             }
224 224
 
225 225
             if ( ! $field ) {
226 226
                 continue;
227 227
             }
228 228
 
229
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
230 230
 			if ( $is_settings_page ) {
231 231
                 //updating the settings page
232
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
233
-					$field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
234
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
232
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
233
+					$field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) );
234
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
235 235
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
236 236
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
237 237
                     $prev_opts = $field->field_options;
238
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
239 239
                     if ( $prev_opts != $field->field_options ) {
240 240
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
241 241
                     }
242
-                    unset($prev_opts);
242
+                    unset( $prev_opts );
243 243
                 }
244 244
             }
245 245
 
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
254 254
 
255 255
 			foreach ( $update_options as $opt => $default ) {
256
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
257 257
             }
258 258
 
259
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
260
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
259
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
260
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
261 261
 
262 262
 			$new_field = array(
263 263
 				'field_options' => $field->field_options,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
 			FrmField::update( $field_id, $new_field );
270 270
 
271
-            FrmField::delete_form_transient($field->form_id);
271
+            FrmField::delete_form_transient( $field->form_id );
272 272
         }
273 273
 		self::clear_form_cache();
274 274
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		);
283 283
 		foreach ( $field_cols as $col => $default ) {
284 284
 			$default = ( $default === '' ) ? $field->{$col} : $default;
285
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
285
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
286 286
 		}
287 287
 	}
288 288
 
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
      */
293 293
 	public static function set_status( $id, $status ) {
294 294
         if ( 'trash' == $status ) {
295
-            return self::trash($id);
295
+            return self::trash( $id );
296 296
         }
297 297
 
298
-		$statuses  = array( 'published', 'draft', 'trash' );
298
+		$statuses = array( 'published', 'draft', 'trash' );
299 299
         if ( ! in_array( $status, $statuses ) ) {
300 300
             return false;
301 301
         }
302 302
 
303 303
         global $wpdb;
304 304
 
305
-        if ( is_array($id) ) {
305
+        if ( is_array( $id ) ) {
306 306
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
307 307
 			FrmDb::get_where_clause_and_values( $where );
308 308
 			array_unshift( $where['values'], $status );
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             return self::destroy( $id );
329 329
         }
330 330
 
331
-        $form = self::getOne($id);
331
+        $form = self::getOne( $id );
332 332
         if ( ! $form ) {
333 333
             return false;
334 334
         }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	public static function destroy( $id ) {
363 363
         global $wpdb;
364 364
 
365
-        $form = self::getOne($id);
365
+        $form = self::getOne( $id );
366 366
         if ( ! $form ) {
367 367
             return false;
368 368
         }
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
         // Disconnect the entries from this form
372 372
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
373 373
         foreach ( $entries as $entry_id ) {
374
-            FrmEntry::destroy($entry_id);
375
-            unset($entry_id);
374
+            FrmEntry::destroy( $entry_id );
375
+            unset( $entry_id );
376 376
         }
377 377
 
378 378
         // Disconnect the fields from this form
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         if ( $query_results ) {
383 383
             // Delete all form actions linked to this form
384 384
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
385
-            $action_control->destroy($id, 'all');
385
+            $action_control->destroy( $id, 'all' );
386 386
 
387 387
 			// Clear form caching
388 388
 			self::clear_form_cache();
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 			$form->options = maybe_unserialize( $form->options );
417 417
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
418 418
 				self::destroy( $form->id );
419
-				$count++;
419
+				$count ++;
420 420
 			}
421 421
 
422 422
 			unset( $form );
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
      * @return string form name
429 429
      */
430 430
     public static function getName( $id ) {
431
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
431
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
432 432
         if ( $form ) {
433
-            $r = stripslashes($form->name);
433
+            $r = stripslashes( $form->name );
434 434
             return $r;
435 435
         }
436 436
 
437 437
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
438 438
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
439
-        $r = stripslashes($r);
439
+        $r = stripslashes( $r );
440 440
 
441 441
         return $r;
442 442
     }
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      */
457 457
 	public static function getKeyById( $id ) {
458 458
         $id = (int) $id;
459
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
459
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
460 460
         if ( $cache ) {
461 461
             return $cache->form_key;
462 462
         }
@@ -490,17 +490,17 @@  discard block
 block discarded – undo
490 490
 			$table_name = $prefix . 'frm_forms';
491 491
         } else {
492 492
 			$table_name = $wpdb->prefix . 'frm_forms';
493
-            $cache = wp_cache_get($id, 'frm_form');
493
+            $cache = wp_cache_get( $id, 'frm_form' );
494 494
             if ( $cache ) {
495
-                if ( isset($cache->options) ) {
496
-                    $cache->options = maybe_unserialize($cache->options);
495
+                if ( isset( $cache->options ) ) {
496
+                    $cache->options = maybe_unserialize( $cache->options );
497 497
                 }
498 498
 
499
-                return stripslashes_deep($cache);
499
+                return stripslashes_deep( $cache );
500 500
             }
501 501
         }
502 502
 
503
-        if ( is_numeric($id) ) {
503
+        if ( is_numeric( $id ) ) {
504 504
             $where = array( 'id' => $id );
505 505
         } else {
506 506
             $where = array( 'form_key' => $id );
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 
509 509
         $results = FrmDb::get_row( $table_name, $where );
510 510
 
511
-        if ( isset($results->options) ) {
511
+        if ( isset( $results->options ) ) {
512 512
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
513
-            $results->options = maybe_unserialize($results->options);
513
+            $results->options = maybe_unserialize( $results->options );
514 514
         }
515
-        return stripslashes_deep($results);
515
+        return stripslashes_deep( $results );
516 516
     }
517 517
 
518 518
     /**
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			$results = reset( $results );
542 542
 		}
543 543
 
544
-        return stripslashes_deep($results);
544
+        return stripslashes_deep( $results );
545 545
     }
546 546
 
547 547
 	/**
@@ -581,19 +581,19 @@  discard block
 block discarded – undo
581 581
     	foreach ( $results as $row ) {
582 582
             if ( 'trash' != $row->status ) {
583 583
     	        if ( $row->is_template ) {
584
-					$counts['template']++;
584
+					$counts['template'] ++;
585 585
     	        } else {
586
-					$counts['published']++;
586
+					$counts['published'] ++;
587 587
     	        }
588 588
     	    } else {
589
-				$counts['trash']++;
589
+				$counts['trash'] ++;
590 590
         	}
591 591
 
592 592
     	    if ( 'draft' == $row->status ) {
593
-				$counts['draft']++;
593
+				$counts['draft'] ++;
594 594
     	    }
595 595
 
596
-    		unset($row);
596
+    		unset( $row );
597 597
     	}
598 598
 
599 599
     	$counts = (object) $counts;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	public static function validate( $values ) {
620 620
         $errors = array();
621 621
 
622
-        return apply_filters('frm_validate_form', $errors, $values);
622
+        return apply_filters( 'frm_validate_form', $errors, $values );
623 623
     }
624 624
 
625 625
 	public static function get_params( $form = null ) {
@@ -631,11 +631,11 @@  discard block
 block discarded – undo
631 631
 			self::maybe_get_form( $form );
632 632
 		}
633 633
 
634
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
635
-			return $frm_vars['form_params'][ $form->id ];
634
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
635
+			return $frm_vars['form_params'][$form->id];
636 636
 		}
637 637
 
638
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
638
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
639 639
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
640 640
 
641 641
 		$default_values = array(
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 			//if there are two forms on the same page, make sure not to submit both
654 654
 			foreach ( $default_values as $var => $default ) {
655 655
 				if ( $var == 'action' ) {
656
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
656
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
657 657
 				} else {
658
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
658
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
659 659
 				}
660 660
 				unset( $var, $default );
661 661
 			}
662 662
 		} else {
663 663
 			foreach ( $default_values as $var => $default ) {
664
-				$values[ $var ] = $default;
664
+				$values[$var] = $default;
665 665
 				unset( $var, $default );
666 666
 			}
667 667
 		}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	public static function list_page_params() {
677 677
 		$values = array();
678 678
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
679
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
679
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
680 680
 		}
681 681
 
682 682
 		return $values;
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
697 697
 			'keep_post' => '',
698 698
 		) as $var => $default ) {
699
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
699
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
700 700
 		}
701 701
 
702 702
 		return $values;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 		$small_form = new stdClass();
754 754
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
755 755
 			$small_form->{$var} = $form->{$var};
756
-			unset($var);
756
+			unset( $var );
757 757
 		}
758 758
 
759 759
 		$frm_vars['forms_loaded'][] = $small_form;
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 			$frm_vars['load_css'] = true;
764 764
 		}
765 765
 
766
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
766
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
767 767
 	}
768 768
 
769 769
 	public static function show_submit( $form ) {
@@ -777,6 +777,6 @@  discard block
 block discarded – undo
777 777
 	 */
778 778
 	public static function get_option( $atts ) {
779 779
 		$form = $atts['form'];
780
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
780
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
781 781
 	}
782 782
 }
Please login to merge, or discard this patch.