Completed
Push — master ( 640e69...4e3097 )
by Jamie
04:14
created
classes/controllers/FrmXMLController.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class FrmXMLController {
4 4
 
5 5
     public static function menu() {
6
-        add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route');
6
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' );
7 7
     }
8 8
 
9 9
     public static function add_default_templates() {
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     		return;
13 13
     	}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
15
+        $set_err = libxml_use_internal_errors( true );
16 16
         $loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20 20
         foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
21
+            FrmXMLHelper::import_xml( $file );
22
+            unset( $file );
23 23
         }
24 24
         /*
25 25
         if(is_wp_error($result))
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
             $csv_format = 'UTF-8';
67 67
         }
68 68
 
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php');
69
+        include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' );
70 70
     }
71 71
 
72 72
     public static function import_xml() {
73 73
         $errors = array();
74 74
         $message = '';
75 75
 
76
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
76
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
77 77
         if ( $permission_error !== false ) {
78 78
             $errors[] = $permission_error;
79
-            self::form($errors);
79
+            self::form( $errors );
80 80
             return;
81 81
         }
82 82
 
83
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
83
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
84 84
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
85
-            self::form($errors);
85
+            self::form( $errors );
86 86
             return;
87 87
         }
88 88
 
89 89
         $file = $_FILES['frm_import_file']['tmp_name'];
90 90
 
91 91
         if ( ! is_uploaded_file( $file ) ) {
92
-            unset($file);
92
+            unset( $file );
93 93
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
94
-            self::form($errors);
94
+            self::form( $errors );
95 95
             return;
96 96
         }
97 97
 
98 98
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
99 99
 
100
-        $export_format = apply_filters('frm_export_formats', array(
100
+        $export_format = apply_filters( 'frm_export_formats', array(
101 101
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
102 102
 		) );
103 103
 
104
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
105
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
104
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
105
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
106 106
             // allow other file types to be imported
107
-            do_action('frm_before_import_'. $file_type );
107
+            do_action( 'frm_before_import_' . $file_type );
108 108
             return;
109 109
         }
110
-        unset($file_type);
110
+        unset( $file_type );
111 111
 
112 112
         //$media_id = FrmProAppHelper::upload_file('frm_import_file');
113 113
 
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
 		libxml_use_internal_errors( $set_err );
129 129
 		libxml_disable_entity_loader( $loader );
130 130
 
131
-        self::form($errors, $message);
131
+        self::form( $errors, $message );
132 132
     }
133 133
 
134 134
     public static function export_xml() {
135 135
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
136
-        if ( ! empty($error) ) {
136
+        if ( ! empty( $error ) ) {
137 137
             wp_die( $error );
138 138
         }
139 139
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         }
148 148
 
149 149
         if ( $format == 'xml' ) {
150
-            self::generate_xml($type, compact('ids'));
150
+            self::generate_xml( $type, compact( 'ids' ) );
151 151
         } else {
152
-            do_action('frm_export_format_'. $format, compact('ids'));
152
+            do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
153 153
         }
154 154
 
155 155
         wp_die();
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
     	global $wpdb;
160 160
 
161 161
 	    $type = (array) $type;
162
-        if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
162
+        if ( in_array( 'items', $type ) && ! in_array( 'forms', $type ) ) {
163 163
             // make sure the form is included if there are entries
164 164
             $type[] = 'forms';
165 165
         }
166 166
 
167
-	    if ( in_array( 'forms', $type) ) {
167
+	    if ( in_array( 'forms', $type ) ) {
168 168
             // include actions with forms
169 169
 	        $type[] = 'actions';
170 170
 	    }
171 171
 
172 172
 	    $tables = array(
173
-	        'items'     => $wpdb->prefix .'frm_items',
174
-	        'forms'     => $wpdb->prefix .'frm_forms',
173
+	        'items'     => $wpdb->prefix . 'frm_items',
174
+	        'forms'     => $wpdb->prefix . 'frm_forms',
175 175
 	        'posts'     => $wpdb->posts,
176 176
 	        'styles'    => $wpdb->posts,
177 177
 	        'actions'   => $wpdb->posts,
@@ -201,31 +201,31 @@  discard block
 block discarded – undo
201 201
 		foreach ( $type as $tb_type ) {
202 202
             $where = array();
203 203
 			$join = '';
204
-            $table = $tables[ $tb_type ];
204
+            $table = $tables[$tb_type];
205 205
 
206
-            $select = $table .'.id';
206
+            $select = $table . '.id';
207 207
             $query_vars = array();
208 208
 
209 209
             switch ( $tb_type ) {
210 210
                 case 'forms':
211 211
                     //add forms
212 212
                     if ( $args['ids'] ) {
213
-						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table .'.parent_form_id' => $args['ids'] );
213
+						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
214 214
                 	} else {
215
-						$where[ $table . '.status !' ] = 'draft';
215
+						$where[$table . '.status !'] = 'draft';
216 216
                 	}
217 217
                 break;
218 218
                 case 'actions':
219
-                    $select = $table .'.ID';
219
+                    $select = $table . '.ID';
220 220
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
221
-                    if ( ! empty($args['ids']) ) {
221
+                    if ( ! empty( $args['ids'] ) ) {
222 222
 						$where['menu_order'] = $args['ids'];
223 223
                     }
224 224
                 break;
225 225
                 case 'items':
226 226
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
227 227
                     if ( $args['ids'] ) {
228
-						$where[ $table . '.form_id' ] = $args['ids'];
228
+						$where[$table . '.form_id'] = $args['ids'];
229 229
                     }
230 230
                 break;
231 231
                 case 'styles':
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                         }
241 241
                         unset( $form_id, $form_data );
242 242
                     }
243
-                    $select = $table .'.ID';
243
+                    $select = $table . '.ID';
244 244
                     $where['post_type'] = 'frm_styles';
245 245
 
246 246
                     // Only export selected styles
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
                     }
250 250
                 break;
251 251
                 default:
252
-                    $select = $table .'.ID';
252
+                    $select = $table . '.ID';
253 253
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
254 254
                     $where['pm.meta_key'] = 'frm_form_id';
255 255
 
256
-                    if ( empty($args['ids']) ) {
256
+                    if ( empty( $args['ids'] ) ) {
257 257
                         $where['pm.meta_value >'] = 1;
258 258
                     } else {
259 259
                         $where['pm.meta_value'] = $args['ids'];
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
                 break;
262 262
             }
263 263
 
264
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
265
-            unset($tb_type);
264
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
265
+            unset( $tb_type );
266 266
         }
267 267
 
268
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
269
-        include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php');
268
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
269
+        include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
270 270
     }
271 271
 
272 272
 	public static function allow_mime( $mimes ) {
Please login to merge, or discard this patch.
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -2,118 +2,118 @@  discard block
 block discarded – undo
2 2
 
3 3
 class FrmXMLController {
4 4
 
5
-    public static function menu() {
6
-        add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route');
7
-    }
5
+	public static function menu() {
6
+		add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route');
7
+	}
8 8
 
9
-    public static function add_default_templates() {
9
+	public static function add_default_templates() {
10 10
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
11
-    		// XML import is not enabled on your server
12
-    		return;
13
-    	}
11
+			// XML import is not enabled on your server
12
+			return;
13
+		}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
16
-        $loader = libxml_disable_entity_loader( true );
15
+		$set_err = libxml_use_internal_errors(true);
16
+		$loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20
-        foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
23
-        }
24
-        /*
20
+		foreach ( (array) $files as $file ) {
21
+			FrmXMLHelper::import_xml($file);
22
+			unset($file);
23
+		}
24
+		/*
25 25
         if(is_wp_error($result))
26 26
             $errors[] = $result->get_error_message();
27 27
         else if($result)
28 28
             $message = $result;
29 29
         */
30 30
 
31
-        unset( $files );
31
+		unset( $files );
32 32
 
33
-        libxml_use_internal_errors( $set_err );
34
-    	libxml_disable_entity_loader( $loader );
35
-    }
33
+		libxml_use_internal_errors( $set_err );
34
+		libxml_disable_entity_loader( $loader );
35
+	}
36 36
 
37
-    public static function route() {
38
-        $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
37
+	public static function route() {
38
+		$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
39 39
 		$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
40 40
 		if ( $action == 'import_xml' ) {
41
-            return self::import_xml();
41
+			return self::import_xml();
42 42
 		} else if ( $action == 'export_xml' ) {
43
-            return self::export_xml();
44
-        } else {
45
-            if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
-                return self::form();
47
-            }
48
-        }
49
-    }
50
-
51
-    public static function form( $errors = array(), $message = '' ) {
43
+			return self::export_xml();
44
+		} else {
45
+			if ( apply_filters( 'frm_xml_route', true, $action ) ) {
46
+				return self::form();
47
+			}
48
+		}
49
+	}
50
+
51
+	public static function form( $errors = array(), $message = '' ) {
52 52
 		$where = array(
53 53
 			'parent_form_id' => array( null, 0 ),
54 54
 			'status' => array( null, '', 'published' )
55 55
 		);
56 56
 		$forms = FrmForm::getAll( $where, 'name' );
57 57
 
58
-        $export_types = apply_filters( 'frm_xml_export_types',
59
-            array( 'forms' => __( 'Forms', 'formidable' ) )
60
-        );
61
-
62
-        $export_format = apply_filters( 'frm_export_formats', array(
63
-            'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
64
-        ) );
65
-
66
-        if ( FrmAppHelper::pro_is_installed() ) {
67
-            $frmpro_settings = new FrmProSettings();
68
-            $csv_format = $frmpro_settings->csv_format;
69
-        } else {
70
-            $csv_format = 'UTF-8';
71
-        }
72
-
73
-        include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php');
74
-    }
75
-
76
-    public static function import_xml() {
77
-        $errors = array();
78
-        $message = '';
79
-
80
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
81
-        if ( $permission_error !== false ) {
82
-            $errors[] = $permission_error;
83
-            self::form($errors);
84
-            return;
85
-        }
86
-
87
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
88
-            $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
89
-            self::form($errors);
90
-            return;
91
-        }
92
-
93
-        $file = $_FILES['frm_import_file']['tmp_name'];
94
-
95
-        if ( ! is_uploaded_file( $file ) ) {
96
-            unset($file);
97
-            $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
98
-            self::form($errors);
99
-            return;
100
-        }
101
-
102
-        //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
103
-
104
-        $export_format = apply_filters('frm_export_formats', array(
58
+		$export_types = apply_filters( 'frm_xml_export_types',
59
+			array( 'forms' => __( 'Forms', 'formidable' ) )
60
+		);
61
+
62
+		$export_format = apply_filters( 'frm_export_formats', array(
105 63
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
106 64
 		) );
107 65
 
108
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
109
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
110
-            // allow other file types to be imported
111
-            do_action('frm_before_import_'. $file_type );
112
-            return;
113
-        }
114
-        unset($file_type);
66
+		if ( FrmAppHelper::pro_is_installed() ) {
67
+			$frmpro_settings = new FrmProSettings();
68
+			$csv_format = $frmpro_settings->csv_format;
69
+		} else {
70
+			$csv_format = 'UTF-8';
71
+		}
72
+
73
+		include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php');
74
+	}
75
+
76
+	public static function import_xml() {
77
+		$errors = array();
78
+		$message = '';
79
+
80
+		$permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
81
+		if ( $permission_error !== false ) {
82
+			$errors[] = $permission_error;
83
+			self::form($errors);
84
+			return;
85
+		}
86
+
87
+		if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
88
+			$errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
89
+			self::form($errors);
90
+			return;
91
+		}
92
+
93
+		$file = $_FILES['frm_import_file']['tmp_name'];
94
+
95
+		if ( ! is_uploaded_file( $file ) ) {
96
+			unset($file);
97
+			$errors[] = __( 'The file does not exist, please try again.', 'formidable' );
98
+			self::form($errors);
99
+			return;
100
+		}
115 101
 
116
-        //$media_id = FrmProAppHelper::upload_file('frm_import_file');
102
+		//add_filter('upload_mimes', 'FrmXMLController::allow_mime');
103
+
104
+		$export_format = apply_filters('frm_export_formats', array(
105
+			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
106
+		) );
107
+
108
+		$file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
109
+		if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
110
+			// allow other file types to be imported
111
+			do_action('frm_before_import_'. $file_type );
112
+			return;
113
+		}
114
+		unset($file_type);
115
+
116
+		//$media_id = FrmProAppHelper::upload_file('frm_import_file');
117 117
 
118 118
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
119 119
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -132,158 +132,158 @@  discard block
 block discarded – undo
132 132
 		libxml_use_internal_errors( $set_err );
133 133
 		libxml_disable_entity_loader( $loader );
134 134
 
135
-        self::form($errors, $message);
136
-    }
135
+		self::form($errors, $message);
136
+	}
137 137
 
138
-    public static function export_xml() {
139
-        $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
140
-        if ( ! empty($error) ) {
141
-            wp_die( $error );
142
-        }
138
+	public static function export_xml() {
139
+		$error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
140
+		if ( ! empty($error) ) {
141
+			wp_die( $error );
142
+		}
143 143
 
144 144
 		$ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() );
145 145
 		$type = FrmAppHelper::get_post_param( 'type', array() );
146 146
 		$format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' );
147 147
 
148
-        if ( ! headers_sent() && ! $type ) {
149
-            wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
150
-            die();
151
-        }
148
+		if ( ! headers_sent() && ! $type ) {
149
+			wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) );
150
+			die();
151
+		}
152 152
 
153
-        if ( $format == 'xml' ) {
154
-            self::generate_xml($type, compact('ids'));
155
-        } else {
156
-            do_action('frm_export_format_'. $format, compact('ids'));
157
-        }
153
+		if ( $format == 'xml' ) {
154
+			self::generate_xml($type, compact('ids'));
155
+		} else {
156
+			do_action('frm_export_format_'. $format, compact('ids'));
157
+		}
158 158
 
159
-        wp_die();
160
-    }
159
+		wp_die();
160
+	}
161 161
 
162 162
 	public static function generate_xml( $type, $args = array() ) {
163
-    	global $wpdb;
164
-
165
-	    $type = (array) $type;
166
-        if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
167
-            // make sure the form is included if there are entries
168
-            $type[] = 'forms';
169
-        }
170
-
171
-	    if ( in_array( 'forms', $type) ) {
172
-            // include actions with forms
173
-	        $type[] = 'actions';
174
-	    }
175
-
176
-	    $tables = array(
177
-	        'items'     => $wpdb->prefix .'frm_items',
178
-	        'forms'     => $wpdb->prefix .'frm_forms',
179
-	        'posts'     => $wpdb->posts,
180
-	        'styles'    => $wpdb->posts,
181
-	        'actions'   => $wpdb->posts,
182
-	    );
163
+		global $wpdb;
164
+
165
+		$type = (array) $type;
166
+		if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) {
167
+			// make sure the form is included if there are entries
168
+			$type[] = 'forms';
169
+		}
170
+
171
+		if ( in_array( 'forms', $type) ) {
172
+			// include actions with forms
173
+			$type[] = 'actions';
174
+		}
175
+
176
+		$tables = array(
177
+			'items'     => $wpdb->prefix .'frm_items',
178
+			'forms'     => $wpdb->prefix .'frm_forms',
179
+			'posts'     => $wpdb->posts,
180
+			'styles'    => $wpdb->posts,
181
+			'actions'   => $wpdb->posts,
182
+		);
183 183
 
184 184
 		$defaults = array( 'ids' => false );
185
-	    $args = wp_parse_args( $args, $defaults );
185
+		$args = wp_parse_args( $args, $defaults );
186 186
 
187
-        $sitename = sanitize_key( get_bloginfo( 'name' ) );
187
+		$sitename = sanitize_key( get_bloginfo( 'name' ) );
188 188
 
189
-    	if ( ! empty( $sitename ) ) {
189
+		if ( ! empty( $sitename ) ) {
190 190
 			$sitename .= '.';
191 191
 		}
192
-    	$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
192
+		$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
193 193
 
194
-    	header( 'Content-Description: File Transfer' );
195
-    	header( 'Content-Disposition: attachment; filename=' . $filename );
196
-    	header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
194
+		header( 'Content-Description: File Transfer' );
195
+		header( 'Content-Disposition: attachment; filename=' . $filename );
196
+		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
197 197
 
198
-        //make sure ids are numeric
199
-    	if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
200
-	        $args['ids'] = array_filter( $args['ids'], 'is_numeric' );
201
-	    }
198
+		//make sure ids are numeric
199
+		if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
200
+			$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
201
+		}
202 202
 
203
-	    $records = array();
203
+		$records = array();
204 204
 
205 205
 		foreach ( $type as $tb_type ) {
206
-            $where = array();
206
+			$where = array();
207 207
 			$join = '';
208
-            $table = $tables[ $tb_type ];
208
+			$table = $tables[ $tb_type ];
209 209
 
210
-            $select = $table .'.id';
211
-            $query_vars = array();
210
+			$select = $table .'.id';
211
+			$query_vars = array();
212 212
 
213
-            switch ( $tb_type ) {
214
-                case 'forms':
215
-                    //add forms
216
-                    if ( $args['ids'] ) {
213
+			switch ( $tb_type ) {
214
+				case 'forms':
215
+					//add forms
216
+					if ( $args['ids'] ) {
217 217
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table .'.parent_form_id' => $args['ids'] );
218
-                	} else {
218
+					} else {
219 219
 						$where[ $table . '.status !' ] = 'draft';
220
-                	}
221
-                break;
222
-                case 'actions':
223
-                    $select = $table .'.ID';
220
+					}
221
+				break;
222
+				case 'actions':
223
+					$select = $table .'.ID';
224 224
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
225
-                    if ( ! empty($args['ids']) ) {
225
+					if ( ! empty($args['ids']) ) {
226 226
 						$where['menu_order'] = $args['ids'];
227
-                    }
228
-                break;
229
-                case 'items':
230
-                    //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
231
-                    if ( $args['ids'] ) {
227
+					}
228
+				break;
229
+				case 'items':
230
+					//$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
231
+					if ( $args['ids'] ) {
232 232
 						$where[ $table . '.form_id' ] = $args['ids'];
233
-                    }
234
-                break;
235
-                case 'styles':
236
-                    // Loop through all exported forms and get their selected style IDs
237
-                    $form_ids = $args['ids'];
238
-                    $style_ids = array();
239
-                    foreach ( $form_ids as $form_id ) {
240
-                        $form_data = FrmForm::getOne( $form_id );
241
-                        // For forms that have not been updated while running 2.0, check if custom_style is set
242
-                        if ( isset( $form_data->options['custom_style'] ) ) {
243
-                            $style_ids[] = $form_data->options['custom_style'];
244
-                        }
245
-                        unset( $form_id, $form_data );
246
-                    }
247
-                    $select = $table .'.ID';
248
-                    $where['post_type'] = 'frm_styles';
249
-
250
-                    // Only export selected styles
251
-                    if ( ! empty( $style_ids ) ) {
252
-                        $where['ID'] = $style_ids;
253
-                    }
254
-                break;
255
-                default:
256
-                    $select = $table .'.ID';
257
-                    $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
258
-                    $where['pm.meta_key'] = 'frm_form_id';
259
-
260
-                    if ( empty($args['ids']) ) {
261
-                        $where['pm.meta_value >'] = 1;
262
-                    } else {
263
-                        $where['pm.meta_value'] = $args['ids'];
264
-                    }
265
-                break;
266
-            }
233
+					}
234
+				break;
235
+				case 'styles':
236
+					// Loop through all exported forms and get their selected style IDs
237
+					$form_ids = $args['ids'];
238
+					$style_ids = array();
239
+					foreach ( $form_ids as $form_id ) {
240
+						$form_data = FrmForm::getOne( $form_id );
241
+						// For forms that have not been updated while running 2.0, check if custom_style is set
242
+						if ( isset( $form_data->options['custom_style'] ) ) {
243
+							$style_ids[] = $form_data->options['custom_style'];
244
+						}
245
+						unset( $form_id, $form_data );
246
+					}
247
+					$select = $table .'.ID';
248
+					$where['post_type'] = 'frm_styles';
249
+
250
+					// Only export selected styles
251
+					if ( ! empty( $style_ids ) ) {
252
+						$where['ID'] = $style_ids;
253
+					}
254
+				break;
255
+				default:
256
+					$select = $table .'.ID';
257
+					$join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
258
+					$where['pm.meta_key'] = 'frm_form_id';
259
+
260
+					if ( empty($args['ids']) ) {
261
+						$where['pm.meta_value >'] = 1;
262
+					} else {
263
+						$where['pm.meta_value'] = $args['ids'];
264
+					}
265
+				break;
266
+			}
267 267
 
268 268
 			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
269
-            unset($tb_type);
270
-        }
269
+			unset($tb_type);
270
+		}
271 271
 
272 272
 		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
273
-        include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php');
274
-    }
273
+		include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php');
274
+	}
275 275
 
276 276
 	public static function allow_mime( $mimes ) {
277
-        if ( ! isset( $mimes['csv'] ) ) {
278
-            // allow csv files
279
-            $mimes['csv'] = 'text/csv';
280
-        }
281
-
282
-        if ( ! isset( $mimes['xml'] ) ) {
283
-            // allow xml
284
-            $mimes['xml'] = 'text/xml';
285
-        }
286
-
287
-        return $mimes;
288
-    }
277
+		if ( ! isset( $mimes['csv'] ) ) {
278
+			// allow csv files
279
+			$mimes['csv'] = 'text/csv';
280
+		}
281
+
282
+		if ( ! isset( $mimes['xml'] ) ) {
283
+			// allow xml
284
+			$mimes['xml'] = 'text/xml';
285
+		}
286
+
287
+		return $mimes;
288
+	}
289 289
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -5,68 +5,68 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
-        global $frm_vars;
10
-        $values = array();
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9
+		global $frm_vars;
10
+		$values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
-        }
14
-
15
-        $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
18
-        }
19
-
20
-        foreach ( (array) $fields as $field ) {
21
-            $new_value = self::get_field_value_for_new_entry( $field, $reset );
22
-
23
-            $field_array = array(
24
-                'id' => $field->id,
25
-                'value' => $new_value,
26
-                'default_value' => $field->default_value,
27
-                'name' => $field->name,
28
-                'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
-                'options' => $field->options,
31
-                'required' => $field->required,
32
-                'field_key' => $field->field_key,
33
-                'field_order' => $field->field_order,
34
-                'form_id' => $field->form_id,
12
+			$values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
13
+		}
14
+
15
+		$values['fields'] = array();
16
+		if ( empty($fields) ) {
17
+			return apply_filters('frm_setup_new_entry', $values);
18
+		}
19
+
20
+		foreach ( (array) $fields as $field ) {
21
+			$new_value = self::get_field_value_for_new_entry( $field, $reset );
22
+
23
+			$field_array = array(
24
+				'id' => $field->id,
25
+				'value' => $new_value,
26
+				'default_value' => $field->default_value,
27
+				'name' => $field->name,
28
+				'description' => $field->description,
29
+				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
30
+				'options' => $field->options,
31
+				'required' => $field->required,
32
+				'field_key' => $field->field_key,
33
+				'field_order' => $field->field_order,
34
+				'form_id' => $field->form_id,
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36
-            );
36
+			);
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
-            $opt_defaults['required_indicator'] = '';
38
+			$opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
39
+			$opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
45
-            }
43
+				$field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
+				unset($opt, $default_opt);
45
+			}
46 46
 
47
-            unset($opt_defaults);
47
+			unset($opt_defaults);
48 48
 
49
-            if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
-            }
49
+			if ( $field_array['custom_html'] == '' ) {
50
+				$field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
51
+			}
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
-            $field_array = array_merge( $field->field_options, $field_array );
53
+			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
54
+			$field_array = array_merge( $field->field_options, $field_array );
55 55
 
56
-            $values['fields'][] = $field_array;
56
+			$values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
60
-            }
61
-        }
58
+			if ( ! $form || ! isset($form->id) ) {
59
+				$form = FrmForm::getOne($field->form_id);
60
+			}
61
+		}
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
65
-            foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
68
-            }
69
-        }
63
+		$form->options = maybe_unserialize($form->options);
64
+		if ( is_array($form->options) ) {
65
+			foreach ( $form->options as $opt => $value ) {
66
+				$values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
+				unset($opt, $value);
68
+			}
69
+		}
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
78 78
 		return apply_filters( 'frm_setup_new_entry', $values );
79
-    }
79
+	}
80 80
 
81 81
 	/**
82
-	* Set the value for each field
83
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
84
-	*
85
-	* @since 2.0.13
86
-	*
87
-	* @param object $field - this is passed by reference since it is an object
88
-	* @param boolean $reset
89
-	* @return string|array $new_value
90
-	*/
82
+	 * Set the value for each field
83
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
84
+	 *
85
+	 * @since 2.0.13
86
+	 *
87
+	 * @param object $field - this is passed by reference since it is an object
88
+	 * @param boolean $reset
89
+	 * @return string|array $new_value
90
+	 */
91 91
 	private static function get_field_value_for_new_entry( $field, $reset ) {
92 92
 		//If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 
119 119
 	public static function setup_edit_vars( $values, $record ) {
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121
-        $values['form_id'] = $record->form_id;
122
-        $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
-    }
121
+		$values['form_id'] = $record->form_id;
122
+		$values['is_draft'] = $record->is_draft;
123
+		return apply_filters('frm_setup_edit_entry_vars', $values, $record);
124
+	}
125 125
 
126
-    public static function get_admin_params( $form = null ) {
126
+	public static function get_admin_params( $form = null ) {
127 127
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' );
128 128
 		return FrmForm::set_current_form( $form );
129
-    }
129
+	}
130 130
 
131 131
 	public static function set_current_form( $form_id ) {
132 132
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' );
@@ -138,280 +138,280 @@  discard block
 block discarded – undo
138 138
 		return FrmForm::get_current_form( $form_id );
139 139
 	}
140 140
 
141
-    public static function get_current_form_id() {
141
+	public static function get_current_form_id() {
142 142
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' );
143 143
 		return FrmForm::get_current_form_id();
144
-    }
144
+	}
145 145
 
146
-    public static function maybe_get_entry( &$entry ) {
146
+	public static function maybe_get_entry( &$entry ) {
147 147
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' );
148 148
 		FrmEntry::maybe_get_entry( $entry );
149
-    }
149
+	}
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
154
-            ! empty( $message ) ) {
155
-            return $message;
156
-        }
157
-
158
-        if ( empty($message) ) {
159
-            $message = '[default-message]';
160
-        }
161
-
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
-
164
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
-            if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
168
-            } else {
169
-                $this_atts = $atts;
170
-            }
152
+		if ( strpos($message, '[default-message') === false &&
153
+			strpos($message, '[default_message') === false &&
154
+			! empty( $message ) ) {
155
+			return $message;
156
+		}
157
+
158
+		if ( empty($message) ) {
159
+			$message = '[default-message]';
160
+		}
161
+
162
+		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
163
+
164
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
165
+			$add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
166
+			if ( $add_atts ) {
167
+				$this_atts = array_merge($atts, $add_atts);
168
+			} else {
169
+				$this_atts = $atts;
170
+			}
171 171
 
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174
-            // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
-        }
174
+			// Add the default message
175
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
176
+		}
177 177
 
178
-        return $message;
179
-    }
178
+		return $message;
179
+	}
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182 182
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
183
-        if ( FrmAppHelper::pro_is_installed() ) {
183
+		if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185
-        }
185
+		}
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
189
-        }
187
+		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
+			return self::display_value($field_value, $field, $atts);
189
+		}
190 190
 
191
-        // this is an embeded form
192
-        $val = '';
191
+		// this is an embeded form
192
+		$val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
-            //this is a repeating section
194
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
195
+			//this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197
-        } else {
198
-            // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
197
+		} else {
198
+			// get all values for this field
199
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
200 200
 
201
-            if ( $child_values ) {
202
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
-	        }
204
-	    }
201
+			if ( $child_values ) {
202
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
203
+			}
204
+		}
205 205
 
206
-	    $field_value = array();
206
+		$field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
-            return $val;
210
-        }
208
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209
+			return $val;
210
+		}
211 211
 
212
-        foreach ( $child_entries as $child_entry ) {
213
-            $atts['item_id'] = $child_entry->id;
214
-            $atts['post_id'] = $child_entry->post_id;
212
+		foreach ( $child_entries as $child_entry ) {
213
+			$atts['item_id'] = $child_entry->id;
214
+			$atts['post_id'] = $child_entry->post_id;
215 215
 
216
-            // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
216
+			// get the value for this field -- check for post values as well
217
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
218 218
 
219
-            if ( $entry_val ) {
220
-                // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
222
-            }
219
+			if ( $entry_val ) {
220
+				// foreach entry get display_value
221
+				$field_value[] = self::display_value($entry_val, $field, $atts);
222
+			}
223 223
 
224
-            unset($child_entry);
225
-        }
224
+			unset($child_entry);
225
+		}
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+		$val = implode(', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230
-        return $val;
231
-    }
230
+		return $val;
231
+	}
232 232
 
233
-    /**
234
-     * Prepare the saved value for display
235
-     * @return string
236
-     */
233
+	/**
234
+	 * Prepare the saved value for display
235
+	 * @return string
236
+	 */
237 237
 	public static function display_value( $value, $field, $atts = array() ) {
238 238
 
239
-        $defaults = array(
240
-            'type' => '', 'html' => false, 'show_filename' => true,
241
-            'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
-            'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
239
+		$defaults = array(
240
+			'type' => '', 'html' => false, 'show_filename' => true,
241
+			'truncate' => false, 'sep' => ', ', 'post_id' => 0,
242
+			'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0,
243 243
 			'return_array' => false,
244
-        );
244
+		);
245 245
 
246
-        $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
246
+		$atts = wp_parse_args( $atts, $defaults );
247
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
250
-            $field->field_options['post_field'] = '';
251
-        }
249
+		if ( ! isset($field->field_options['post_field']) ) {
250
+			$field->field_options['post_field'] = '';
251
+		}
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
254
-            $field->field_options['custom_field'] = '';
255
-        }
253
+		if ( ! isset($field->field_options['custom_field']) ) {
254
+			$field->field_options['custom_field'] = '';
255
+		}
256 256
 
257
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
-            $atts['pre_truncate'] = $atts['truncate'];
259
-            $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
257
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258
+			$atts['pre_truncate'] = $atts['truncate'];
259
+			$atts['truncate'] = true;
260
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
-            $atts['truncate'] = $atts['pre_truncate'];
264
-        }
262
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
263
+			$atts['truncate'] = $atts['pre_truncate'];
264
+		}
265 265
 
266
-        if ( $value == '' ) {
267
-            return $value;
268
-        }
266
+		if ( $value == '' ) {
267
+			return $value;
268
+		}
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
271 271
 
272
-        $new_value = '';
272
+		$new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
275
-            foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
274
+		if ( is_array($value) && $atts['type'] != 'file' ) {
275
+			foreach ( $value as $val ) {
276
+				if ( is_array($val) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
279
-                    if ( $atts['type'] != 'data' ) {
280
-                        $new_value .= '<br/>';
281
-                    }
282
-                }
283
-                unset($val);
284
-            }
285
-        }
286
-
287
-        if ( ! empty($new_value) ) {
288
-            $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
291
-        }
292
-
293
-        if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
295
-        }
278
+					$new_value .= implode($atts['sep'], $val);
279
+					if ( $atts['type'] != 'data' ) {
280
+						$new_value .= '<br/>';
281
+					}
282
+				}
283
+				unset($val);
284
+			}
285
+		}
286
+
287
+		if ( ! empty($new_value) ) {
288
+			$value = $new_value;
289
+		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+			$value = implode($atts['sep'], $value);
291
+		}
292
+
293
+		if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
+			$value = FrmAppHelper::truncate($value, 50);
295
+		}
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
302
-    }
301
+		return apply_filters('frm_display_value', $value, $field, $atts);
302
+	}
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
305
-        // If validating a field with "other" opt, set back to prev value now
306
-        if ( isset( $args['other'] ) && $args['other'] ) {
307
-            $value = $args['temp_value'];
308
-        }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
311
-        } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
-        }
314
-    }
305
+		// If validating a field with "other" opt, set back to prev value now
306
+		if ( isset( $args['other'] ) && $args['other'] ) {
307
+			$value = $args['temp_value'];
308
+		}
309
+		if ( empty($args['parent_field_id']) ) {
310
+			$_POST['item_meta'][ $field->id ] = $value;
311
+		} else {
312
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
313
+		}
314
+	}
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
-        } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
-        }
324
-    }
325
-
326
-    /**
327
-    * Check if field has an "Other" option and if any other values are posted
328
-    *
329
-    * @since 2.0
330
-    *
331
-    * @param object $field
332
-    * @param string|array $value
333
-    * @param array $args
334
-    */
335
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
-        $args['other'] = false;
337
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
-            return;
339
-        }
340
-
341
-        // Get other value for fields in repeating section
342
-        self::set_other_repeating_vals( $field, $value, $args );
343
-
344
-        // Check if there are any posted "Other" values
319
+		if ( empty($args['parent_field_id']) ) {
320
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
321
+		} else {
322
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
323
+		}
324
+	}
325
+
326
+	/**
327
+	 * Check if field has an "Other" option and if any other values are posted
328
+	 *
329
+	 * @since 2.0
330
+	 *
331
+	 * @param object $field
332
+	 * @param string|array $value
333
+	 * @param array $args
334
+	 */
335
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
336
+		$args['other'] = false;
337
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
338
+			return;
339
+		}
340
+
341
+		// Get other value for fields in repeating section
342
+		self::set_other_repeating_vals( $field, $value, $args );
343
+
344
+		// Check if there are any posted "Other" values
345 345
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
346 346
 
347
-            // Save original value
348
-            $args['temp_value'] = $value;
349
-            $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
-
352
-            // Set the validation value now
353
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
354
-        }
355
-    }
356
-
357
-    /**
358
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
-    *
360
-    * @since 2.0
361
-    *
362
-    * @param object $field
363
-    * @param string|array $value
364
-    * @param array $args
365
-    */
366
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
-        if ( ! $args['parent_field_id'] ) {
368
-            return;
369
-        }
370
-
371
-        // Check if there are any other posted "other" values for this field
347
+			// Save original value
348
+			$args['temp_value'] = $value;
349
+			$args['other'] = true;
350
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
351
+
352
+			// Set the validation value now
353
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
354
+		}
355
+	}
356
+
357
+	/**
358
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
359
+	 *
360
+	 * @since 2.0
361
+	 *
362
+	 * @param object $field
363
+	 * @param string|array $value
364
+	 * @param array $args
365
+	 */
366
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
367
+		if ( ! $args['parent_field_id'] ) {
368
+			return;
369
+		}
370
+
371
+		// Check if there are any other posted "other" values for this field
372 372
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
373
-            // Save original value
374
-            $args['temp_value'] = $value;
375
-            $args['other'] = true;
376
-
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
-
379
-            // Set the validation value now
380
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
381
-        }
382
-    }
383
-
384
-    /**
385
-    * Modify value used for validation
386
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
-    * It also adds any text from the free text fields to the value
388
-    *
389
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
-    *
391
-    * @since 2.0
392
-    *
393
-    * @param string|array $value
394
-    * @param string|array $other_vals (usually of posted values)
395
-    * @param object $field
396
-    * @param array $args
397
-    */
398
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
-        // Checkboxes and multi-select dropdowns
400
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
402
-            $value = array_merge( $value, $other_vals );
403
-            $value = array_filter( $value );
404
-            if ( count( $value ) == 0 ) {
405
-                $value = '';
406
-            }
407
-        } else {
373
+			// Save original value
374
+			$args['temp_value'] = $value;
375
+			$args['other'] = true;
376
+
377
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
378
+
379
+			// Set the validation value now
380
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
381
+		}
382
+	}
383
+
384
+	/**
385
+	 * Modify value used for validation
386
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
387
+	 * It also adds any text from the free text fields to the value
388
+	 *
389
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
390
+	 *
391
+	 * @since 2.0
392
+	 *
393
+	 * @param string|array $value
394
+	 * @param string|array $other_vals (usually of posted values)
395
+	 * @param object $field
396
+	 * @param array $args
397
+	 */
398
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
399
+		// Checkboxes and multi-select dropdowns
400
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
401
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
402
+			$value = array_merge( $value, $other_vals );
403
+			$value = array_filter( $value );
404
+			if ( count( $value ) == 0 ) {
405
+				$value = '';
406
+			}
407
+		} else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
410
-            $other_key = reset( $other_key );
409
+			$other_key = array_filter( array_keys($field->options), 'is_string');
410
+			$other_key = reset( $other_key );
411 411
 
412
-            // Multi-select dropdown
413
-            if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
412
+			// Multi-select dropdown
413
+			if ( is_array( $value ) ) {
414
+				$o_key = array_search( $field->options[ $other_key ], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
@@ -426,20 +426,20 @@  discard block
 block discarded – undo
426 426
 					$args['temp_value'] = $value;
427 427
 					$value[ $other_key ] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
430
-                $value = $other_vals;
431
-            }
432
-        }
433
-    }
429
+			} else if ( $field->options[ $other_key ] == $value ) {
430
+				$value = $other_vals;
431
+			}
432
+		}
433
+	}
434 434
 
435 435
 	public static function enqueue_scripts( $params ) {
436 436
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' );
437 437
 		return FrmFormsController::enqueue_scripts( $params );
438 438
 	}
439 439
 
440
-    // Add submitted values to a string for spam checking
440
+	// Add submitted values to a string for spam checking
441 441
 	public static function entry_array_to_string( $values ) {
442
-        $content = '';
442
+		$content = '';
443 443
 		foreach ( $values['item_meta'] as $val ) {
444 444
 			if ( $content != '' ) {
445 445
 				$content .= "\n\n";
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 
448 448
 			if ( is_array($val) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+				$val = implode(',', $val);
451 451
 			}
452 452
 
453 453
 			$content .= $val;
454 454
 		}
455 455
 
456 456
 		return $content;
457
-    }
457
+	}
458 458
 
459 459
 	public static function fill_entry_values( $atts, $f, array &$values ) {
460 460
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 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
 
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
         global $frm_vars;
10 10
         $values = array();
11 11
 		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) {
12
-            $values[ $var ] = FrmAppHelper::get_post_param( $var, $default );
12
+            $values[$var] = FrmAppHelper::get_post_param( $var, $default );
13 13
         }
14 14
 
15 15
         $values['fields'] = array();
16
-        if ( empty($fields) ) {
17
-            return apply_filters('frm_setup_new_entry', $values);
16
+        if ( empty( $fields ) ) {
17
+            return apply_filters( 'frm_setup_new_entry', $values );
18 18
         }
19 19
 
20 20
         foreach ( (array) $fields as $field ) {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                 'default_value' => $field->default_value,
27 27
                 'name' => $field->name,
28 28
                 'description' => $field->description,
29
-                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value),
29
+                'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ),
30 30
                 'options' => $field->options,
31 31
                 'required' => $field->required,
32 32
                 'field_key' => $field->field_key,
@@ -35,43 +35,43 @@  discard block
 block discarded – undo
35 35
 				'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id,
36 36
             );
37 37
 
38
-            $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
38
+            $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true );
39 39
             $opt_defaults['required_indicator'] = '';
40 40
 			$opt_defaults['original_type'] = $field->type;
41 41
 
42 42
 			foreach ( $opt_defaults as $opt => $default_opt ) {
43
-                $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt;
44
-                unset($opt, $default_opt);
43
+                $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt;
44
+                unset( $opt, $default_opt );
45 45
             }
46 46
 
47
-            unset($opt_defaults);
47
+            unset( $opt_defaults );
48 48
 
49 49
             if ( $field_array['custom_html'] == '' ) {
50
-                $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
50
+                $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
51 51
             }
52 52
 
53
-            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
53
+            $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field );
54 54
             $field_array = array_merge( $field->field_options, $field_array );
55 55
 
56 56
             $values['fields'][] = $field_array;
57 57
 
58
-            if ( ! $form || ! isset($form->id) ) {
59
-                $form = FrmForm::getOne($field->form_id);
58
+            if ( ! $form || ! isset( $form->id ) ) {
59
+                $form = FrmForm::getOne( $field->form_id );
60 60
             }
61 61
         }
62 62
 
63
-        $form->options = maybe_unserialize($form->options);
64
-        if ( is_array($form->options) ) {
63
+        $form->options = maybe_unserialize( $form->options );
64
+        if ( is_array( $form->options ) ) {
65 65
             foreach ( $form->options as $opt => $value ) {
66
-                $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value );
67
-                unset($opt, $value);
66
+                $values[$opt] = FrmAppHelper::get_post_param( $opt, $value );
67
+                unset( $opt, $value );
68 68
             }
69 69
         }
70 70
 
71 71
 		$form_defaults = FrmFormsHelper::get_default_opts();
72 72
 
73 73
 		$frm_settings = FrmAppHelper::get_settings();
74
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
74
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
75 75
 
76 76
 		$values = array_merge( $form_defaults, $values );
77 77
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		$return_array = FrmField::is_field_with_multiple_values( $field );
94 94
 
95 95
 		// Do any shortcodes in default value and allow customization of default value
96
-		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
96
+		$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array );
97 97
 		// Calls FrmProFieldsHelper::get_default_value
98 98
 
99 99
 		$new_value = $field->default_value;
100 100
 
101
-		if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) {
101
+		if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) {
102 102
 			// If value was posted, get it
103 103
 
104
-			$new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] );
104
+			$new_value = stripslashes_deep( $_POST['item_meta'][$field->id] );
105 105
 
106 106
 		} else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) {
107 107
 			// If clear on focus is selected, the value should be blank (unless it was posted, of course)
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 
112 112
 		if ( ! is_array( $new_value ) ) {
113
-			$new_value = str_replace('"', '&quot;', $new_value);
113
+			$new_value = str_replace( '"', '&quot;', $new_value );
114 114
 		}
115 115
 
116 116
 		return $new_value;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
121 121
         $values['form_id'] = $record->form_id;
122 122
         $values['is_draft'] = $record->is_draft;
123
-        return apply_filters('frm_setup_edit_entry_vars', $values, $record);
123
+        return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
124 124
     }
125 125
 
126 126
     public static function get_admin_params( $form = null ) {
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
 	public static function replace_default_message( $message, $atts ) {
152
-        if ( strpos($message, '[default-message') === false &&
153
-            strpos($message, '[default_message') === false &&
152
+        if ( strpos( $message, '[default-message' ) === false &&
153
+            strpos( $message, '[default_message' ) === false &&
154 154
             ! empty( $message ) ) {
155 155
             return $message;
156 156
         }
157 157
 
158
-        if ( empty($message) ) {
158
+        if ( empty( $message ) ) {
159 159
             $message = '[default-message]';
160 160
         }
161 161
 
162
-        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER);
162
+        preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
163 163
 
164 164
         foreach ( $shortcodes[0] as $short_key => $tag ) {
165
-            $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] );
165
+            $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] );
166 166
             if ( $add_atts ) {
167
-                $this_atts = array_merge($atts, $add_atts);
167
+                $this_atts = array_merge( $atts, $add_atts );
168 168
             } else {
169 169
                 $this_atts = $atts;
170 170
             }
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 			$default = FrmEntryFormat::show_entry( $this_atts );
173 173
 
174 174
             // Add the default message
175
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
175
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
176 176
         }
177 177
 
178 178
         return $message;
179 179
     }
180 180
 
181 181
 	public static function prepare_display_value( $entry, $field, $atts ) {
182
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
182
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
183 183
         if ( FrmAppHelper::pro_is_installed() ) {
184 184
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
185 185
         }
186 186
 
187
-        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) {
188
-            return self::display_value($field_value, $field, $atts);
187
+        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
188
+            return self::display_value( $field_value, $field, $atts );
189 189
         }
190 190
 
191 191
         // this is an embeded form
192 192
         $val = '';
193 193
 
194
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
194
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
195 195
             //this is a repeating section
196 196
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
197 197
         } else {
198 198
             // get all values for this field
199
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
199
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
200 200
 
201 201
             if ( $child_values ) {
202 202
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 	    $field_value = array();
207 207
 
208
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
208
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
209 209
             return $val;
210 210
         }
211 211
 
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
             $atts['post_id'] = $child_entry->post_id;
215 215
 
216 216
             // get the value for this field -- check for post values as well
217
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
217
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
218 218
 
219 219
             if ( $entry_val ) {
220 220
                 // foreach entry get display_value
221
-                $field_value[] = self::display_value($entry_val, $field, $atts);
221
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
222 222
             }
223 223
 
224
-            unset($child_entry);
224
+            unset( $child_entry );
225 225
         }
226 226
 
227
-        $val = implode(', ', (array) $field_value );
227
+        $val = implode( ', ', (array) $field_value );
228 228
 		$val = wp_kses_post( $val );
229 229
 
230 230
         return $val;
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
         );
245 245
 
246 246
         $atts = wp_parse_args( $atts, $defaults );
247
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
247
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
248 248
 
249
-        if ( ! isset($field->field_options['post_field']) ) {
249
+        if ( ! isset( $field->field_options['post_field'] ) ) {
250 250
             $field->field_options['post_field'] = '';
251 251
         }
252 252
 
253
-        if ( ! isset($field->field_options['custom_field']) ) {
253
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
254 254
             $field->field_options['custom_field'] = '';
255 255
         }
256 256
 
257 257
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
258 258
             $atts['pre_truncate'] = $atts['truncate'];
259 259
             $atts['truncate'] = true;
260
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
260
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
261 261
 
262
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
262
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
263 263
             $atts['truncate'] = $atts['pre_truncate'];
264 264
         }
265 265
 
@@ -267,38 +267,38 @@  discard block
 block discarded – undo
267 267
             return $value;
268 268
         }
269 269
 
270
-        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts);
270
+        $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts );
271 271
 
272 272
         $new_value = '';
273 273
 
274
-        if ( is_array($value) && $atts['type'] != 'file' ) {
274
+        if ( is_array( $value ) && $atts['type'] != 'file' ) {
275 275
             foreach ( $value as $val ) {
276
-                if ( is_array($val) ) {
276
+                if ( is_array( $val ) ) {
277 277
 					//TODO: add options for display (li or ,)
278
-                    $new_value .= implode($atts['sep'], $val);
278
+                    $new_value .= implode( $atts['sep'], $val );
279 279
                     if ( $atts['type'] != 'data' ) {
280 280
                         $new_value .= '<br/>';
281 281
                     }
282 282
                 }
283
-                unset($val);
283
+                unset( $val );
284 284
             }
285 285
         }
286 286
 
287
-        if ( ! empty($new_value) ) {
287
+        if ( ! empty( $new_value ) ) {
288 288
             $value = $new_value;
289
-        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
-            $value = implode($atts['sep'], $value);
289
+        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) {
290
+            $value = implode( $atts['sep'], $value );
291 291
         }
292 292
 
293 293
         if ( $atts['truncate'] && $atts['type'] != 'image' ) {
294
-            $value = FrmAppHelper::truncate($value, 50);
294
+            $value = FrmAppHelper::truncate( $value, 50 );
295 295
         }
296 296
 
297 297
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
298 298
 			$value = wp_kses_post( $value );
299 299
 		}
300 300
 
301
-        return apply_filters('frm_display_value', $value, $field, $atts);
301
+        return apply_filters( 'frm_display_value', $value, $field, $atts );
302 302
     }
303 303
 
304 304
 	public static function set_posted_value( $field, $value, $args ) {
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
         if ( isset( $args['other'] ) && $args['other'] ) {
307 307
             $value = $args['temp_value'];
308 308
         }
309
-        if ( empty($args['parent_field_id']) ) {
310
-            $_POST['item_meta'][ $field->id ] = $value;
309
+        if ( empty( $args['parent_field_id'] ) ) {
310
+            $_POST['item_meta'][$field->id] = $value;
311 311
         } else {
312
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
312
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
313 313
         }
314 314
     }
315 315
 
316 316
 	public static function get_posted_value( $field, &$value, $args ) {
317 317
 		$field_id = is_object( $field ) ? $field->id : $field;
318 318
 
319
-        if ( empty($args['parent_field_id']) ) {
320
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
319
+        if ( empty( $args['parent_field_id'] ) ) {
320
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
321 321
         } else {
322
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
322
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
323 323
         }
324 324
     }
325 325
 
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
         self::set_other_repeating_vals( $field, $value, $args );
343 343
 
344 344
         // Check if there are any posted "Other" values
345
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
345
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
346 346
 
347 347
             // Save original value
348 348
             $args['temp_value'] = $value;
349 349
             $args['other'] = true;
350
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
350
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
351 351
 
352 352
             // Set the validation value now
353 353
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
         }
370 370
 
371 371
         // Check if there are any other posted "other" values for this field
372
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
372
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
373 373
             // Save original value
374 374
             $args['temp_value'] = $value;
375 375
             $args['other'] = true;
376 376
 
377
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
377
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
378 378
 
379 379
             // Set the validation value now
380 380
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -406,27 +406,27 @@  discard block
 block discarded – undo
406 406
             }
407 407
         } else {
408 408
 			// Radio and dropdowns
409
-            $other_key = array_filter( array_keys($field->options), 'is_string');
409
+            $other_key = array_filter( array_keys( $field->options ), 'is_string' );
410 410
             $other_key = reset( $other_key );
411 411
 
412 412
             // Multi-select dropdown
413 413
             if ( is_array( $value ) ) {
414
-                $o_key = array_search( $field->options[ $other_key ], $value );
414
+                $o_key = array_search( $field->options[$other_key], $value );
415 415
 
416 416
 				if ( $o_key !== false ) {
417 417
 					// Modify the original value so other key will be preserved
418
-					$value[ $other_key ] = $value[ $o_key ];
418
+					$value[$other_key] = $value[$o_key];
419 419
 
420 420
 					// By default, the array keys will be numeric for multi-select dropdowns
421 421
 					// If going backwards and forwards between pages, the array key will match the other key
422 422
 					if ( $o_key != $other_key ) {
423
-						unset( $value[ $o_key ] );
423
+						unset( $value[$o_key] );
424 424
 					}
425 425
 
426 426
 					$args['temp_value'] = $value;
427
-					$value[ $other_key ] = reset( $other_vals );
427
+					$value[$other_key] = reset( $other_vals );
428 428
 				}
429
-            } else if ( $field->options[ $other_key ] == $value ) {
429
+            } else if ( $field->options[$other_key] == $value ) {
430 430
                 $value = $other_vals;
431 431
             }
432 432
         }
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 				$content .= "\n\n";
446 446
 			}
447 447
 
448
-			if ( is_array($val) ) {
448
+			if ( is_array( $val ) ) {
449 449
 				$val = FrmAppHelper::array_flatten( $val );
450
-			    $val = implode(',', $val);
450
+			    $val = implode( ',', $val );
451 451
 			}
452 452
 
453 453
 			$content .= $val;
@@ -492,6 +492,6 @@  discard block
 block discarded – undo
492 492
 	}
493 493
 
494 494
 	public static function entries_dropdown() {
495
-		_deprecated_function( __FUNCTION__, '1.07.09');
495
+		_deprecated_function( __FUNCTION__, '1.07.09' );
496 496
 	}
497 497
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $wpdb, $per_page;
9
+		global $wpdb, $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12 12
 
13
-        $form_id = $this->params['form'];
14
-        if ( ! $form_id ) {
15
-            $this->items = array();
16
-    		$this->set_pagination_args( array(
17
-    			'total_items' => 0,
13
+		$form_id = $this->params['form'];
14
+		if ( ! $form_id ) {
15
+			$this->items = array();
16
+			$this->set_pagination_args( array(
17
+				'total_items' => 0,
18 18
 				'per_page' => $per_page,
19
-    		) );
20
-            return;
21
-        }
19
+			) );
20
+			return;
21
+		}
22 22
 
23 23
 		$default_orderby = 'id';
24 24
 		$default_order = 'DESC';
25 25
 
26
-	    $s_query = array( 'it.form_id' => $form_id );
26
+		$s_query = array( 'it.form_id' => $form_id );
27 27
 
28 28
 		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
29 29
 
30
-	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
-	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
-	    }
30
+		if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31
+			$fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
+			$s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
33
+		}
34 34
 
35
-        $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
37
-            $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
35
+		$orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
+		if ( strpos($orderby, 'meta') !== false ) {
37
+			$order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39
-        }
39
+		}
40 40
 
41 41
 		$order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order;
42 42
 		$order = ' ORDER BY ' . $orderby . ' ' . $order;
43 43
 
44
-        $page = $this->get_pagenum();
44
+		$page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47
-        $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
-        $total_items = FrmEntry::getRecordCount($s_query);
47
+		$this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
+		$total_items = FrmEntry::getRecordCount($s_query);
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function no_items() {
57
-        $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
59
-            _e( 'No Entries Found', 'formidable' );
60
-            return;
61
-        }
62
-
63
-        $form_id = $form = $this->params['form'];
64
-        if ( $form_id ) {
65
-            $form = FrmForm::getOne($form_id);
66
-        }
67
-        $colspan = $this->get_column_count();
68
-
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
57
+		$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
+		if ( ! empty($s) ) {
59
+			_e( 'No Entries Found', 'formidable' );
60
+			return;
61
+		}
62
+
63
+		$form_id = $form = $this->params['form'];
64
+		if ( $form_id ) {
65
+			$form = FrmForm::getOne($form_id);
66
+		}
67
+		$colspan = $this->get_column_count();
68
+
69
+		include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
70 70
 	}
71 71
 
72 72
 	public function search_box( $text, $input_id ) {
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	* Gets the name of the primary column in the Entries screen
78
-	*
79
-	* @since 2.0.14
80
-	*
81
-	* @return string $primary_column
82
-	*/
77
+	 * Gets the name of the primary column in the Entries screen
78
+	 *
79
+	 * @since 2.0.14
80
+	 *
81
+	 * @return string $primary_column
82
+	 */
83 83
 	protected function get_primary_column_name() {
84 84
 		$columns = get_column_headers( $this->screen );
85 85
 		$hidden = get_hidden_columns( $this->screen );
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
106
-        $action_links = $this->row_actions( $actions );
106
+		$action_links = $this->row_actions( $actions );
107 107
 
108 108
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
109 109
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113 113
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
114
-        $action_col = false;
114
+		$action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117 117
 			$class = $column_name .' column-'. $column_name;
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 			if ( in_array( $column_name, $hidden ) ) {
124 124
 				$class .= ' frm_hidden';
125 125
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
126
-			    $action_col = $column_name;
127
-            }
126
+				$action_col = $column_name;
127
+			}
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130 130
 			unset($class);
131 131
 			$attributes .= ' data-colname="' . $column_display_name  . '"';
132 132
 
133
-            $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
133
+			$col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
134 134
 			$this->column_name = $col_name;
135 135
 
136 136
 			switch ( $col_name ) {
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 				case 'ip':
141 141
 				case 'id':
142 142
 				case 'item_key':
143
-				    $val = $item->{$col_name};
144
-				    break;
143
+					$val = $item->{$col_name};
144
+					break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
-				    break;
147
+					$val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
148
+					break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+					$date = FrmAppHelper::get_formatted_time($item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
-			        break;
155
+					$val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
156
+					break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
159
-    				break;
158
+					$val = FrmFormsHelper::edit_form_link($item->form_id);
159
+					break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
162
-				    break;
161
+					$val = FrmAppHelper::post_edit_link($item->post_id);
162
+					break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
165
-				    $val = $user->user_login;
166
-				    break;
164
+					$user = get_userdata($item->user_id);
165
+					$val = $user->user_login;
166
+					break;
167 167
 				default:
168 168
 					$val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
169 169
 					if ( $val === false ) {
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 
175 175
 			if ( isset( $val ) ) {
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 		return $r;
191 191
 	}
192 192
 
193
-    /**
194
-     * @param string $view_link
195
-     */
196
-    private function get_actions( &$actions, $item, $view_link ) {
193
+	/**
194
+	 * @param string $view_link
195
+	 */
196
+	private function get_actions( &$actions, $item, $view_link ) {
197 197
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
200
-            $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
199
+		if ( current_user_can('frm_delete_entries') ) {
200
+			$delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
201 201
 			$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>';
202
-	    }
202
+		}
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
205
-    }
204
+		$actions = apply_filters('frm_row_actions', $actions, $item);
205
+	}
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
208 208
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 	    $s_query = array( 'it.form_id' => $form_id );
27 27
 
28
-		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
28
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
29 29
 
30 30
 	    if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
31 31
 	        $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : '';
32
-	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid);
32
+	        $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
33 33
 	    }
34 34
 
35 35
         $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby;
36
-        if ( strpos($orderby, 'meta') !== false ) {
36
+        if ( strpos( $orderby, 'meta' ) !== false ) {
37 37
             $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
38 38
 			$orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : '';
39 39
         }
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
         $page = $this->get_pagenum();
45 45
 		$start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page );
46 46
 
47
-        $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false);
48
-        $total_items = FrmEntry::getRecordCount($s_query);
47
+        $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false );
48
+        $total_items = FrmEntry::getRecordCount( $s_query );
49 49
 
50 50
 		$this->set_pagination_args( array(
51 51
 			'total_items' => $total_items,
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function no_items() {
57 57
         $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
58
-	    if ( ! empty($s) ) {
58
+	    if ( ! empty( $s ) ) {
59 59
             _e( 'No Entries Found', 'formidable' );
60 60
             return;
61 61
         }
62 62
 
63 63
         $form_id = $form = $this->params['form'];
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
 
69
-        include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php');
69
+        include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
70 70
 	}
71 71
 
72 72
 	public function search_box( $text, $input_id ) {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	public function single_row( $item, $style = '' ) {
100 100
 		// Set up the hover actions for this user
101 101
 		$actions = array();
102
-		$view_link = '?page=formidable-entries&frm_action=show&id='. $item->id;
102
+		$view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id;
103 103
 
104 104
 		$this->get_actions( $actions, $item, $view_link );
105 105
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$r = "<tr id='item-action-{$item->id}'$style>";
112 112
 
113
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
113
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
114 114
         $action_col = false;
115 115
 
116 116
 		foreach ( $columns as $column_name => $column_display_name ) {
117
-			$class = $column_name .' column-'. $column_name;
117
+			$class = $column_name . ' column-' . $column_name;
118 118
 
119 119
 			if ( $column_name === $primary ) {
120 120
 				$class .= ' column-primary';
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
 			$attributes = 'class="' . esc_attr( $class ) . '"';
130
-			unset($class);
131
-			$attributes .= ' data-colname="' . $column_display_name  . '"';
130
+			unset( $class );
131
+			$attributes .= ' data-colname="' . $column_display_name . '"';
132 132
 
133
-            $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name);
133
+            $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name );
134 134
 			$this->column_name = $col_name;
135 135
 
136 136
 			switch ( $col_name ) {
@@ -144,24 +144,24 @@  discard block
 block discarded – undo
144 144
 				    break;
145 145
 				case 'name':
146 146
 				case 'description':
147
-				    $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100);
147
+				    $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 );
148 148
 				    break;
149 149
 				case 'created_at':
150 150
 				case 'updated_at':
151
-				    $date = FrmAppHelper::get_formatted_time($item->{$col_name});
151
+				    $date = FrmAppHelper::get_formatted_time( $item->{$col_name});
152 152
 					$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
153 153
 					break;
154 154
 				case 'is_draft':
155
-				    $val = empty($item->is_draft) ? __( 'No') : __( 'Yes');
155
+				    $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' );
156 156
 			        break;
157 157
 				case 'form_id':
158
-				    $val = FrmFormsHelper::edit_form_link($item->form_id);
158
+				    $val = FrmFormsHelper::edit_form_link( $item->form_id );
159 159
     				break;
160 160
 				case 'post_id':
161
-				    $val = FrmAppHelper::post_edit_link($item->post_id);
161
+				    $val = FrmAppHelper::post_edit_link( $item->post_id );
162 162
 				    break;
163 163
 				case 'user_id':
164
-				    $user = get_userdata($item->user_id);
164
+				    $user = get_userdata( $item->user_id );
165 165
 				    $val = $user->user_login;
166 166
 				    break;
167 167
 				default:
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			if ( isset( $val ) ) {
176 176
 			    $r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178
-					$edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id;
178
+					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180 180
 			        $r .= $action_links;
181 181
 				} else {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
      * @param string $view_link
195 195
      */
196 196
     private function get_actions( &$actions, $item, $view_link ) {
197
-		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>';
197
+		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
198 198
 
199
-        if ( current_user_can('frm_delete_entries') ) {
200
-            $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form'];
199
+        if ( current_user_can( 'frm_delete_entries' ) ) {
200
+            $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
201 201
 			$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>';
202 202
 	    }
203 203
 
204
-        $actions = apply_filters('frm_row_actions', $actions, $item);
204
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
205 205
     }
206 206
 
207 207
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 3 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	public static function get_direct_link( $key, $form = false ) {
14
-        $target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
-
17
-        return $target_url;
18
-    }
19
-
20
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
21
-        $defaults = array(
22
-            'blank'     => true,
23
-            'field_id'  => false,
24
-            'onchange'  => false,
25
-            'exclude'   => false,
26
-            'class'     => '',
14
+		$target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
16
+
17
+		return $target_url;
18
+	}
19
+
20
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
21
+		$defaults = array(
22
+			'blank'     => true,
23
+			'field_id'  => false,
24
+			'onchange'  => false,
25
+			'exclude'   => false,
26
+			'class'     => '',
27 27
 			'inc_children' => 'exclude',
28
-        );
29
-        $args = wp_parse_args( $args, $defaults );
28
+		);
29
+		$args = wp_parse_args( $args, $defaults );
30 30
 
31
-        if ( ! $args['field_id'] ) {
32
-            $args['field_id'] = $field_name;
33
-        }
31
+		if ( ! $args['field_id'] ) {
32
+			$args['field_id'] = $field_name;
33
+		}
34 34
 
35 35
 		$query = array();
36
-        if ( $args['exclude'] ) {
36
+		if ( $args['exclude'] ) {
37 37
 			$query['id !'] = $args['exclude'];
38
-        }
38
+		}
39 39
 
40
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
40
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
41 41
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
42 42
 		$add_html = array();
43 43
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
44 44
 		self::add_html_attr( $args['class'], 'class', $add_html );
45 45
 
46
-        ?>
46
+		?>
47 47
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
48 48
 		<?php if ( $args['blank'] ) { ?>
49 49
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		<?php } ?>
56 56
         </select>
57 57
         <?php
58
-    }
58
+	}
59 59
 
60 60
 	/**
61 61
 	 * @param string $class
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 	}
72 72
 
73
-    public static function form_switcher() {
73
+	public static function form_switcher() {
74 74
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
75 75
 		$forms = FrmForm::get_published_forms( $where );
76 76
 
@@ -79,32 +79,32 @@  discard block
 block discarded – undo
79 79
 			unset( $args['form'] );
80 80
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
81 81
 			unset( $args['id'] );
82
-        }
82
+		}
83 83
 
84 84
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
85 85
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
86
-            $args['frm_action'] = 'list';
87
-            $args['form'] = 0;
86
+			$args['frm_action'] = 'list';
87
+			$args['form'] = 0;
88 88
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
89
-            $args['frm_action'] = 'edit';
89
+			$args['frm_action'] = 'edit';
90 90
 		} else if ( isset( $_GET['post'] ) ) {
91
-            $args['form'] = 0;
92
-            $base = admin_url('edit.php?post_type=frm_display');
93
-        }
91
+			$args['form'] = 0;
92
+			$base = admin_url('edit.php?post_type=frm_display');
93
+		}
94 94
 
95
-        ?>
95
+		?>
96 96
 		<li class="dropdown last" id="frm_bs_dropdown">
97 97
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
98 98
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
99 99
 			<?php
100 100
 			foreach ( $forms as $form ) {
101 101
 				if ( isset( $args['id'] ) ) {
102
-			        $args['id'] = $form->id;
102
+					$args['id'] = $form->id;
103 103
 				}
104
-			    if ( isset( $args['form'] ) ) {
105
-			        $args['form'] = $form->id;
104
+				if ( isset( $args['form'] ) ) {
105
+					$args['form'] = $form->id;
106 106
 				}
107
-                ?>
107
+				?>
108 108
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
109 109
 			<?php
110 110
 				unset( $form );
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 			</ul>
113 113
 		</li>
114 114
         <?php
115
-    }
115
+	}
116 116
 
117 117
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
118
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
-    }
118
+		echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
+		echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
120
+	}
121 121
 
122 122
 	public static function get_success_message( $atts ) {
123 123
 		$message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] );
@@ -125,110 +125,110 @@  discard block
 block discarded – undo
125 125
 		return $message;
126 126
 	}
127 127
 
128
-    /**
129
-     * Used when a form is created
130
-     */
131
-    public static function setup_new_vars( $values = array() ) {
132
-        global $wpdb;
128
+	/**
129
+	 * Used when a form is created
130
+	 */
131
+	public static function setup_new_vars( $values = array() ) {
132
+		global $wpdb;
133 133
 
134
-        if ( ! empty( $values ) ) {
135
-            $post_values = $values;
136
-        } else {
137
-            $values = array();
138
-            $post_values = isset($_POST) ? $_POST : array();
139
-        }
134
+		if ( ! empty( $values ) ) {
135
+			$post_values = $values;
136
+		} else {
137
+			$values = array();
138
+			$post_values = isset($_POST) ? $_POST : array();
139
+		}
140 140
 
141 141
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
142 142
 			if ( ! isset( $values[ $var ] ) ) {
143 143
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
144
-            }
145
-        }
144
+			}
145
+		}
146 146
 
147
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
147
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
148 148
 
149 149
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
150
-            if ( ! isset( $values[ $var ] ) ) {
150
+			if ( ! isset( $values[ $var ] ) ) {
151 151
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
152
-            }
153
-        }
152
+			}
153
+		}
154 154
 
155
-        if ( ! isset( $values['form_key'] ) ) {
156
-            $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key');
157
-        }
155
+		if ( ! isset( $values['form_key'] ) ) {
156
+			$values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key');
157
+		}
158 158
 
159
-        $values = self::fill_default_opts($values, false, $post_values);
159
+		$values = self::fill_default_opts($values, false, $post_values);
160 160
 
161
-        if ( $post_values && isset($post_values['options']['custom_style']) ) {
162
-            $values['custom_style'] = $post_values['options']['custom_style'];
163
-        } else {
164
-            $frm_settings = FrmAppHelper::get_settings();
165
-            $values['custom_style'] = ( $frm_settings->load_style != 'none' );
166
-        }
161
+		if ( $post_values && isset($post_values['options']['custom_style']) ) {
162
+			$values['custom_style'] = $post_values['options']['custom_style'];
163
+		} else {
164
+			$frm_settings = FrmAppHelper::get_settings();
165
+			$values['custom_style'] = ( $frm_settings->load_style != 'none' );
166
+		}
167 167
 
168
-        return apply_filters('frm_setup_new_form_vars', $values);
169
-    }
168
+		return apply_filters('frm_setup_new_form_vars', $values);
169
+	}
170 170
 
171
-    /**
172
-     * Used when editing a form
173
-     */
174
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
171
+	/**
172
+	 * Used when editing a form
173
+	 */
174
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
175 175
 		if ( empty( $post_values ) ) {
176 176
 			$post_values = stripslashes_deep( $_POST );
177 177
 		}
178 178
 
179
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
180
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
181
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
182
-        $values['status'] = $record->status;
179
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
180
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
181
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
182
+		$values['status'] = $record->status;
183 183
 
184
-        $values = self::fill_default_opts($values, $record, $post_values);
184
+		$values = self::fill_default_opts($values, $record, $post_values);
185 185
 
186
-        return apply_filters('frm_setup_edit_form_vars', $values);
187
-    }
186
+		return apply_filters('frm_setup_edit_form_vars', $values);
187
+	}
188 188
 
189 189
 	public static function fill_default_opts( $values, $record, $post_values ) {
190 190
 
191
-        $defaults = self::get_default_opts();
191
+		$defaults = self::get_default_opts();
192 192
 		foreach ( $defaults as $var => $default ) {
193
-            if ( is_array($default) ) {
194
-                if ( ! isset( $values[ $var ] ) ) {
193
+			if ( is_array($default) ) {
194
+				if ( ! isset( $values[ $var ] ) ) {
195 195
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
196
-                }
196
+				}
197 197
 
198
-                foreach ( $default as $k => $v ) {
198
+				foreach ( $default as $k => $v ) {
199 199
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
200 200
 
201
-                    if ( is_array( $v ) ) {
202
-                        foreach ( $v as $k1 => $v1 ) {
201
+					if ( is_array( $v ) ) {
202
+						foreach ( $v as $k1 => $v1 ) {
203 203
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
204
-                            unset( $k1, $v1 );
205
-                        }
206
-                    }
204
+							unset( $k1, $v1 );
205
+						}
206
+					}
207 207
 
208
-                    unset($k, $v);
209
-                }
210
-            } else {
208
+					unset($k, $v);
209
+				}
210
+			} else {
211 211
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
212
-            }
212
+			}
213 213
 
214
-            unset($var, $default);
215
-        }
214
+			unset($var, $default);
215
+		}
216 216
 
217
-        return $values;
218
-    }
217
+		return $values;
218
+	}
219 219
 
220
-    public static function get_default_opts() {
221
-        $frm_settings = FrmAppHelper::get_settings();
220
+	public static function get_default_opts() {
221
+		$frm_settings = FrmAppHelper::get_settings();
222 222
 
223
-        return array(
224
-            'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
225
-            'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
226
-            'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
227
-            'before_html' => self::get_default_html('before'),
228
-            'after_html' => '',
229
-            'submit_html' => self::get_default_html('submit'),
230
-        );
231
-    }
223
+		return array(
224
+			'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
225
+			'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
226
+			'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
227
+			'before_html' => self::get_default_html('before'),
228
+			'after_html' => '',
229
+			'submit_html' => self::get_default_html('submit'),
230
+		);
231
+	}
232 232
 
233 233
 	/**
234 234
 	 * @param array $options
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 		}
244 244
 	}
245 245
 
246
-    /**
247
-     * @param string $loc
248
-     */
246
+	/**
247
+	 * @param string $loc
248
+	 */
249 249
 	public static function get_default_html( $loc ) {
250 250
 		if ( $loc == 'submit' ) {
251
-            $sending = __( 'Sending', 'formidable' );
252
-            $draft_link = self::get_draft_link();
253
-            $img = '[frmurl]/images/ajax_loader.gif';
254
-            $default_html = <<<SUBMIT_HTML
251
+			$sending = __( 'Sending', 'formidable' );
252
+			$draft_link = self::get_draft_link();
253
+			$img = '[frmurl]/images/ajax_loader.gif';
254
+			$default_html = <<<SUBMIT_HTML
255 255
 <div class="frm_submit">
256 256
 [if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button]
257 257
 <input type="submit" value="[button_label]" [button_action] />
@@ -260,49 +260,49 @@  discard block
 block discarded – undo
260 260
 </div>
261 261
 SUBMIT_HTML;
262 262
 		} else if ( $loc == 'before' ) {
263
-            $default_html = <<<BEFORE_HTML
263
+			$default_html = <<<BEFORE_HTML
264 264
 <legend class="frm_hidden">[form_name]</legend>
265 265
 [if form_name]<h3>[form_name]</h3>[/if form_name]
266 266
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
267 267
 BEFORE_HTML;
268 268
 		} else {
269
-            $default_html = '';
270
-        }
269
+			$default_html = '';
270
+		}
271 271
 
272
-        return $default_html;
273
-    }
272
+		return $default_html;
273
+	}
274 274
 
275
-    public static function get_draft_link() {
276
-        $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
277
-        return $link;
278
-    }
275
+	public static function get_draft_link() {
276
+		$link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
277
+		return $link;
278
+	}
279 279
 
280 280
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
281
-        $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
-        if ( ! strpos($button, '[button_action]') ) {
283
-            return;
284
-        }
281
+		$button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
+		if ( ! strpos($button, '[button_action]') ) {
283
+			return;
284
+		}
285 285
 
286
-        $button_parts = explode('[button_action]', $button);
287
-        echo $button_parts[0];
288
-        //echo ' id="frm_submit_"';
286
+		$button_parts = explode('[button_action]', $button);
287
+		echo $button_parts[0];
288
+		//echo ' id="frm_submit_"';
289 289
 
290
-        $classes = apply_filters('frm_submit_button_class', array(), $form);
291
-        if ( ! empty($classes) ) {
290
+		$classes = apply_filters('frm_submit_button_class', array(), $form);
291
+		if ( ! empty($classes) ) {
292 292
 			echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
293
-        }
294
-
295
-        do_action('frm_submit_button_action', $form, $form_action);
296
-        echo $button_parts[1];
297
-    }
298
-
299
-    /**
300
-     * Automatically add end section fields if they don't exist (2.0 migration)
301
-     * @since 2.0
302
-     *
303
-     * @param boolean $reset_fields
304
-     */
305
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
293
+		}
294
+
295
+		do_action('frm_submit_button_action', $form, $form_action);
296
+		echo $button_parts[1];
297
+	}
298
+
299
+	/**
300
+	 * Automatically add end section fields if they don't exist (2.0 migration)
301
+	 * @since 2.0
302
+	 *
303
+	 * @param boolean $reset_fields
304
+	 */
305
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
306 306
 		if ( empty( $fields ) ) {
307 307
 			return;
308 308
 		}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		$open = $prev_order = false;
312 312
 		$add_order = 0;
313 313
 		$last_field = false;
314
-        foreach ( $fields as $field ) {
314
+		foreach ( $fields as $field ) {
315 315
 			if ( $prev_order === $field->field_order ) {
316 316
 				$add_order++;
317 317
 			}
@@ -322,48 +322,48 @@  discard block
 block discarded – undo
322 322
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
323 323
 			}
324 324
 
325
-            switch ( $field->type ) {
326
-                case 'divider':
327
-                    // create an end section if open
325
+			switch ( $field->type ) {
326
+				case 'divider':
327
+					// create an end section if open
328 328
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
329 329
 
330
-                    // mark it open for the next end section
331
-                    $open = true;
332
-                break;
333
-                case 'break';
330
+					// mark it open for the next end section
331
+					$open = true;
332
+				break;
333
+				case 'break';
334 334
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
335
-                break;
336
-                case 'end_divider':
337
-                    if ( ! $open ) {
338
-                        // the section isn't open, so this is an extra field that needs to be removed
339
-                        FrmField::destroy( $field->id );
340
-                        $reset_fields = true;
341
-                    }
342
-
343
-                    // There is already an end section here, so there is no need to create one
344
-                    $open = false;
345
-            }
335
+				break;
336
+				case 'end_divider':
337
+					if ( ! $open ) {
338
+						// the section isn't open, so this is an extra field that needs to be removed
339
+						FrmField::destroy( $field->id );
340
+						$reset_fields = true;
341
+					}
342
+
343
+					// There is already an end section here, so there is no need to create one
344
+					$open = false;
345
+			}
346 346
 			$prev_order = $field->field_order;
347 347
 
348 348
 			$last_field = $field;
349 349
 			unset( $field );
350
-        }
350
+		}
351 351
 
352 352
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
353
-    }
353
+	}
354 354
 
355 355
 	/**
356 356
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
357 357
 	 * Fix any ordering that may be messed up
358 358
 	 */
359 359
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
360
-        if ( ! $open ) {
361
-            return;
362
-        }
360
+		if ( ! $open ) {
361
+			return;
362
+		}
363 363
 
364 364
 		$end_section_values['field_order'] = $field->field_order + 1;
365 365
 
366
-        FrmField::create( $end_section_values );
366
+		FrmField::create( $end_section_values );
367 367
 
368 368
 		if ( $move == 'move' ) {
369 369
 			// bump the order of current field unless we're at the end of the form
@@ -371,38 +371,38 @@  discard block
 block discarded – undo
371 371
 		}
372 372
 
373 373
 		$add_order += 2;
374
-        $open = false;
375
-        $reset_fields = true;
376
-    }
374
+		$open = false;
375
+		$reset_fields = true;
376
+	}
377 377
 
378
-    public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
378
+	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
379 379
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
380
-            if ( $code == 'form_name' ) {
381
-                $replace_with = $form->name;
382
-            } else if ( $code == 'form_description' ) {
383
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
384
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
385
-                $replace_with = FrmAppHelper::simple_get( 'entry' );
386
-            } else {
387
-                $replace_with = '';
388
-            }
380
+			if ( $code == 'form_name' ) {
381
+				$replace_with = $form->name;
382
+			} else if ( $code == 'form_description' ) {
383
+				$replace_with = FrmAppHelper::use_wpautop($form->description);
384
+			} else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
385
+				$replace_with = FrmAppHelper::simple_get( 'entry' );
386
+			} else {
387
+				$replace_with = '';
388
+			}
389 389
 
390
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
391
-        }
390
+			FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
391
+		}
392 392
 
393
-        //replace [form_key]
394
-        $html = str_replace('[form_key]', $form->form_key, $html);
393
+		//replace [form_key]
394
+		$html = str_replace('[form_key]', $form->form_key, $html);
395 395
 
396
-        //replace [frmurl]
397
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
396
+		//replace [frmurl]
397
+		$html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
398 398
 
399 399
 		if ( strpos( $html, '[button_label]' ) ) {
400 400
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
401 401
 			$replace_with = apply_filters( 'frm_submit_button', $title, $form );
402 402
 			$html = str_replace( '[button_label]', $replace_with, $html );
403
-        }
403
+		}
404 404
 
405
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
405
+		$html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
406 406
 
407 407
 		if ( strpos( $html, '[if back_button]' ) ) {
408 408
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -416,32 +416,32 @@  discard block
 block discarded – undo
416 416
 			$html = do_shortcode( $html );
417 417
 		}
418 418
 
419
-        return $html;
420
-    }
419
+		return $html;
420
+	}
421 421
 
422 422
 	public static function submit_button_label( $submit ) {
423
-        if ( ! $submit || empty($submit) ) {
424
-            $frm_settings = FrmAppHelper::get_settings();
425
-            $submit = $frm_settings->submit_value;
426
-        }
423
+		if ( ! $submit || empty($submit) ) {
424
+			$frm_settings = FrmAppHelper::get_settings();
425
+			$submit = $frm_settings->submit_value;
426
+		}
427 427
 
428
-        return $submit;
429
-    }
428
+		return $submit;
429
+	}
430 430
 
431 431
 	public static function get_form_style_class( $form = false ) {
432
-        $style = self::get_form_style($form);
433
-        $class = ' with_frm_style';
434
-
435
-        if ( empty($style) ) {
436
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
437
-                return $class;
438
-            } else {
439
-                return;
440
-            }
441
-        }
442
-
443
-        //If submit button needs to be inline or centered
444
-        if ( is_object($form) ) {
432
+		$style = self::get_form_style($form);
433
+		$class = ' with_frm_style';
434
+
435
+		if ( empty($style) ) {
436
+			if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
437
+				return $class;
438
+			} else {
439
+				return;
440
+			}
441
+		}
442
+
443
+		//If submit button needs to be inline or centered
444
+		if ( is_object($form) ) {
445 445
 			$form = $form->options;
446 446
 		}
447 447
 
@@ -453,17 +453,17 @@  discard block
 block discarded – undo
453 453
 			$class .= ' frm_center_submit';
454 454
 		}
455 455
 
456
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
456
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
457 457
 
458
-        return $class;
459
-    }
458
+		return $class;
459
+	}
460 460
 
461
-    /**
462
-     * @param string|boolean $form
463
-     *
464
-     * @return string
465
-     */
466
-    public static function get_form_style( $form ) {
461
+	/**
462
+	 * @param string|boolean $form
463
+	 *
464
+	 * @return string
465
+	 */
466
+	public static function get_form_style( $form ) {
467 467
 		$style = 1;
468 468
 		if ( empty( $form ) || 'default' == 'form' ) {
469 469
 			return $style;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
484 484
 
485 485
 		return $style;
486
-    }
486
+	}
487 487
 
488 488
 	/**
489 489
 	 * Display the validation error messages when an entry is submitted
@@ -537,74 +537,74 @@  discard block
 block discarded – undo
537 537
 	}
538 538
 
539 539
 	public static function get_scroll_js( $form_id ) {
540
-        ?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
541
-    }
540
+		?><script type="text/javascript">jQuery(document).ready(function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php
541
+	}
542 542
 
543 543
 	public static function edit_form_link( $form_id ) {
544
-        if ( is_object($form_id) ) {
545
-            $form = $form_id;
546
-            $name = $form->name;
547
-            $form_id = $form->id;
548
-        } else {
549
-            $name = FrmForm::getName($form_id);
550
-        }
551
-
552
-        if ( $form_id ) {
544
+		if ( is_object($form_id) ) {
545
+			$form = $form_id;
546
+			$name = $form->name;
547
+			$form_id = $form->id;
548
+		} else {
549
+			$name = FrmForm::getName($form_id);
550
+		}
551
+
552
+		if ( $form_id ) {
553 553
 			$val = '<a href="' . esc_url( admin_url( 'admin.php' ) . '?page=formidable&frm_action=edit&id=' . $form_id ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
554
-	    } else {
555
-	        $val = '';
556
-	    }
554
+		} else {
555
+			$val = '';
556
+		}
557 557
 
558
-	    return $val;
558
+		return $val;
559 559
 	}
560 560
 
561 561
 	public static function delete_trash_link( $id, $status, $length = 'long' ) {
562
-        $link = '';
563
-        $labels = array(
564
-            'restore' => array(
565
-                'long'  => __( 'Restore from Trash', 'formidable' ),
566
-                'short' => __( 'Restore', 'formidable' ),
567
-            ),
568
-            'trash' => array(
569
-                'long'  => __( 'Move to Trash', 'formidable' ),
570
-                'short' => __( 'Trash', 'formidable' ),
571
-            ),
572
-            'delete' => array(
573
-                'long'  => __( 'Delete Permanently', 'formidable' ),
574
-                'short' => __( 'Delete', 'formidable' ),
575
-            ),
576
-        );
577
-
578
-        $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
579
-        $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id;
580
-        if ( 'trash' == $status ) {
562
+		$link = '';
563
+		$labels = array(
564
+			'restore' => array(
565
+				'long'  => __( 'Restore from Trash', 'formidable' ),
566
+				'short' => __( 'Restore', 'formidable' ),
567
+			),
568
+			'trash' => array(
569
+				'long'  => __( 'Move to Trash', 'formidable' ),
570
+				'short' => __( 'Trash', 'formidable' ),
571
+			),
572
+			'delete' => array(
573
+				'long'  => __( 'Delete Permanently', 'formidable' ),
574
+				'short' => __( 'Delete', 'formidable' ),
575
+			),
576
+		);
577
+
578
+		$current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
579
+		$base_url = '?page=formidable&form_type='. $current_page .'&id='. $id;
580
+		if ( 'trash' == $status ) {
581 581
 			$link = '<a href="'. esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
582
-        } else if ( current_user_can('frm_delete_forms') ) {
583
-            if ( EMPTY_TRASH_DAYS ) {
582
+		} else if ( current_user_can('frm_delete_forms') ) {
583
+			if ( EMPTY_TRASH_DAYS ) {
584 584
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
585
-            } else {
585
+			} else {
586 586
 				$link = '<a href="' . esc_url( wp_nonce_url( $base_url .'&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
587
-            }
588
-        }
587
+			}
588
+		}
589 589
 
590
-        return $link;
591
-    }
590
+		return $link;
591
+	}
592 592
 
593 593
 	public static function status_nice_name( $status ) {
594
-        $nice_names = array(
595
-            'draft'     => __( 'Draft', 'formidable' ),
596
-            'trash'     => __( 'Trash', 'formidable' ),
597
-            'publish'   => __( 'Published', 'formidable' ),
598
-        );
599
-
600
-        if ( ! in_array($status, array_keys($nice_names)) ) {
601
-            $status = 'publish';
602
-        }
594
+		$nice_names = array(
595
+			'draft'     => __( 'Draft', 'formidable' ),
596
+			'trash'     => __( 'Trash', 'formidable' ),
597
+			'publish'   => __( 'Published', 'formidable' ),
598
+		);
599
+
600
+		if ( ! in_array($status, array_keys($nice_names)) ) {
601
+			$status = 'publish';
602
+		}
603 603
 
604 604
 		$name = $nice_names[ $status ];
605 605
 
606
-        return $name;
607
-    }
606
+		return $name;
607
+	}
608 608
 
609 609
 	public static function get_params() {
610 610
 		_deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' );
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 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
 
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	public static function get_direct_link( $key, $form = false ) {
14
-        $target_url = esc_url(admin_url('admin-ajax.php') . '?action=frm_forms_preview&form='. $key);
15
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
14
+        $target_url = esc_url( admin_url( 'admin-ajax.php' ) . '?action=frm_forms_preview&form=' . $key );
15
+        $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
16 16
 
17 17
         return $target_url;
18 18
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$query['id !'] = $args['exclude'];
38 38
         }
39 39
 
40
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
40
+        $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
41 41
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
42 42
 		$add_html = array();
43 43
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		<?php } ?>
51 51
 		<?php foreach ( $forms as $form ) { ?>
52 52
 			<option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php
53
-				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 33 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ;
53
+				echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 33 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' );
54 54
 			?></option>
55 55
 		<?php } ?>
56 56
         </select>
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public static function add_html_attr( $class, $param, &$add_html ) {
68 68
 		if ( ! empty( $class ) ) {
69
-			$add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
69
+			$add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
70 70
 		}
71 71
 	}
72 72
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$args = array( 'id' => 0, 'form' => 0 );
78 78
 		if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
79 79
 			unset( $args['form'] );
80
-		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
80
+		} else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
81 81
 			unset( $args['id'] );
82 82
         }
83 83
 
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
86 86
             $args['frm_action'] = 'list';
87 87
             $args['form'] = 0;
88
-		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
88
+		} else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
89 89
             $args['frm_action'] = 'edit';
90 90
 		} else if ( isset( $_GET['post'] ) ) {
91 91
             $args['form'] = 0;
92
-            $base = admin_url('edit.php?post_type=frm_display');
92
+            $base = admin_url( 'edit.php?post_type=frm_display' );
93 93
         }
94 94
 
95 95
         ?>
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			        $args['form'] = $form->id;
106 106
 				}
107 107
                 ?>
108
-				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
108
+				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
109 109
 			<?php
110 110
 				unset( $form );
111 111
 			} ?>
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
118
-        echo ($sort_col == $col) ? 'sorted' : 'sortable';
119
-        echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc';
118
+        echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
119
+        echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc';
120 120
     }
121 121
 
122 122
 	public static function get_success_message( $atts ) {
@@ -135,37 +135,37 @@  discard block
 block discarded – undo
135 135
             $post_values = $values;
136 136
         } else {
137 137
             $values = array();
138
-            $post_values = isset($_POST) ? $_POST : array();
138
+            $post_values = isset( $_POST ) ? $_POST : array();
139 139
         }
140 140
 
141 141
 		foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) {
142
-			if ( ! isset( $values[ $var ] ) ) {
143
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
142
+			if ( ! isset( $values[$var] ) ) {
143
+				$values[$var] = FrmAppHelper::get_param( $var, $default );
144 144
             }
145 145
         }
146 146
 
147
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
147
+        $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
148 148
 
149 149
 		foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) {
150
-            if ( ! isset( $values[ $var ] ) ) {
151
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default );
150
+            if ( ! isset( $values[$var] ) ) {
151
+				$values[$var] = FrmAppHelper::get_param( $var, $default );
152 152
             }
153 153
         }
154 154
 
155 155
         if ( ! isset( $values['form_key'] ) ) {
156
-            $values['form_key'] = ($post_values && isset($post_values['form_key'])) ? $post_values['form_key'] : FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_forms', 'form_key');
156
+            $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
157 157
         }
158 158
 
159
-        $values = self::fill_default_opts($values, false, $post_values);
159
+        $values = self::fill_default_opts( $values, false, $post_values );
160 160
 
161
-        if ( $post_values && isset($post_values['options']['custom_style']) ) {
161
+        if ( $post_values && isset( $post_values['options']['custom_style'] ) ) {
162 162
             $values['custom_style'] = $post_values['options']['custom_style'];
163 163
         } else {
164 164
             $frm_settings = FrmAppHelper::get_settings();
165 165
             $values['custom_style'] = ( $frm_settings->load_style != 'none' );
166 166
         }
167 167
 
168
-        return apply_filters('frm_setup_new_form_vars', $values);
168
+        return apply_filters( 'frm_setup_new_form_vars', $values );
169 169
     }
170 170
 
171 171
     /**
@@ -176,42 +176,42 @@  discard block
 block discarded – undo
176 176
 			$post_values = stripslashes_deep( $_POST );
177 177
 		}
178 178
 
179
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
180
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
181
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
179
+        $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
180
+        $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
181
+        $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
182 182
         $values['status'] = $record->status;
183 183
 
184
-        $values = self::fill_default_opts($values, $record, $post_values);
184
+        $values = self::fill_default_opts( $values, $record, $post_values );
185 185
 
186
-        return apply_filters('frm_setup_edit_form_vars', $values);
186
+        return apply_filters( 'frm_setup_edit_form_vars', $values );
187 187
     }
188 188
 
189 189
 	public static function fill_default_opts( $values, $record, $post_values ) {
190 190
 
191 191
         $defaults = self::get_default_opts();
192 192
 		foreach ( $defaults as $var => $default ) {
193
-            if ( is_array($default) ) {
194
-                if ( ! isset( $values[ $var ] ) ) {
195
-					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
193
+            if ( is_array( $default ) ) {
194
+                if ( ! isset( $values[$var] ) ) {
195
+					$values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array();
196 196
                 }
197 197
 
198 198
                 foreach ( $default as $k => $v ) {
199
-					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v);
199
+					$values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v );
200 200
 
201 201
                     if ( is_array( $v ) ) {
202 202
                         foreach ( $v as $k1 => $v1 ) {
203
-							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
203
+							$values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 );
204 204
                             unset( $k1, $v1 );
205 205
                         }
206 206
                     }
207 207
 
208
-                    unset($k, $v);
208
+                    unset( $k, $v );
209 209
                 }
210 210
             } else {
211
-				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
211
+				$values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default );
212 212
             }
213 213
 
214
-            unset($var, $default);
214
+            unset( $var, $default );
215 215
         }
216 216
 
217 217
         return $values;
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
             'submit_value' => $frm_settings->submit_value, 'success_action' => 'message',
225 225
             'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '',
226 226
             'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1,
227
-            'before_html' => self::get_default_html('before'),
227
+            'before_html' => self::get_default_html( 'before' ),
228 228
             'after_html' => '',
229
-            'submit_html' => self::get_default_html('submit'),
229
+            'submit_html' => self::get_default_html( 'submit' ),
230 230
         );
231 231
     }
232 232
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	public static function fill_form_options( &$options, $values ) {
239 239
 		$defaults = self::get_default_opts();
240 240
 		foreach ( $defaults as $var => $default ) {
241
-			$options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
241
+			$options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default;
242 242
 			unset( $var, $default );
243 243
 		}
244 244
 	}
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
     }
279 279
 
280 280
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
281
-        $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values);
282
-        if ( ! strpos($button, '[button_action]') ) {
281
+        $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
282
+        if ( ! strpos( $button, '[button_action]' ) ) {
283 283
             return;
284 284
         }
285 285
 
286
-        $button_parts = explode('[button_action]', $button);
286
+        $button_parts = explode( '[button_action]', $button );
287 287
         echo $button_parts[0];
288 288
         //echo ' id="frm_submit_"';
289 289
 
290
-        $classes = apply_filters('frm_submit_button_class', array(), $form);
291
-        if ( ! empty($classes) ) {
290
+        $classes = apply_filters( 'frm_submit_button_class', array(), $form );
291
+        if ( ! empty( $classes ) ) {
292 292
 			echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"';
293 293
         }
294 294
 
295
-        do_action('frm_submit_button_action', $form, $form_action);
295
+        do_action( 'frm_submit_button_action', $form, $form_action );
296 296
         echo $button_parts[1];
297 297
     }
298 298
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$last_field = false;
314 314
         foreach ( $fields as $field ) {
315 315
 			if ( $prev_order === $field->field_order ) {
316
-				$add_order++;
316
+				$add_order ++;
317 317
 			}
318 318
 
319 319
 			if ( $add_order ) {
@@ -380,21 +380,21 @@  discard block
 block discarded – undo
380 380
             if ( $code == 'form_name' ) {
381 381
                 $replace_with = $form->name;
382 382
             } else if ( $code == 'form_description' ) {
383
-                $replace_with = FrmAppHelper::use_wpautop($form->description);
384
-            } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) {
383
+                $replace_with = FrmAppHelper::use_wpautop( $form->description );
384
+            } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) {
385 385
                 $replace_with = FrmAppHelper::simple_get( 'entry' );
386 386
             } else {
387 387
                 $replace_with = '';
388 388
             }
389 389
 
390
-            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html );
390
+            FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
391 391
         }
392 392
 
393 393
         //replace [form_key]
394
-        $html = str_replace('[form_key]', $form->form_key, $html);
394
+        $html = str_replace( '[form_key]', $form->form_key, $html );
395 395
 
396 396
         //replace [frmurl]
397
-        $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html);
397
+        $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html );
398 398
 
399 399
 		if ( strpos( $html, '[button_label]' ) ) {
400 400
 			add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 );
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			$html = str_replace( '[button_label]', $replace_with, $html );
403 403
         }
404 404
 
405
-        $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
405
+        $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
406 406
 
407 407
 		if ( strpos( $html, '[if back_button]' ) ) {
408 408
 			$html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html );
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
 	public static function submit_button_label( $submit ) {
423
-        if ( ! $submit || empty($submit) ) {
423
+        if ( ! $submit || empty( $submit ) ) {
424 424
             $frm_settings = FrmAppHelper::get_settings();
425 425
             $submit = $frm_settings->submit_value;
426 426
         }
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
     }
430 430
 
431 431
 	public static function get_form_style_class( $form = false ) {
432
-        $style = self::get_form_style($form);
432
+        $style = self::get_form_style( $form );
433 433
         $class = ' with_frm_style';
434 434
 
435
-        if ( empty($style) ) {
436
-            if ( FrmAppHelper::is_admin_page('formidable-entries') ) {
435
+        if ( empty( $style ) ) {
436
+            if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
437 437
                 return $class;
438 438
             } else {
439 439
                 return;
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         }
442 442
 
443 443
         //If submit button needs to be inline or centered
444
-        if ( is_object($form) ) {
444
+        if ( is_object( $form ) ) {
445 445
 			$form = $form->options;
446 446
 		}
447 447
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			$class .= ' frm_center_submit';
454 454
 		}
455 455
 
456
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
456
+        $class = apply_filters( 'frm_add_form_style_class', $class, $style );
457 457
 
458 458
         return $class;
459 459
     }
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
     }
542 542
 
543 543
 	public static function edit_form_link( $form_id ) {
544
-        if ( is_object($form_id) ) {
544
+        if ( is_object( $form_id ) ) {
545 545
             $form = $form_id;
546 546
             $name = $form->name;
547 547
             $form_id = $form->id;
548 548
         } else {
549
-            $name = FrmForm::getName($form_id);
549
+            $name = FrmForm::getName( $form_id );
550 550
         }
551 551
 
552 552
         if ( $form_id ) {
@@ -576,14 +576,14 @@  discard block
 block discarded – undo
576 576
         );
577 577
 
578 578
         $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
579
-        $base_url = '?page=formidable&form_type='. $current_page .'&id='. $id;
579
+        $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id;
580 580
         if ( 'trash' == $status ) {
581
-			$link = '<a href="'. esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>';
582
-        } else if ( current_user_can('frm_delete_forms') ) {
581
+			$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>';
582
+        } else if ( current_user_can( 'frm_delete_forms' ) ) {
583 583
             if ( EMPTY_TRASH_DAYS ) {
584
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>';
584
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>';
585 585
             } else {
586
-				$link = '<a href="' . esc_url( wp_nonce_url( $base_url .'&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>';
586
+				$link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>';
587 587
             }
588 588
         }
589 589
 
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
             'publish'   => __( 'Published', 'formidable' ),
598 598
         );
599 599
 
600
-        if ( ! in_array($status, array_keys($nice_names)) ) {
600
+        if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
601 601
             $status = 'publish';
602 602
         }
603 603
 
604
-		$name = $nice_names[ $status ];
604
+		$name = $nice_names[$status];
605 605
 
606 606
         return $name;
607 607
     }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -375,6 +375,9 @@
 block discarded – undo
375 375
         $reset_fields = true;
376 376
     }
377 377
 
378
+    /**
379
+     * @return string
380
+     */
378 381
     public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
379 382
 		foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) {
380 383
             if ( $code == 'form_name' ) {
Please login to merge, or discard this patch.
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 }
5 5
 
6 6
 class FrmFormsListHelper extends FrmListHelper {
7
-    var $status = '';
7
+	var $status = '';
8 8
 
9 9
 	public function __construct( $args ) {
10 10
 		$this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : '';
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	public function prepare_items() {
16
-	    global $wpdb, $per_page, $mode;
16
+		global $wpdb, $per_page, $mode;
17 17
 
18
-	    $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
18
+		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
19 19
 
20 20
 		$default_orderby = 'name';
21 21
 		$default_order = 'ASC';
22 22
 
23
-        $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
23
+		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby;
24 24
 		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order;
25 25
 
26 26
 		$page = $this->get_pagenum();
@@ -28,40 +28,40 @@  discard block
 block discarded – undo
28 28
 
29 29
 		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
30 30
 
31
-        $s_query = array();
32
-        $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
31
+		$s_query = array();
32
+		$s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
33 33
 		switch ( $this->status ) {
34
-		    case 'template':
35
-                $s_query['is_template'] = 1;
36
-                $s_query['status !'] = 'trash';
37
-		        break;
38
-		    case 'draft':
39
-                $s_query['is_template'] = 0;
40
-                $s_query['status'] = 'draft';
41
-		        break;
42
-		    case 'trash':
43
-                $s_query['status'] = 'trash';
44
-		        break;
45
-		    default:
46
-                $s_query['is_template'] = 0;
47
-                $s_query['status !'] = 'trash';
48
-		        break;
34
+			case 'template':
35
+				$s_query['is_template'] = 1;
36
+				$s_query['status !'] = 'trash';
37
+				break;
38
+			case 'draft':
39
+				$s_query['is_template'] = 0;
40
+				$s_query['status'] = 'draft';
41
+				break;
42
+			case 'trash':
43
+				$s_query['status'] = 'trash';
44
+				break;
45
+			default:
46
+				$s_query['is_template'] = 0;
47
+				$s_query['status !'] = 'trash';
48
+				break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
-	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
55
-	        foreach ( (array) $search_terms as $term ) {
56
-                $s_query[] = array(
57
-                    'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
-                );
59
-	            unset($term);
60
-            }
61
-	    }
62
-
63
-        $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page);
64
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
51
+		$s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
52
+		if ( $s != '' ) {
53
+			preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
+			$search_terms = array_map('trim', $matches[0]);
55
+			foreach ( (array) $search_terms as $term ) {
56
+				$s_query[] = array(
57
+					'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58
+				);
59
+				unset($term);
60
+			}
61
+		}
62
+
63
+		$this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page);
64
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
67 67
 			'total_items' => $total_items,
@@ -70,69 +70,69 @@  discard block
 block discarded – undo
70 70
 	}
71 71
 
72 72
 	public function no_items() {
73
-	    if ( 'template' == $this->status ) {
74
-            _e( 'No Templates Found.', 'formidable' ) ?>
73
+		if ( 'template' == $this->status ) {
74
+			_e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76 76
             <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77 77
                 <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
81
-            _e( 'No Forms Found.', 'formidable' ) ?>
81
+			_e( 'No Forms Found.', 'formidable' ) ?>
82 82
             <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a>
83 83
 <?php   }
84 84
 	}
85 85
 
86 86
 	public function get_bulk_actions() {
87
-	    $actions = array();
87
+		$actions = array();
88 88
 
89 89
 		if ( in_array( $this->status, array( '', 'published' ) ) ) {
90
-	        $actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
-	    }
92
-
93
-	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
95
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
-	        }
97
-
98
-	        if ( current_user_can('frm_delete_forms') ) {
99
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
-	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
105
-	    }
106
-
107
-        return $actions;
108
-    }
90
+			$actions['bulk_create_template'] = __( 'Create Template', 'formidable' );
91
+		}
92
+
93
+		if ( 'trash' == $this->status ) {
94
+			if ( current_user_can('frm_edit_forms') ) {
95
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96
+			}
97
+
98
+			if ( current_user_can('frm_delete_forms') ) {
99
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100
+			}
101
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
102
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
+		} else if ( current_user_can('frm_delete_forms') ) {
104
+			$actions['bulk_delete'] = __( 'Delete');
105
+		}
106
+
107
+		return $actions;
108
+	}
109 109
 
110 110
 	public function extra_tablenav( $which ) {
111
-        if ( 'top' != $which ) {
112
-            return;
113
-        }
111
+		if ( 'top' != $which ) {
112
+			return;
113
+		}
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
119 119
             </div>
120 120
 <?php
121
-            return;
122
-        }
121
+			return;
122
+		}
123 123
 
124
-        if ( 'template' != $this->status ) {
125
-            return;
126
-        }
124
+		if ( 'template' != $this->status ) {
125
+			return;
126
+		}
127 127
 
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
132
-        $args = array(
133
-            'frm_action'    => 'duplicate',
134
-            'template'      => true,
135
-        );
131
+		$base = admin_url('admin.php?page=formidable&form_type=template');
132
+		$args = array(
133
+			'frm_action'    => 'duplicate',
134
+			'template'      => true,
135
+		);
136 136
 
137 137
 ?>
138 138
     <div class="alignleft actions frm_visible_overflow">
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
         <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a>
141 141
 		<ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop">
142 142
 		<?php
143
-        if ( empty( $forms ) ) { ?>
143
+		if ( empty( $forms ) ) { ?>
144 144
             <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li>
145 145
         <?php
146
-        } else {
147
-            foreach ( $forms as $form ) {
148
-		        $args['id'] = $form->id; ?>
146
+		} else {
147
+			foreach ( $forms as $form ) {
148
+				$args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+				unset($form);
152 152
 			}
153
-        }
154
-        ?>
153
+		}
154
+		?>
155 155
 		</ul>
156 156
 	</div>
157 157
 	</div>
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
 	public function get_views() {
162 162
 
163 163
 		$statuses = array(
164
-		    'published' => __( 'My Forms', 'formidable' ),
165
-		    'template'  => __( 'Templates', 'formidable' ),
166
-		    'draft'     => __( 'Drafts', 'formidable' ),
167
-		    'trash'     => __( 'Trash', 'formidable' ),
164
+			'published' => __( 'My Forms', 'formidable' ),
165
+			'template'  => __( 'Templates', 'formidable' ),
166
+			'draft'     => __( 'Drafts', 'formidable' ),
167
+			'trash'     => __( 'Trash', 'formidable' ),
168 168
 		);
169 169
 
170
-	    $links = array();
171
-	    $counts = FrmForm::get_count();
172
-        $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
170
+		$links = array();
171
+		$counts = FrmForm::get_count();
172
+		$form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published';
173 173
 
174
-	    foreach ( $statuses as $status => $name ) {
174
+		foreach ( $statuses as $status => $name ) {
175 175
 
176
-	        if ( $status == $form_type ) {
177
-    			$class = ' class="current"';
178
-    		} else {
179
-    		    $class = '';
180
-    		}
176
+			if ( $status == $form_type ) {
177
+				$class = ' class="current"';
178
+			} else {
179
+				$class = '';
180
+			}
181 181
 
182
-    		if ( $counts->{$status} || 'published' == $status ) {
182
+			if ( $counts->{$status} || 'published' == $status ) {
183 183
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184
-		    }
184
+			}
185 185
 
186
-		    unset($status, $name);
187
-	    }
186
+			unset($status, $name);
187
+		}
188 188
 
189 189
 		return $links;
190 190
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	}
201 201
 
202 202
 	public function single_row( $item, $style = '' ) {
203
-	    global $frm_vars, $mode;
203
+		global $frm_vars, $mode;
204 204
 
205 205
 		// Set up the hover actions for this user
206 206
 		$actions = array();
207
-        $edit_link = '?page=formidable&frm_action=edit&id='. $item->id;
208
-	    $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id;
207
+		$edit_link = '?page=formidable&frm_action=edit&id='. $item->id;
208
+		$duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+		$this->get_actions($actions, $item, $edit_link, $duplicate_link);
211 211
 
212
-        $action_links = $this->row_actions( $actions );
212
+		$action_links = $this->row_actions( $actions );
213 213
 
214 214
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
215 215
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 
219 219
 		list( $columns, $hidden ) = $this->get_column_info();
220 220
 
221
-        $format = 'Y/m/d';
222
-        if ( 'list' != $mode ) {
223
-            $format .= ' \<\b\r \/\> g:i:s a';
221
+		$format = 'Y/m/d';
222
+		if ( 'list' != $mode ) {
223
+			$format .= ' \<\b\r \/\> g:i:s a';
224 224
 		}
225 225
 
226 226
 		foreach ( $columns as $column_name => $column_display_name ) {
227
-            $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' );
227
+			$class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' );
228 228
 
229 229
 			$style = '';
230 230
 			if ( in_array( $column_name, $hidden ) ) {
231
-                $class .= ' frm_hidden';
231
+				$class .= ' frm_hidden';
232 232
 			}
233 233
 
234 234
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -241,41 +241,41 @@  discard block
 block discarded – undo
241 241
 					break;
242 242
 				case 'id':
243 243
 				case 'form_key':
244
-				    $val = $item->{$column_name};
245
-				    break;
244
+					$val = $item->{$column_name};
245
+					break;
246 246
 				case 'name':
247
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
-			        $val .= $action_links;
247
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
248
+					$val .= $action_links;
249 249
 
250
-				    break;
250
+					break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+					$date = date($format, strtotime($item->created_at));
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
256 256
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id .']' ) . '" /><br/>';
257
-				    if ( 'excerpt' == $mode ) {
257
+					if ( 'excerpt' == $mode ) {
258 258
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
259
-				    }
260
-			        break;
261
-			    case 'entries':
259
+					}
260
+					break;
261
+				case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263
-			            $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="'. esc_attr('Entries are not being saved', 'formidable' ) .'"></i>';
264
-			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
266
-                        $val = (current_user_can('frm_view_entries')) ? '<a href="'. esc_url(admin_url('admin.php') .'?page=formidable-entries&form='. $item->id ) .'">'. $text .'</a>' : $text;
267
-                        unset($text);
268
-                    }
269
-			        break;
270
-                case 'type':
271
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
-                    break;
263
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="'. esc_attr('Entries are not being saved', 'formidable' ) .'"></i>';
264
+					} else {
265
+						$text = FrmEntry::getRecordCount($item->id);
266
+						$val = (current_user_can('frm_view_entries')) ? '<a href="'. esc_url(admin_url('admin.php') .'?page=formidable-entries&form='. $item->id ) .'">'. $text .'</a>' : $text;
267
+						unset($text);
268
+					}
269
+					break;
270
+				case 'type':
271
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
272
+					break;
273 273
 			}
274 274
 
275 275
 			if ( isset($val) ) {
276
-			    $r .= "<td $attributes>";
277
-			    $r .= $val;
278
-			    $r .= '</td>';
276
+				$r .= "<td $attributes>";
277
+				$r .= $val;
278
+				$r .= '</td>';
279 279
 			}
280 280
 			unset($val);
281 281
 		}
@@ -284,37 +284,37 @@  discard block
 block discarded – undo
284 284
 		return $r;
285 285
 	}
286 286
 
287
-    /**
288
-     * @param string $edit_link
289
-     * @param string $duplicate_link
290
-     */
291
-    private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
287
+	/**
288
+	 * @param string $edit_link
289
+	 * @param string $duplicate_link
290
+	 */
291
+	private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293 293
 			if ( current_user_can('frm_edit_forms') ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
298
-    		    $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete"  onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>';
299
-    		}
300
-            return;
297
+			if ( current_user_can('frm_delete_forms') ) {
298
+				$actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete"  onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>';
299
+			}
300
+			return;
301 301
 		}
302 302
 
303 303
 		if ( current_user_can('frm_edit_forms') ) {
304
-            if ( ! $item->is_template || ! $item->default_template ) {
305
-		        $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>';
306
-            }
304
+			if ( ! $item->is_template || ! $item->default_template ) {
305
+				$actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>';
306
+			}
307 307
 
308
-		    if ( $item->is_template ) {
308
+			if ( $item->is_template ) {
309 309
 				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
310
-            } else {
311
-    		    $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>';
310
+			} else {
311
+				$actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>';
312 312
 
313
-    		    if ( FrmAppHelper::pro_is_installed() ) {
313
+				if ( FrmAppHelper::pro_is_installed() ) {
314 314
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
315
-        	    }
316
-        	}
317
-        }
315
+				}
316
+			}
317
+		}
318 318
 
319 319
 		$actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
320 320
 		if ( empty( $actions['trash'] ) ) {
@@ -323,52 +323,52 @@  discard block
 block discarded – undo
323 323
 		}
324 324
 
325 325
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
326
-    }
326
+	}
327 327
 
328
-    /**
329
-     * @param string $edit_link
330
-     */
328
+	/**
329
+	 * @param string $edit_link
330
+	 */
331 331
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
332
-        $form_name = $item->name;
333
-        if ( trim($form_name) == '' ) {
334
-            $form_name = __( '(no title)');
335
-        }
332
+		$form_name = $item->name;
333
+		if ( trim($form_name) == '' ) {
334
+			$form_name = __( '(no title)');
335
+		}
336 336
 		$form_name = FrmAppHelper::kses( $form_name );
337 337
 		if ( 'excerpt' != $mode ) {
338 338
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
339 339
 		}
340 340
 
341
-        $val = '<strong>';
342
-        if ( 'trash' == $this->status ) {
343
-            $val .= $form_name;
344
-        } else {
341
+		$val = '<strong>';
342
+		if ( 'trash' == $this->status ) {
343
+			$val .= $form_name;
344
+		} else {
345 345
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
346
-        }
347
-
348
-        $this->add_draft_label( $item, $val );
349
-        $val .= '</strong>';
350
-
351
-        $this->add_form_description( $item, $val );
352
-
353
-        return $val;
354
-    }
355
-
356
-    /**
357
-     * @param string $val
358
-     */
359
-    private function add_draft_label( $item, &$val ) {
360
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
361
-            $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>';
362
-        }
363
-    }
364
-
365
-    /**
366
-     * @param string $val
367
-     */
368
-    private function add_form_description( $item, &$val ) {
369
-        global $mode;
370
-        if ( 'excerpt' == $mode ) {
371
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
-        }
373
-    }
346
+		}
347
+
348
+		$this->add_draft_label( $item, $val );
349
+		$val .= '</strong>';
350
+
351
+		$this->add_form_description( $item, $val );
352
+
353
+		return $val;
354
+	}
355
+
356
+	/**
357
+	 * @param string $val
358
+	 */
359
+	private function add_draft_label( $item, &$val ) {
360
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
361
+			$val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>';
362
+		}
363
+	}
364
+
365
+	/**
366
+	 * @param string $val
367
+	 */
368
+	private function add_form_description( $item, &$val ) {
369
+		global $mode;
370
+		if ( 'excerpt' == $mode ) {
371
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
372
+		}
373
+	}
374 374
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$page = $this->get_pagenum();
27 27
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
28 28
 
29
-		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page);
29
+		$start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page );
30 30
 
31 31
         $s_query = array();
32 32
         $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 );
@@ -48,19 +48,19 @@  discard block
 block discarded – undo
48 48
 		        break;
49 49
 		}
50 50
 
51
-        $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : '';
51
+        $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
52 52
 	    if ( $s != '' ) {
53
-	        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
54
-		    $search_terms = array_map('trim', $matches[0]);
53
+	        preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
54
+		    $search_terms = array_map( 'trim', $matches[0] );
55 55
 	        foreach ( (array) $search_terms as $term ) {
56 56
                 $s_query[] = array(
57 57
                     'or'    => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term,
58 58
                 );
59
-	            unset($term);
59
+	            unset( $term );
60 60
             }
61 61
 	    }
62 62
 
63
-        $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page);
63
+        $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
64 64
         $total_items = FrmDb::get_count( 'frm_forms', $s_query );
65 65
 
66 66
 		$this->set_pagination_args( array(
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	    if ( 'template' == $this->status ) {
74 74
             _e( 'No Templates Found.', 'formidable' ) ?>
75 75
             <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?>
76
-            <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="'. esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77
-                <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li>
76
+            <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li>
77
+                <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li>
78 78
                 <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li>
79 79
             </ol>
80 80
 <?php   } else {
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 	    }
92 92
 
93 93
 	    if ( 'trash' == $this->status ) {
94
-	        if ( current_user_can('frm_edit_forms') ) {
94
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
95 95
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
96 96
 	        }
97 97
 
98
-	        if ( current_user_can('frm_delete_forms') ) {
98
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
99 99
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
100 100
 	        }
101
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
101
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
102 102
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
103
-	    } else if ( current_user_can('frm_delete_forms') ) {
104
-	        $actions['bulk_delete'] = __( 'Delete');
103
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
104
+	        $actions['bulk_delete'] = __( 'Delete' );
105 105
 	    }
106 106
 
107 107
         return $actions;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             return;
113 113
         }
114 114
 
115
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
115
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
116 116
 ?>
117 117
             <div class="alignleft actions frm_visible_overflow">
118 118
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
129 129
 		$forms = FrmForm::get_published_forms( $where );
130 130
 
131
-        $base = admin_url('admin.php?page=formidable&form_type=template');
131
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
132 132
         $args = array(
133 133
             'frm_action'    => 'duplicate',
134 134
             'template'      => true,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		        $args['id'] = $form->id; ?>
149 149
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
150 150
 			<?php
151
-			    unset($form);
151
+			    unset( $form );
152 152
 			}
153 153
         }
154 154
         ?>
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
     		}
181 181
 
182 182
     		if ( $counts->{$status} || 'published' == $status ) {
183
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
183
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
184 184
 		    }
185 185
 
186
-		    unset($status, $name);
186
+		    unset( $status, $name );
187 187
 	    }
188 188
 
189 189
 		return $links;
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 
205 205
 		// Set up the hover actions for this user
206 206
 		$actions = array();
207
-        $edit_link = '?page=formidable&frm_action=edit&id='. $item->id;
208
-	    $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id;
207
+        $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id;
208
+	    $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id;
209 209
 
210
-        $this->get_actions($actions, $item, $edit_link, $duplicate_link);
210
+        $this->get_actions( $actions, $item, $edit_link, $duplicate_link );
211 211
 
212 212
         $action_links = $this->row_actions( $actions );
213 213
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 		foreach ( $columns as $column_name => $column_display_name ) {
227
-            $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' );
227
+            $class = $column_name . ' column-' . $column_name . ( ( 'name' == $column_name ) ? ' post-title page-title column-title' : '' );
228 228
 
229 229
 			$style = '';
230 230
 			if ( in_array( $column_name, $hidden ) ) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 			switch ( $column_name ) {
239 239
 				case 'cb':
240
-					$r .= '<th scope="row" class="check-column">'. $checkbox .'</th>';
240
+					$r .= '<th scope="row" class="check-column">' . $checkbox . '</th>';
241 241
 					break;
242 242
 				case 'id':
243 243
 				case 'form_key':
@@ -249,22 +249,22 @@  discard block
 block discarded – undo
249 249
 
250 250
 				    break;
251 251
 				case 'created_at':
252
-				    $date = date($format, strtotime($item->created_at));
252
+				    $date = date( $format, strtotime( $item->created_at ) );
253 253
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
254 254
 					break;
255 255
 				case 'shortcode':
256
-					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id .']' ) . '" /><br/>';
256
+					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
257 257
 				    if ( 'excerpt' == $mode ) {
258 258
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
259 259
 				    }
260 260
 			        break;
261 261
 			    case 'entries':
262 262
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
263
-			            $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="'. esc_attr('Entries are not being saved', 'formidable' ) .'"></i>';
263
+			            $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>';
264 264
 			        } else {
265
-			            $text = FrmEntry::getRecordCount($item->id);
266
-                        $val = (current_user_can('frm_view_entries')) ? '<a href="'. esc_url(admin_url('admin.php') .'?page=formidable-entries&form='. $item->id ) .'">'. $text .'</a>' : $text;
267
-                        unset($text);
265
+			            $text = FrmEntry::getRecordCount( $item->id );
266
+                        $val = ( current_user_can( 'frm_view_entries' ) ) ? '<a href="' . esc_url( admin_url( 'admin.php' ) . '?page=formidable-entries&form=' . $item->id ) . '">' . $text . '</a>' : $text;
267
+                        unset( $text );
268 268
                     }
269 269
 			        break;
270 270
                 case 'type':
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                     break;
273 273
 			}
274 274
 
275
-			if ( isset($val) ) {
275
+			if ( isset( $val ) ) {
276 276
 			    $r .= "<td $attributes>";
277 277
 			    $r .= $val;
278 278
 			    $r .= '</td>';
279 279
 			}
280
-			unset($val);
280
+			unset( $val );
281 281
 		}
282 282
 		$r .= '</tr>';
283 283
 
@@ -290,25 +290,25 @@  discard block
 block discarded – undo
290 290
      */
291 291
     private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) {
292 292
 		if ( 'trash' == $this->status ) {
293
-			if ( current_user_can('frm_edit_forms') ) {
293
+			if ( current_user_can( 'frm_edit_forms' ) ) {
294 294
 				$actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' );
295 295
 			}
296 296
 
297
-		    if ( current_user_can('frm_delete_forms') ) {
298
-    		    $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete"  onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>';
297
+		    if ( current_user_can( 'frm_delete_forms' ) ) {
298
+    		    $actions['trash'] = '<a href="' . esc_url( wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ) ) . '" class="submitdelete"  onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>';
299 299
     		}
300 300
             return;
301 301
 		}
302 302
 
303
-		if ( current_user_can('frm_edit_forms') ) {
303
+		if ( current_user_can( 'frm_edit_forms' ) ) {
304 304
             if ( ! $item->is_template || ! $item->default_template ) {
305
-		        $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>';
305
+		        $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
306 306
             }
307 307
 
308 308
 		    if ( $item->is_template ) {
309
-				$actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
309
+				$actions['frm_duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>';
310 310
             } else {
311
-    		    $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>';
311
+    		    $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
312 312
 
313 313
     		    if ( FrmAppHelper::pro_is_installed() ) {
314 314
 					$actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>';
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			unset( $actions['trash'] );
323 323
 		}
324 324
 
325
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
325
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
326 326
     }
327 327
 
328 328
     /**
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
      */
331 331
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
332 332
         $form_name = $item->name;
333
-        if ( trim($form_name) == '' ) {
334
-            $form_name = __( '(no title)');
333
+        if ( trim( $form_name ) == '' ) {
334
+            $form_name = __( '(no title)' );
335 335
         }
336 336
 		$form_name = FrmAppHelper::kses( $form_name );
337 337
 		if ( 'excerpt' != $mode ) {
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
      */
359 359
     private function add_draft_label( $item, &$val ) {
360 360
         if ( 'draft' == $item->status && 'draft' != $this->status ) {
361
-            $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>';
361
+            $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
362 362
         }
363 363
     }
364 364
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     private function add_form_description( $item, &$val ) {
369 369
         global $mode;
370 370
         if ( 'excerpt' == $mode ) {
371
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
371
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
372 372
         }
373 373
     }
374 374
 }
Please login to merge, or discard this patch.
classes/helpers/FrmStylesHelper.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class FrmStylesHelper {
3 3
 
4
-    public static function jquery_themes() {
5
-        $themes = array(
6
-            'ui-lightness'  => 'UI Lightness',
7
-            'ui-darkness'   => 'UI Darkness',
8
-            'smoothness'    => 'Smoothness',
9
-            'start'         => 'Start',
10
-            'redmond'       => 'Redmond',
11
-            'sunny'         => 'Sunny',
12
-            'overcast'      => 'Overcast',
13
-            'le-frog'       => 'Le Frog',
14
-            'flick'         => 'Flick',
4
+	public static function jquery_themes() {
5
+		$themes = array(
6
+			'ui-lightness'  => 'UI Lightness',
7
+			'ui-darkness'   => 'UI Darkness',
8
+			'smoothness'    => 'Smoothness',
9
+			'start'         => 'Start',
10
+			'redmond'       => 'Redmond',
11
+			'sunny'         => 'Sunny',
12
+			'overcast'      => 'Overcast',
13
+			'le-frog'       => 'Le Frog',
14
+			'flick'         => 'Flick',
15 15
 			'pepper-grinder' => 'Pepper Grinder',
16
-            'eggplant'      => 'Eggplant',
17
-            'dark-hive'     => 'Dark Hive',
18
-            'cupertino'     => 'Cupertino',
19
-            'south-street'  => 'South Street',
20
-            'blitzer'       => 'Blitzer',
21
-            'humanity'      => 'Humanity',
22
-            'hot-sneaks'    => 'Hot Sneaks',
23
-            'excite-bike'   => 'Excite Bike',
24
-            'vader'         => 'Vader',
25
-            'dot-luv'       => 'Dot Luv',
26
-            'mint-choc'     => 'Mint Choc',
27
-            'black-tie'     => 'Black Tie',
28
-            'trontastic'    => 'Trontastic',
29
-            'swanky-purse'  => 'Swanky Purse',
30
-        );
31
-
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
33
-        return $themes;
34
-    }
16
+			'eggplant'      => 'Eggplant',
17
+			'dark-hive'     => 'Dark Hive',
18
+			'cupertino'     => 'Cupertino',
19
+			'south-street'  => 'South Street',
20
+			'blitzer'       => 'Blitzer',
21
+			'humanity'      => 'Humanity',
22
+			'hot-sneaks'    => 'Hot Sneaks',
23
+			'excite-bike'   => 'Excite Bike',
24
+			'vader'         => 'Vader',
25
+			'dot-luv'       => 'Dot Luv',
26
+			'mint-choc'     => 'Mint Choc',
27
+			'black-tie'     => 'Black Tie',
28
+			'trontastic'    => 'Trontastic',
29
+			'swanky-purse'  => 'Swanky Purse',
30
+		);
31
+
32
+		$themes = apply_filters('frm_jquery_themes', $themes);
33
+		return $themes;
34
+	}
35 35
 
36 36
 	public static function jquery_css_url( $theme_css ) {
37
-        if ( $theme_css == -1 ) {
38
-            return;
39
-        }
40
-
41
-        if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
-            $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
-            $css_file = $theme_css;
45
-        } else {
46
-            $uploads = self::get_upload_base();
47
-            $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
49
-                $css_file = $uploads['baseurl'] . $file_path;
50
-            } else {
51
-                $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css';
52
-            }
53
-        }
54
-
55
-        return $css_file;
56
-    }
57
-
58
-    public static function enqueue_jquery_css() {
37
+		if ( $theme_css == -1 ) {
38
+			return;
39
+		}
40
+
41
+		if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42
+			$css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
+		} else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
44
+			$css_file = $theme_css;
45
+		} else {
46
+			$uploads = self::get_upload_base();
47
+			$file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css';
48
+			if ( file_exists($uploads['basedir'] . $file_path) ) {
49
+				$css_file = $uploads['baseurl'] . $file_path;
50
+			} else {
51
+				$css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css';
52
+			}
53
+		}
54
+
55
+		return $css_file;
56
+	}
57
+
58
+	public static function enqueue_jquery_css() {
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61
-        if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
-        }
64
-    }
61
+		if ( $theme_css != -1 ) {
62
+			wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
63
+		}
64
+	}
65 65
 
66 66
 	public static function get_form_for_page() {
67 67
 		global $frm_vars;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		return $form_id;
78 78
 	}
79 79
 
80
-    public static function get_upload_base() {
81
-        $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
-        }
80
+	public static function get_upload_base() {
81
+		$uploads = wp_upload_dir();
82
+		if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
+			$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
84
+		}
85 85
 
86
-        return $uploads;
87
-    }
86
+		return $uploads;
87
+	}
88 88
 
89 89
 	public static function style_menu( $active = '' ) {
90 90
 ?>
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97
-    }
97
+	}
98 98
 
99
-    public static function minus_icons() {
100
-        return array(
99
+	public static function minus_icons() {
100
+		return array(
101 101
 			0 => array( '-' => '62e', '+' => '62f' ),
102 102
 			1 => array( '-' => '600', '+' => '602' ),
103 103
 			2 => array( '-' => '604', '+' => '603' ),
104 104
 			3 => array( '-' => '633', '+' => '632' ),
105 105
 			4 => array( '-' => '613', '+' => '60f' ),
106
-        );
107
-    }
106
+		);
107
+	}
108 108
 
109
-    public static function arrow_icons() {
110
-        $minus_icons = self::minus_icons();
109
+	public static function arrow_icons() {
110
+		$minus_icons = self::minus_icons();
111 111
 
112
-        return array(
112
+		return array(
113 113
 			6 => array( '-' => '62d', '+' => '62a' ),
114 114
 			0 => array( '-' => '60d', '+' => '609' ),
115 115
 			1 => array( '-' => '60e', '+' => '60c' ),
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 			3 => array( '-' => '62b', '+' => '628' ),
118 118
 			4 => array( '-' => '62c', '+' => '629' ),
119 119
 			5 => array( '-' => '635', '+' => '634' ),
120
-            'p0' => $minus_icons[0],
121
-            'p1' => $minus_icons[1],
122
-            'p2' => $minus_icons[2],
123
-            'p3' => $minus_icons[3],
124
-            'p4' => $minus_icons[4],
125
-        );
126
-    }
127
-
128
-    /**
129
-     * @since 2.0
130
-     * @return The class for this icon
131
-     */
120
+			'p0' => $minus_icons[0],
121
+			'p1' => $minus_icons[1],
122
+			'p2' => $minus_icons[2],
123
+			'p3' => $minus_icons[3],
124
+			'p4' => $minus_icons[4],
125
+		);
126
+	}
127
+
128
+	/**
129
+	 * @since 2.0
130
+	 * @return The class for this icon
131
+	 */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
134
-            //frm_arrowup6_icon
133
+		if ( 'arrow' == $type && is_numeric($key) ) {
134
+			//frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136 136
 			$class = 'frm_arrow' . $arrow[ $icon ];
137
-        } else {
138
-            //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
137
+		} else {
138
+			//frm_minus1_icon
139
+			$key = str_replace('p', '', $key);
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141 141
 			$class = 'frm_' . $plus[ $icon ];
142
-        }
142
+		}
143 143
 
144
-        if ( $key ) {
145
-            $class .= $key;
146
-        }
147
-        $class .= '_icon';
144
+		if ( $key ) {
145
+			$class .= $key;
146
+		}
147
+		$class .= '_icon';
148 148
 
149
-        return $class;
150
-    }
149
+		return $class;
150
+	}
151 151
 
152 152
 	public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
153 153
 		$function_name = $type . '_icons';
154 154
 		$icons = self::$function_name();
155 155
 		unset( $function_name );
156 156
 
157
-        $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
157
+		$name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159 159
     	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
             </ul>
188 188
         </div>
189 189
 <?php
190
-    }
190
+	}
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
194
-
195
-        if ( strlen($hex) == 3 ) {
196
-            $r = hexdec( substr($hex,0,1).substr($hex,0,1) );
197
-            $g = hexdec( substr($hex,1,1).substr($hex,1,1) );
198
-            $b = hexdec( substr($hex,2,1).substr($hex,2,1) );
199
-        } else {
200
-            $r = hexdec( substr($hex,0,2) );
201
-            $g = hexdec( substr($hex,2,2) );
202
-            $b = hexdec( substr($hex,4,2) );
203
-        }
193
+		$hex = str_replace('#', '', $hex);
194
+
195
+		if ( strlen($hex) == 3 ) {
196
+			$r = hexdec( substr($hex,0,1).substr($hex,0,1) );
197
+			$g = hexdec( substr($hex,1,1).substr($hex,1,1) );
198
+			$b = hexdec( substr($hex,2,1).substr($hex,2,1) );
199
+		} else {
200
+			$r = hexdec( substr($hex,0,2) );
201
+			$g = hexdec( substr($hex,2,2) );
202
+			$b = hexdec( substr($hex,4,2) );
203
+		}
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
206
-        //return $rgb; // returns an array with the rgb values
207
-    }
205
+		return implode(',', $rgb); // returns the rgb values separated by commas
206
+		//return $rgb; // returns an array with the rgb values
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             'swanky-purse'  => 'Swanky Purse',
30 30
         );
31 31
 
32
-        $themes = apply_filters('frm_jquery_themes', $themes);
32
+        $themes = apply_filters( 'frm_jquery_themes', $themes );
33 33
         return $themes;
34 34
     }
35 35
 
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 
41 41
         if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) {
42 42
             $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css';
43
-        } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) {
43
+        } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) {
44 44
             $css_file = $theme_css;
45 45
         } else {
46 46
             $uploads = self::get_upload_base();
47
-            $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css';
48
-            if ( file_exists($uploads['basedir'] . $file_path) ) {
47
+            $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css';
48
+            if ( file_exists( $uploads['basedir'] . $file_path ) ) {
49 49
                 $css_file = $uploads['baseurl'] . $file_path;
50 50
             } else {
51
-                $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css';
51
+                $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css';
52 52
             }
53 53
         }
54 54
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$form = self::get_form_for_page();
60 60
 		$theme_css = FrmStylesController::get_style_val( 'theme_css', $form );
61 61
         if ( $theme_css != -1 ) {
62
-            wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version());
62
+            wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() );
63 63
         }
64 64
     }
65 65
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 
80 80
     public static function get_upload_base() {
81 81
         $uploads = wp_upload_dir();
82
-        if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) {
83
-            $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
82
+        if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) {
83
+            $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
84 84
         }
85 85
 
86 86
         return $uploads;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         <h2 class="nav-tab-wrapper">
92 92
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a>
93 93
 			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a>
94
-			<a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
94
+			<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a>
95 95
         </h2>
96 96
 <?php
97 97
     }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
      * @return The class for this icon
131 131
      */
132 132
 	public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
133
-        if ( 'arrow' == $type && is_numeric($key) ) {
133
+        if ( 'arrow' == $type && is_numeric( $key ) ) {
134 134
             //frm_arrowup6_icon
135 135
 			$arrow = array( '-' => 'down', '+' => 'up' );
136
-			$class = 'frm_arrow' . $arrow[ $icon ];
136
+			$class = 'frm_arrow' . $arrow[$icon];
137 137
         } else {
138 138
             //frm_minus1_icon
139
-            $key = str_replace('p', '', $key);
139
+            $key = str_replace( 'p', '', $key );
140 140
 			$plus = array( '-' => 'minus', '+' => 'plus' );
141
-			$class = 'frm_' . $plus[ $icon ];
141
+			$class = 'frm_' . $plus[$icon];
142 142
         }
143 143
 
144 144
         if ( $key ) {
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
 
157 157
         $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon';
158 158
 ?>
159
-    	<select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
159
+    	<select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js">
160 160
             <?php foreach ( $icons as $key => $icon ) { ?>
161
-			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>>
162
-                <?php echo '&#xe'. $icon['+'] .'; &#xe'. $icon['-'] .';'; ?>
161
+			<option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>>
162
+                <?php echo '&#xe' . $icon['+'] . '; &#xe' . $icon['-'] . ';'; ?>
163 163
             </option>
164 164
             <?php } ?>
165 165
     	</select>
166 166
 
167 167
         <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select">
168 168
             <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button">
169
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i>
170
-				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i>
169
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i>
170
+				<i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i>
171 171
                 <b class="caret"></b>
172 172
             </button>
173 173
             <ul class="multiselect-container frm-dropdown-menu">
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
     }
191 191
 
192 192
 	public static function hex2rgb( $hex ) {
193
-        $hex = str_replace('#', '', $hex);
193
+        $hex = str_replace( '#', '', $hex );
194 194
 
195
-        if ( strlen($hex) == 3 ) {
196
-            $r = hexdec( substr($hex,0,1).substr($hex,0,1) );
197
-            $g = hexdec( substr($hex,1,1).substr($hex,1,1) );
198
-            $b = hexdec( substr($hex,2,1).substr($hex,2,1) );
195
+        if ( strlen( $hex ) == 3 ) {
196
+            $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
197
+            $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
198
+            $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
199 199
         } else {
200
-            $r = hexdec( substr($hex,0,2) );
201
-            $g = hexdec( substr($hex,2,2) );
202
-            $b = hexdec( substr($hex,4,2) );
200
+            $r = hexdec( substr( $hex, 0, 2 ) );
201
+            $g = hexdec( substr( $hex, 2, 2 ) );
202
+            $b = hexdec( substr( $hex, 4, 2 ) );
203 203
         }
204 204
 		$rgb = array( $r, $g, $b );
205
-        return implode(',', $rgb); // returns the rgb values separated by commas
205
+        return implode( ',', $rgb ); // returns the rgb values separated by commas
206 206
         //return $rgb; // returns an array with the rgb values
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +591 added lines, -591 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public static function import_xml( $file ) {
26
-        $defaults = array(
27
-            'forms' => 0, 'fields' => 0, 'terms' => 0,
28
-            'posts' => 0, 'views' => 0, 'actions' => 0,
29
-            'styles' => 0,
30
-        );
31
-
32
-        $imported = array(
33
-            'imported' => $defaults,
26
+		$defaults = array(
27
+			'forms' => 0, 'fields' => 0, 'terms' => 0,
28
+			'posts' => 0, 'views' => 0, 'actions' => 0,
29
+			'styles' => 0,
30
+		);
31
+
32
+		$imported = array(
33
+			'imported' => $defaults,
34 34
 			'updated'  => $defaults,
35 35
 			'forms'    => array(),
36 36
 			'terms'    => array(),
37
-        );
37
+		);
38 38
 
39
-        unset($defaults);
39
+		unset($defaults);
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
43
-        }
42
+			define('WP_IMPORTING', true);
43
+		}
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
46
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
-        }
46
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
47
+		}
48 48
 
49
-        $dom = new DOMDocument;
49
+		$dom = new DOMDocument;
50 50
 		$success = $dom->loadXML( file_get_contents( $file ) );
51 51
 		if ( ! $success ) {
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -64,46 +64,46 @@  discard block
 block discarded – undo
64 64
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
65 65
 		}
66 66
 
67
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
67
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69
-            // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
69
+			// grab cats, tags, and terms, or forms or posts
70
+			if ( isset($xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74
-            }
75
-        }
74
+			}
75
+		}
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+		$return = apply_filters('frm_importing_xml', $imported, $xml );
78 78
 
79
-	    return $return;
80
-    }
79
+		return $return;
80
+	}
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83
-        foreach ( $terms as $t ) {
83
+		foreach ( $terms as $t ) {
84 84
 			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
85
-			    continue;
85
+				continue;
86 86
 			}
87 87
 
88 88
 			$parent = self::get_term_parent_id( $t );
89 89
 
90 90
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
91
-                'slug'          => (string) $t->term_slug,
92
-                'description'   => (string) $t->term_description,
91
+				'slug'          => (string) $t->term_slug,
92
+				'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94
-                'slug'          => (string) $t->term_slug,
95
-            ));
94
+				'slug'          => (string) $t->term_slug,
95
+			));
96 96
 
97 97
 			if ( $term && is_array( $term ) ) {
98
-                $imported['imported']['terms']++;
98
+				$imported['imported']['terms']++;
99 99
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
100
-            }
100
+			}
101 101
 
102 102
 			unset( $term, $t );
103 103
 		}
104 104
 
105 105
 		return $imported;
106
-    }
106
+	}
107 107
 
108 108
 	/**
109 109
 	 * @since 2.0.8
@@ -128,97 +128,97 @@  discard block
 block discarded – undo
128 128
 		self::put_child_forms_first( $forms );
129 129
 
130 130
 		foreach ( $forms as $item ) {
131
-            $form = array(
132
-                'id'            => (int) $item->id,
133
-                'form_key'      => (string) $item->form_key,
134
-                'name'          => (string) $item->name,
135
-                'description'   => (string) $item->description,
136
-                'options'       => (string) $item->options,
137
-                'logged_in'     => (int) $item->logged_in,
138
-                'is_template'   => (int) $item->is_template,
139
-                'default_template' => (int) $item->default_template,
140
-                'editable'      => (int) $item->editable,
141
-                'status'        => (string) $item->status,
142
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
143
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
144
-            );
145
-
146
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
147
-
148
-            // if template, allow to edit if form keys match, otherwise, creation date must also match
131
+			$form = array(
132
+				'id'            => (int) $item->id,
133
+				'form_key'      => (string) $item->form_key,
134
+				'name'          => (string) $item->name,
135
+				'description'   => (string) $item->description,
136
+				'options'       => (string) $item->options,
137
+				'logged_in'     => (int) $item->logged_in,
138
+				'is_template'   => (int) $item->is_template,
139
+				'default_template' => (int) $item->default_template,
140
+				'editable'      => (int) $item->editable,
141
+				'status'        => (string) $item->status,
142
+				'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
143
+				'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
144
+			);
145
+
146
+			$form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
147
+
148
+			// if template, allow to edit if form keys match, otherwise, creation date must also match
149 149
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
150
-            if ( ! $form['is_template'] ) {
151
-                $edit_query['created_at'] = $form['created_at'];
152
-            }
150
+			if ( ! $form['is_template'] ) {
151
+				$edit_query['created_at'] = $form['created_at'];
152
+			}
153 153
 
154
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
154
+			$edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
155 155
 
156
-            $this_form = FrmForm::getAll($edit_query, '', 1);
157
-            unset($edit_query);
156
+			$this_form = FrmForm::getAll($edit_query, '', 1);
157
+			unset($edit_query);
158 158
 
159
-            if ( ! empty( $this_form ) ) {
160
-                $old_id = $form_id = $this_form->id;
161
-                FrmForm::update($form_id, $form );
162
-                $imported['updated']['forms']++;
163
-                // Keep track of whether this specific form was updated or not
159
+			if ( ! empty( $this_form ) ) {
160
+				$old_id = $form_id = $this_form->id;
161
+				FrmForm::update($form_id, $form );
162
+				$imported['updated']['forms']++;
163
+				// Keep track of whether this specific form was updated or not
164 164
 				$imported['form_status'][ $form_id ] = 'updated';
165 165
 
166 166
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
167
-                $old_fields = array();
168
-                foreach ( $form_fields as $f ) {
167
+				$old_fields = array();
168
+				foreach ( $form_fields as $f ) {
169 169
 					$old_fields[ $f->id ] = $f;
170 170
 					$old_fields[ $f->field_key ] = $f->id;
171
-                    unset($f);
172
-                }
173
-                $form_fields = $old_fields;
174
-                unset($old_fields);
175
-            } else {
176
-                $old_id = false;
177
-                //form does not exist, so create it
171
+					unset($f);
172
+				}
173
+				$form_fields = $old_fields;
174
+				unset($old_fields);
175
+			} else {
176
+				$old_id = false;
177
+				//form does not exist, so create it
178 178
 				$form_id = FrmForm::create( $form );
179
-                if ( $form_id ) {
180
-                    $imported['imported']['forms']++;
181
-                    // Keep track of whether this specific form was updated or not
179
+				if ( $form_id ) {
180
+					$imported['imported']['forms']++;
181
+					// Keep track of whether this specific form was updated or not
182 182
 					$imported['form_status'][ $form_id ] = 'imported';
183 183
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
184
-                }
185
-            }
184
+				}
185
+			}
186 186
 
187
-    		self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
187
+			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
188 188
 
189
-    		// Delete any fields attached to this form that were not included in the template
190
-    		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
189
+			// Delete any fields attached to this form that were not included in the template
190
+			if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
191 191
 				foreach ( $form_fields as $field ) {
192
-                    if ( is_object($field) ) {
193
-                        FrmField::destroy($field->id);
194
-                    }
195
-                    unset($field);
196
-                }
197
-                unset($form_fields);
198
-            }
199
-
200
-		    // Update field ids/keys to new ones
192
+					if ( is_object($field) ) {
193
+						FrmField::destroy($field->id);
194
+					}
195
+					unset($field);
196
+				}
197
+				unset($form_fields);
198
+			}
199
+
200
+			// Update field ids/keys to new ones
201 201
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
202 202
 
203 203
 			$imported['forms'][ (int) $item->id ] = $form_id;
204 204
 
205
-            // Send pre 2.0 form options through function that creates actions
206
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
205
+			// Send pre 2.0 form options through function that creates actions
206
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
207 207
 
208
-		    unset($form, $item);
208
+			unset($form, $item);
209 209
 		}
210 210
 
211 211
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
212 212
 
213 213
 		return $imported;
214
-    }
214
+	}
215 215
 
216 216
 	/**
217
-	* Put child forms first so they will be imported before parents
218
-	*
219
-	* @since 2.0.16
220
-	* @param array $forms
221
-	*/
217
+	 * Put child forms first so they will be imported before parents
218
+	 *
219
+	 * @since 2.0.16
220
+	 * @param array $forms
221
+	 */
222 222
 	private static function put_child_forms_first( &$forms ) {
223 223
 		$child_forms = array();
224 224
 		$regular_forms = array();
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 	}
238 238
 
239 239
 	/**
240
-	* Keep track of all imported child forms
241
-	*
242
-	* @since 2.0.16
243
-	* @param int $form_id
244
-	* @param int $parent_form_id
245
-	* @param array $child_forms
246
-	*/
240
+	 * Keep track of all imported child forms
241
+	 *
242
+	 * @since 2.0.16
243
+	 * @param int $form_id
244
+	 * @param int $parent_form_id
245
+	 * @param array $child_forms
246
+	 */
247 247
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
248 248
 		if ( $parent_form_id ) {
249 249
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 	}
252 252
 
253 253
 	/**
254
-	* Update the parent_form_id on imported child forms
255
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
256
-	*
257
-	* @since 2.0.6
258
-	* @param array $imported_forms
259
-	* @param array $child_forms
260
-	*/
254
+	 * Update the parent_form_id on imported child forms
255
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
256
+	 *
257
+	 * @since 2.0.6
258
+	 * @param array $imported_forms
259
+	 * @param array $child_forms
260
+	 */
261 261
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
262 262
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
263 263
 
@@ -271,61 +271,61 @@  discard block
 block discarded – undo
271 271
 	}
272 272
 
273 273
 	/**
274
-	* Import all fields for a form
275
-	* @since 2.0.13
276
-	*
277
-	* TODO: Cut down on params
278
-	*/
274
+	 * Import all fields for a form
275
+	 * @since 2.0.13
276
+	 *
277
+	 * TODO: Cut down on params
278
+	 */
279 279
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
280 280
 		foreach ( $xml_fields as $field ) {
281
-		    $f = array(
282
-		        'id'            => (int) $field->id,
283
-		        'field_key'     => (string) $field->field_key,
284
-		        'name'          => (string) $field->name,
285
-		        'description'   => (string) $field->description,
286
-		        'type'          => (string) $field->type,
287
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
288
-		        'field_order'   => (int) $field->field_order,
289
-		        'form_id'       => (int) $form_id,
290
-		        'required'      => (int) $field->required,
291
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
281
+			$f = array(
282
+				'id'            => (int) $field->id,
283
+				'field_key'     => (string) $field->field_key,
284
+				'name'          => (string) $field->name,
285
+				'description'   => (string) $field->description,
286
+				'type'          => (string) $field->type,
287
+				'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
288
+				'field_order'   => (int) $field->field_order,
289
+				'form_id'       => (int) $form_id,
290
+				'required'      => (int) $field->required,
291
+				'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
292 292
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
293
-		    );
294
-
295
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
296
-		        'text', 'email', 'url', 'textarea',
297
-		        'number','phone', 'date', 'time',
298
-		        'hidden', 'password', 'tag', 'image',
299
-		    )) ) {
300
-		        if ( count($f['default_value']) === 1 ) {
301
-		            $f['default_value'] = '['. reset($f['default_value']) .']';
302
-		        } else {
303
-		            $f['default_value'] = reset($f['default_value']);
304
-		        }
305
-		    }
306
-
307
-		    $f = apply_filters('frm_duplicated_field', $f);
293
+			);
294
+
295
+			if ( is_array($f['default_value']) && in_array($f['type'], array(
296
+				'text', 'email', 'url', 'textarea',
297
+				'number','phone', 'date', 'time',
298
+				'hidden', 'password', 'tag', 'image',
299
+			)) ) {
300
+				if ( count($f['default_value']) === 1 ) {
301
+					$f['default_value'] = '['. reset($f['default_value']) .']';
302
+				} else {
303
+					$f['default_value'] = reset($f['default_value']);
304
+				}
305
+			}
306
+
307
+			$f = apply_filters('frm_duplicated_field', $f);
308 308
 
309 309
 			self::maybe_update_form_select( $f, $imported );
310 310
 
311
-		    if ( ! empty($this_form) ) {
312
-		        // check for field to edit by field id
311
+			if ( ! empty($this_form) ) {
312
+				// check for field to edit by field id
313 313
 				if ( isset( $form_fields[ $f['id'] ] ) ) {
314
-		            FrmField::update( $f['id'], $f );
315
-		            $imported['updated']['fields']++;
314
+					FrmField::update( $f['id'], $f );
315
+					$imported['updated']['fields']++;
316 316
 
317 317
 					unset( $form_fields[ $f['id'] ] );
318 318
 
319
-		            //unset old field key
319
+					//unset old field key
320 320
 					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
321 321
 						unset( $form_fields[ $f['field_key'] ] );
322 322
 					}
323 323
 				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
324
-		            // check for field to edit by field key
325
-		            unset($f['id']);
324
+					// check for field to edit by field key
325
+					unset($f['id']);
326 326
 
327 327
 					FrmField::update( $form_fields[ $f['field_key'] ], $f );
328
-		            $imported['updated']['fields']++;
328
+					$imported['updated']['fields']++;
329 329
 
330 330
 					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
331 331
 					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
@@ -335,29 +335,29 @@  discard block
 block discarded – undo
335 335
 						continue;
336 336
 					}
337 337
 
338
-		            // if no matching field id or key in this form, create the field
339
-		            $imported['imported']['fields']++;
340
-		        }
338
+					// if no matching field id or key in this form, create the field
339
+					$imported['imported']['fields']++;
340
+				}
341 341
 			} else {
342 342
 				$new_id = FrmField::create( $f );
343 343
 				if ( $new_id == false ) {
344 344
 					continue;
345 345
 				}
346 346
 
347
-	            $imported['imported']['fields']++;
348
-		    }
347
+				$imported['imported']['fields']++;
348
+			}
349 349
 
350 350
 			unset($field, $new_id);
351 351
 		}
352 352
 	}
353 353
 
354 354
 	/**
355
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
356
-	*
357
-	* @since 2.0.16
358
-	* @param array $f
359
-	* @param array $imported
360
-	*/
355
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
356
+	 *
357
+	 * @since 2.0.16
358
+	 * @param array $f
359
+	 * @param array $imported
360
+	 */
361 361
 	private static function maybe_update_form_select( &$f, $imported ) {
362 362
 		if ( ! isset( $imported['forms'] ) ) {
363 363
 			return;
@@ -374,16 +374,16 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 
376 376
 	public static function import_xml_views( $views, $imported ) {
377
-        $imported['posts'] = array();
378
-        $form_action_type = FrmFormActionsController::$action_post_type;
377
+		$imported['posts'] = array();
378
+		$form_action_type = FrmFormActionsController::$action_post_type;
379 379
 
380
-        $post_types = array(
381
-            'frm_display' => 'views',
382
-            $form_action_type => 'actions',
383
-            'frm_styles'    => 'styles',
384
-        );
380
+		$post_types = array(
381
+			'frm_display' => 'views',
382
+			$form_action_type => 'actions',
383
+			'frm_styles'    => 'styles',
384
+		);
385 385
 
386
-        foreach ( $views as $item ) {
386
+		foreach ( $views as $item ) {
387 387
 			$post = array(
388 388
 				'post_title'    => (string) $item->title,
389 389
 				'post_name'     => (string) $item->post_name,
@@ -402,52 +402,52 @@  discard block
 block discarded – undo
402 402
 				'post_date'     => (string) $item->post_date,
403 403
 				'post_date_gmt' => (string) $item->post_date_gmt,
404 404
 				'ping_status'   => (string) $item->ping_status,
405
-                'postmeta'      => array(),
406
-                'tax_input'     => array(),
405
+				'postmeta'      => array(),
406
+				'tax_input'     => array(),
407 407
 			);
408 408
 
409
-            $old_id = $post['post_id'];
410
-            self::populate_post($post, $item, $imported);
409
+			$old_id = $post['post_id'];
410
+			self::populate_post($post, $item, $imported);
411 411
 
412 412
 			unset($item);
413 413
 
414 414
 			$post_id = false;
415
-            if ( $post['post_type'] == $form_action_type ) {
416
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
415
+			if ( $post['post_type'] == $form_action_type ) {
416
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
417 417
 				if ( $action_control ) {
418 418
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
419 419
 				}
420
-                unset($action_control);
421
-            } else if ( $post['post_type'] == 'frm_styles' ) {
422
-                // Properly encode post content before inserting the post
423
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
424
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
425
-
426
-                // Create/update post now
427
-                $post_id = wp_insert_post( $post );
428
-            } else {
429
-                // Create/update post now
430
-                $post_id = wp_insert_post( $post );
431
-            }
432
-
433
-            if ( ! is_numeric($post_id) ) {
434
-                continue;
435
-            }
436
-
437
-            self::update_postmeta($post, $post_id);
438
-
439
-            $this_type = 'posts';
420
+				unset($action_control);
421
+			} else if ( $post['post_type'] == 'frm_styles' ) {
422
+				// Properly encode post content before inserting the post
423
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
424
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
425
+
426
+				// Create/update post now
427
+				$post_id = wp_insert_post( $post );
428
+			} else {
429
+				// Create/update post now
430
+				$post_id = wp_insert_post( $post );
431
+			}
432
+
433
+			if ( ! is_numeric($post_id) ) {
434
+				continue;
435
+			}
436
+
437
+			self::update_postmeta($post, $post_id);
438
+
439
+			$this_type = 'posts';
440 440
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
441 441
 				$this_type = $post_types[ $post['post_type'] ];
442
-            }
442
+			}
443 443
 
444
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
445
-                $imported['updated'][ $this_type ]++;
446
-            } else {
447
-                $imported['imported'][ $this_type ]++;
448
-            }
444
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
445
+				$imported['updated'][ $this_type ]++;
446
+			} else {
447
+				$imported['imported'][ $this_type ]++;
448
+			}
449 449
 
450
-            unset($post);
450
+			unset($post);
451 451
 
452 452
 			$imported['posts'][ (int) $old_id ] = $post_id;
453 453
 		}
@@ -455,157 +455,157 @@  discard block
 block discarded – undo
455 455
 		self::maybe_update_stylesheet( $imported );
456 456
 
457 457
 		return $imported;
458
-    }
458
+	}
459 459
 
460
-    private static function populate_post( &$post, $item, $imported ) {
460
+	private static function populate_post( &$post, $item, $imported ) {
461 461
 		if ( isset($item->attachment_url) ) {
462 462
 			$post['attachment_url'] = (string) $item->attachment_url;
463 463
 		}
464 464
 
465 465
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
466
-		    // update to new form id
467
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
466
+			// update to new form id
467
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
468 468
 		}
469 469
 
470 470
 		foreach ( $item->postmeta as $meta ) {
471
-		    self::populate_postmeta($post, $meta, $imported);
471
+			self::populate_postmeta($post, $meta, $imported);
472 472
 			unset($meta);
473 473
 		}
474 474
 
475
-        self::populate_taxonomies($post, $item);
475
+		self::populate_taxonomies($post, $item);
476 476
 
477
-        self::maybe_editing_post($post);
478
-    }
477
+		self::maybe_editing_post($post);
478
+	}
479 479
 
480
-    private static function populate_postmeta( &$post, $meta, $imported ) {
481
-        global $frm_duplicate_ids;
480
+	private static function populate_postmeta( &$post, $meta, $imported ) {
481
+		global $frm_duplicate_ids;
482 482
 
483
-	    $m = array(
483
+		$m = array(
484 484
 			'key'   => (string) $meta->meta_key,
485 485
 			'value' => (string) $meta->meta_value,
486 486
 		);
487 487
 
488 488
 		//switch old form and field ids to new ones
489 489
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
490
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
490
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
491 491
 		} else {
492
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
492
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
493 493
 
494
-		    if ( ! empty($frm_duplicate_ids) ) {
494
+			if ( ! empty($frm_duplicate_ids) ) {
495 495
 
496
-		        if ( $m['key'] == 'frm_dyncontent' ) {
497
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
498
-    		    } else if ( $m['key'] == 'frm_options' ) {
496
+				if ( $m['key'] == 'frm_dyncontent' ) {
497
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
498
+				} else if ( $m['key'] == 'frm_options' ) {
499 499
 
500 500
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
501 501
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
502 502
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
503
-    		            }
504
-    		        }
505
-
506
-                    $check_dup_array = array();
507
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
508
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
509
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
510
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
511
-                            $check_dup_array[] = 'order_by';
512
-    		            }
513
-    		        }
514
-
515
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
516
-    		            $check_dup_array[] = 'where';
517
-    		        }
518
-
519
-                    foreach ( $check_dup_array as $check_k ) {
503
+						}
504
+					}
505
+
506
+					$check_dup_array = array();
507
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
508
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
509
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
510
+						} else if ( is_array( $m['value']['order_by'] ) ) {
511
+							$check_dup_array[] = 'order_by';
512
+						}
513
+					}
514
+
515
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
516
+						$check_dup_array[] = 'where';
517
+					}
518
+
519
+					foreach ( $check_dup_array as $check_k ) {
520 520
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
521 521
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
522 522
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
523
-		                    }
524
-		                    unset($mk, $mv);
525
-		                }
526
-                    }
527
-    		    }
528
-		    }
523
+							}
524
+							unset($mk, $mv);
525
+						}
526
+					}
527
+				}
528
+			}
529 529
 		}
530 530
 
531 531
 		if ( ! is_array($m['value']) ) {
532
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
532
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
533 533
 		}
534 534
 
535 535
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
536
-    }
537
-
538
-    /**
539
-     * Add terms to post
540
-     * @param array $post by reference
541
-     * @param object $item The XML object data
542
-     */
543
-    private static function populate_taxonomies( &$post, $item ) {
536
+	}
537
+
538
+	/**
539
+	 * Add terms to post
540
+	 * @param array $post by reference
541
+	 * @param object $item The XML object data
542
+	 */
543
+	private static function populate_taxonomies( &$post, $item ) {
544 544
 		foreach ( $item->category as $c ) {
545 545
 			$att = $c->attributes();
546 546
 			if ( ! isset( $att['nicename'] ) ) {
547
-                continue;
548
-            }
549
-
550
-		    $taxonomy = (string) $att['domain'];
551
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
552
-		        $name = (string) $att['nicename'];
553
-		        $h_term = get_term_by('slug', $name, $taxonomy);
554
-		        if ( $h_term ) {
555
-		            $name = $h_term->term_id;
556
-		        }
557
-		        unset($h_term);
558
-		    } else {
559
-		        $name = (string) $c;
560
-		    }
547
+				continue;
548
+			}
549
+
550
+			$taxonomy = (string) $att['domain'];
551
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
552
+				$name = (string) $att['nicename'];
553
+				$h_term = get_term_by('slug', $name, $taxonomy);
554
+				if ( $h_term ) {
555
+					$name = $h_term->term_id;
556
+				}
557
+				unset($h_term);
558
+			} else {
559
+				$name = (string) $c;
560
+			}
561 561
 
562 562
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
563 563
 				$post['tax_input'][ $taxonomy ] = array();
564 564
 			}
565 565
 
566 566
 			$post['tax_input'][ $taxonomy ][] = $name;
567
-		    unset($name);
567
+			unset($name);
568 568
 		}
569
-    }
569
+	}
570 570
 
571
-    /**
572
-     * Edit post if the key and created time match
573
-     */
574
-    private static function maybe_editing_post( &$post ) {
571
+	/**
572
+	 * Edit post if the key and created time match
573
+	 */
574
+	private static function maybe_editing_post( &$post ) {
575 575
 		$match_by = array(
576
-		    'post_type'     => $post['post_type'],
577
-		    'name'          => $post['post_name'],
578
-		    'post_status'   => $post['post_status'],
579
-		    'posts_per_page' => 1,
576
+			'post_type'     => $post['post_type'],
577
+			'name'          => $post['post_name'],
578
+			'post_status'   => $post['post_status'],
579
+			'posts_per_page' => 1,
580 580
 		);
581 581
 
582 582
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
583
-		    $match_by['include'] = $post['post_id'];
584
-		    unset($match_by['name']);
583
+			$match_by['include'] = $post['post_id'];
584
+			unset($match_by['name']);
585 585
 		}
586 586
 
587 587
 		$editing = get_posts($match_by);
588 588
 
589
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
590
-            // set the id of the post to edit
591
-            $post['ID'] = current($editing)->ID;
592
-        }
593
-    }
589
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
590
+			// set the id of the post to edit
591
+			$post['ID'] = current($editing)->ID;
592
+		}
593
+	}
594 594
 
595
-    private static function update_postmeta( &$post, $post_id ) {
596
-        foreach ( $post['postmeta'] as $k => $v ) {
597
-            if ( '_edit_last' == $k ) {
598
-                $v = FrmAppHelper::get_user_id_param($v);
599
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
600
-                //change the attachment ID
601
-                $v = FrmProXMLHelper::get_file_id($v);
602
-            }
595
+	private static function update_postmeta( &$post, $post_id ) {
596
+		foreach ( $post['postmeta'] as $k => $v ) {
597
+			if ( '_edit_last' == $k ) {
598
+				$v = FrmAppHelper::get_user_id_param($v);
599
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
600
+				//change the attachment ID
601
+				$v = FrmProXMLHelper::get_file_id($v);
602
+			}
603 603
 
604
-            update_post_meta($post_id, $k, $v);
604
+			update_post_meta($post_id, $k, $v);
605 605
 
606
-            unset($k, $v);
607
-        }
608
-    }
606
+			unset($k, $v);
607
+		}
608
+	}
609 609
 
610 610
 	private static function maybe_update_stylesheet( $imported ) {
611 611
 		if ( ( isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ) ) || ( isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] ) ) ) {
@@ -616,84 +616,84 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 	}
618 618
 
619
-    /**
620
-     * @param string $message
621
-     */
619
+	/**
620
+	 * @param string $message
621
+	 */
622 622
 	public static function parse_message( $result, &$message, &$errors ) {
623
-        if ( is_wp_error($result) ) {
624
-            $errors[] = $result->get_error_message();
625
-        } else if ( ! $result ) {
626
-            return;
627
-        }
628
-
629
-        if ( ! is_array($result) ) {
630
-            $message = is_string( $result ) ? $result : print_r( $result, 1 );
631
-            return;
632
-        }
633
-
634
-        $t_strings = array(
635
-            'imported'  => __( 'Imported', 'formidable' ),
636
-            'updated'   => __( 'Updated', 'formidable' ),
637
-        );
638
-
639
-        $message = '<ul>';
640
-        foreach ( $result as $type => $results ) {
623
+		if ( is_wp_error($result) ) {
624
+			$errors[] = $result->get_error_message();
625
+		} else if ( ! $result ) {
626
+			return;
627
+		}
628
+
629
+		if ( ! is_array($result) ) {
630
+			$message = is_string( $result ) ? $result : print_r( $result, 1 );
631
+			return;
632
+		}
633
+
634
+		$t_strings = array(
635
+			'imported'  => __( 'Imported', 'formidable' ),
636
+			'updated'   => __( 'Updated', 'formidable' ),
637
+		);
638
+
639
+		$message = '<ul>';
640
+		foreach ( $result as $type => $results ) {
641 641
 			if ( ! isset( $t_strings[ $type ] ) ) {
642
-                // only print imported and updated
643
-                continue;
644
-            }
642
+				// only print imported and updated
643
+				continue;
644
+			}
645 645
 
646
-            $s_message = array();
647
-            foreach ( $results as $k => $m ) {
648
-                self::item_count_message($m, $k, $s_message);
649
-                unset($k, $m);
650
-            }
646
+			$s_message = array();
647
+			foreach ( $results as $k => $m ) {
648
+				self::item_count_message($m, $k, $s_message);
649
+				unset($k, $m);
650
+			}
651 651
 
652
-            if ( ! empty($s_message) ) {
652
+			if ( ! empty($s_message) ) {
653 653
 				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
654
-                $message .= implode(', ', $s_message);
655
-                $message .= '</li>';
656
-            }
657
-        }
658
-
659
-        if ( $message == '<ul>' ) {
660
-            $message = '';
661
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
662
-        } else {
663
-            $message .= '</ul>';
664
-        }
665
-    }
654
+				$message .= implode(', ', $s_message);
655
+				$message .= '</li>';
656
+			}
657
+		}
658
+
659
+		if ( $message == '<ul>' ) {
660
+			$message = '';
661
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
662
+		} else {
663
+			$message .= '</ul>';
664
+		}
665
+	}
666 666
 
667 667
 	public static function item_count_message( $m, $type, &$s_message ) {
668
-        if ( ! $m ) {
669
-            return;
670
-        }
671
-
672
-        $strings = array(
673
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
674
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
675
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
676
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
677
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
678
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
679
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
680
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
681
-        );
668
+		if ( ! $m ) {
669
+			return;
670
+		}
671
+
672
+		$strings = array(
673
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
674
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
675
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
676
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
677
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
678
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
679
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
680
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
681
+		);
682 682
 
683 683
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
684
-    }
684
+	}
685 685
 
686 686
 	public static function cdata( $str ) {
687
-	    $str = maybe_unserialize($str);
688
-	    if ( is_array($str) ) {
689
-	        $str = json_encode($str);
687
+		$str = maybe_unserialize($str);
688
+		if ( is_array($str) ) {
689
+			$str = json_encode($str);
690 690
 		} else if ( seems_utf8( $str ) == false ) {
691 691
 			$str = utf8_encode( $str );
692 692
 		}
693 693
 
694
-        if ( is_numeric($str) ) {
695
-            return $str;
696
-        }
694
+		if ( is_numeric($str) ) {
695
+			return $str;
696
+		}
697 697
 
698 698
 		// $str = ent2ncr(esc_html($str));
699 699
 		$str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
@@ -701,58 +701,58 @@  discard block
 block discarded – undo
701 701
 		return $str;
702 702
 	}
703 703
 
704
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
705
-        // Get post type
706
-        $post_type = FrmFormActionsController::$action_post_type;
707
-
708
-        // Set up imported index, if not set up yet
709
-        if ( ! isset( $imported['imported']['actions'] ) ) {
710
-            $imported['imported']['actions'] = 0;
711
-        }
712
-
713
-        // Migrate post settings to action
714
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
715
-
716
-        // Migrate email settings to action
717
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
718
-    }
719
-
720
-    /**
721
-    * Migrate post settings to form action
722
-    *
723
-    * @param string $post_type
724
-    */
725
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
726
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
727
-            return;
728
-        }
729
-
730
-        $new_action = array(
731
-            'post_type'     => $post_type,
732
-            'post_excerpt'  => 'wppost',
704
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
705
+		// Get post type
706
+		$post_type = FrmFormActionsController::$action_post_type;
707
+
708
+		// Set up imported index, if not set up yet
709
+		if ( ! isset( $imported['imported']['actions'] ) ) {
710
+			$imported['imported']['actions'] = 0;
711
+		}
712
+
713
+		// Migrate post settings to action
714
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
715
+
716
+		// Migrate email settings to action
717
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
718
+	}
719
+
720
+	/**
721
+	 * Migrate post settings to form action
722
+	 *
723
+	 * @param string $post_type
724
+	 */
725
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
726
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
727
+			return;
728
+		}
729
+
730
+		$new_action = array(
731
+			'post_type'     => $post_type,
732
+			'post_excerpt'  => 'wppost',
733 733
 			'post_title'    => __( 'Create Posts', 'formidable' ),
734
-            'menu_order'    => $form_id,
735
-            'post_status'   => 'publish',
736
-            'post_content'  => array(),
737
-            'post_name'     => $form_id .'_wppost_1',
738
-        );
739
-
740
-        $post_settings = array(
741
-            'post_type', 'post_category', 'post_content',
742
-            'post_excerpt', 'post_title', 'post_name', 'post_date',
734
+			'menu_order'    => $form_id,
735
+			'post_status'   => 'publish',
736
+			'post_content'  => array(),
737
+			'post_name'     => $form_id .'_wppost_1',
738
+		);
739
+
740
+		$post_settings = array(
741
+			'post_type', 'post_category', 'post_content',
742
+			'post_excerpt', 'post_title', 'post_name', 'post_date',
743 743
 			'post_status', 'post_custom_fields', 'post_password',
744
-        );
744
+		);
745 745
 
746
-        foreach ( $post_settings as $post_setting ) {
746
+		foreach ( $post_settings as $post_setting ) {
747 747
 			if ( isset( $form_options[ $post_setting ] ) ) {
748 748
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
749
-            }
750
-            unset($post_setting);
751
-        }
749
+			}
750
+			unset($post_setting);
751
+		}
752 752
 
753 753
 		$new_action['event'] = array( 'create', 'update' );
754 754
 
755
-        if ( $switch ) {
755
+		if ( $switch ) {
756 756
 			// Fields with string or int saved
757 757
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
758 758
 
@@ -760,22 +760,22 @@  discard block
 block discarded – undo
760 760
 			$array_fields = array( 'post_category', 'post_custom_fields' );
761 761
 
762 762
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
763
-        }
764
-        $new_action['post_content'] = json_encode($new_action['post_content']);
763
+		}
764
+		$new_action['post_content'] = json_encode($new_action['post_content']);
765 765
 
766
-        $exists = get_posts( array(
767
-            'name'          => $new_action['post_name'],
768
-            'post_type'     => $new_action['post_type'],
769
-            'post_status'   => $new_action['post_status'],
770
-            'numberposts'   => 1,
771
-        ) );
766
+		$exists = get_posts( array(
767
+			'name'          => $new_action['post_name'],
768
+			'post_type'     => $new_action['post_type'],
769
+			'post_status'   => $new_action['post_status'],
770
+			'numberposts'   => 1,
771
+		) );
772 772
 
773
-        if ( ! $exists ) {
773
+		if ( ! $exists ) {
774 774
 			// this isn't an email, but we need to use a class that will always be included
775 775
 			FrmAppHelper::save_json_post( $new_action );
776
-            $imported['imported']['actions']++;
777
-        }
778
-    }
776
+			$imported['imported']['actions']++;
777
+		}
778
+	}
779 779
 
780 780
 	/**
781 781
 	 * Switch old field IDs for new field IDs in emails and post
@@ -788,211 +788,211 @@  discard block
 block discarded – undo
788 788
 	 * @return string $post_content - new field IDs
789 789
 	 */
790 790
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
791
-        global $frm_duplicate_ids;
791
+		global $frm_duplicate_ids;
792 792
 
793
-        // If there aren't IDs that were switched, end now
794
-        if ( ! $frm_duplicate_ids ) {
795
-            return;
796
-        }
793
+		// If there aren't IDs that were switched, end now
794
+		if ( ! $frm_duplicate_ids ) {
795
+			return;
796
+		}
797 797
 
798
-        // Get old IDs
799
-        $old = array_keys( $frm_duplicate_ids );
798
+		// Get old IDs
799
+		$old = array_keys( $frm_duplicate_ids );
800 800
 
801
-        // Get new IDs
802
-        $new = array_values( $frm_duplicate_ids );
801
+		// Get new IDs
802
+		$new = array_values( $frm_duplicate_ids );
803 803
 
804
-        // Do a str_replace with each item to set the new IDs
805
-        foreach ( $post_content as $key => $setting ) {
806
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
807
-                // Replace old IDs with new IDs
804
+		// Do a str_replace with each item to set the new IDs
805
+		foreach ( $post_content as $key => $setting ) {
806
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
807
+				// Replace old IDs with new IDs
808 808
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
809
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
810
-                foreach ( $setting as $k => $val ) {
811
-                    // Replace old IDs with new IDs
809
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
810
+				foreach ( $setting as $k => $val ) {
811
+					// Replace old IDs with new IDs
812 812
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
813
-                }
814
-            }
815
-            unset( $key, $setting );
816
-        }
817
-        return $post_content;
818
-    }
819
-
820
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
821
-        // No old notifications or autoresponders to carry over
813
+				}
814
+			}
815
+			unset( $key, $setting );
816
+		}
817
+		return $post_content;
818
+	}
819
+
820
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
821
+		// No old notifications or autoresponders to carry over
822 822
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
823
-            return;
824
-        }
823
+			return;
824
+		}
825 825
 
826
-        // Initialize notifications array
827
-        $notifications = array();
826
+		// Initialize notifications array
827
+		$notifications = array();
828 828
 
829
-        // Migrate regular notifications
830
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
829
+		// Migrate regular notifications
830
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
831 831
 
832
-        // Migrate autoresponders
833
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
832
+		// Migrate autoresponders
833
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
834 834
 
835
-        if (  empty( $notifications ) ) {
836
-            return;
837
-        }
835
+		if (  empty( $notifications ) ) {
836
+			return;
837
+		}
838 838
 
839
-        foreach ( $notifications as $new_notification ) {
840
-            $new_notification['post_type']      = $post_type;
841
-            $new_notification['post_excerpt']   = 'email';
839
+		foreach ( $notifications as $new_notification ) {
840
+			$new_notification['post_type']      = $post_type;
841
+			$new_notification['post_excerpt']   = 'email';
842 842
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
843
-            $new_notification['menu_order']     = $form_id;
844
-            $new_notification['post_status']    = 'publish';
843
+			$new_notification['menu_order']     = $form_id;
844
+			$new_notification['post_status']    = 'publish';
845 845
 
846
-            // Switch field IDs and keys, if needed
847
-            if ( $switch ) {
846
+			// Switch field IDs and keys, if needed
847
+			if ( $switch ) {
848 848
 
849 849
 				// Switch field IDs in email conditional logic
850 850
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
851 851
 
852 852
 				// Switch all other field IDs in email
853
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
854
-            }
855
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
856
-
857
-            $exists = get_posts( array(
858
-                'name'          => $new_notification['post_name'],
859
-                'post_type'     => $new_notification['post_type'],
860
-                'post_status'   => $new_notification['post_status'],
861
-                'numberposts'   => 1,
862
-            ) );
863
-
864
-            if ( empty($exists) ) {
853
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
854
+			}
855
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
856
+
857
+			$exists = get_posts( array(
858
+				'name'          => $new_notification['post_name'],
859
+				'post_type'     => $new_notification['post_type'],
860
+				'post_status'   => $new_notification['post_status'],
861
+				'numberposts'   => 1,
862
+			) );
863
+
864
+			if ( empty($exists) ) {
865 865
 				FrmAppHelper::save_json_post( $new_notification );
866
-                $imported['imported']['actions']++;
867
-            }
868
-            unset($new_notification);
869
-        }
870
-    }
871
-
872
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
873
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
874
-            // add old settings into notification array
866
+				$imported['imported']['actions']++;
867
+			}
868
+			unset($new_notification);
869
+		}
870
+	}
871
+
872
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
873
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
874
+			// add old settings into notification array
875 875
 			$form_options['notification'] = array( 0 => $form_options );
876
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
877
-            // make sure it's in the correct format
876
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
877
+			// make sure it's in the correct format
878 878
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
879
-        }
879
+		}
880 880
 
881
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
882
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
881
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
882
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
883 883
 
884
-                $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
884
+				$atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
885 885
 
886
-                // Format the email data
887
-                self::format_email_data( $atts, $notification );
886
+				// Format the email data
887
+				self::format_email_data( $atts, $notification );
888 888
 
889 889
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
890 890
 					do_action( 'frm_create_twilio_action', $atts, $notification );
891 891
 				}
892 892
 
893
-                // Setup the new notification
894
-                $new_notification = array();
895
-                self::setup_new_notification( $new_notification, $notification, $atts );
893
+				// Setup the new notification
894
+				$new_notification = array();
895
+				self::setup_new_notification( $new_notification, $notification, $atts );
896 896
 
897
-                $notifications[] = $new_notification;
898
-            }
899
-        }
900
-    }
897
+				$notifications[] = $new_notification;
898
+			}
899
+		}
900
+	}
901 901
 
902
-    private static function format_email_data( &$atts, $notification ) {
903
-        // Format email_to
904
-        self::format_email_to_data( $atts, $notification );
902
+	private static function format_email_data( &$atts, $notification ) {
903
+		// Format email_to
904
+		self::format_email_to_data( $atts, $notification );
905 905
 
906
-        // Format the reply to email and name
907
-        $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
908
-        foreach ( $reply_fields as $f => $val ) {
906
+		// Format the reply to email and name
907
+		$reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
908
+		foreach ( $reply_fields as $f => $val ) {
909 909
 			if ( isset( $notification[ $f ] ) ) {
910 910
 				$atts[ $f ] = $notification[ $f ];
911 911
 				if ( 'custom' == $notification[ $f ] ) {
912 912
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
913 913
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
914 914
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
915
-                }
916
-            }
917
-            unset( $f, $val );
918
-        }
915
+				}
916
+			}
917
+			unset( $f, $val );
918
+		}
919 919
 
920
-        // Format event
920
+		// Format event
921 921
 		$atts['event'] = array( 'create' );
922
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
923
-            $atts['event'][] = 'update';
924
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
922
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
923
+			$atts['event'][] = 'update';
924
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
925 925
 			$atts['event'] = array( 'update' );
926
-        }
927
-    }
926
+		}
927
+	}
928 928
 
929
-    private static function format_email_to_data( &$atts, $notification ) {
930
-        if ( isset( $notification['email_to'] ) ) {
929
+	private static function format_email_to_data( &$atts, $notification ) {
930
+		if ( isset( $notification['email_to'] ) ) {
931 931
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
932
-        } else {
933
-            $atts['email_to'] = array();
934
-        }
932
+		} else {
933
+			$atts['email_to'] = array();
934
+		}
935 935
 
936
-        if ( isset( $notification['also_email_to'] ) ) {
937
-            $email_fields = (array) $notification['also_email_to'];
938
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
939
-            unset( $email_fields );
940
-        }
936
+		if ( isset( $notification['also_email_to'] ) ) {
937
+			$email_fields = (array) $notification['also_email_to'];
938
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
939
+			unset( $email_fields );
940
+		}
941 941
 
942
-        foreach ( $atts['email_to'] as $key => $email_field ) {
942
+		foreach ( $atts['email_to'] as $key => $email_field ) {
943 943
 
944
-            if ( is_numeric( $email_field ) ) {
944
+			if ( is_numeric( $email_field ) ) {
945 945
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
946
-            }
946
+			}
947 947
 
948
-            if ( strpos( $email_field, '|') ) {
949
-                $email_opt = explode( '|', $email_field );
950
-                if ( isset( $email_opt[0] ) ) {
948
+			if ( strpos( $email_field, '|') ) {
949
+				$email_opt = explode( '|', $email_field );
950
+				if ( isset( $email_opt[0] ) ) {
951 951
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
952
-                }
953
-                unset( $email_opt );
954
-            }
955
-        }
956
-        $atts['email_to'] = implode(', ', $atts['email_to']);
957
-    }
958
-
959
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
960
-        // Set up new notification
961
-        $new_notification = array(
962
-            'post_content'  => array(
963
-                'email_to'      => $atts['email_to'],
964
-                'event'         => $atts['event'],
965
-            ),
966
-            'post_name'         => $atts['form_id'] .'_email_'. $atts['email_key'],
967
-        );
968
-
969
-        // Add more fields to the new notification
970
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
971
-        foreach ( $add_fields as $add_field ) {
952
+				}
953
+				unset( $email_opt );
954
+			}
955
+		}
956
+		$atts['email_to'] = implode(', ', $atts['email_to']);
957
+	}
958
+
959
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
960
+		// Set up new notification
961
+		$new_notification = array(
962
+			'post_content'  => array(
963
+				'email_to'      => $atts['email_to'],
964
+				'event'         => $atts['event'],
965
+			),
966
+			'post_name'         => $atts['form_id'] .'_email_'. $atts['email_key'],
967
+		);
968
+
969
+		// Add more fields to the new notification
970
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
971
+		foreach ( $add_fields as $add_field ) {
972 972
 			if ( isset( $notification[ $add_field ] ) ) {
973 973
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
974
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
974
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
975 975
 				$new_notification['post_content'][ $add_field ] = 0;
976
-            } else {
976
+			} else {
977 977
 				$new_notification['post_content'][ $add_field ] = '';
978
-            }
979
-            unset( $add_field );
980
-        }
978
+			}
979
+			unset( $add_field );
980
+		}
981 981
 
982 982
 		// Set reply to
983 983
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
984 984
 
985
-        // Set from
985
+		// Set from
986 986
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
987
-            $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
988
-        }
989
-    }
987
+			$new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
988
+		}
989
+	}
990 990
 
991 991
 	/**
992
-	* Switch field IDs in pre-2.0 email conditional logic
993
-	*
994
-	* @param $post_content array, pass by reference
995
-	*/
992
+	 * Switch field IDs in pre-2.0 email conditional logic
993
+	 *
994
+	 * @param $post_content array, pass by reference
995
+	 */
996 996
 	private static function switch_email_contition_field_ids( &$post_content ) {
997 997
 		// Switch field IDs in conditional logic
998 998
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1005,48 +1005,48 @@  discard block
 block discarded – undo
1005 1005
 		}
1006 1006
 	}
1007 1007
 
1008
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1009
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1010
-            // migrate autoresponder
1011
-
1012
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1013
-            if ( strpos($email_field, '|') ) {
1014
-                // data from entries field
1015
-                $email_field = explode('|', $email_field);
1016
-                if ( isset($email_field[1]) ) {
1017
-                    $email_field = $email_field[1];
1018
-                }
1019
-            }
1020
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1021
-                $email_field = '['. $email_field .']';
1022
-            }
1023
-
1024
-            $notification = $form_options;
1025
-            $new_notification2 = array(
1026
-                'post_content'  => array(
1027
-                    'email_message' => $notification['ar_email_message'],
1028
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1029
-                    'email_to'      => $email_field,
1030
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1031
-                    'inc_user_info' => 0,
1032
-                ),
1033
-                'post_name'     => $form_id .'_email_'. count( $notifications ),
1034
-            );
1035
-
1036
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1037
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1008
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1009
+		if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1010
+			// migrate autoresponder
1011
+
1012
+			$email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1013
+			if ( strpos($email_field, '|') ) {
1014
+				// data from entries field
1015
+				$email_field = explode('|', $email_field);
1016
+				if ( isset($email_field[1]) ) {
1017
+					$email_field = $email_field[1];
1018
+				}
1019
+			}
1020
+			if ( is_numeric($email_field) && ! empty($email_field) ) {
1021
+				$email_field = '['. $email_field .']';
1022
+			}
1023
+
1024
+			$notification = $form_options;
1025
+			$new_notification2 = array(
1026
+				'post_content'  => array(
1027
+					'email_message' => $notification['ar_email_message'],
1028
+					'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1029
+					'email_to'      => $email_field,
1030
+					'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1031
+					'inc_user_info' => 0,
1032
+				),
1033
+				'post_name'     => $form_id .'_email_'. count( $notifications ),
1034
+			);
1035
+
1036
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1037
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1038 1038
 
1039 1039
 			if ( ! empty( $reply_to ) ) {
1040 1040
 				$new_notification2['post_content']['reply_to'] = $reply_to;
1041 1041
 			}
1042 1042
 
1043 1043
 			if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) {
1044
-                $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>';
1044
+				$new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>';
1045 1045
 			}
1046 1046
 
1047
-            $notifications[] = $new_notification2;
1048
-            unset( $new_notification2 );
1049
-        }
1050
-    }
1047
+			$notifications[] = $new_notification2;
1048
+			unset( $new_notification2 );
1049
+		}
1050
+	}
1051 1051
 }
1052 1052
 
Please login to merge, or discard this patch.
Spacing   +175 added lines, -175 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 				echo "\n" . $padding;
12 12
 				$tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok;
13 13
 				echo '<' . $tag . '>';
14
-				self::get_xml_values( $ov, $padding .'    ' );
14
+				self::get_xml_values( $ov, $padding . '    ' );
15 15
 				if ( is_array( $ov ) ) {
16 16
 					echo "\n" . $padding;
17 17
 				}
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 			'terms'    => array(),
37 37
         );
38 38
 
39
-        unset($defaults);
39
+        unset( $defaults );
40 40
 
41 41
 		if ( ! defined( 'WP_IMPORTING' ) ) {
42
-            define('WP_IMPORTING', true);
42
+            define( 'WP_IMPORTING', true );
43 43
         }
44 44
 
45 45
 		if ( ! class_exists( 'DOMDocument' ) ) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
53 53
 		}
54 54
 
55
-		if ( ! function_exists('simplexml_import_dom') ) {
55
+		if ( ! function_exists( 'simplexml_import_dom' ) ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() );
57 57
 		}
58 58
 
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
         // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
68 68
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
69 69
             // grab cats, tags, and terms, or forms or posts
70
-            if ( isset($xml->{$item_type} ) ) {
70
+            if ( isset( $xml->{$item_type} ) ) {
71 71
 				$function_name = 'import_xml_' . $item_type . 's';
72 72
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
73 73
 				unset( $function_name, $xml->{$item_type} );
74 74
             }
75 75
         }
76 76
 
77
-	    $return = apply_filters('frm_importing_xml', $imported, $xml );
77
+	    $return = apply_filters( 'frm_importing_xml', $imported, $xml );
78 78
 
79 79
 	    return $return;
80 80
     }
81 81
 
82 82
 	public static function import_xml_terms( $terms, $imported ) {
83 83
         foreach ( $terms as $t ) {
84
-			if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) {
84
+			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
85 85
 			    continue;
86 86
 			}
87 87
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
                 'description'   => (string) $t->term_description,
93 93
 				'parent'        => empty( $parent ) ? 0 : $parent,
94 94
                 'slug'          => (string) $t->term_slug,
95
-            ));
95
+            ) );
96 96
 
97 97
 			if ( $term && is_array( $term ) ) {
98
-                $imported['imported']['terms']++;
99
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
98
+                $imported['imported']['terms'] ++;
99
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
100 100
             }
101 101
 
102 102
 			unset( $term, $t );
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
                 'default_template' => (int) $item->default_template,
140 140
                 'editable'      => (int) $item->editable,
141 141
                 'status'        => (string) $item->status,
142
-                'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0,
143
-                'created_at'    => date('Y-m-d H:i:s', strtotime((string) $item->created_at)),
142
+                'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
143
+                'created_at'    => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ),
144 144
             );
145 145
 
146
-            $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
146
+            $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] );
147 147
 
148 148
             // if template, allow to edit if form keys match, otherwise, creation date must also match
149 149
 			$edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] );
@@ -151,35 +151,35 @@  discard block
 block discarded – undo
151 151
                 $edit_query['created_at'] = $form['created_at'];
152 152
             }
153 153
 
154
-            $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
154
+            $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form );
155 155
 
156
-            $this_form = FrmForm::getAll($edit_query, '', 1);
157
-            unset($edit_query);
156
+            $this_form = FrmForm::getAll( $edit_query, '', 1 );
157
+            unset( $edit_query );
158 158
 
159 159
             if ( ! empty( $this_form ) ) {
160 160
                 $old_id = $form_id = $this_form->id;
161
-                FrmForm::update($form_id, $form );
162
-                $imported['updated']['forms']++;
161
+                FrmForm::update( $form_id, $form );
162
+                $imported['updated']['forms'] ++;
163 163
                 // Keep track of whether this specific form was updated or not
164
-				$imported['form_status'][ $form_id ] = 'updated';
164
+				$imported['form_status'][$form_id] = 'updated';
165 165
 
166 166
 				$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
167 167
                 $old_fields = array();
168 168
                 foreach ( $form_fields as $f ) {
169
-					$old_fields[ $f->id ] = $f;
170
-					$old_fields[ $f->field_key ] = $f->id;
171
-                    unset($f);
169
+					$old_fields[$f->id] = $f;
170
+					$old_fields[$f->field_key] = $f->id;
171
+                    unset( $f );
172 172
                 }
173 173
                 $form_fields = $old_fields;
174
-                unset($old_fields);
174
+                unset( $old_fields );
175 175
             } else {
176 176
                 $old_id = false;
177 177
                 //form does not exist, so create it
178 178
 				$form_id = FrmForm::create( $form );
179 179
                 if ( $form_id ) {
180
-                    $imported['imported']['forms']++;
180
+                    $imported['imported']['forms'] ++;
181 181
                     // Keep track of whether this specific form was updated or not
182
-					$imported['form_status'][ $form_id ] = 'imported';
182
+					$imported['form_status'][$form_id] = 'imported';
183 183
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
184 184
                 }
185 185
             }
@@ -189,23 +189,23 @@  discard block
 block discarded – undo
189 189
     		// Delete any fields attached to this form that were not included in the template
190 190
     		if ( isset( $form_fields ) && ! empty( $form_fields ) ) {
191 191
 				foreach ( $form_fields as $field ) {
192
-                    if ( is_object($field) ) {
193
-                        FrmField::destroy($field->id);
192
+                    if ( is_object( $field ) ) {
193
+                        FrmField::destroy( $field->id );
194 194
                     }
195
-                    unset($field);
195
+                    unset( $field );
196 196
                 }
197
-                unset($form_fields);
197
+                unset( $form_fields );
198 198
             }
199 199
 
200 200
 		    // Update field ids/keys to new ones
201 201
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
202 202
 
203
-			$imported['forms'][ (int) $item->id ] = $form_id;
203
+			$imported['forms'][(int) $item->id] = $form_id;
204 204
 
205 205
             // Send pre 2.0 form options through function that creates actions
206 206
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true );
207 207
 
208
-		    unset($form, $item);
208
+		    unset( $form, $item );
209 209
 		}
210 210
 
211 211
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$regular_forms = array();
225 225
 
226 226
 		foreach ( $forms as $form ) {
227
-			$parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0;
227
+			$parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0;
228 228
 
229 229
 			if ( $parent_form_id ) {
230 230
 				$child_forms[] = $form;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	*/
247 247
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
248 248
 		if ( $parent_form_id ) {
249
-			$child_forms[ $form_id ] = $parent_form_id;
249
+			$child_forms[$form_id] = $parent_form_id;
250 250
 		}
251 251
 	}
252 252
 
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
262 262
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
263 263
 
264
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
264
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
265 265
 				// Update all children with this old parent_form_id
266
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
266
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
267 267
 
268 268
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
269 269
 			}
@@ -284,51 +284,51 @@  discard block
 block discarded – undo
284 284
 		        'name'          => (string) $field->name,
285 285
 		        'description'   => (string) $field->description,
286 286
 		        'type'          => (string) $field->type,
287
-		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value),
287
+		        'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ),
288 288
 		        'field_order'   => (int) $field->field_order,
289 289
 		        'form_id'       => (int) $form_id,
290 290
 		        'required'      => (int) $field->required,
291
-		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options),
291
+		        'options'       => FrmAppHelper::maybe_json_decode( (string) $field->options ),
292 292
 				'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ),
293 293
 		    );
294 294
 
295
-		    if ( is_array($f['default_value']) && in_array($f['type'], array(
295
+		    if ( is_array( $f['default_value'] ) && in_array( $f['type'], array(
296 296
 		        'text', 'email', 'url', 'textarea',
297
-		        'number','phone', 'date', 'time',
297
+		        'number', 'phone', 'date', 'time',
298 298
 		        'hidden', 'password', 'tag', 'image',
299
-		    )) ) {
300
-		        if ( count($f['default_value']) === 1 ) {
301
-		            $f['default_value'] = '['. reset($f['default_value']) .']';
299
+		    ) ) ) {
300
+		        if ( count( $f['default_value'] ) === 1 ) {
301
+		            $f['default_value'] = '[' . reset( $f['default_value'] ) . ']';
302 302
 		        } else {
303
-		            $f['default_value'] = reset($f['default_value']);
303
+		            $f['default_value'] = reset( $f['default_value'] );
304 304
 		        }
305 305
 		    }
306 306
 
307
-		    $f = apply_filters('frm_duplicated_field', $f);
307
+		    $f = apply_filters( 'frm_duplicated_field', $f );
308 308
 
309 309
 			self::maybe_update_form_select( $f, $imported );
310 310
 
311
-		    if ( ! empty($this_form) ) {
311
+		    if ( ! empty( $this_form ) ) {
312 312
 		        // check for field to edit by field id
313
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
313
+				if ( isset( $form_fields[$f['id']] ) ) {
314 314
 		            FrmField::update( $f['id'], $f );
315
-		            $imported['updated']['fields']++;
315
+		            $imported['updated']['fields'] ++;
316 316
 
317
-					unset( $form_fields[ $f['id'] ] );
317
+					unset( $form_fields[$f['id']] );
318 318
 
319 319
 		            //unset old field key
320
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
321
-						unset( $form_fields[ $f['field_key'] ] );
320
+					if ( isset( $form_fields[$f['field_key']] ) ) {
321
+						unset( $form_fields[$f['field_key']] );
322 322
 					}
323
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
323
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
324 324
 		            // check for field to edit by field key
325
-		            unset($f['id']);
325
+		            unset( $f['id'] );
326 326
 
327
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
328
-		            $imported['updated']['fields']++;
327
+					FrmField::update( $form_fields[$f['field_key']], $f );
328
+		            $imported['updated']['fields'] ++;
329 329
 
330
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
331
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
330
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
331
+					unset( $form_fields[$f['field_key']] ); //unset old field key
332 332
 				} else {
333 333
 					$new_id = FrmField::create( $f );
334 334
 					if ( $new_id == false ) {
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 					}
337 337
 
338 338
 		            // if no matching field id or key in this form, create the field
339
-		            $imported['imported']['fields']++;
339
+		            $imported['imported']['fields'] ++;
340 340
 		        }
341 341
 			} else {
342 342
 				$new_id = FrmField::create( $f );
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 					continue;
345 345
 				}
346 346
 
347
-	            $imported['imported']['fields']++;
347
+	            $imported['imported']['fields'] ++;
348 348
 		    }
349 349
 
350
-			unset($field, $new_id);
350
+			unset( $field, $new_id );
351 351
 		}
352 352
 	}
353 353
 
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
367 367
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
368 368
 				$form_select = $f['field_options']['form_select'];
369
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
370
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
369
+				if ( isset( $imported['forms'][$form_select] ) ) {
370
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
371 371
 				}
372 372
 			}
373 373
 		}
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 				'post_id'       => (int) $item->post_id,
396 396
 				'post_parent'   => (int) $item->post_parent,
397 397
 				'menu_order'    => (int) $item->menu_order,
398
-				'post_content'  => FrmFieldsHelper::switch_field_ids((string) $item->content),
399
-				'post_excerpt'  => FrmFieldsHelper::switch_field_ids((string) $item->excerpt),
398
+				'post_content'  => FrmFieldsHelper::switch_field_ids( (string) $item->content ),
399
+				'post_excerpt'  => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ),
400 400
 				'is_sticky'     => (string) $item->is_sticky,
401 401
 				'comment_status' => (string) $item->comment_status,
402 402
 				'post_date'     => (string) $item->post_date,
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 			);
408 408
 
409 409
             $old_id = $post['post_id'];
410
-            self::populate_post($post, $item, $imported);
410
+            self::populate_post( $post, $item, $imported );
411 411
 
412
-			unset($item);
412
+			unset( $item );
413 413
 
414 414
 			$post_id = false;
415 415
             if ( $post['post_type'] == $form_action_type ) {
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				if ( $action_control ) {
418 418
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
419 419
 				}
420
-                unset($action_control);
420
+                unset( $action_control );
421 421
             } else if ( $post['post_type'] == 'frm_styles' ) {
422 422
                 // Properly encode post content before inserting the post
423 423
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -430,26 +430,26 @@  discard block
 block discarded – undo
430 430
                 $post_id = wp_insert_post( $post );
431 431
             }
432 432
 
433
-            if ( ! is_numeric($post_id) ) {
433
+            if ( ! is_numeric( $post_id ) ) {
434 434
                 continue;
435 435
             }
436 436
 
437
-            self::update_postmeta($post, $post_id);
437
+            self::update_postmeta( $post, $post_id );
438 438
 
439 439
             $this_type = 'posts';
440
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
441
-				$this_type = $post_types[ $post['post_type'] ];
440
+			if ( isset( $post_types[$post['post_type']] ) ) {
441
+				$this_type = $post_types[$post['post_type']];
442 442
             }
443 443
 
444
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
445
-                $imported['updated'][ $this_type ]++;
444
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
445
+                $imported['updated'][$this_type] ++;
446 446
             } else {
447
-                $imported['imported'][ $this_type ]++;
447
+                $imported['imported'][$this_type] ++;
448 448
             }
449 449
 
450
-            unset($post);
450
+            unset( $post );
451 451
 
452
-			$imported['posts'][ (int) $old_id ] = $post_id;
452
+			$imported['posts'][(int) $old_id] = $post_id;
453 453
 		}
454 454
 
455 455
 		self::maybe_update_stylesheet( $imported );
@@ -458,23 +458,23 @@  discard block
 block discarded – undo
458 458
     }
459 459
 
460 460
     private static function populate_post( &$post, $item, $imported ) {
461
-		if ( isset($item->attachment_url) ) {
461
+		if ( isset( $item->attachment_url ) ) {
462 462
 			$post['attachment_url'] = (string) $item->attachment_url;
463 463
 		}
464 464
 
465
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
465
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
466 466
 		    // update to new form id
467
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
467
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
468 468
 		}
469 469
 
470 470
 		foreach ( $item->postmeta as $meta ) {
471
-		    self::populate_postmeta($post, $meta, $imported);
472
-			unset($meta);
471
+		    self::populate_postmeta( $post, $meta, $imported );
472
+			unset( $meta );
473 473
 		}
474 474
 
475
-        self::populate_taxonomies($post, $item);
475
+        self::populate_taxonomies( $post, $item );
476 476
 
477
-        self::maybe_editing_post($post);
477
+        self::maybe_editing_post( $post );
478 478
     }
479 479
 
480 480
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -486,27 +486,27 @@  discard block
 block discarded – undo
486 486
 		);
487 487
 
488 488
 		//switch old form and field ids to new ones
489
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
490
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
489
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
490
+		    $m['value'] = $imported['forms'][(int) $m['value']];
491 491
 		} else {
492
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
492
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
493 493
 
494
-		    if ( ! empty($frm_duplicate_ids) ) {
494
+		    if ( ! empty( $frm_duplicate_ids ) ) {
495 495
 
496 496
 		        if ( $m['key'] == 'frm_dyncontent' ) {
497
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
497
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
498 498
     		    } else if ( $m['key'] == 'frm_options' ) {
499 499
 
500 500
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
501
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
502
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
501
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
502
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
503 503
     		            }
504 504
     		        }
505 505
 
506 506
                     $check_dup_array = array();
507 507
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
508
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
509
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
508
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
509
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
510 510
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
511 511
                             $check_dup_array[] = 'order_by';
512 512
     		            }
@@ -517,22 +517,22 @@  discard block
 block discarded – undo
517 517
     		        }
518 518
 
519 519
                     foreach ( $check_dup_array as $check_k ) {
520
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
521
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
522
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
520
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
521
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
522
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
523 523
 		                    }
524
-		                    unset($mk, $mv);
524
+		                    unset( $mk, $mv );
525 525
 		                }
526 526
                     }
527 527
     		    }
528 528
 		    }
529 529
 		}
530 530
 
531
-		if ( ! is_array($m['value']) ) {
532
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
531
+		if ( ! is_array( $m['value'] ) ) {
532
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
533 533
 		}
534 534
 
535
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
535
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
536 536
     }
537 537
 
538 538
     /**
@@ -548,23 +548,23 @@  discard block
 block discarded – undo
548 548
             }
549 549
 
550 550
 		    $taxonomy = (string) $att['domain'];
551
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
551
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
552 552
 		        $name = (string) $att['nicename'];
553
-		        $h_term = get_term_by('slug', $name, $taxonomy);
553
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
554 554
 		        if ( $h_term ) {
555 555
 		            $name = $h_term->term_id;
556 556
 		        }
557
-		        unset($h_term);
557
+		        unset( $h_term );
558 558
 		    } else {
559 559
 		        $name = (string) $c;
560 560
 		    }
561 561
 
562
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
563
-				$post['tax_input'][ $taxonomy ] = array();
562
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
563
+				$post['tax_input'][$taxonomy] = array();
564 564
 			}
565 565
 
566
-			$post['tax_input'][ $taxonomy ][] = $name;
567
-		    unset($name);
566
+			$post['tax_input'][$taxonomy][] = $name;
567
+		    unset( $name );
568 568
 		}
569 569
     }
570 570
 
@@ -581,29 +581,29 @@  discard block
 block discarded – undo
581 581
 
582 582
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
583 583
 		    $match_by['include'] = $post['post_id'];
584
-		    unset($match_by['name']);
584
+		    unset( $match_by['name'] );
585 585
 		}
586 586
 
587
-		$editing = get_posts($match_by);
587
+		$editing = get_posts( $match_by );
588 588
 
589
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
589
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
590 590
             // set the id of the post to edit
591
-            $post['ID'] = current($editing)->ID;
591
+            $post['ID'] = current( $editing )->ID;
592 592
         }
593 593
     }
594 594
 
595 595
     private static function update_postmeta( &$post, $post_id ) {
596 596
         foreach ( $post['postmeta'] as $k => $v ) {
597 597
             if ( '_edit_last' == $k ) {
598
-                $v = FrmAppHelper::get_user_id_param($v);
598
+                $v = FrmAppHelper::get_user_id_param( $v );
599 599
             } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
600 600
                 //change the attachment ID
601
-                $v = FrmProXMLHelper::get_file_id($v);
601
+                $v = FrmProXMLHelper::get_file_id( $v );
602 602
             }
603 603
 
604
-            update_post_meta($post_id, $k, $v);
604
+            update_post_meta( $post_id, $k, $v );
605 605
 
606
-            unset($k, $v);
606
+            unset( $k, $v );
607 607
         }
608 608
     }
609 609
 
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
      * @param string $message
621 621
      */
622 622
 	public static function parse_message( $result, &$message, &$errors ) {
623
-        if ( is_wp_error($result) ) {
623
+        if ( is_wp_error( $result ) ) {
624 624
             $errors[] = $result->get_error_message();
625 625
         } else if ( ! $result ) {
626 626
             return;
627 627
         }
628 628
 
629
-        if ( ! is_array($result) ) {
629
+        if ( ! is_array( $result ) ) {
630 630
             $message = is_string( $result ) ? $result : print_r( $result, 1 );
631 631
             return;
632 632
         }
@@ -638,20 +638,20 @@  discard block
 block discarded – undo
638 638
 
639 639
         $message = '<ul>';
640 640
         foreach ( $result as $type => $results ) {
641
-			if ( ! isset( $t_strings[ $type ] ) ) {
641
+			if ( ! isset( $t_strings[$type] ) ) {
642 642
                 // only print imported and updated
643 643
                 continue;
644 644
             }
645 645
 
646 646
             $s_message = array();
647 647
             foreach ( $results as $k => $m ) {
648
-                self::item_count_message($m, $k, $s_message);
649
-                unset($k, $m);
648
+                self::item_count_message( $m, $k, $s_message );
649
+                unset( $k, $m );
650 650
             }
651 651
 
652
-            if ( ! empty($s_message) ) {
653
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
654
-                $message .= implode(', ', $s_message);
652
+            if ( ! empty( $s_message ) ) {
653
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
654
+                $message .= implode( ', ', $s_message );
655 655
                 $message .= '</li>';
656 656
             }
657 657
         }
@@ -680,18 +680,18 @@  discard block
 block discarded – undo
680 680
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
681 681
         );
682 682
 
683
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
683
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
684 684
     }
685 685
 
686 686
 	public static function cdata( $str ) {
687
-	    $str = maybe_unserialize($str);
688
-	    if ( is_array($str) ) {
689
-	        $str = json_encode($str);
687
+	    $str = maybe_unserialize( $str );
688
+	    if ( is_array( $str ) ) {
689
+	        $str = json_encode( $str );
690 690
 		} else if ( seems_utf8( $str ) == false ) {
691 691
 			$str = utf8_encode( $str );
692 692
 		}
693 693
 
694
-        if ( is_numeric($str) ) {
694
+        if ( is_numeric( $str ) ) {
695 695
             return $str;
696 696
         }
697 697
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     * @param string $post_type
724 724
     */
725 725
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
726
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
726
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
727 727
             return;
728 728
         }
729 729
 
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
             'menu_order'    => $form_id,
735 735
             'post_status'   => 'publish',
736 736
             'post_content'  => array(),
737
-            'post_name'     => $form_id .'_wppost_1',
737
+            'post_name'     => $form_id . '_wppost_1',
738 738
         );
739 739
 
740 740
         $post_settings = array(
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
         );
745 745
 
746 746
         foreach ( $post_settings as $post_setting ) {
747
-			if ( isset( $form_options[ $post_setting ] ) ) {
748
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
747
+			if ( isset( $form_options[$post_setting] ) ) {
748
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
749 749
             }
750
-            unset($post_setting);
750
+            unset( $post_setting );
751 751
         }
752 752
 
753 753
 		$new_action['event'] = array( 'create', 'update' );
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 
762 762
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
763 763
         }
764
-        $new_action['post_content'] = json_encode($new_action['post_content']);
764
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
765 765
 
766 766
         $exists = get_posts( array(
767 767
             'name'          => $new_action['post_name'],
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
         if ( ! $exists ) {
774 774
 			// this isn't an email, but we need to use a class that will always be included
775 775
 			FrmAppHelper::save_json_post( $new_action );
776
-            $imported['imported']['actions']++;
776
+            $imported['imported']['actions'] ++;
777 777
         }
778 778
     }
779 779
 
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
         foreach ( $post_content as $key => $setting ) {
806 806
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
807 807
                 // Replace old IDs with new IDs
808
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
808
+				$post_content[$key] = str_replace( $old, $new, $setting );
809 809
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
810 810
                 foreach ( $setting as $k => $val ) {
811 811
                     // Replace old IDs with new IDs
812
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
812
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
813 813
                 }
814 814
             }
815 815
             unset( $key, $setting );
@@ -832,14 +832,14 @@  discard block
 block discarded – undo
832 832
         // Migrate autoresponders
833 833
         self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
834 834
 
835
-        if (  empty( $notifications ) ) {
835
+        if ( empty( $notifications ) ) {
836 836
             return;
837 837
         }
838 838
 
839 839
         foreach ( $notifications as $new_notification ) {
840 840
             $new_notification['post_type']      = $post_type;
841 841
             $new_notification['post_excerpt']   = 'email';
842
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
842
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
843 843
             $new_notification['menu_order']     = $form_id;
844 844
             $new_notification['post_status']    = 'publish';
845 845
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 				// Switch all other field IDs in email
853 853
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
854 854
             }
855
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
855
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
856 856
 
857 857
             $exists = get_posts( array(
858 858
                 'name'          => $new_notification['post_name'],
@@ -861,11 +861,11 @@  discard block
 block discarded – undo
861 861
                 'numberposts'   => 1,
862 862
             ) );
863 863
 
864
-            if ( empty($exists) ) {
864
+            if ( empty( $exists ) ) {
865 865
 				FrmAppHelper::save_json_post( $new_notification );
866
-                $imported['imported']['actions']++;
866
+                $imported['imported']['actions'] ++;
867 867
             }
868
-            unset($new_notification);
868
+            unset( $new_notification );
869 869
         }
870 870
     }
871 871
 
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
879 879
         }
880 880
 
881
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
881
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
882 882
             foreach ( $form_options['notification'] as $email_key => $notification ) {
883 883
 
884 884
                 $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key );
@@ -906,12 +906,12 @@  discard block
 block discarded – undo
906 906
         // Format the reply to email and name
907 907
         $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' );
908 908
         foreach ( $reply_fields as $f => $val ) {
909
-			if ( isset( $notification[ $f ] ) ) {
910
-				$atts[ $f ] = $notification[ $f ];
911
-				if ( 'custom' == $notification[ $f ] ) {
912
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
913
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
914
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
909
+			if ( isset( $notification[$f] ) ) {
910
+				$atts[$f] = $notification[$f];
911
+				if ( 'custom' == $notification[$f] ) {
912
+					$atts[$f] = $notification['cust_' . $f];
913
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
914
+					$atts[$f] = '[' . $atts[$f] . ']';
915 915
                 }
916 916
             }
917 917
             unset( $f, $val );
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 		$atts['event'] = array( 'create' );
922 922
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
923 923
             $atts['event'][] = 'update';
924
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
924
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
925 925
 			$atts['event'] = array( 'update' );
926 926
         }
927 927
     }
@@ -942,18 +942,18 @@  discard block
 block discarded – undo
942 942
         foreach ( $atts['email_to'] as $key => $email_field ) {
943 943
 
944 944
             if ( is_numeric( $email_field ) ) {
945
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
945
+				$atts['email_to'][$key] = '[' . $email_field . ']';
946 946
             }
947 947
 
948
-            if ( strpos( $email_field, '|') ) {
948
+            if ( strpos( $email_field, '|' ) ) {
949 949
                 $email_opt = explode( '|', $email_field );
950 950
                 if ( isset( $email_opt[0] ) ) {
951
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
951
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
952 952
                 }
953 953
                 unset( $email_opt );
954 954
             }
955 955
         }
956
-        $atts['email_to'] = implode(', ', $atts['email_to']);
956
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
957 957
     }
958 958
 
959 959
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
                 'email_to'      => $atts['email_to'],
964 964
                 'event'         => $atts['event'],
965 965
             ),
966
-            'post_name'         => $atts['form_id'] .'_email_'. $atts['email_key'],
966
+            'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
967 967
         );
968 968
 
969 969
         // Add more fields to the new notification
970 970
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
971 971
         foreach ( $add_fields as $add_field ) {
972
-			if ( isset( $notification[ $add_field ] ) ) {
973
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
972
+			if ( isset( $notification[$add_field] ) ) {
973
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
974 974
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
975
-				$new_notification['post_content'][ $add_field ] = 0;
975
+				$new_notification['post_content'][$add_field] = 0;
976 976
             } else {
977
-				$new_notification['post_content'][ $add_field ] = '';
977
+				$new_notification['post_content'][$add_field] = '';
978 978
             }
979 979
             unset( $add_field );
980 980
         }
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 
985 985
         // Set from
986 986
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
987
-            $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>';
987
+            $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
988 988
         }
989 989
     }
990 990
 
@@ -998,50 +998,50 @@  discard block
 block discarded – undo
998 998
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
999 999
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1000 1000
 				if ( is_numeric( $email_key ) ) {
1001
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1001
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1002 1002
 				}
1003
-				unset( $email_key, $val);
1003
+				unset( $email_key, $val );
1004 1004
 			}
1005 1005
 		}
1006 1006
 	}
1007 1007
 
1008 1008
     private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1009
-        if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) {
1009
+        if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1010 1010
             // migrate autoresponder
1011 1011
 
1012
-            $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0;
1013
-            if ( strpos($email_field, '|') ) {
1012
+            $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0;
1013
+            if ( strpos( $email_field, '|' ) ) {
1014 1014
                 // data from entries field
1015
-                $email_field = explode('|', $email_field);
1016
-                if ( isset($email_field[1]) ) {
1015
+                $email_field = explode( '|', $email_field );
1016
+                if ( isset( $email_field[1] ) ) {
1017 1017
                     $email_field = $email_field[1];
1018 1018
                 }
1019 1019
             }
1020
-            if ( is_numeric($email_field) && ! empty($email_field) ) {
1021
-                $email_field = '['. $email_field .']';
1020
+            if ( is_numeric( $email_field ) && ! empty( $email_field ) ) {
1021
+                $email_field = '[' . $email_field . ']';
1022 1022
             }
1023 1023
 
1024 1024
             $notification = $form_options;
1025 1025
             $new_notification2 = array(
1026 1026
                 'post_content'  => array(
1027 1027
                     'email_message' => $notification['ar_email_message'],
1028
-                    'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '',
1028
+                    'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
1029 1029
                     'email_to'      => $email_field,
1030
-                    'plain_text'    => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0,
1030
+                    'plain_text'    => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0,
1031 1031
                     'inc_user_info' => 0,
1032 1032
                 ),
1033
-                'post_name'     => $form_id .'_email_'. count( $notifications ),
1033
+                'post_name'     => $form_id . '_email_' . count( $notifications ),
1034 1034
             );
1035 1035
 
1036
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1037
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1036
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1037
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1038 1038
 
1039 1039
 			if ( ! empty( $reply_to ) ) {
1040 1040
 				$new_notification2['post_content']['reply_to'] = $reply_to;
1041 1041
 			}
1042 1042
 
1043 1043
 			if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) {
1044
-                $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>';
1044
+                $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1045 1045
 			}
1046 1046
 
1047 1047
             $notifications[] = $new_notification2;
Please login to merge, or discard this patch.
classes/models/FrmAddon.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	public function insert_installed_addon( $plugins ) {
35
-		$plugins[ $this->plugin_slug ] = $this;
35
+		$plugins[$this->plugin_slug] = $this;
36 36
 		return $plugins;
37 37
 	}
38 38
 
39 39
 	public static function get_addon( $plugin_slug ) {
40 40
 		$plugins = apply_filters( 'frm_installed_addons', array() );
41 41
 		$plugin = false;
42
-		if ( isset( $plugins[ $plugin_slug ] ) ) {
43
-			$plugin = $plugins[ $plugin_slug ];
42
+		if ( isset( $plugins[$plugin_slug] ) ) {
43
+			$plugin = $plugins[$plugin_slug];
44 44
 		}
45 45
 		return $plugin;
46 46
 	}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		if ( empty( $license ) ) {
54 54
 			add_action( 'after_plugin_row_' . plugin_basename( $this->plugin_file ), array( $this, 'show_license_message' ), 10, 2 );
55 55
 		} else {
56
-			if ( ! class_exists('EDD_SL_Plugin_Updater') ) {
56
+			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
57 57
 				include( dirname( __FILE__ ) . '/EDD_SL_Plugin_Updater.php' );
58 58
 			}
59 59
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	public function show_license_message( $file, $plugin ) {
70 70
 		$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
71 71
 		echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
72
-		echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
72
+		echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
73 73
 		$id = sanitize_title( $plugin['Name'] );
74 74
 		echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>';
75 75
 		echo '</div></td></tr>';
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 		$body = wp_remote_retrieve_body( $resp );
157 157
 
158 158
 		if ( is_wp_error( $resp ) ) {
159
-			$message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>');
159
+			$message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' );
160 160
 			if ( is_wp_error( $resp ) ) {
161
-				$message .= ' '. $resp->get_error_message();
161
+				$message .= ' ' . $resp->get_error_message();
162 162
 			}
163 163
 			return $message;
164 164
 		} else if ( $body == 'error' || is_wp_error( $body ) ) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 					return $json_res;
173 173
 				}
174 174
 			} else if ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) {
175
-				return sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] .' '. $resp['body'] );
175
+				return sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] );
176 176
 			}
177 177
 		}
178 178
 
Please login to merge, or discard this patch.
classes/models/FrmDb.php 2 patches
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -1,81 +1,81 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class FrmDb {
4
-    var $fields;
5
-    var $forms;
6
-    var $entries;
7
-    var $entry_metas;
8
-
9
-    public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
12
-        }
13
-
14
-        global $wpdb;
15
-        $this->fields         = $wpdb->prefix . 'frm_fields';
16
-        $this->forms          = $wpdb->prefix . 'frm_forms';
17
-        $this->entries        = $wpdb->prefix . 'frm_items';
18
-        $this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
-    }
20
-
21
-    public function upgrade( $old_db_version = false ) {
22
-        global $wpdb;
23
-        //$frm_db_version is the version of the database we're moving to
24
-        $frm_db_version = FrmAppHelper::$db_version;
25
-        $old_db_version = (float) $old_db_version;
26
-        if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
28
-        }
29
-
30
-        if ( $frm_db_version != $old_db_version ) {
4
+	var $fields;
5
+	var $forms;
6
+	var $entries;
7
+	var $entry_metas;
8
+
9
+	public function __construct() {
10
+		if ( ! defined('ABSPATH') ) {
11
+			die('You are not allowed to call this page directly.');
12
+		}
13
+
14
+		global $wpdb;
15
+		$this->fields         = $wpdb->prefix . 'frm_fields';
16
+		$this->forms          = $wpdb->prefix . 'frm_forms';
17
+		$this->entries        = $wpdb->prefix . 'frm_items';
18
+		$this->entry_metas    = $wpdb->prefix . 'frm_item_metas';
19
+	}
20
+
21
+	public function upgrade( $old_db_version = false ) {
22
+		global $wpdb;
23
+		//$frm_db_version is the version of the database we're moving to
24
+		$frm_db_version = FrmAppHelper::$db_version;
25
+		$old_db_version = (float) $old_db_version;
26
+		if ( ! $old_db_version ) {
27
+			$old_db_version = get_option('frm_db_version');
28
+		}
29
+
30
+		if ( $frm_db_version != $old_db_version ) {
31 31
 			// update rewrite rules for views and other custom post types
32 32
 			flush_rewrite_rules();
33 33
 
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36
-            $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
36
+			$this->create_tables();
37
+			$this->migrate_data($frm_db_version, $old_db_version);
38 38
 
39
-            /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
39
+			/***** SAVE DB VERSION *****/
40
+			update_option('frm_db_version', $frm_db_version);
41 41
 
42
-            /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
-            FrmXMLController::add_default_templates();
44
-        }
42
+			/**** ADD/UPDATE DEFAULT TEMPLATES ****/
43
+			FrmXMLController::add_default_templates();
44
+		}
45 45
 
46
-        do_action('frm_after_install');
46
+		do_action('frm_after_install');
47 47
 
48
-        /**** update the styling settings ****/
48
+		/**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
50 50
 			$frm_style = new FrmStyle();
51 51
 			$frm_style->update( 'default' );
52 52
 		}
53
-    }
53
+	}
54 54
 
55
-    public function collation() {
56
-        global $wpdb;
57
-        if ( ! $wpdb->has_cap( 'collation' ) ) {
58
-            return '';
59
-        }
55
+	public function collation() {
56
+		global $wpdb;
57
+		if ( ! $wpdb->has_cap( 'collation' ) ) {
58
+			return '';
59
+		}
60 60
 
61
-        $charset_collate = '';
61
+		$charset_collate = '';
62 62
 		if ( ! empty( $wpdb->charset ) ) {
63 63
 			$charset_collate .= ' DEFAULT CHARACTER SET '. $wpdb->charset;
64 64
 		}
65 65
 
66
-        if ( ! empty($wpdb->collate) ) {
67
-            $charset_collate .= ' COLLATE '. $wpdb->collate;
68
-        }
66
+		if ( ! empty($wpdb->collate) ) {
67
+			$charset_collate .= ' COLLATE '. $wpdb->collate;
68
+		}
69 69
 
70
-        return $charset_collate;
71
-    }
70
+		return $charset_collate;
71
+	}
72 72
 
73
-    private function create_tables() {
74
-        $charset_collate = $this->collation();
75
-        $sql = array();
73
+	private function create_tables() {
74
+		$charset_collate = $this->collation();
75
+		$sql = array();
76 76
 
77
-        /* Create/Upgrade Fields Table */
78
-        $sql[] = 'CREATE TABLE '. $this->fields .' (
77
+		/* Create/Upgrade Fields Table */
78
+		$sql[] = 'CREATE TABLE '. $this->fields .' (
79 79
                 id int(11) NOT NULL auto_increment,
80 80
 				field_key varchar(100) default NULL,
81 81
                 name text default NULL,
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
                 UNIQUE KEY field_key (field_key)
94 94
         )';
95 95
 
96
-        /* Create/Upgrade Forms Table */
97
-        $sql[] = 'CREATE TABLE '. $this->forms .' (
96
+		/* Create/Upgrade Forms Table */
97
+		$sql[] = 'CREATE TABLE '. $this->forms .' (
98 98
                 id int(11) NOT NULL auto_increment,
99 99
 				form_key varchar(100) default NULL,
100 100
                 name varchar(255) default NULL,
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
                 UNIQUE KEY form_key (form_key)
112 112
         )';
113 113
 
114
-        /* Create/Upgrade Items Table */
115
-        $sql[] = 'CREATE TABLE '. $this->entries .' (
114
+		/* Create/Upgrade Items Table */
115
+		$sql[] = 'CREATE TABLE '. $this->entries .' (
116 116
                 id int(11) NOT NULL auto_increment,
117 117
 				item_key varchar(100) default NULL,
118 118
                 name varchar(255) default NULL,
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
                 UNIQUE KEY item_key (item_key)
135 135
         )';
136 136
 
137
-        /* Create/Upgrade Meta Table */
138
-        $sql[] = 'CREATE TABLE '. $this->entry_metas .' (
137
+		/* Create/Upgrade Meta Table */
138
+		$sql[] = 'CREATE TABLE '. $this->entry_metas .' (
139 139
                 id int(11) NOT NULL auto_increment,
140 140
                 meta_value longtext default NULL,
141 141
                 field_id int(11) NOT NULL,
@@ -146,39 +146,39 @@  discard block
 block discarded – undo
146 146
                 KEY item_id (item_id)
147 147
         )';
148 148
 
149
-        foreach ( $sql as $q ) {
149
+		foreach ( $sql as $q ) {
150 150
 			if ( function_exists( 'dbDelta' ) ) {
151 151
 				dbDelta( $q . $charset_collate .';' );
152 152
 			} else {
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
157
-        }
158
-    }
156
+			unset($q);
157
+		}
158
+	}
159 159
 
160
-    /**
161
-     * @param integer $frm_db_version
162
-     */
160
+	/**
161
+	 * @param integer $frm_db_version
162
+	 */
163 163
 	private function migrate_data( $frm_db_version, $old_db_version ) {
164 164
 		$migrations = array( 4, 6, 11, 16, 17, 23, 25 );
165
-        foreach ( $migrations as $migration ) {
166
-            if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
167
-                $function_name = 'migrate_to_'. $migration;
168
-                $this->$function_name();
169
-            }
170
-        }
171
-    }
172
-
173
-    /**
174
-     * Change array into format $wpdb->prepare can use
175
-     */
176
-    public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
177
-        if ( empty($args) ) {
165
+		foreach ( $migrations as $migration ) {
166
+			if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
167
+				$function_name = 'migrate_to_'. $migration;
168
+				$this->$function_name();
169
+			}
170
+		}
171
+	}
172
+
173
+	/**
174
+	 * Change array into format $wpdb->prepare can use
175
+	 */
176
+	public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
177
+		if ( empty($args) ) {
178 178
 			// add an arg to prevent prepare from failing
179 179
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
180 180
 			return;
181
-        }
181
+		}
182 182
 
183 183
 		$where = '';
184 184
 		$values = array();
@@ -189,60 +189,60 @@  discard block
 block discarded – undo
189 189
 		}
190 190
 
191 191
 		$args = compact( 'where', 'values' );
192
-    }
193
-
194
-    /**
195
-     * @param string $base_where
196
-     * @param string $where
197
-     */
198
-    public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
199
-        $condition = ' AND';
200
-        if ( isset( $args['or'] ) ) {
201
-            $condition = ' OR';
202
-            unset( $args['or'] );
203
-        }
204
-
205
-        foreach ( $args as $key => $value ) {
206
-            $where .= empty( $where ) ? $base_where : $condition;
207
-            $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
208
-            if ( is_numeric( $key ) || $array_inc_null ) {
209
-                $where .= ' ( ';
210
-                $nested_where = '';
211
-                if ( $array_inc_null ) {
212
-                    foreach ( $value as $val ) {
213
-                        self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
214
-                    }
215
-                } else {
216
-                    self::parse_where_from_array( $value, '', $nested_where, $values );
217
-                }
218
-                $where .= $nested_where;
219
-                $where .= ' ) ';
220
-            } else {
221
-                self::interpret_array_to_sql( $key, $value, $where, $values );
222
-            }
223
-        }
224
-    }
225
-
226
-    /**
227
-     * @param string $key
228
-     * @param string $where
229
-     */
230
-    private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
192
+	}
193
+
194
+	/**
195
+	 * @param string $base_where
196
+	 * @param string $where
197
+	 */
198
+	public static function parse_where_from_array( $args, $base_where, &$where, &$values ) {
199
+		$condition = ' AND';
200
+		if ( isset( $args['or'] ) ) {
201
+			$condition = ' OR';
202
+			unset( $args['or'] );
203
+		}
204
+
205
+		foreach ( $args as $key => $value ) {
206
+			$where .= empty( $where ) ? $base_where : $condition;
207
+			$array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) );
208
+			if ( is_numeric( $key ) || $array_inc_null ) {
209
+				$where .= ' ( ';
210
+				$nested_where = '';
211
+				if ( $array_inc_null ) {
212
+					foreach ( $value as $val ) {
213
+						self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values );
214
+					}
215
+				} else {
216
+					self::parse_where_from_array( $value, '', $nested_where, $values );
217
+				}
218
+				$where .= $nested_where;
219
+				$where .= ' ) ';
220
+			} else {
221
+				self::interpret_array_to_sql( $key, $value, $where, $values );
222
+			}
223
+		}
224
+	}
225
+
226
+	/**
227
+	 * @param string $key
228
+	 * @param string $where
229
+	 */
230
+	private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
231 231
 		$key = trim( $key );
232 232
 
233
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
234
-            $k = explode(' ', $key);
235
-            $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
236
-            $values[] = '%Y-%m-%d %H:%i:%s';
237
-        } else {
238
-            $where .= ' '. $key;
239
-        }
233
+		if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
234
+			$k = explode(' ', $key);
235
+			$where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
236
+			$values[] = '%Y-%m-%d %H:%i:%s';
237
+		} else {
238
+			$where .= ' '. $key;
239
+		}
240 240
 
241 241
 		$lowercase_key = explode( ' ', strtolower( $key ) );
242 242
 		$lowercase_key = end( $lowercase_key );
243 243
 
244
-        if ( is_array( $value ) ) {
245
-            // translate array of values to "in"
244
+		if ( is_array( $value ) ) {
245
+			// translate array of values to "in"
246 246
 			if ( strpos( $lowercase_key, 'like' ) !== false ) {
247 247
 				$where = rtrim( $where, $key );
248 248
 				$where .= '(';
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 				}
258 258
 				$where .= ')';
259 259
 			} else if ( ! empty( $value ) ) {
260
-            	$where .= ' in ('. FrmAppHelper::prepare_array_values( $value, '%s' ) .')';
260
+				$where .= ' in ('. FrmAppHelper::prepare_array_values( $value, '%s' ) .')';
261 261
 				$values = array_merge( $values, $value );
262 262
 			}
263
-        } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
263
+		} else if ( strpos( $lowercase_key, 'like' ) !== false ) {
264 264
 			/**
265 265
 			 * Allow string to start or end with the value
266 266
 			 * If the key is like% then skip the first % for starts with
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 			$where .= ' %s';
280 280
 			$values[] = $start . FrmAppHelper::esc_like( $value ) . $end;
281 281
 
282
-        } else if ( $value === null ) {
283
-            $where .= ' IS NULL';
284
-        } else {
282
+		} else if ( $value === null ) {
283
+			$where .= ' IS NULL';
284
+		} else {
285 285
 			// allow a - to prevent = from being added
286 286
 			if ( substr( $key, -1 ) == '-' ) {
287 287
 				$where = rtrim( $where, '-' );
@@ -289,28 +289,28 @@  discard block
 block discarded – undo
289 289
 				$where .= '=';
290 290
 			}
291 291
 
292
-            $where .= is_numeric( $value ) ? ( strpos( $value, '.' ) !== false ? '%f' : '%d' ) : '%s';
293
-            $values[] = $value;
294
-        }
295
-    }
296
-
297
-    /**
298
-     * @param string $table
299
-     */
300
-    public static function get_count( $table, $where = array(), $args = array() ) {
301
-        $count = self::get_var( $table, $where, 'COUNT(*)', $args );
302
-        return $count;
303
-    }
304
-
305
-    public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
306
-        $group = '';
307
-        self::get_group_and_table_name( $table, $group );
292
+			$where .= is_numeric( $value ) ? ( strpos( $value, '.' ) !== false ? '%f' : '%d' ) : '%s';
293
+			$values[] = $value;
294
+		}
295
+	}
296
+
297
+	/**
298
+	 * @param string $table
299
+	 */
300
+	public static function get_count( $table, $where = array(), $args = array() ) {
301
+		$count = self::get_var( $table, $where, 'COUNT(*)', $args );
302
+		return $count;
303
+	}
304
+
305
+	public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) {
306
+		$group = '';
307
+		self::get_group_and_table_name( $table, $group );
308 308
 		self::convert_options_to_array( $args, '', $limit );
309 309
 
310 310
 		$query = 'SELECT ' . $field . ' FROM ' . $table;
311 311
 		if ( is_array( $where ) || empty( $where ) ) {
312 312
 			// only separate into array values and query string if is array
313
-        	self::get_where_clause_and_values( $where );
313
+			self::get_where_clause_and_values( $where );
314 314
 			global $wpdb;
315 315
 			$query = $wpdb->prepare( $query . $where['where'] . ' ' . implode( ' ', $args ), $where['values'] );
316 316
 		} else {
@@ -322,49 +322,49 @@  discard block
 block discarded – undo
322 322
 			$query .= $where . ' ' . implode( ' ', $args );
323 323
 		}
324 324
 
325
-        $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode('_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field .'_'. $type, ' WHERE' ) );
326
-        $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_'. $type );
327
-        return $results;
328
-    }
329
-
330
-    /**
331
-     * @param string $table
332
-     * @param array $where
333
-     */
334
-    public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
335
-        return self::get_var( $table, $where, $field, $args, $limit, 'col' );
336
-    }
337
-
338
-    /**
339
-     * @since 2.0
340
-     * @param string $table
341
-     */
342
-    public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
343
-        $args['limit'] = 1;
344
-        return self::get_var( $table, $where, $fields, $args, '', 'row' );
345
-    }
346
-
347
-    /**
348
-     * @param string $table
349
-     */
350
-    public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
351
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
325
+		$cache_key = str_replace( array( ' ', ',' ), '_', trim( implode('_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field .'_'. $type, ' WHERE' ) );
326
+		$results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_'. $type );
327
+		return $results;
328
+	}
329
+
330
+	/**
331
+	 * @param string $table
332
+	 * @param array $where
333
+	 */
334
+	public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) {
335
+		return self::get_var( $table, $where, $field, $args, $limit, 'col' );
336
+	}
337
+
338
+	/**
339
+	 * @since 2.0
340
+	 * @param string $table
341
+	 */
342
+	public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) {
343
+		$args['limit'] = 1;
344
+		return self::get_var( $table, $where, $fields, $args, '', 'row' );
345
+	}
346
+
347
+	/**
348
+	 * @param string $table
349
+	 */
350
+	public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) {
351
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' );
352 352
 		return self::get_var( $table, $args, $fields, array( 'order_by' => $order_by, 'limit' => 1 ), '', 'row' );
353
-    }
354
-
355
-    public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
356
-        _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
357
-        return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
358
-    }
359
-
360
-    /**
361
-     * Prepare a key/value array before DB call
362
-     * @since 2.0
363
-     * @param string $table
364
-     */
365
-    public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
366
-        return self::get_var( $table, $where, $fields, $args, '', 'results' );
367
-    }
353
+	}
354
+
355
+	public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
356
+		_deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
357
+		return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
358
+	}
359
+
360
+	/**
361
+	 * Prepare a key/value array before DB call
362
+	 * @since 2.0
363
+	 * @param string $table
364
+	 */
365
+	public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) {
366
+		return self::get_var( $table, $where, $fields, $args, '', 'results' );
367
+	}
368 368
 
369 369
 	/**
370 370
 	 * Check for like, not like, in, not in, =, !=, >, <, <=, >=
@@ -400,86 +400,86 @@  discard block
 block discarded – undo
400 400
 		return '';
401 401
 	}
402 402
 
403
-    /**
404
-     * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
405
-     * Also add the wpdb->prefix to the table if it's missing
406
-     *
407
-     * @param string $table
408
-     * @param string $group
409
-     */
410
-    private static function get_group_and_table_name( &$table, &$group ) {
403
+	/**
404
+	 * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join
405
+	 * Also add the wpdb->prefix to the table if it's missing
406
+	 *
407
+	 * @param string $table
408
+	 * @param string $group
409
+	 */
410
+	private static function get_group_and_table_name( &$table, &$group ) {
411 411
 		global $wpdb, $wpmuBaseTablePrefix;
412 412
 
413
-        $table_parts = explode(' ', $table);
414
-        $group = reset($table_parts);
415
-        $group = str_replace( $wpdb->prefix, '', $group );
413
+		$table_parts = explode(' ', $table);
414
+		$group = reset($table_parts);
415
+		$group = str_replace( $wpdb->prefix, '', $group );
416 416
 
417 417
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
418 418
 		$group = str_replace( $prefix, '', $group );
419 419
 
420
-        if ( $group == $table ) {
421
-            $table = $wpdb->prefix . $table;
422
-        }
420
+		if ( $group == $table ) {
421
+			$table = $wpdb->prefix . $table;
422
+		}
423 423
 
424 424
 		// switch to singular group name
425 425
 		$group = rtrim( $group, 's' );
426
-    }
426
+	}
427 427
 
428
-    private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
429
-        if ( ! is_array($args) ) {
428
+	private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
429
+		if ( ! is_array($args) ) {
430 430
 			$args = array( 'order_by' => $args );
431
-        }
431
+		}
432 432
 
433
-        if ( ! empty( $order_by ) ) {
434
-            $args['order_by'] = $order_by;
435
-        }
433
+		if ( ! empty( $order_by ) ) {
434
+			$args['order_by'] = $order_by;
435
+		}
436 436
 
437
-        if ( ! empty( $limit ) ) {
438
-            $args['limit'] = $limit;
439
-        }
437
+		if ( ! empty( $limit ) ) {
438
+			$args['limit'] = $limit;
439
+		}
440 440
 
441
-        $temp_args = $args;
442
-        foreach ( $temp_args as $k => $v ) {
443
-            if ( $v == '' ) {
441
+		$temp_args = $args;
442
+		foreach ( $temp_args as $k => $v ) {
443
+			if ( $v == '' ) {
444 444
 				unset( $args[ $k ] );
445
-                continue;
446
-            }
445
+				continue;
446
+			}
447 447
 
448
-            if ( $k == 'limit' ) {
448
+			if ( $k == 'limit' ) {
449 449
 				$args[ $k ] = FrmAppHelper::esc_limit( $v );
450
-            }
451
-            $db_name = strtoupper( str_replace( '_', ' ', $k ) );
452
-            if ( strpos( $v, $db_name ) === false ) {
450
+			}
451
+			$db_name = strtoupper( str_replace( '_', ' ', $k ) );
452
+			if ( strpos( $v, $db_name ) === false ) {
453 453
 				$args[ $k ] = $db_name . ' ' . $v;
454
-            }
455
-        }
456
-    }
454
+			}
455
+		}
456
+	}
457 457
 
458
-    public function uninstall() {
458
+	public function uninstall() {
459 459
 		if ( ! current_user_can( 'administrator' ) ) {
460
-            $frm_settings = FrmAppHelper::get_settings();
461
-            wp_die($frm_settings->admin_permission);
462
-        }
463
-
464
-        global $wpdb, $wp_roles;
465
-
466
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->fields );
467
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->forms );
468
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->entries );
469
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->entry_metas );
470
-
471
-        delete_option('frm_options');
472
-        delete_option('frm_db_version');
473
-
474
-        //delete roles
475
-        $frm_roles = FrmAppHelper::frm_capabilities();
476
-        $roles = get_editable_roles();
477
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
478
-            foreach ( $roles as $role => $details ) {
479
-                $wp_roles->remove_cap( $role, $frm_role );
480
-                unset($role, $details);
481
-    		}
482
-    		unset($frm_role, $frm_role_description);
460
+			$frm_settings = FrmAppHelper::get_settings();
461
+			wp_die($frm_settings->admin_permission);
462
+		}
463
+
464
+		global $wpdb, $wp_roles;
465
+
466
+		$wpdb->query( 'DROP TABLE IF EXISTS '. $this->fields );
467
+		$wpdb->query( 'DROP TABLE IF EXISTS '. $this->forms );
468
+		$wpdb->query( 'DROP TABLE IF EXISTS '. $this->entries );
469
+		$wpdb->query( 'DROP TABLE IF EXISTS '. $this->entry_metas );
470
+
471
+		delete_option('frm_options');
472
+		delete_option('frm_db_version');
473
+
474
+		//delete roles
475
+		$frm_roles = FrmAppHelper::frm_capabilities();
476
+		$roles = get_editable_roles();
477
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
478
+			foreach ( $roles as $role => $details ) {
479
+				$wp_roles->remove_cap( $role, $frm_role );
480
+				unset($role, $details);
481
+			}
482
+			unset($frm_role, $frm_role_description);
483 483
 		}
484 484
 		unset($roles, $frm_roles);
485 485
 
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 
504 504
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM '. $wpdb->options .' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
505 505
 
506
-        do_action('frm_after_uninstall');
507
-        return true;
508
-    }
506
+		do_action('frm_after_uninstall');
507
+		return true;
508
+	}
509 509
 
510 510
 	/**
511 511
 	 * Migrate old styling settings. If sites are using the old
@@ -544,150 +544,150 @@  discard block
 block discarded – undo
544 544
 		}
545 545
 	}
546 546
 
547
-    /**
548
-     * Change field size from character to pixel -- Multiply by 9
549
-     */
550
-    private function migrate_to_17() {
551
-        global $wpdb;
547
+	/**
548
+	 * Change field size from character to pixel -- Multiply by 9
549
+	 */
550
+	private function migrate_to_17() {
551
+		global $wpdb;
552 552
 		$pixel_conversion = 9;
553 553
 
554
-        // Get query arguments
554
+		// Get query arguments
555 555
 		$field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' );
556 556
 		$query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' );
557 557
 
558
-        // Get results
558
+		// Get results
559 559
 		$fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' );
560 560
 
561
-        $updated = 0;
562
-        foreach ( $fields as $f ) {
563
-            $f->field_options = maybe_unserialize($f->field_options);
564
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
565
-                continue;
566
-            }
561
+		$updated = 0;
562
+		foreach ( $fields as $f ) {
563
+			$f->field_options = maybe_unserialize($f->field_options);
564
+			if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
565
+				continue;
566
+			}
567 567
 
568 568
 			$f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] );
569
-            $f->field_options['size'] .= 'px';
570
-            $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
571
-            if ( $u ) {
572
-                $updated++;
573
-            }
574
-            unset($f);
575
-        }
576
-
577
-        // Change the characters in widgets to pixels
578
-        $widgets = get_option('widget_frm_show_form');
579
-        if ( empty($widgets) ) {
580
-            return;
581
-        }
582
-
583
-        $widgets = maybe_unserialize($widgets);
584
-        foreach ( $widgets as $k => $widget ) {
585
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
586
-                continue;
587
-            }
569
+			$f->field_options['size'] .= 'px';
570
+			$u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
571
+			if ( $u ) {
572
+				$updated++;
573
+			}
574
+			unset($f);
575
+		}
576
+
577
+		// Change the characters in widgets to pixels
578
+		$widgets = get_option('widget_frm_show_form');
579
+		if ( empty($widgets) ) {
580
+			return;
581
+		}
582
+
583
+		$widgets = maybe_unserialize($widgets);
584
+		foreach ( $widgets as $k => $widget ) {
585
+			if ( ! is_array($widget) || ! isset($widget['size']) ) {
586
+				continue;
587
+			}
588 588
 			$size = round( $pixel_conversion * (int) $widget['size'] );
589
-            $size .= 'px';
589
+			$size .= 'px';
590 590
 			$widgets[ $k ]['size'] = $size;
591
-        }
592
-        update_option('widget_frm_show_form', $widgets);
593
-    }
594
-
595
-    /**
596
-     * Migrate post and email notification settings into actions
597
-     */
598
-    private function migrate_to_16() {
599
-        global $wpdb;
600
-
601
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
602
-
603
-        /**
604
-        * Old email settings format:
605
-        * email_to: Email or field id
606
-        * also_email_to: array of fields ids
607
-        * reply_to: Email, field id, 'custom'
608
-        * cust_reply_to: string
609
-        * reply_to_name: field id, 'custom'
610
-        * cust_reply_to_name: string
611
-        * plain_text: 0|1
612
-        * email_message: string or ''
613
-        * email_subject: string or ''
614
-        * inc_user_info: 0|1
615
-        * update_email: 0, 1, 2
616
-        *
617
-        * Old autoresponder settings format:
618
-        * auto_responder: 0|1
619
-        * ar_email_message: string or ''
620
-        * ar_email_to: field id
621
-        * ar_plain_text: 0|1
622
-        * ar_reply_to_name: string
623
-        * ar_reply_to: string
624
-        * ar_email_subject: string
625
-        * ar_update_email: 0, 1, 2
626
-        *
627
-        * New email settings:
628
-        * post_content: json settings
629
-        * post_title: form id
630
-        * post_excerpt: message
631
-        *
632
-        */
633
-
634
-        foreach ( $forms as $form ) {
591
+		}
592
+		update_option('widget_frm_show_form', $widgets);
593
+	}
594
+
595
+	/**
596
+	 * Migrate post and email notification settings into actions
597
+	 */
598
+	private function migrate_to_16() {
599
+		global $wpdb;
600
+
601
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
602
+
603
+		/**
604
+		 * Old email settings format:
605
+		 * email_to: Email or field id
606
+		 * also_email_to: array of fields ids
607
+		 * reply_to: Email, field id, 'custom'
608
+		 * cust_reply_to: string
609
+		 * reply_to_name: field id, 'custom'
610
+		 * cust_reply_to_name: string
611
+		 * plain_text: 0|1
612
+		 * email_message: string or ''
613
+		 * email_subject: string or ''
614
+		 * inc_user_info: 0|1
615
+		 * update_email: 0, 1, 2
616
+		 *
617
+		 * Old autoresponder settings format:
618
+		 * auto_responder: 0|1
619
+		 * ar_email_message: string or ''
620
+		 * ar_email_to: field id
621
+		 * ar_plain_text: 0|1
622
+		 * ar_reply_to_name: string
623
+		 * ar_reply_to: string
624
+		 * ar_email_subject: string
625
+		 * ar_update_email: 0, 1, 2
626
+		 *
627
+		 * New email settings:
628
+		 * post_content: json settings
629
+		 * post_title: form id
630
+		 * post_excerpt: message
631
+		 *
632
+		 */
633
+
634
+		foreach ( $forms as $form ) {
635 635
 			if ( $form->is_template && $form->default_template ) {
636 636
 				// don't migrate the default templates since the email will be added anyway
637 637
 				continue;
638 638
 			}
639 639
 
640
-            // Format form options
641
-            $form_options = maybe_unserialize($form->options);
640
+			// Format form options
641
+			$form_options = maybe_unserialize($form->options);
642 642
 
643
-            // Migrate settings to actions
644
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
645
-        }
646
-    }
643
+			// Migrate settings to actions
644
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
645
+		}
646
+	}
647 647
 
648
-    private function migrate_to_11() {
649
-        global $wpdb;
648
+	private function migrate_to_11() {
649
+		global $wpdb;
650 650
 
651
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
651
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
652 652
 
653
-        $sending = __( 'Sending', 'formidable' );
654
-        $img = FrmAppHelper::plugin_url() .'/images/ajax_loader.gif';
655
-        $old_default_html = <<<DEFAULT_HTML
653
+		$sending = __( 'Sending', 'formidable' );
654
+		$img = FrmAppHelper::plugin_url() .'/images/ajax_loader.gif';
655
+		$old_default_html = <<<DEFAULT_HTML
656 656
 <div class="frm_submit">
657 657
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
658 658
 <input type="submit" value="[button_label]" [button_action] />
659 659
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
660 660
 </div>
661 661
 DEFAULT_HTML;
662
-        unset($sending, $img);
662
+		unset($sending, $img);
663 663
 
664
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
665
-        $draft_link = FrmFormsHelper::get_draft_link();
664
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
665
+		$draft_link = FrmFormsHelper::get_draft_link();
666 666
 		foreach ( $forms as $form ) {
667
-            $form->options = maybe_unserialize($form->options);
668
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
669
-                continue;
670
-            }
667
+			$form->options = maybe_unserialize($form->options);
668
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
669
+				continue;
670
+			}
671 671
 
672
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
673
-                $form->options['submit_html'] = $new_default_html;
672
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
673
+				$form->options['submit_html'] = $new_default_html;
674 674
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
675 675
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
676
-                $form->options['submit_html'] = preg_replace('~\<\/div\>(?!.*\<\/div\>)~', $draft_link ."\r\n</div>", $form->options['submit_html']);
676
+				$form->options['submit_html'] = preg_replace('~\<\/div\>(?!.*\<\/div\>)~', $draft_link ."\r\n</div>", $form->options['submit_html']);
677 677
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
678
-            }
679
-            unset($form);
680
-        }
681
-        unset($forms);
682
-    }
678
+			}
679
+			unset($form);
680
+		}
681
+		unset($forms);
682
+	}
683 683
 
684
-    private function migrate_to_6() {
685
-        global $wpdb;
684
+	private function migrate_to_6() {
685
+		global $wpdb;
686 686
 
687 687
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
688 688
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
689 689
 
690
-        $default_html = <<<DEFAULT_HTML
690
+		$default_html = <<<DEFAULT_HTML
691 691
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
692 692
     <label class="frm_pos_[label_position]">[field_name]
693 693
         <span class="frm_required">[required_label]</span>
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 </div>
698 698
 DEFAULT_HTML;
699 699
 
700
-        $old_default_html = <<<DEFAULT_HTML
700
+		$old_default_html = <<<DEFAULT_HTML
701 701
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
702 702
     <label class="frm_pos_[label_position]">[field_name]
703 703
         <span class="frm_required">[required_label]</span>
@@ -707,23 +707,23 @@  discard block
 block discarded – undo
707 707
 </div>
708 708
 DEFAULT_HTML;
709 709
 
710
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
711
-        foreach ( $fields as $field ) {
712
-            $field->field_options = maybe_unserialize($field->field_options);
710
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
711
+		foreach ( $fields as $field ) {
712
+			$field->field_options = maybe_unserialize($field->field_options);
713 713
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
714
-                $field->field_options['custom_html'] = $new_default_html;
714
+				$field->field_options['custom_html'] = $new_default_html;
715 715
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
716
-            }
717
-            unset($field);
718
-        }
719
-        unset($default_html, $old_default_html, $fields);
720
-    }
721
-
722
-    private function migrate_to_4() {
723
-        global $wpdb;
716
+			}
717
+			unset($field);
718
+		}
719
+		unset($default_html, $old_default_html, $fields);
720
+	}
721
+
722
+	private function migrate_to_4() {
723
+		global $wpdb;
724 724
 		$user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) );
725
-        foreach ( $user_ids as $user_id ) {
725
+		foreach ( $user_ids as $user_id ) {
726 726
 			$wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) );
727
-        }
728
-    }
727
+		}
728
+	}
729 729
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
     var $entry_metas;
8 8
 
9 9
     public function __construct() {
10
-        if ( ! defined('ABSPATH') ) {
11
-            die('You are not allowed to call this page directly.');
10
+        if ( ! defined( 'ABSPATH' ) ) {
11
+            die( 'You are not allowed to call this page directly.' );
12 12
         }
13 13
 
14 14
         global $wpdb;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         $frm_db_version = FrmAppHelper::$db_version;
25 25
         $old_db_version = (float) $old_db_version;
26 26
         if ( ! $old_db_version ) {
27
-            $old_db_version = get_option('frm_db_version');
27
+            $old_db_version = get_option( 'frm_db_version' );
28 28
         }
29 29
 
30 30
         if ( $frm_db_version != $old_db_version ) {
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
35 35
 
36 36
             $this->create_tables();
37
-            $this->migrate_data($frm_db_version, $old_db_version);
37
+            $this->migrate_data( $frm_db_version, $old_db_version );
38 38
 
39 39
             /***** SAVE DB VERSION *****/
40
-            update_option('frm_db_version', $frm_db_version);
40
+            update_option( 'frm_db_version', $frm_db_version );
41 41
 
42 42
             /**** ADD/UPDATE DEFAULT TEMPLATES ****/
43 43
             FrmXMLController::add_default_templates();
44 44
         }
45 45
 
46
-        do_action('frm_after_install');
46
+        do_action( 'frm_after_install' );
47 47
 
48 48
         /**** update the styling settings ****/
49 49
 		if ( is_admin() && function_exists( 'get_filesystem_method' ) ) {
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
         $charset_collate = '';
62 62
 		if ( ! empty( $wpdb->charset ) ) {
63
-			$charset_collate .= ' DEFAULT CHARACTER SET '. $wpdb->charset;
63
+			$charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset;
64 64
 		}
65 65
 
66
-        if ( ! empty($wpdb->collate) ) {
67
-            $charset_collate .= ' COLLATE '. $wpdb->collate;
66
+        if ( ! empty( $wpdb->collate ) ) {
67
+            $charset_collate .= ' COLLATE ' . $wpdb->collate;
68 68
         }
69 69
 
70 70
         return $charset_collate;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $sql = array();
76 76
 
77 77
         /* Create/Upgrade Fields Table */
78
-        $sql[] = 'CREATE TABLE '. $this->fields .' (
78
+        $sql[] = 'CREATE TABLE ' . $this->fields . ' (
79 79
                 id int(11) NOT NULL auto_increment,
80 80
 				field_key varchar(100) default NULL,
81 81
                 name text default NULL,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         )';
95 95
 
96 96
         /* Create/Upgrade Forms Table */
97
-        $sql[] = 'CREATE TABLE '. $this->forms .' (
97
+        $sql[] = 'CREATE TABLE ' . $this->forms . ' (
98 98
                 id int(11) NOT NULL auto_increment,
99 99
 				form_key varchar(100) default NULL,
100 100
                 name varchar(255) default NULL,
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         )';
113 113
 
114 114
         /* Create/Upgrade Items Table */
115
-        $sql[] = 'CREATE TABLE '. $this->entries .' (
115
+        $sql[] = 'CREATE TABLE ' . $this->entries . ' (
116 116
                 id int(11) NOT NULL auto_increment,
117 117
 				item_key varchar(100) default NULL,
118 118
                 name varchar(255) default NULL,
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         )';
136 136
 
137 137
         /* Create/Upgrade Meta Table */
138
-        $sql[] = 'CREATE TABLE '. $this->entry_metas .' (
138
+        $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
139 139
                 id int(11) NOT NULL auto_increment,
140 140
                 meta_value longtext default NULL,
141 141
                 field_id int(11) NOT NULL,
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 
149 149
         foreach ( $sql as $q ) {
150 150
 			if ( function_exists( 'dbDelta' ) ) {
151
-				dbDelta( $q . $charset_collate .';' );
151
+				dbDelta( $q . $charset_collate . ';' );
152 152
 			} else {
153 153
 				global $wpdb;
154 154
 				$wpdb->query( $q . $charset_collate );
155 155
 			}
156
-            unset($q);
156
+            unset( $q );
157 157
         }
158 158
     }
159 159
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		$migrations = array( 4, 6, 11, 16, 17, 23, 25 );
165 165
         foreach ( $migrations as $migration ) {
166 166
             if ( $frm_db_version >= $migration && $old_db_version < $migration ) {
167
-                $function_name = 'migrate_to_'. $migration;
167
+                $function_name = 'migrate_to_' . $migration;
168 168
                 $this->$function_name();
169 169
             }
170 170
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * Change array into format $wpdb->prepare can use
175 175
      */
176 176
     public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) {
177
-        if ( empty($args) ) {
177
+        if ( empty( $args ) ) {
178 178
 			// add an arg to prevent prepare from failing
179 179
 			$args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) );
180 180
 			return;
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
     private static function interpret_array_to_sql( $key, $value, &$where, &$values ) {
231 231
 		$key = trim( $key );
232 232
 
233
-        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false  ) {
234
-            $k = explode(' ', $key);
233
+        if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) {
234
+            $k = explode( ' ', $key );
235 235
             $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key );
236 236
             $values[] = '%Y-%m-%d %H:%i:%s';
237 237
         } else {
238
-            $where .= ' '. $key;
238
+            $where .= ' ' . $key;
239 239
         }
240 240
 
241 241
 		$lowercase_key = explode( ' ', strtolower( $key ) );
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 				}
258 258
 				$where .= ')';
259 259
 			} else if ( ! empty( $value ) ) {
260
-            	$where .= ' in ('. FrmAppHelper::prepare_array_values( $value, '%s' ) .')';
260
+            	$where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')';
261 261
 				$values = array_merge( $values, $value );
262 262
 			}
263 263
         } else if ( strpos( $lowercase_key, 'like' ) !== false ) {
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 			$query .= $where . ' ' . implode( ' ', $args );
323 323
 		}
324 324
 
325
-        $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode('_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field .'_'. $type, ' WHERE' ) );
326
-        $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_'. $type );
325
+        $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) );
326
+        $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type );
327 327
         return $results;
328 328
     }
329 329
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
     public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) {
356 356
         _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' );
357
-        return self::get_results( $table, $args, $fields, compact('order_by', 'limit') );
357
+        return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) );
358 358
     }
359 359
 
360 360
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 		);
388 388
 
389 389
 		$where_is = strtolower( $where_is );
390
-		if ( isset( $switch_to[ $where_is ] ) ) {
391
-			return ' ' . $switch_to[ $where_is ];
390
+		if ( isset( $switch_to[$where_is] ) ) {
391
+			return ' ' . $switch_to[$where_is];
392 392
 		}
393 393
 
394 394
 		// > and < need a little more work since we don't want them switched to >= and <=
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
     private static function get_group_and_table_name( &$table, &$group ) {
411 411
 		global $wpdb, $wpmuBaseTablePrefix;
412 412
 
413
-        $table_parts = explode(' ', $table);
414
-        $group = reset($table_parts);
413
+        $table_parts = explode( ' ', $table );
414
+        $group = reset( $table_parts );
415 415
         $group = str_replace( $wpdb->prefix, '', $group );
416 416
 
417 417
 		$prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix;
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
     }
427 427
 
428 428
     private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) {
429
-        if ( ! is_array($args) ) {
429
+        if ( ! is_array( $args ) ) {
430 430
 			$args = array( 'order_by' => $args );
431 431
         }
432 432
 
@@ -441,16 +441,16 @@  discard block
 block discarded – undo
441 441
         $temp_args = $args;
442 442
         foreach ( $temp_args as $k => $v ) {
443 443
             if ( $v == '' ) {
444
-				unset( $args[ $k ] );
444
+				unset( $args[$k] );
445 445
                 continue;
446 446
             }
447 447
 
448 448
             if ( $k == 'limit' ) {
449
-				$args[ $k ] = FrmAppHelper::esc_limit( $v );
449
+				$args[$k] = FrmAppHelper::esc_limit( $v );
450 450
             }
451 451
             $db_name = strtoupper( str_replace( '_', ' ', $k ) );
452 452
             if ( strpos( $v, $db_name ) === false ) {
453
-				$args[ $k ] = $db_name . ' ' . $v;
453
+				$args[$k] = $db_name . ' ' . $v;
454 454
             }
455 455
         }
456 456
     }
@@ -458,18 +458,18 @@  discard block
 block discarded – undo
458 458
     public function uninstall() {
459 459
 		if ( ! current_user_can( 'administrator' ) ) {
460 460
             $frm_settings = FrmAppHelper::get_settings();
461
-            wp_die($frm_settings->admin_permission);
461
+            wp_die( $frm_settings->admin_permission );
462 462
         }
463 463
 
464 464
         global $wpdb, $wp_roles;
465 465
 
466
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->fields );
467
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->forms );
468
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->entries );
469
-        $wpdb->query( 'DROP TABLE IF EXISTS '. $this->entry_metas );
466
+        $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
467
+        $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
468
+        $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
469
+        $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
470 470
 
471
-        delete_option('frm_options');
472
-        delete_option('frm_db_version');
471
+        delete_option( 'frm_options' );
472
+        delete_option( 'frm_db_version' );
473 473
 
474 474
         //delete roles
475 475
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
478 478
             foreach ( $roles as $role => $details ) {
479 479
                 $wp_roles->remove_cap( $role, $frm_role );
480
-                unset($role, $details);
480
+                unset( $role, $details );
481 481
     		}
482
-    		unset($frm_role, $frm_role_description);
482
+    		unset( $frm_role, $frm_role_description );
483 483
 		}
484
-		unset($roles, $frm_roles);
484
+		unset( $roles, $frm_roles );
485 485
 
486 486
 		// delete actions, views, and styles
487 487
 
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		remove_action( 'before_delete_post', 'FrmProDisplaysController::before_delete_post' );
490 490
 		remove_action( 'deleted_post', 'FrmProEntriesController::delete_entry' );
491 491
 
492
-		$post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts .' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) );
492
+		$post_ids = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display' ) );
493 493
 		foreach ( $post_ids as $post_id ) {
494 494
 			// Delete's each post.
495 495
 			wp_delete_post( $post_id, true );
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 		delete_transient( 'frm_options' );
502 502
 		delete_transient( 'frmpro_options' );
503 503
 
504
-		$wpdb->query( $wpdb->prepare( 'DELETE FROM '. $wpdb->options .' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
504
+		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
505 505
 
506
-        do_action('frm_after_uninstall');
506
+        do_action( 'frm_after_uninstall' );
507 507
         return true;
508 508
     }
509 509
 
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
 	 */
539 539
 	private function migrate_to_23() {
540 540
 		global $wpdb;
541
-		$exists = $wpdb->get_row( 'SHOW COLUMNS FROM '. $this->forms .' LIKE "parent_form_id"' );
541
+		$exists = $wpdb->get_row( 'SHOW COLUMNS FROM ' . $this->forms . ' LIKE "parent_form_id"' );
542 542
 		if ( empty( $exists ) ) {
543
-			$wpdb->query( 'ALTER TABLE '. $this->forms .' ADD parent_form_id int(11) default 0' );
543
+			$wpdb->query( 'ALTER TABLE ' . $this->forms . ' ADD parent_form_id int(11) default 0' );
544 544
 		}
545 545
 	}
546 546
 
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 
561 561
         $updated = 0;
562 562
         foreach ( $fields as $f ) {
563
-            $f->field_options = maybe_unserialize($f->field_options);
564
-            if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) {
563
+            $f->field_options = maybe_unserialize( $f->field_options );
564
+            if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) {
565 565
                 continue;
566 566
             }
567 567
 
@@ -569,27 +569,27 @@  discard block
 block discarded – undo
569 569
             $f->field_options['size'] .= 'px';
570 570
             $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) );
571 571
             if ( $u ) {
572
-                $updated++;
572
+                $updated ++;
573 573
             }
574
-            unset($f);
574
+            unset( $f );
575 575
         }
576 576
 
577 577
         // Change the characters in widgets to pixels
578
-        $widgets = get_option('widget_frm_show_form');
579
-        if ( empty($widgets) ) {
578
+        $widgets = get_option( 'widget_frm_show_form' );
579
+        if ( empty( $widgets ) ) {
580 580
             return;
581 581
         }
582 582
 
583
-        $widgets = maybe_unserialize($widgets);
583
+        $widgets = maybe_unserialize( $widgets );
584 584
         foreach ( $widgets as $k => $widget ) {
585
-            if ( ! is_array($widget) || ! isset($widget['size']) ) {
585
+            if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
586 586
                 continue;
587 587
             }
588 588
 			$size = round( $pixel_conversion * (int) $widget['size'] );
589 589
             $size .= 'px';
590
-			$widgets[ $k ]['size'] = $size;
590
+			$widgets[$k]['size'] = $size;
591 591
         }
592
-        update_option('widget_frm_show_form', $widgets);
592
+        update_option( 'widget_frm_show_form', $widgets );
593 593
     }
594 594
 
595 595
     /**
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 			}
639 639
 
640 640
             // Format form options
641
-            $form_options = maybe_unserialize($form->options);
641
+            $form_options = maybe_unserialize( $form->options );
642 642
 
643 643
             // Migrate settings to actions
644 644
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -648,10 +648,10 @@  discard block
 block discarded – undo
648 648
     private function migrate_to_11() {
649 649
         global $wpdb;
650 650
 
651
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
651
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
652 652
 
653 653
         $sending = __( 'Sending', 'formidable' );
654
-        $img = FrmAppHelper::plugin_url() .'/images/ajax_loader.gif';
654
+        $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
655 655
         $old_default_html = <<<DEFAULT_HTML
656 656
 <div class="frm_submit">
657 657
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
@@ -659,13 +659,13 @@  discard block
 block discarded – undo
659 659
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
660 660
 </div>
661 661
 DEFAULT_HTML;
662
-        unset($sending, $img);
662
+        unset( $sending, $img );
663 663
 
664
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
664
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
665 665
         $draft_link = FrmFormsHelper::get_draft_link();
666 666
 		foreach ( $forms as $form ) {
667
-            $form->options = maybe_unserialize($form->options);
668
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
667
+            $form->options = maybe_unserialize( $form->options );
668
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
669 669
                 continue;
670 670
             }
671 671
 
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
                 $form->options['submit_html'] = $new_default_html;
674 674
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
675 675
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
676
-                $form->options['submit_html'] = preg_replace('~\<\/div\>(?!.*\<\/div\>)~', $draft_link ."\r\n</div>", $form->options['submit_html']);
676
+                $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
677 677
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
678 678
             }
679
-            unset($form);
679
+            unset( $form );
680 680
         }
681
-        unset($forms);
681
+        unset( $forms );
682 682
     }
683 683
 
684 684
     private function migrate_to_6() {
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 </div>
708 708
 DEFAULT_HTML;
709 709
 
710
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
710
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
711 711
         foreach ( $fields as $field ) {
712
-            $field->field_options = maybe_unserialize($field->field_options);
712
+            $field->field_options = maybe_unserialize( $field->field_options );
713 713
 			if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) {
714 714
                 $field->field_options['custom_html'] = $new_default_html;
715 715
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
716 716
             }
717
-            unset($field);
717
+            unset( $field );
718 718
         }
719
-        unset($default_html, $old_default_html, $fields);
719
+        unset( $default_html, $old_default_html, $fields );
720 720
     }
721 721
 
722 722
     private function migrate_to_4() {
Please login to merge, or discard this patch.