Completed
Push — master ( 9a3154...1c793d )
by Stephanie
05:58 queued 02:41
created
classes/models/FrmStyle.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 	public $id = 0; // the id of the post
5 5
 
6 6
 	/**
7
-	 * @param int|string $id The id of the stylsheet or 'default'
7
+	 * @param integer $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10 10
         $this->id = $id;
@@ -127,6 +127,9 @@  discard block
 block discarded – undo
127 127
 		set_transient( 'frmpro_css', $css );
128 128
 	}
129 129
 
130
+	/**
131
+	 * @param string $filename
132
+	 */
130 133
 	private function get_css_content( $filename ) {
131 134
 		$css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n";
132 135
 
Please login to merge, or discard this patch.
Indentation   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -7,46 +7,46 @@  discard block
 block discarded – undo
7 7
 	 * @param int|string $id The id of the stylsheet or 'default'
8 8
 	 */
9 9
 	public function __construct( $id = 0 ) {
10
-        $this->id = $id;
11
-    }
10
+		$this->id = $id;
11
+	}
12 12
 
13
-    public function get_new() {
13
+	public function get_new() {
14 14
 		$this->id = 0;
15 15
 
16
-        $max_slug_value = 2147483647;
17
-        $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
-
20
-        $style = array(
21
-            'post_type'     => FrmStylesController::$post_type,
22
-            'ID'            => '',
23
-            'post_title'    => __( 'New Style', 'formidable' ),
24
-            'post_name'     => $key,
25
-            'post_content'  => $this->get_defaults(),
26
-            'menu_order'    => '',
27
-            'post_status'   => 'publish',
28
-        );
16
+		$max_slug_value = 2147483647;
17
+		$min_slug_value = 37; // we want to have at least 2 characters in the slug
18
+		$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
19
+
20
+		$style = array(
21
+			'post_type'     => FrmStylesController::$post_type,
22
+			'ID'            => '',
23
+			'post_title'    => __( 'New Style', 'formidable' ),
24
+			'post_name'     => $key,
25
+			'post_content'  => $this->get_defaults(),
26
+			'menu_order'    => '',
27
+			'post_status'   => 'publish',
28
+		);
29 29
 
30
-        return (object) $style;
31
-    }
30
+		return (object) $style;
31
+	}
32 32
 
33 33
 	public function save( $settings ) {
34 34
 		return FrmDb::save_settings( $settings, 'frm_styles' );
35
-    }
35
+	}
36 36
 
37 37
 	public function duplicate( $id ) {
38
-        // duplicating is a pro feature
39
-    }
38
+		// duplicating is a pro feature
39
+	}
40 40
 
41
-    public function update( $id = 'default' ) {
41
+	public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44 44
  		if ( empty($id) ) {
45
- 		     $new_style = (array) $this->get_new();
46
- 		     $all_instances[] = $new_style;
45
+ 			 $new_style = (array) $this->get_new();
46
+ 			 $all_instances[] = $new_style;
47 47
  		}
48 48
 
49
-        $action_ids = array();
49
+		$action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52 52
  			$new_instance = stripslashes_deep( (array) $new_instance);
@@ -54,46 +54,46 @@  discard block
 block discarded – undo
54 54
  			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55 55
 				$all_instances[ $number ] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
- 			        // this style was set to default, so remove default setting on previous default style
59
- 			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
61
- 			    }
57
+ 				if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
58
+ 					// this style was set to default, so remove default setting on previous default style
59
+ 					$new_instance['menu_order'] = 0;
60
+ 					$action_ids[] = $this->save($new_instance);
61
+ 				}
62 62
 
63
- 			    // don't continue if not saving this style
64
- 			    continue;
63
+ 				// don't continue if not saving this style
64
+ 				continue;
65 65
  			}
66 66
 
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+			$new_instance['post_status']  = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
74
-                $new_instance['post_name'] = $new_instance['post_title'];
75
-            }
73
+			if ( empty($id) ) {
74
+				$new_instance['post_name'] = $new_instance['post_title'];
75
+			}
76 76
 
77
-            $default_settings = $this->get_defaults();
77
+			$default_settings = $this->get_defaults();
78 78
 
79
-            foreach ( $default_settings as $setting => $default ) {
79
+			foreach ( $default_settings as $setting => $default ) {
80 80
 				if ( ! isset( $new_instance['post_content'][ $setting ] ) ) {
81 81
 					$new_instance['post_content'][ $setting ] = $default;
82 82
 				}
83 83
 
84 84
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
85
-                    //if is a color
85
+					//if is a color
86 86
 					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
87 87
 				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
88 88
 					$new_instance['post_content'][ $setting ] = 0;
89
-                } else if ( $setting == 'font' ) {
90
-                	$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
91
-                }
92
-            }
89
+				} else if ( $setting == 'font' ) {
90
+					$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
91
+				}
92
+			}
93 93
 
94 94
 			$all_instances[ $number ] = $new_instance;
95 95
 
96
-            $action_ids[] = $this->save($new_instance);
96
+			$action_ids[] = $this->save($new_instance);
97 97
 
98 98
  		}
99 99
 
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
  		return $action_ids;
103 103
  	}
104 104
 
105
-    /**
106
-     * Create static css file
107
-     */
105
+	/**
106
+	 * Create static css file
107
+	 */
108 108
 	public function save_settings() {
109 109
 		$filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
110 110
 		update_option( 'frm_last_style_update', date('njGi') );
111 111
 
112
-        if ( ! is_file($filename) ) {
113
-            return;
114
-        }
112
+		if ( ! is_file($filename) ) {
113
+			return;
114
+		}
115 115
 
116 116
 		$this->clear_cache();
117 117
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 		$saving = true;
134 134
 		$frm_style = $this;
135 135
 
136
-        ob_start();
137
-        include( $filename );
136
+		ob_start();
137
+		include( $filename );
138 138
 		$css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", '    ' ), '', ob_get_contents() ) );
139
-        ob_end_clean();
139
+		ob_end_clean();
140 140
 
141 141
 		return $css;
142 142
 	}
@@ -156,269 +156,269 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	public function destroy( $id ) {
159
-        return wp_delete_post($id);
160
-    }
159
+		return wp_delete_post($id);
160
+	}
161 161
 
162
-    public function get_one() {
163
-        if ( 'default' == $this->id ) {
164
-            $style = $this->get_default_style();
165
-            if ( $style ) {
166
-                $this->id = $style->ID;
167
-            } else {
168
-                $this->id = 0;
169
-            }
170
-            return $style;
171
-        }
162
+	public function get_one() {
163
+		if ( 'default' == $this->id ) {
164
+			$style = $this->get_default_style();
165
+			if ( $style ) {
166
+				$this->id = $style->ID;
167
+			} else {
168
+				$this->id = 0;
169
+			}
170
+			return $style;
171
+		}
172 172
 
173
-        $style = get_post($this->id);
173
+		$style = get_post($this->id);
174 174
 
175
-        if ( ! $style ) {
176
-            return $style;
177
-        }
175
+		if ( ! $style ) {
176
+			return $style;
177
+		}
178 178
 
179
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
179
+		$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
180 180
 
181
-        $default_values = $this->get_defaults();
181
+		$default_values = $this->get_defaults();
182 182
 
183
-        // fill default values
184
-        $style->post_content = $this->override_defaults($style->post_content);
185
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
183
+		// fill default values
184
+		$style->post_content = $this->override_defaults($style->post_content);
185
+		$style->post_content = wp_parse_args( $style->post_content, $default_values);
186 186
 
187
-        return $style;
188
-    }
187
+		return $style;
188
+	}
189 189
 
190
-    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
191
-        $post_atts = array(
190
+	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) {
191
+		$post_atts = array(
192 192
 			'post_type'   => FrmStylesController::$post_type,
193 193
 			'post_status' => 'publish',
194 194
 			'numberposts' => $limit,
195 195
 			'orderby'     => $orderby,
196 196
 			'order'       => $order,
197
-        );
197
+		);
198 198
 
199 199
 		$temp_styles = FrmDb::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
200 200
 
201
-        if ( empty($temp_styles) ) {
202
-            global $wpdb;
203
-            // make sure there wasn't a conflict with the query
201
+		if ( empty($temp_styles) ) {
202
+			global $wpdb;
203
+			// make sure there wasn't a conflict with the query
204 204
 			$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
205
-            $temp_styles = FrmDb::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
205
+			$temp_styles = FrmDb::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
206 206
 
207
-            if ( empty($temp_styles) ) {
208
-                // create a new style if there are none
209
-         		$new = $this->get_new();
207
+			if ( empty($temp_styles) ) {
208
+				// create a new style if there are none
209
+		 		$new = $this->get_new();
210 210
 				$new->post_title = __( 'Formidable Style', 'formidable' );
211 211
 				$new->post_name = $new->post_title;
212
-         		$new->menu_order = 1;
213
-         		$new = $this->save( (array) $new);
214
-         		$this->update('default');
215
-
216
-                $post_atts['include'] = $new;
217
-
218
-                $temp_styles = get_posts( $post_atts );
219
-            }
220
-        }
221
-
222
-        $default_values = $this->get_defaults();
223
-        $default_style = false;
224
-
225
-        $styles = array();
226
-        foreach ( $temp_styles as $style ) {
227
-            $this->id = $style->ID;
228
-            if ( $style->menu_order ) {
229
-                if ( $default_style ) {
230
-                    // only return one default
231
-                    $style->menu_order = 0;
232
-                } else {
233
-                    // check for a default style
234
-                    $default_style = $style->ID;
235
-                }
236
-            }
237
-
238
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
239
-
240
-            // fill default values
241
-            $style->post_content = $this->override_defaults($style->post_content);
242
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
212
+		 		$new->menu_order = 1;
213
+		 		$new = $this->save( (array) $new);
214
+		 		$this->update('default');
215
+
216
+				$post_atts['include'] = $new;
217
+
218
+				$temp_styles = get_posts( $post_atts );
219
+			}
220
+		}
221
+
222
+		$default_values = $this->get_defaults();
223
+		$default_style = false;
224
+
225
+		$styles = array();
226
+		foreach ( $temp_styles as $style ) {
227
+			$this->id = $style->ID;
228
+			if ( $style->menu_order ) {
229
+				if ( $default_style ) {
230
+					// only return one default
231
+					$style->menu_order = 0;
232
+				} else {
233
+					// check for a default style
234
+					$default_style = $style->ID;
235
+				}
236
+			}
237
+
238
+			$style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
239
+
240
+			// fill default values
241
+			$style->post_content = $this->override_defaults($style->post_content);
242
+			$style->post_content = wp_parse_args( $style->post_content, $default_values);
243 243
 
244 244
 			$styles[ $style->ID ] = $style;
245
-        }
245
+		}
246 246
 
247
-        if ( ! $default_style ) {
248
-            $default_style = reset($styles);
247
+		if ( ! $default_style ) {
248
+			$default_style = reset($styles);
249 249
 			$styles[ $default_style->ID ]->menu_order = 1;
250
-        }
250
+		}
251 251
 
252
-        return $styles;
253
-    }
252
+		return $styles;
253
+	}
254 254
 
255 255
 	public function get_default_style( $styles = null ) {
256
-        if ( ! isset($styles) ) {
256
+		if ( ! isset($styles) ) {
257 257
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
258
-        }
258
+		}
259 259
 
260
-        foreach ( $styles as $style ) {
261
-            if ( $style->menu_order ) {
262
-                return $style;
263
-            }
264
-        }
265
-    }
260
+		foreach ( $styles as $style ) {
261
+			if ( $style->menu_order ) {
262
+				return $style;
263
+			}
264
+		}
265
+	}
266 266
 
267 267
 	public function override_defaults( $settings ) {
268
-	    if ( ! is_array($settings) ) {
269
-	        return $settings;
270
-	    }
268
+		if ( ! is_array($settings) ) {
269
+			return $settings;
270
+		}
271 271
 
272 272
 		$settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
273 273
 
274
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
275
-	        $settings['form_desc_size'] = $settings['description_font_size'];
276
-	        $settings['form_desc_color'] = $settings['description_color'];
277
-	        $settings['title_color'] = $settings['label_color'];
278
-	    }
274
+		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
275
+			$settings['form_desc_size'] = $settings['description_font_size'];
276
+			$settings['form_desc_color'] = $settings['description_color'];
277
+			$settings['title_color'] = $settings['label_color'];
278
+		}
279 279
 
280
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
281
-	        $settings['section_color'] = $settings['label_color'];
282
-	        $settings['section_border_color'] = $settings['border_color'];
283
-	    }
280
+		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
281
+			$settings['section_color'] = $settings['label_color'];
282
+			$settings['section_border_color'] = $settings['border_color'];
283
+		}
284 284
 
285
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
286
-	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
287
-	        $settings['submit_hover_color'] = $settings['submit_text_color'];
288
-	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
285
+		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
286
+			$settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
287
+			$settings['submit_hover_color'] = $settings['submit_text_color'];
288
+			$settings['submit_hover_border_color'] = $settings['submit_border_color'];
289 289
 
290
-	        $settings['submit_active_bg_color'] = $settings['submit_bg_color'];
291
-	        $settings['submit_active_color'] = $settings['submit_text_color'];
292
-            $settings['submit_active_border_color'] = $settings['submit_border_color'];
293
-	    }
290
+			$settings['submit_active_bg_color'] = $settings['submit_bg_color'];
291
+			$settings['submit_active_color'] = $settings['submit_text_color'];
292
+			$settings['submit_active_border_color'] = $settings['submit_border_color'];
293
+		}
294 294
 
295
-	    return $settings;
295
+		return $settings;
296 296
 	}
297 297
 
298 298
 	public function get_defaults() {
299
-        return array(
300
-            'theme_css'         => 'ui-lightness',
301
-            'theme_name'        => 'UI Lightness',
299
+		return array(
300
+			'theme_css'         => 'ui-lightness',
301
+			'theme_name'        => 'UI Lightness',
302 302
 
303 303
 			'center_form'       => '',
304
-            'form_width'        => '100%',
305
-            'form_align'        => 'left',
306
-            'direction'         => is_rtl() ? 'rtl' : 'ltr',
307
-            'fieldset'          => '0px',
308
-            'fieldset_color'    => '000000',
309
-            'fieldset_padding'  => '0 0 15px 0',
310
-            'fieldset_bg_color' => '',
311
-
312
-            'title_size'        => '20px',
313
-            'title_color'       => '444444',
304
+			'form_width'        => '100%',
305
+			'form_align'        => 'left',
306
+			'direction'         => is_rtl() ? 'rtl' : 'ltr',
307
+			'fieldset'          => '0px',
308
+			'fieldset_color'    => '000000',
309
+			'fieldset_padding'  => '0 0 15px 0',
310
+			'fieldset_bg_color' => '',
311
+
312
+			'title_size'        => '20px',
313
+			'title_color'       => '444444',
314 314
 			'title_margin_top'  => '10px',
315 315
 			'title_margin_bottom' => '10px',
316
-            'form_desc_size'    => '14px',
317
-            'form_desc_color'   => '666666',
316
+			'form_desc_size'    => '14px',
317
+			'form_desc_color'   => '666666',
318 318
 			'form_desc_margin_top' => '10px',
319 319
 			'form_desc_margin_bottom' => '25px',
320 320
 
321
-            'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
322
-            'font_size'         => '14px',
323
-            'label_color'       => '444444',
324
-            'weight'            => 'bold',
325
-            'position'          => 'none',
326
-            'align'             => 'left',
327
-            'width'             => '150px',
328
-            'required_color'    => 'B94A48',
329
-            'required_weight'   => 'bold',
330
-            'label_padding'     => '0 0 3px 0',
331
-
332
-            'description_font_size' => '12px',
333
-            'description_color' => '666666',
334
-            'description_weight' => 'normal',
335
-            'description_style' => 'normal',
336
-            'description_align' => 'left',
321
+			'font'              => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif',
322
+			'font_size'         => '14px',
323
+			'label_color'       => '444444',
324
+			'weight'            => 'bold',
325
+			'position'          => 'none',
326
+			'align'             => 'left',
327
+			'width'             => '150px',
328
+			'required_color'    => 'B94A48',
329
+			'required_weight'   => 'bold',
330
+			'label_padding'     => '0 0 3px 0',
331
+
332
+			'description_font_size' => '12px',
333
+			'description_color' => '666666',
334
+			'description_weight' => 'normal',
335
+			'description_style' => 'normal',
336
+			'description_align' => 'left',
337 337
 			'description_margin' => '0',
338 338
 
339
-            'field_font_size'   => '14px',
340
-            'field_height'      => '32px',
341
-            'line_height'       => 'normal',
342
-            'field_width'       => '100%',
343
-            'auto_width'        => false,
344
-            'field_pad'         => '6px 10px',
345
-            'field_margin'      => '20px',
339
+			'field_font_size'   => '14px',
340
+			'field_height'      => '32px',
341
+			'line_height'       => 'normal',
342
+			'field_width'       => '100%',
343
+			'auto_width'        => false,
344
+			'field_pad'         => '6px 10px',
345
+			'field_margin'      => '20px',
346 346
 			'field_weight' => 'normal',
347
-            'text_color'        => '555555',
348
-            //'border_color_hv'   => 'cccccc',
349
-            'border_color'      => 'cccccc',
350
-            'field_border_width' => '1px',
351
-            'field_border_style' => 'solid',
352
-
353
-            'bg_color'          => 'ffffff',
354
-            //'bg_color_hv'       => 'ffffff',
347
+			'text_color'        => '555555',
348
+			//'border_color_hv'   => 'cccccc',
349
+			'border_color'      => 'cccccc',
350
+			'field_border_width' => '1px',
351
+			'field_border_style' => 'solid',
352
+
353
+			'bg_color'          => 'ffffff',
354
+			//'bg_color_hv'       => 'ffffff',
355 355
 			'remove_box_shadow' => '',
356
-            'bg_color_active'   => 'ffffff',
356
+			'bg_color_active'   => 'ffffff',
357 357
 			'border_color_active' => '66afe9',
358 358
 			'remove_box_shadow_active' => '',
359
-            'text_color_error'  => '444444',
360
-            'bg_color_error'    => 'ffffff',
359
+			'text_color_error'  => '444444',
360
+			'bg_color_error'    => 'ffffff',
361 361
 			'border_color_error' => 'B94A48',
362 362
 			'border_width_error' => '1px',
363 363
 			'border_style_error' => 'solid',
364
-            'bg_color_disabled' => 'ffffff',
365
-            'border_color_disabled' => 'E5E5E5',
366
-            'text_color_disabled' => 'A1A1A1',
367
-
368
-            'radio_align'       => 'block',
369
-            'check_align'       => 'block',
370
-            'check_font_size'   => '13px',
371
-            'check_label_color' => '444444',
372
-            'check_weight'      => 'normal',
373
-
374
-            'section_font_size' => '18px',
375
-            'section_color'     => '444444',
376
-            'section_weight'    => 'bold',
377
-            'section_pad'       => '15px 0 3px 0',
378
-            'section_mar_top'   => '15px',
364
+			'bg_color_disabled' => 'ffffff',
365
+			'border_color_disabled' => 'E5E5E5',
366
+			'text_color_disabled' => 'A1A1A1',
367
+
368
+			'radio_align'       => 'block',
369
+			'check_align'       => 'block',
370
+			'check_font_size'   => '13px',
371
+			'check_label_color' => '444444',
372
+			'check_weight'      => 'normal',
373
+
374
+			'section_font_size' => '18px',
375
+			'section_color'     => '444444',
376
+			'section_weight'    => 'bold',
377
+			'section_pad'       => '15px 0 3px 0',
378
+			'section_mar_top'   => '15px',
379 379
 			'section_mar_bottom' => '12px',
380
-            'section_bg_color'  => '',
381
-            'section_border_color' => 'e8e8e8',
382
-            'section_border_width' => '2px',
383
-            'section_border_style' => 'solid',
384
-            'section_border_loc' => '-top',
385
-            'collapse_icon'     => '6',
386
-            'collapse_pos'      => 'after',
387
-            'repeat_icon'       => '1',
388
-
389
-            'submit_style'      => false,
390
-            'submit_font_size'  => '14px',
391
-            'submit_width'      => 'auto',
392
-            'submit_height'     => 'auto',
393
-            'submit_bg_color'   => 'ffffff',
394
-            'submit_border_color' => 'cccccc',
395
-            'submit_border_width' => '1px',
396
-            'submit_text_color' => '444444',
397
-            'submit_weight'     => 'normal',
398
-            'submit_border_radius' => '4px',
399
-            'submit_bg_img'     => '',
400
-            'submit_margin'     => '10px',
401
-            'submit_padding'    => '6px 11px',
402
-            'submit_shadow_color' => 'eeeeee',
403
-            'submit_hover_bg_color' => 'efefef',
404
-            'submit_hover_color' => '444444',
405
-            'submit_hover_border_color' => 'cccccc',
406
-            'submit_active_bg_color' => 'efefef',
407
-            'submit_active_color' => '444444',
408
-            'submit_active_border_color' => 'cccccc',
409
-
410
-            'border_radius'     => '4px',
411
-            'error_bg'          => 'F2DEDE',
412
-            'error_border'      => 'EBCCD1',
413
-            'error_text'        => 'B94A48',
414
-            'error_font_size'   => '14px',
415
-
416
-            'success_bg_color'  => 'DFF0D8',
417
-            'success_border_color' => 'D6E9C6',
418
-            'success_text_color' => '468847',
419
-            'success_font_size' => '14px',
420
-
421
-            'important_style'   => false,
380
+			'section_bg_color'  => '',
381
+			'section_border_color' => 'e8e8e8',
382
+			'section_border_width' => '2px',
383
+			'section_border_style' => 'solid',
384
+			'section_border_loc' => '-top',
385
+			'collapse_icon'     => '6',
386
+			'collapse_pos'      => 'after',
387
+			'repeat_icon'       => '1',
388
+
389
+			'submit_style'      => false,
390
+			'submit_font_size'  => '14px',
391
+			'submit_width'      => 'auto',
392
+			'submit_height'     => 'auto',
393
+			'submit_bg_color'   => 'ffffff',
394
+			'submit_border_color' => 'cccccc',
395
+			'submit_border_width' => '1px',
396
+			'submit_text_color' => '444444',
397
+			'submit_weight'     => 'normal',
398
+			'submit_border_radius' => '4px',
399
+			'submit_bg_img'     => '',
400
+			'submit_margin'     => '10px',
401
+			'submit_padding'    => '6px 11px',
402
+			'submit_shadow_color' => 'eeeeee',
403
+			'submit_hover_bg_color' => 'efefef',
404
+			'submit_hover_color' => '444444',
405
+			'submit_hover_border_color' => 'cccccc',
406
+			'submit_active_bg_color' => 'efefef',
407
+			'submit_active_color' => '444444',
408
+			'submit_active_border_color' => 'cccccc',
409
+
410
+			'border_radius'     => '4px',
411
+			'error_bg'          => 'F2DEDE',
412
+			'error_border'      => 'EBCCD1',
413
+			'error_text'        => 'B94A48',
414
+			'error_font_size'   => '14px',
415
+
416
+			'success_bg_color'  => 'DFF0D8',
417
+			'success_border_color' => 'D6E9C6',
418
+			'success_text_color' => '468847',
419
+			'success_font_size' => '14px',
420
+
421
+			'important_style'   => false,
422 422
 
423 423
 			'progress_bg_color'     => 'dddddd',
424 424
 			'progress_active_color' => 'ffffff',
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
 			'progress_border_size'  => '2px',
429 429
 			'progress_size'         => '30px',
430 430
 
431
-            'custom_css'        => '',
432
-        );
433
-    }
431
+			'custom_css'        => '',
432
+		);
433
+	}
434 434
 
435 435
 	public function get_field_name( $field_name, $post_field = 'post_content' ) {
436 436
 		return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']';
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
         $max_slug_value = 2147483647;
17 17
         $min_slug_value = 37; // we want to have at least 2 characters in the slug
18
-        $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
18
+        $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
19 19
 
20 20
         $style = array(
21 21
             'post_type'     => FrmStylesController::$post_type,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function update( $id = 'default' ) {
42 42
  		$all_instances = $this->get_all();
43 43
 
44
- 		if ( empty($id) ) {
44
+ 		if ( empty( $id ) ) {
45 45
  		     $new_style = (array) $this->get_new();
46 46
  		     $all_instances[] = $new_style;
47 47
  		}
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         $action_ids = array();
50 50
 
51 51
  		foreach ( $all_instances as $number => $new_instance ) {
52
- 			$new_instance = stripslashes_deep( (array) $new_instance);
52
+ 			$new_instance = stripslashes_deep( (array) $new_instance );
53 53
  			$this->id = $new_instance['ID'];
54
- 			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) {
55
-				$all_instances[ $number ] = $new_instance;
54
+ 			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) {
55
+				$all_instances[$number] = $new_instance;
56 56
 
57
- 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) {
57
+ 			    if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) {
58 58
  			        // this style was set to default, so remove default setting on previous default style
59 59
  			        $new_instance['menu_order'] = 0;
60
- 			        $action_ids[] = $this->save($new_instance);
60
+ 			        $action_ids[] = $this->save( $new_instance );
61 61
  			    }
62 62
 
63 63
  			    // don't continue if not saving this style
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
  			$new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] );
68 68
  			$new_instance['post_content'] = $_POST['frm_style_setting']['post_content'];
69 69
  			$new_instance['post_type']  = FrmStylesController::$post_type;
70
-            $new_instance['post_status']  = 'publish';
70
+            $new_instance['post_status'] = 'publish';
71 71
 			$new_instance['menu_order']  = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0;
72 72
 
73
-            if ( empty($id) ) {
73
+            if ( empty( $id ) ) {
74 74
                 $new_instance['post_name'] = $new_instance['post_title'];
75 75
             }
76 76
 
77 77
             $default_settings = $this->get_defaults();
78 78
 
79 79
             foreach ( $default_settings as $setting => $default ) {
80
-				if ( ! isset( $new_instance['post_content'][ $setting ] ) ) {
81
-					$new_instance['post_content'][ $setting ] = $default;
80
+				if ( ! isset( $new_instance['post_content'][$setting] ) ) {
81
+					$new_instance['post_content'][$setting] = $default;
82 82
 				}
83 83
 
84 84
 				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) {
85 85
                     //if is a color
86
-					$new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] );
87
-				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) {
88
-					$new_instance['post_content'][ $setting ] = 0;
86
+					$new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] );
87
+				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) {
88
+					$new_instance['post_content'][$setting] = 0;
89 89
                 } else if ( $setting == 'font' ) {
90
-                	$new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] );
90
+                	$new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] );
91 91
                 }
92 92
             }
93 93
 
94
-			$all_instances[ $number ] = $new_instance;
94
+			$all_instances[$number] = $new_instance;
95 95
 
96
-            $action_ids[] = $this->save($new_instance);
96
+            $action_ids[] = $this->save( $new_instance );
97 97
 
98 98
  		}
99 99
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
      */
108 108
 	public function save_settings() {
109 109
 		$filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
110
-		update_option( 'frm_last_style_update', date('njGi') );
110
+		update_option( 'frm_last_style_update', date( 'njGi' ) );
111 111
 
112
-        if ( ! is_file($filename) ) {
112
+        if ( ! is_file( $filename ) ) {
113 113
             return;
114 114
         }
115 115
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	public function destroy( $id ) {
159
-        return wp_delete_post($id);
159
+        return wp_delete_post( $id );
160 160
     }
161 161
 
162 162
     public function get_one() {
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
             return $style;
171 171
         }
172 172
 
173
-        $style = get_post($this->id);
173
+        $style = get_post( $this->id );
174 174
 
175 175
         if ( ! $style ) {
176 176
             return $style;
177 177
         }
178 178
 
179
-        $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
179
+        $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
180 180
 
181 181
         $default_values = $this->get_defaults();
182 182
 
183 183
         // fill default values
184
-        $style->post_content = $this->override_defaults($style->post_content);
185
-        $style->post_content = wp_parse_args( $style->post_content, $default_values);
184
+        $style->post_content = $this->override_defaults( $style->post_content );
185
+        $style->post_content = wp_parse_args( $style->post_content, $default_values );
186 186
 
187 187
         return $style;
188 188
     }
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 
199 199
 		$temp_styles = FrmDb::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' );
200 200
 
201
-        if ( empty($temp_styles) ) {
201
+        if ( empty( $temp_styles ) ) {
202 202
             global $wpdb;
203 203
             // make sure there wasn't a conflict with the query
204 204
 			$query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' );
205
-            $temp_styles = FrmDb::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
205
+            $temp_styles = FrmDb::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' );
206 206
 
207
-            if ( empty($temp_styles) ) {
207
+            if ( empty( $temp_styles ) ) {
208 208
                 // create a new style if there are none
209 209
          		$new = $this->get_new();
210 210
 				$new->post_title = __( 'Formidable Style', 'formidable' );
211 211
 				$new->post_name = $new->post_title;
212 212
          		$new->menu_order = 1;
213
-         		$new = $this->save( (array) $new);
214
-         		$this->update('default');
213
+         		$new = $this->save( (array) $new );
214
+         		$this->update( 'default' );
215 215
 
216 216
                 $post_atts['include'] = $new;
217 217
 
@@ -235,25 +235,25 @@  discard block
 block discarded – undo
235 235
                 }
236 236
             }
237 237
 
238
-            $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
238
+            $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content );
239 239
 
240 240
             // fill default values
241
-            $style->post_content = $this->override_defaults($style->post_content);
242
-            $style->post_content = wp_parse_args( $style->post_content, $default_values);
241
+            $style->post_content = $this->override_defaults( $style->post_content );
242
+            $style->post_content = wp_parse_args( $style->post_content, $default_values );
243 243
 
244
-			$styles[ $style->ID ] = $style;
244
+			$styles[$style->ID] = $style;
245 245
         }
246 246
 
247 247
         if ( ! $default_style ) {
248
-            $default_style = reset($styles);
249
-			$styles[ $default_style->ID ]->menu_order = 1;
248
+            $default_style = reset( $styles );
249
+			$styles[$default_style->ID]->menu_order = 1;
250 250
         }
251 251
 
252 252
         return $styles;
253 253
     }
254 254
 
255 255
 	public function get_default_style( $styles = null ) {
256
-        if ( ! isset($styles) ) {
256
+        if ( ! isset( $styles ) ) {
257 257
 			$styles = $this->get_all( 'menu_order', 'DESC', 1 );
258 258
         }
259 259
 
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
     }
266 266
 
267 267
 	public function override_defaults( $settings ) {
268
-	    if ( ! is_array($settings) ) {
268
+	    if ( ! is_array( $settings ) ) {
269 269
 	        return $settings;
270 270
 	    }
271 271
 
272 272
 		$settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height'];
273 273
 
274
-	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) {
274
+	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) {
275 275
 	        $settings['form_desc_size'] = $settings['description_font_size'];
276 276
 	        $settings['form_desc_color'] = $settings['description_color'];
277 277
 	        $settings['title_color'] = $settings['label_color'];
278 278
 	    }
279 279
 
280
-	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) {
280
+	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) {
281 281
 	        $settings['section_color'] = $settings['label_color'];
282 282
 	        $settings['section_border_color'] = $settings['border_color'];
283 283
 	    }
284 284
 
285
-	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) {
285
+	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) {
286 286
 	        $settings['submit_hover_bg_color'] = $settings['submit_bg_color'];
287 287
 	        $settings['submit_hover_color'] = $settings['submit_text_color'];
288 288
 	        $settings['submit_hover_border_color'] = $settings['submit_border_color'];
Please login to merge, or discard this patch.