Completed
Branch uploads (08d8c9)
by Stephanie
04:20
created
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +60 added lines, -60 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';
@@ -21,25 +21,25 @@  discard block
 block discarded – undo
21 21
 
22 22
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
23 23
 
24
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
26
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
27
-	    }
24
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
26
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
27
+		}
28 28
 
29
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
30
-        if ( strpos($orderby, 'meta') !== false ) {
31
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
29
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
30
+		if ( strpos($orderby, 'meta') !== false ) {
31
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
32 32
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
33
-        }
33
+		}
34 34
 
35 35
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
36 36
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
37 37
 
38
-        $page = $this->get_pagenum();
38
+		$page = $this->get_pagenum();
39 39
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
40 40
 
41 41
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
42
-        $total_items = FrmEntry::getRecordCount($s_query);
42
+		$total_items = FrmEntry::getRecordCount($s_query);
43 43
 
44 44
 		$this->set_pagination_args( array(
45 45
 			'total_items' => $total_items,
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 
50 50
 	public function no_items() {
51
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
52
-	    if ( ! empty($s) ) {
53
-            _e( 'No Entries Found', 'formidable' );
54
-            return;
55
-        }
56
-
57
-        $form_id = $form = $this->params['form'];
58
-        if ( $form_id ) {
59
-            $form = FrmForm::getOne($form_id);
60
-        }
61
-        $colspan = $this->get_column_count();
51
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
52
+		if ( ! empty($s) ) {
53
+			_e( 'No Entries Found', 'formidable' );
54
+			return;
55
+		}
56
+
57
+		$form_id = $form = $this->params['form'];
58
+		if ( $form_id ) {
59
+			$form = FrmForm::getOne($form_id);
60
+		}
61
+		$colspan = $this->get_column_count();
62 62
 
63 63
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
64 64
 	}
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Gets the name of the primary column in the Entries screen
72
-	*
73
-	* @since 2.0.14
74
-	*
75
-	* @return string $primary_column
76
-	*/
71
+	 * Gets the name of the primary column in the Entries screen
72
+	 *
73
+	 * @since 2.0.14
74
+	 *
75
+	 * @return string $primary_column
76
+	 */
77 77
 	protected function get_primary_column_name() {
78 78
 		$columns = get_column_headers( $this->screen );
79 79
 		$hidden = get_hidden_columns( $this->screen );
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 		$this->get_actions( $actions, $item, $view_link );
99 99
 
100
-        $action_links = $this->row_actions( $actions );
100
+		$action_links = $this->row_actions( $actions );
101 101
 
102 102
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
103 103
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$r = "<tr id='item-action-{$item->id}'$style>";
106 106
 
107 107
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
108
-        $action_col = false;
108
+		$action_col = false;
109 109
 
110 110
 		foreach ( $columns as $column_name => $column_display_name ) {
111 111
 			$class = $column_name . ' column-' . $column_name;
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 			if ( in_array( $column_name, $hidden ) ) {
118 118
 				$class .= ' frm_hidden';
119 119
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
120
-			    $action_col = $column_name;
121
-            }
120
+				$action_col = $column_name;
121
+			}
122 122
 
123 123
 			$attributes = 'class="' . esc_attr( $class ) . '"';
124 124
 			unset($class);
@@ -134,30 +134,30 @@  discard block
 block discarded – undo
134 134
 				case 'ip':
135 135
 				case 'id':
136 136
 				case 'item_key':
137
-				    $val = $item->{$col_name};
138
-				    break;
137
+					$val = $item->{$col_name};
138
+					break;
139 139
 				case 'name':
140 140
 				case 'description':
141
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
142
-				    break;
141
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
142
+					break;
143 143
 				case 'created_at':
144 144
 				case 'updated_at':
145
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
145
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
146 146
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
147 147
 					break;
148 148
 				case 'is_draft':
149
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
150
-			        break;
149
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
150
+					break;
151 151
 				case 'form_id':
152
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
153
-    				break;
152
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
153
+					break;
154 154
 				case 'post_id':
155
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
156
-				    break;
155
+					$val = FrmAppHelper::post_edit_link($item->post_id);
156
+					break;
157 157
 				case 'user_id':
158
-				    $user = get_userdata($item->user_id);
159
-				    $val = $user->user_login;
160
-				    break;
158
+					$user = get_userdata($item->user_id);
159
+					$val = $user->user_login;
160
+					break;
161 161
 				default:
162 162
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
163 163
 					if ( $val === false ) {
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 			}
168 168
 
169 169
 			if ( isset( $val ) ) {
170
-			    $r .= "<td $attributes>";
170
+				$r .= "<td $attributes>";
171 171
 				if ( $column_name == $action_col ) {
172 172
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
173 173
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
174
-			        $r .= $action_links;
174
+					$r .= $action_links;
175 175
 				} else {
176
-			        $r .= $val;
177
-			    }
178
-			    $r .= '</td>';
176
+					$r .= $val;
177
+				}
178
+				$r .= '</td>';
179 179
 			}
180 180
 			unset($val);
181 181
 		}
@@ -184,19 +184,19 @@  discard block
 block discarded – undo
184 184
 		return $r;
185 185
 	}
186 186
 
187
-    /**
188
-     * @param string $view_link
189
-     */
190
-    private function get_actions( &$actions, $item, $view_link ) {
187
+	/**
188
+	 * @param string $view_link
189
+	 */
190
+	private function get_actions( &$actions, $item, $view_link ) {
191 191
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
192 192
 
193
-        if ( current_user_can('frm_delete_entries') ) {
193
+		if ( current_user_can('frm_delete_entries') ) {
194 194
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
195 195
 			$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>';
196
-	    }
196
+		}
197 197
 
198
-        $actions = apply_filters('frm_row_actions', $actions, $item);
199
-    }
198
+		$actions = apply_filters('frm_row_actions', $actions, $item);
199
+	}
200 200
 
201 201
 	private function get_column_value( $item, &$val ) {
202 202
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 			$s_query['it.form_id'] = $form_id;
20 20
 		}
21 21
 
22
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
22
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
23 23
 
24 24
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
25 25
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	    }
28 28
 
29 29
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
30
-        if ( strpos($orderby, 'meta') !== false ) {
30
+        if ( strpos( $orderby, 'meta' ) !== false ) {
31 31
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
32 32
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
33 33
         }
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
40 40
 
41 41
 		$this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
42
-        $total_items = FrmEntry::getRecordCount($s_query);
42
+        $total_items = FrmEntry::getRecordCount( $s_query );
43 43
 
44 44
 		$this->set_pagination_args( array(
45 45
 			'total_items' => $total_items,
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 
50 50
 	public function no_items() {
51 51
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
52
-	    if ( ! empty($s) ) {
52
+	    if ( ! empty( $s ) ) {
53 53
             _e( 'No Entries Found', 'formidable' );
54 54
             return;
55 55
         }
56 56
 
57 57
         $form_id = $form = $this->params['form'];
58 58
         if ( $form_id ) {
59
-            $form = FrmForm::getOne($form_id);
59
+            $form = FrmForm::getOne( $form_id );
60 60
         }
61 61
         $colspan = $this->get_column_count();
62 62
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 		$r = "<tr id='item-action-{$item->id}'$style>";
106 106
 
107
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
107
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
108 108
         $action_col = false;
109 109
 
110 110
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             }
122 122
 
123 123
 			$attributes = 'class="' . esc_attr( $class ) . '"';
124
-			unset($class);
124
+			unset( $class );
125 125
 			$attributes .= ' data-colname="' . $column_display_name . '"';
126 126
 
127 127
 			$col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
@@ -138,24 +138,24 @@  discard block
 block discarded – undo
138 138
 				    break;
139 139
 				case 'name':
140 140
 				case 'description':
141
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
141
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
142 142
 				    break;
143 143
 				case 'created_at':
144 144
 				case 'updated_at':
145
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
145
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
146 146
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
147 147
 					break;
148 148
 				case 'is_draft':
149
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
149
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
150 150
 			        break;
151 151
 				case 'form_id':
152
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
152
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
153 153
     				break;
154 154
 				case 'post_id':
155
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
155
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
156 156
 				    break;
157 157
 				case 'user_id':
158
-				    $user = get_userdata($item->user_id);
158
+				    $user = get_userdata( $item->user_id );
159 159
 				    $val = $user->user_login;
160 160
 				    break;
161 161
 				default:
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 			    }
178 178
 			    $r .= '</td>';
179 179
 			}
180
-			unset($val);
180
+			unset( $val );
181 181
 		}
182 182
 		$r .= '</tr>';
183 183
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
     private function get_actions( &$actions, $item, $view_link ) {
191 191
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
192 192
 
193
-        if ( current_user_can('frm_delete_entries') ) {
193
+        if ( current_user_can( 'frm_delete_entries' ) ) {
194 194
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
195 195
 			$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>';
196 196
 	    }
197 197
 
198
-        $actions = apply_filters('frm_row_actions', $actions, $item);
198
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
199 199
     }
200 200
 
201 201
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/models/FrmForm.php 2 patches
Indentation   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -1,261 +1,261 @@  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
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+		$new_opts = $values['options'] = maybe_unserialize($values['options']);
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
-        }
108
+		if ( isset($new_opts['success_msg']) ) {
109
+			$new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
110
+		}
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+		$new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
113 113
 
114
-        if ( $new_opts != $values['options'] ) {
115
-            global $wpdb;
114
+		if ( $new_opts != $values['options'] ) {
115
+			global $wpdb;
116 116
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) );
117
-        }
118
-    }
117
+		}
118
+	}
119 119
 
120
-    /**
121
-     * @return int|boolean
122
-     */
123
-    public static function update( $id, $values, $create_link = false ) {
124
-        global $wpdb;
120
+	/**
121
+	 * @return int|boolean
122
+	 */
123
+	public static function update( $id, $values, $create_link = false ) {
124
+		global $wpdb;
125 125
 
126
-        if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
-            $values['status'] = 'published';
128
-        }
126
+		if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) {
127
+			$values['status'] = 'published';
128
+		}
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+		if ( isset($values['form_key']) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132
-        }
132
+		}
133 133
 
134 134
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+		$new_values = self::set_update_options( array(), $values);
137 137
 
138
-        foreach ( $values as $value_key => $value ) {
138
+		foreach ( $values as $value_key => $value ) {
139 139
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
140 140
 				$new_values[ $value_key ] = $value;
141
-            }
142
-        }
141
+			}
142
+		}
143 143
 
144
-        if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
-            $new_values['status'] = $values['new_status'];
146
-        }
144
+		if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) {
145
+			$new_values['status'] = $values['new_status'];
146
+		}
147 147
 
148
-        if ( ! empty( $new_values ) ) {
148
+		if ( ! empty( $new_values ) ) {
149 149
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) );
150
-            if ( $query_results ) {
150
+			if ( $query_results ) {
151 151
 				self::clear_form_cache();
152
-            }
153
-        } else {
154
-            $query_results = true;
155
-        }
156
-        unset($new_values);
152
+			}
153
+		} else {
154
+			$query_results = true;
155
+		}
156
+		unset($new_values);
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+		$values = self::update_fields($id, $values);
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
162 162
 
163
-        return $query_results;
164
-    }
163
+		return $query_results;
164
+	}
165 165
 
166
-    /**
167
-     * @return array
168
-     */
166
+	/**
167
+	 * @return array
168
+	 */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
171
-            return $new_values;
172
-        }
170
+		if ( ! isset($values['options']) ) {
171
+			return $new_values;
172
+		}
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+		$options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
+		$options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
+		$options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
+		$options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+		$options = apply_filters('frm_form_options_before_update', $options, $values);
183
+		$new_values['options'] = serialize($options);
184 184
 
185
-        return $new_values;
186
-    }
185
+		return $new_values;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * @return array
191
-     */
189
+	/**
190
+	 * @return array
191
+	 */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
-            return $values;
196
-        }
194
+		if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
195
+			return $values;
196
+		}
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
200
-            return $values;
201
-        }
198
+		$all_fields = FrmField::get_all_for_form($id);
199
+		if ( empty($all_fields) ) {
200
+			return $values;
201
+		}
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
204
-            $values['item_meta'] = array();
205
-        }
203
+		if ( ! isset($values['item_meta']) ) {
204
+			$values['item_meta'] = array();
205
+		}
206 206
 
207
-        $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
209
-        foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
207
+		$field_array = array();
208
+		$existing_keys = array_keys($values['item_meta']);
209
+		foreach ( $all_fields as $fid ) {
210
+			if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211 211
 				$values['item_meta'][ $fid->id ] = '';
212
-            }
212
+			}
213 213
 			$field_array[ $fid->id ] = $fid;
214
-        }
215
-        unset($all_fields);
214
+		}
215
+		unset($all_fields);
216 216
 
217
-        foreach ( $values['item_meta'] as $field_id => $default_value ) {
217
+		foreach ( $values['item_meta'] as $field_id => $default_value ) {
218 218
 			if ( isset( $field_array[ $field_id ] ) ) {
219 219
 				$field = $field_array[ $field_id ];
220
-            } else {
221
-                $field = FrmField::getOne($field_id);
222
-            }
220
+			} else {
221
+				$field = FrmField::getOne($field_id);
222
+			}
223 223
 
224
-            if ( ! $field ) {
225
-                continue;
226
-            }
224
+			if ( ! $field ) {
225
+				continue;
226
+			}
227 227
 
228 228
 			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
229 229
 			if ( $is_settings_page ) {
230
-                //updating the settings page
230
+				//updating the settings page
231 231
 				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232 232
 					$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 ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
233
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235
-                } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
-                    $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
-                    if ( $prev_opts != $field->field_options ) {
235
+				} else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236
+					$prev_opts = $field->field_options;
237
+					$field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
238
+					if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240
-                    }
241
-                    unset($prev_opts);
242
-                }
243
-            }
240
+					}
241
+					unset($prev_opts);
242
+				}
243
+			}
244 244
 
245 245
 			if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) {
246
-                continue;
247
-            }
246
+				continue;
247
+			}
248 248
 
249
-            //updating the form
249
+			//updating the form
250 250
 			$update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true );
251 251
 			unset( $update_options['custom_html'] ); // don't check for POST html
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255 255
 				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
256
-            }
256
+			}
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
258
+			$field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259 259
 			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
260 260
 
261 261
 			$new_field = array(
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 
268 268
 			FrmField::update( $field_id, $new_field );
269 269
 
270
-            FrmField::delete_form_transient($field->form_id);
271
-        }
270
+			FrmField::delete_form_transient($field->form_id);
271
+		}
272 272
 		self::clear_form_cache();
273 273
 
274
-        return $values;
275
-    }
274
+		return $values;
275
+	}
276 276
 
277 277
 	private static function prepare_field_update_values( $field, $values, &$new_field ) {
278 278
 		$field_cols = array(
@@ -285,113 +285,113 @@  discard block
 block discarded – undo
285 285
 		}
286 286
 	}
287 287
 
288
-    /**
289
-     * @param string $status
290
-     * @return int|boolean
291
-     */
288
+	/**
289
+	 * @param string $status
290
+	 * @return int|boolean
291
+	 */
292 292
 	public static function set_status( $id, $status ) {
293
-        if ( 'trash' == $status ) {
294
-            return self::trash($id);
295
-        }
293
+		if ( 'trash' == $status ) {
294
+			return self::trash($id);
295
+		}
296 296
 
297 297
 		$statuses  = array( 'published', 'draft', 'trash' );
298
-        if ( ! in_array( $status, $statuses ) ) {
299
-            return false;
300
-        }
298
+		if ( ! in_array( $status, $statuses ) ) {
299
+			return false;
300
+		}
301 301
 
302
-        global $wpdb;
302
+		global $wpdb;
303 303
 
304
-        if ( is_array($id) ) {
304
+		if ( is_array($id) ) {
305 305
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
306 306
 			FrmDb::get_where_clause_and_values( $where );
307 307
 			array_unshift( $where['values'], $status );
308 308
 
309 309
 			$query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) );
310
-        } else {
310
+		} else {
311 311
 			$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) );
312 312
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) );
313
-        }
313
+		}
314 314
 
315
-        if ( $query_results ) {
315
+		if ( $query_results ) {
316 316
 			self::clear_form_cache();
317
-        }
317
+		}
318 318
 
319
-        return $query_results;
320
-    }
319
+		return $query_results;
320
+	}
321 321
 
322
-    /**
323
-     * @return int|boolean
324
-     */
322
+	/**
323
+	 * @return int|boolean
324
+	 */
325 325
 	public static function trash( $id ) {
326
-        if ( ! EMPTY_TRASH_DAYS ) {
327
-            return self::destroy( $id );
328
-        }
326
+		if ( ! EMPTY_TRASH_DAYS ) {
327
+			return self::destroy( $id );
328
+		}
329 329
 
330
-        $form = self::getOne($id);
331
-        if ( ! $form ) {
332
-            return false;
333
-        }
330
+		$form = self::getOne($id);
331
+		if ( ! $form ) {
332
+			return false;
333
+		}
334 334
 
335
-        $options = $form->options;
336
-        $options['trash_time'] = time();
335
+		$options = $form->options;
336
+		$options['trash_time'] = time();
337 337
 
338
-        global $wpdb;
339
-        $query_results = $wpdb->update(
338
+		global $wpdb;
339
+		$query_results = $wpdb->update(
340 340
 			$wpdb->prefix . 'frm_forms',
341 341
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
342 342
 			array( 'id' => $id )
343
-        );
343
+		);
344 344
 
345
-        $wpdb->update(
345
+		$wpdb->update(
346 346
 			$wpdb->prefix . 'frm_forms',
347 347
 			array( 'status' => 'trash', 'options' => serialize( $options ) ),
348 348
 			array( 'parent_form_id' => $id )
349
-        );
349
+		);
350 350
 
351
-        if ( $query_results ) {
351
+		if ( $query_results ) {
352 352
 			self::clear_form_cache();
353
-        }
353
+		}
354 354
 
355
-        return $query_results;
356
-    }
355
+		return $query_results;
356
+	}
357 357
 
358
-    /**
359
-     * @return int|boolean
360
-     */
358
+	/**
359
+	 * @return int|boolean
360
+	 */
361 361
 	public static function destroy( $id ) {
362
-        global $wpdb;
362
+		global $wpdb;
363 363
 
364
-        $form = self::getOne($id);
365
-        if ( ! $form ) {
366
-            return false;
367
-        }
364
+		$form = self::getOne($id);
365
+		if ( ! $form ) {
366
+			return false;
367
+		}
368 368
 		$id = $form->id;
369 369
 
370
-        // Disconnect the entries from this form
370
+		// Disconnect the entries from this form
371 371
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
372
-        foreach ( $entries as $entry_id ) {
373
-            FrmEntry::destroy($entry_id);
374
-            unset($entry_id);
375
-        }
372
+		foreach ( $entries as $entry_id ) {
373
+			FrmEntry::destroy($entry_id);
374
+			unset($entry_id);
375
+		}
376 376
 
377
-        // Disconnect the fields from this form
377
+		// Disconnect the fields from this form
378 378
 		$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 ) );
379 379
 
380 380
 		$query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) );
381
-        if ( $query_results ) {
382
-            // Delete all form actions linked to this form
383
-            $action_control = FrmFormActionsController::get_form_actions( 'email' );
384
-            $action_control->destroy($id, 'all');
381
+		if ( $query_results ) {
382
+			// Delete all form actions linked to this form
383
+			$action_control = FrmFormActionsController::get_form_actions( 'email' );
384
+			$action_control->destroy($id, 'all');
385 385
 
386 386
 			// Clear form caching
387 387
 			self::clear_form_cache();
388 388
 
389 389
 			do_action( 'frm_destroy_form', $id );
390 390
 			do_action( 'frm_destroy_form_' . $id );
391
-        }
391
+		}
392 392
 
393
-        return $query_results;
394
-    }
393
+		return $query_results;
394
+	}
395 395
 
396 396
 	/**
397 397
 	 * Delete trashed forms based on how long they have been trashed
@@ -423,49 +423,49 @@  discard block
 block discarded – undo
423 423
 		return $count;
424 424
 	}
425 425
 
426
-    /**
427
-     * @return string form name
428
-     */
429
-    public static function &getName( $id ) {
430
-        global $wpdb;
431
-
432
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
433
-        if ( $form ) {
434
-            $r = stripslashes($form->name);
435
-            return $r;
436
-        }
437
-
438
-        $query_key = is_numeric( $id ) ? 'id' : 'form_key';
439
-        $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
440
-        $r = stripslashes($r);
441
-
442
-        return $r;
443
-    }
444
-
445
-    /**
446
-     * @param string $key
447
-     * @return int form id
448
-     */
426
+	/**
427
+	 * @return string form name
428
+	 */
429
+	public static function &getName( $id ) {
430
+		global $wpdb;
431
+
432
+		$form = FrmAppHelper::check_cache($id, 'frm_form');
433
+		if ( $form ) {
434
+			$r = stripslashes($form->name);
435
+			return $r;
436
+		}
437
+
438
+		$query_key = is_numeric( $id ) ? 'id' : 'form_key';
439
+		$r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
440
+		$r = stripslashes($r);
441
+
442
+		return $r;
443
+	}
444
+
445
+	/**
446
+	 * @param string $key
447
+	 * @return int form id
448
+	 */
449 449
 	public static function &getIdByKey( $key ) {
450
-        $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
451
-        return $id;
452
-    }
453
-
454
-    /**
455
-     * @param int $id
456
-     * @return string form key
457
-     */
450
+		$id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) );
451
+		return $id;
452
+	}
453
+
454
+	/**
455
+	 * @param int $id
456
+	 * @return string form key
457
+	 */
458 458
 	public static function &getKeyById( $id ) {
459
-        $id = (int) $id;
460
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
461
-        if ( $cache ) {
462
-            return $cache->form_key;
463
-        }
459
+		$id = (int) $id;
460
+		$cache = FrmAppHelper::check_cache($id, 'frm_form');
461
+		if ( $cache ) {
462
+			return $cache->form_key;
463
+		}
464 464
 
465
-        $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
465
+		$key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' );
466 466
 
467
-        return $key;
468
-    }
467
+		return $key;
468
+	}
469 469
 
470 470
 	/**
471 471
 	 * If $form is numeric, get the form object
@@ -478,47 +478,47 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 	}
480 480
 
481
-    /**
482
-     * @return object form
483
-     */
484
-    public static function getOne( $id, $blog_id = false ) {
485
-        global $wpdb;
481
+	/**
482
+	 * @return object form
483
+	 */
484
+	public static function getOne( $id, $blog_id = false ) {
485
+		global $wpdb;
486 486
 
487
-        if ( $blog_id && is_multisite() ) {
488
-            global $wpmuBaseTablePrefix;
487
+		if ( $blog_id && is_multisite() ) {
488
+			global $wpmuBaseTablePrefix;
489 489
 			$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id );
490 490
 
491 491
 			$table_name = $prefix . 'frm_forms';
492
-        } else {
492
+		} else {
493 493
 			$table_name = $wpdb->prefix . 'frm_forms';
494
-            $cache = wp_cache_get($id, 'frm_form');
495
-            if ( $cache ) {
496
-                if ( isset($cache->options) ) {
497
-                    $cache->options = maybe_unserialize($cache->options);
498
-                }
494
+			$cache = wp_cache_get($id, 'frm_form');
495
+			if ( $cache ) {
496
+				if ( isset($cache->options) ) {
497
+					$cache->options = maybe_unserialize($cache->options);
498
+				}
499 499
 
500
-                return stripslashes_deep($cache);
501
-            }
502
-        }
500
+				return stripslashes_deep($cache);
501
+			}
502
+		}
503 503
 
504
-        if ( is_numeric($id) ) {
505
-            $where = array( 'id' => $id );
506
-        } else {
507
-            $where = array( 'form_key' => $id );
508
-        }
504
+		if ( is_numeric($id) ) {
505
+			$where = array( 'id' => $id );
506
+		} else {
507
+			$where = array( 'form_key' => $id );
508
+		}
509 509
 
510
-        $results = FrmDb::get_row( $table_name, $where );
510
+		$results = FrmDb::get_row( $table_name, $where );
511 511
 
512
-        if ( isset($results->options) ) {
512
+		if ( isset($results->options) ) {
513 513
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
514
-            $results->options = maybe_unserialize($results->options);
515
-        }
516
-        return stripslashes_deep($results);
517
-    }
518
-
519
-    /**
520
-     * @return object|array of objects
521
-     */
514
+			$results->options = maybe_unserialize($results->options);
515
+		}
516
+		return stripslashes_deep($results);
517
+	}
518
+
519
+	/**
520
+	 * @return object|array of objects
521
+	 */
522 522
 	public static function getAll( $where = array(), $order_by = '', $limit = '' ) {
523 523
 		if ( is_array( $where ) && ! empty( $where ) ) {
524 524
 			$results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) );
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 			$results = reset( $results );
543 543
 		}
544 544
 
545
-        return stripslashes_deep($results);
546
-    }
545
+		return stripslashes_deep($results);
546
+	}
547 547
 
548 548
 	/**
549 549
 	 * Get all published forms
@@ -561,47 +561,47 @@  discard block
 block discarded – undo
561 561
 		return $forms;
562 562
 	}
563 563
 
564
-    /**
565
-     * @return int count of forms
566
-     */
567
-    public static function &get_count() {
568
-    	global $wpdb;
564
+	/**
565
+	 * @return int count of forms
566
+	 */
567
+	public static function &get_count() {
568
+		global $wpdb;
569 569
 
570
-    	$cache_key = 'frm_form_counts';
570
+		$cache_key = 'frm_form_counts';
571 571
 
572
-    	$counts = wp_cache_get( $cache_key, 'frm_form' );
573
-    	if ( false !== $counts ) {
574
-    	    return $counts;
575
-    	}
572
+		$counts = wp_cache_get( $cache_key, 'frm_form' );
573
+		if ( false !== $counts ) {
574
+			return $counts;
575
+		}
576 576
 
577
-        $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
577
+		$results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' );
578 578
 
579 579
 		$statuses = array( 'published', 'draft', 'template', 'trash' );
580
-    	$counts = array_fill_keys( $statuses, 0 );
580
+		$counts = array_fill_keys( $statuses, 0 );
581 581
 
582
-    	foreach ( $results as $row ) {
583
-            if ( 'trash' != $row->status ) {
584
-    	        if ( $row->is_template ) {
582
+		foreach ( $results as $row ) {
583
+			if ( 'trash' != $row->status ) {
584
+				if ( $row->is_template ) {
585 585
 					$counts['template']++;
586
-    	        } else {
586
+				} else {
587 587
 					$counts['published']++;
588
-    	        }
589
-    	    } else {
588
+				}
589
+			} else {
590 590
 				$counts['trash']++;
591
-        	}
591
+			}
592 592
 
593
-    	    if ( 'draft' == $row->status ) {
593
+			if ( 'draft' == $row->status ) {
594 594
 				$counts['draft']++;
595
-    	    }
595
+			}
596 596
 
597
-    		unset($row);
598
-    	}
597
+			unset($row);
598
+		}
599 599
 
600
-    	$counts = (object) $counts;
600
+		$counts = (object) $counts;
601 601
 		FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' );
602 602
 
603
-    	return $counts;
604
-    }
603
+		return $counts;
604
+	}
605 605
 
606 606
 	/**
607 607
 	 * Clear form caching
@@ -614,14 +614,14 @@  discard block
 block discarded – undo
614 614
 		FrmAppHelper::cache_delete_group( 'frm_form' );
615 615
 	}
616 616
 
617
-    /**
618
-     * @return array of errors
619
-     */
617
+	/**
618
+	 * @return array of errors
619
+	 */
620 620
 	public static function validate( $values ) {
621
-        $errors = array();
621
+		$errors = array();
622 622
 
623
-        return apply_filters('frm_validate_form', $errors, $values);
624
-    }
623
+		return apply_filters('frm_validate_form', $errors, $values);
624
+	}
625 625
 
626 626
 	public static function get_params( $form = null ) {
627 627
 		global $frm_vars;
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 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 ) );
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
 	public static function after_duplicate( $form_id, $values ) {
106
-        $new_opts = $values['options'] = maybe_unserialize($values['options']);
106
+        $new_opts = $values['options'] = maybe_unserialize( $values['options'] );
107 107
 
108
-        if ( isset($new_opts['success_msg']) ) {
109
-            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']);
108
+        if ( isset( $new_opts['success_msg'] ) ) {
109
+            $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] );
110 110
         }
111 111
 
112
-        $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id);
112
+        $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id );
113 113
 
114 114
         if ( $new_opts != $values['options'] ) {
115 115
             global $wpdb;
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
             $values['status'] = 'published';
128 128
         }
129 129
 
130
-        if ( isset($values['form_key']) ) {
130
+        if ( isset( $values['form_key'] ) ) {
131 131
 			$values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id );
132 132
         }
133 133
 
134 134
 		$form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' );
135 135
 
136
-        $new_values = self::set_update_options( array(), $values);
136
+        $new_values = self::set_update_options( array(), $values );
137 137
 
138 138
         foreach ( $values as $value_key => $value ) {
139 139
 			if ( $value_key && in_array( $value_key, $form_fields ) ) {
140
-				$new_values[ $value_key ] = $value;
140
+				$new_values[$value_key] = $value;
141 141
             }
142 142
         }
143 143
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
         } else {
154 154
             $query_results = true;
155 155
         }
156
-        unset($new_values);
156
+        unset( $new_values );
157 157
 
158
-        $values = self::update_fields($id, $values);
158
+        $values = self::update_fields( $id, $values );
159 159
 
160 160
 		do_action( 'frm_update_form', $id, $values );
161 161
 		do_action( 'frm_update_form_' . $id, $values );
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
      * @return array
168 168
      */
169 169
 	public static function set_update_options( $new_values, $values ) {
170
-        if ( ! isset($values['options']) ) {
170
+        if ( ! isset( $values['options'] ) ) {
171 171
             return $new_values;
172 172
         }
173 173
 
174 174
 		$options = isset( $values['options'] ) ? (array) $values['options'] : array();
175 175
 		FrmFormsHelper::fill_form_options( $options, $values );
176 176
 
177
-        $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0;
178
-        $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before');
179
-        $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after');
180
-        $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit');
177
+        $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0;
178
+        $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' );
179
+        $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' );
180
+        $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' );
181 181
 
182
-        $options = apply_filters('frm_form_options_before_update', $options, $values);
183
-        $new_values['options'] = serialize($options);
182
+        $options = apply_filters( 'frm_form_options_before_update', $options, $values );
183
+        $new_values['options'] = serialize( $options );
184 184
 
185 185
         return $new_values;
186 186
     }
@@ -191,54 +191,54 @@  discard block
 block discarded – undo
191 191
      */
192 192
 	public static function update_fields( $id, $values ) {
193 193
 
194
-        if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) {
194
+        if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) {
195 195
             return $values;
196 196
         }
197 197
 
198
-        $all_fields = FrmField::get_all_for_form($id);
199
-        if ( empty($all_fields) ) {
198
+        $all_fields = FrmField::get_all_for_form( $id );
199
+        if ( empty( $all_fields ) ) {
200 200
             return $values;
201 201
         }
202 202
 
203
-        if ( ! isset($values['item_meta']) ) {
203
+        if ( ! isset( $values['item_meta'] ) ) {
204 204
             $values['item_meta'] = array();
205 205
         }
206 206
 
207 207
         $field_array = array();
208
-        $existing_keys = array_keys($values['item_meta']);
208
+        $existing_keys = array_keys( $values['item_meta'] );
209 209
         foreach ( $all_fields as $fid ) {
210
-            if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) {
211
-				$values['item_meta'][ $fid->id ] = '';
210
+            if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) {
211
+				$values['item_meta'][$fid->id] = '';
212 212
             }
213
-			$field_array[ $fid->id ] = $fid;
213
+			$field_array[$fid->id] = $fid;
214 214
         }
215
-        unset($all_fields);
215
+        unset( $all_fields );
216 216
 
217 217
         foreach ( $values['item_meta'] as $field_id => $default_value ) {
218
-			if ( isset( $field_array[ $field_id ] ) ) {
219
-				$field = $field_array[ $field_id ];
218
+			if ( isset( $field_array[$field_id] ) ) {
219
+				$field = $field_array[$field_id];
220 220
             } else {
221
-                $field = FrmField::getOne($field_id);
221
+                $field = FrmField::getOne( $field_id );
222 222
             }
223 223
 
224 224
             if ( ! $field ) {
225 225
                 continue;
226 226
             }
227 227
 
228
-			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) );
228
+			$is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) );
229 229
 			if ( $is_settings_page ) {
230 230
                 //updating the settings page
231
-				if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) {
232
-					$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 ) );
233
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
231
+				if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) {
232
+					$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 ) );
233
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
234 234
 					FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
235 235
                 } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) {
236 236
                     $prev_opts = $field->field_options;
237
-                    $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
237
+                    $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values );
238 238
                     if ( $prev_opts != $field->field_options ) {
239 239
 						FrmField::update( $field_id, array( 'field_options' => $field->field_options ) );
240 240
                     }
241
-                    unset($prev_opts);
241
+                    unset( $prev_opts );
242 242
                 }
243 243
             }
244 244
 
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 			$update_options = apply_filters( 'frm_field_options_to_update', $update_options );
253 253
 
254 254
 			foreach ( $update_options as $opt => $default ) {
255
-				$field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default;
255
+				$field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default;
256 256
             }
257 257
 
258
-            $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
259
-			$default_value = maybe_serialize( $values['item_meta'][ $field_id ] );
258
+            $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values );
259
+			$default_value = maybe_serialize( $values['item_meta'][$field_id] );
260 260
 
261 261
 			$new_field = array(
262 262
 				'field_options' => $field->field_options,
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 			FrmField::update( $field_id, $new_field );
269 269
 
270
-            FrmField::delete_form_transient($field->form_id);
270
+            FrmField::delete_form_transient( $field->form_id );
271 271
         }
272 272
 		self::clear_form_cache();
273 273
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		);
282 282
 		foreach ( $field_cols as $col => $default ) {
283 283
 			$default = ( $default == '' ) ? $field->{$col} : $default;
284
-			$new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default;
284
+			$new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default;
285 285
 		}
286 286
 	}
287 287
 
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
      */
292 292
 	public static function set_status( $id, $status ) {
293 293
         if ( 'trash' == $status ) {
294
-            return self::trash($id);
294
+            return self::trash( $id );
295 295
         }
296 296
 
297
-		$statuses  = array( 'published', 'draft', 'trash' );
297
+		$statuses = array( 'published', 'draft', 'trash' );
298 298
         if ( ! in_array( $status, $statuses ) ) {
299 299
             return false;
300 300
         }
301 301
 
302 302
         global $wpdb;
303 303
 
304
-        if ( is_array($id) ) {
304
+        if ( is_array( $id ) ) {
305 305
 			$where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 );
306 306
 			FrmDb::get_where_clause_and_values( $where );
307 307
 			array_unshift( $where['values'], $status );
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             return self::destroy( $id );
328 328
         }
329 329
 
330
-        $form = self::getOne($id);
330
+        $form = self::getOne( $id );
331 331
         if ( ! $form ) {
332 332
             return false;
333 333
         }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	public static function destroy( $id ) {
362 362
         global $wpdb;
363 363
 
364
-        $form = self::getOne($id);
364
+        $form = self::getOne( $id );
365 365
         if ( ! $form ) {
366 366
             return false;
367 367
         }
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
         // Disconnect the entries from this form
371 371
 		$entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) );
372 372
         foreach ( $entries as $entry_id ) {
373
-            FrmEntry::destroy($entry_id);
374
-            unset($entry_id);
373
+            FrmEntry::destroy( $entry_id );
374
+            unset( $entry_id );
375 375
         }
376 376
 
377 377
         // Disconnect the fields from this form
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         if ( $query_results ) {
382 382
             // Delete all form actions linked to this form
383 383
             $action_control = FrmFormActionsController::get_form_actions( 'email' );
384
-            $action_control->destroy($id, 'all');
384
+            $action_control->destroy( $id, 'all' );
385 385
 
386 386
 			// Clear form caching
387 387
 			self::clear_form_cache();
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			$form->options = maybe_unserialize( $form->options );
416 416
 			if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
417 417
 				self::destroy( $form->id );
418
-				$count++;
418
+				$count ++;
419 419
 			}
420 420
 
421 421
 			unset( $form );
@@ -429,15 +429,15 @@  discard block
 block discarded – undo
429 429
     public static function &getName( $id ) {
430 430
         global $wpdb;
431 431
 
432
-        $form = FrmAppHelper::check_cache($id, 'frm_form');
432
+        $form = FrmAppHelper::check_cache( $id, 'frm_form' );
433 433
         if ( $form ) {
434
-            $r = stripslashes($form->name);
434
+            $r = stripslashes( $form->name );
435 435
             return $r;
436 436
         }
437 437
 
438 438
         $query_key = is_numeric( $id ) ? 'id' : 'form_key';
439 439
         $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' );
440
-        $r = stripslashes($r);
440
+        $r = stripslashes( $r );
441 441
 
442 442
         return $r;
443 443
     }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
      */
458 458
 	public static function &getKeyById( $id ) {
459 459
         $id = (int) $id;
460
-        $cache = FrmAppHelper::check_cache($id, 'frm_form');
460
+        $cache = FrmAppHelper::check_cache( $id, 'frm_form' );
461 461
         if ( $cache ) {
462 462
             return $cache->form_key;
463 463
         }
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
 			$table_name = $prefix . 'frm_forms';
492 492
         } else {
493 493
 			$table_name = $wpdb->prefix . 'frm_forms';
494
-            $cache = wp_cache_get($id, 'frm_form');
494
+            $cache = wp_cache_get( $id, 'frm_form' );
495 495
             if ( $cache ) {
496
-                if ( isset($cache->options) ) {
497
-                    $cache->options = maybe_unserialize($cache->options);
496
+                if ( isset( $cache->options ) ) {
497
+                    $cache->options = maybe_unserialize( $cache->options );
498 498
                 }
499 499
 
500
-                return stripslashes_deep($cache);
500
+                return stripslashes_deep( $cache );
501 501
             }
502 502
         }
503 503
 
504
-        if ( is_numeric($id) ) {
504
+        if ( is_numeric( $id ) ) {
505 505
             $where = array( 'id' => $id );
506 506
         } else {
507 507
             $where = array( 'form_key' => $id );
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
 
510 510
         $results = FrmDb::get_row( $table_name, $where );
511 511
 
512
-        if ( isset($results->options) ) {
512
+        if ( isset( $results->options ) ) {
513 513
 			FrmAppHelper::set_cache( $results->id, $results, 'frm_form' );
514
-            $results->options = maybe_unserialize($results->options);
514
+            $results->options = maybe_unserialize( $results->options );
515 515
         }
516
-        return stripslashes_deep($results);
516
+        return stripslashes_deep( $results );
517 517
     }
518 518
 
519 519
     /**
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 			$results = reset( $results );
543 543
 		}
544 544
 
545
-        return stripslashes_deep($results);
545
+        return stripslashes_deep( $results );
546 546
     }
547 547
 
548 548
 	/**
@@ -582,19 +582,19 @@  discard block
 block discarded – undo
582 582
     	foreach ( $results as $row ) {
583 583
             if ( 'trash' != $row->status ) {
584 584
     	        if ( $row->is_template ) {
585
-					$counts['template']++;
585
+					$counts['template'] ++;
586 586
     	        } else {
587
-					$counts['published']++;
587
+					$counts['published'] ++;
588 588
     	        }
589 589
     	    } else {
590
-				$counts['trash']++;
590
+				$counts['trash'] ++;
591 591
         	}
592 592
 
593 593
     	    if ( 'draft' == $row->status ) {
594
-				$counts['draft']++;
594
+				$counts['draft'] ++;
595 595
     	    }
596 596
 
597
-    		unset($row);
597
+    		unset( $row );
598 598
     	}
599 599
 
600 600
     	$counts = (object) $counts;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	public static function validate( $values ) {
621 621
         $errors = array();
622 622
 
623
-        return apply_filters('frm_validate_form', $errors, $values);
623
+        return apply_filters( 'frm_validate_form', $errors, $values );
624 624
     }
625 625
 
626 626
 	public static function get_params( $form = null ) {
@@ -632,11 +632,11 @@  discard block
 block discarded – undo
632 632
 			self::maybe_get_form( $form );
633 633
 		}
634 634
 
635
-		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) {
636
-			return $frm_vars['form_params'][ $form->id ];
635
+		if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) {
636
+			return $frm_vars['form_params'][$form->id];
637 637
 		}
638 638
 
639
-		$action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
639
+		$action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
640 640
 		$action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form );
641 641
 
642 642
 		$default_values = array(
@@ -654,15 +654,15 @@  discard block
 block discarded – undo
654 654
 			//if there are two forms on the same page, make sure not to submit both
655 655
 			foreach ( $default_values as $var => $default ) {
656 656
 				if ( $var == 'action' ) {
657
-					$values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
657
+					$values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' );
658 658
 				} else {
659
-					$values[ $var ] = FrmAppHelper::get_param( $var, $default );
659
+					$values[$var] = FrmAppHelper::get_param( $var, $default );
660 660
 				}
661 661
 				unset( $var, $default );
662 662
 			}
663 663
 		} else {
664 664
 			foreach ( $default_values as $var => $default ) {
665
-				$values[ $var ] = $default;
665
+				$values[$var] = $default;
666 666
 				unset( $var, $default );
667 667
 			}
668 668
 		}
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	public static function list_page_params() {
678 678
 		$values = array();
679 679
 		foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) {
680
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
680
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
681 681
 		}
682 682
 
683 683
 		return $values;
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 			'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '',
698 698
 			'keep_post' => '',
699 699
 		) as $var => $default ) {
700
-			$values[ $var ] = FrmAppHelper::get_param( $var, $default );
700
+			$values[$var] = FrmAppHelper::get_param( $var, $default );
701 701
 		}
702 702
 
703 703
 		return $values;
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 
706 706
 	public static function get_current_form_id( $default_form = 'none' ) {
707 707
 		if ( 'first' == $default_form ) {
708
-			var_dump(debug_backtrace());
708
+			var_dump( debug_backtrace() );
709 709
 			$form = self::get_current_form();
710 710
 		} else {
711 711
 			$form = self::maybe_get_current_form();
@@ -755,16 +755,16 @@  discard block
 block discarded – undo
755 755
 		$small_form = new stdClass();
756 756
 		foreach ( array( 'id', 'form_key', 'name' ) as $var ) {
757 757
 			$small_form->{$var} = $form->{$var};
758
-			unset($var);
758
+			unset( $var );
759 759
 		}
760 760
 
761 761
 		$frm_vars['forms_loaded'][] = $small_form;
762 762
 
763
-		if ( $this_load && empty($global_load) ) {
763
+		if ( $this_load && empty( $global_load ) ) {
764 764
 			$global_load = $frm_vars['load_css'] = true;
765 765
 		}
766 766
 
767
-		return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load );
767
+		return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load );
768 768
 	}
769 769
 
770 770
 	public static function show_submit( $form ) {
@@ -778,6 +778,6 @@  discard block
 block discarded – undo
778 778
 	 */
779 779
 	public static function get_option( $atts ) {
780 780
 		$form = $atts['form'];
781
-		return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default'];
781
+		return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default'];
782 782
 	}
783 783
 }
Please login to merge, or discard this patch.