@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmStylesController { |
4 | - public static $post_type = 'frm_styles'; |
|
5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
6 | - |
|
7 | - public static function load_pro_hooks() { |
|
8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | - FrmProStylesController::load_pro_hooks(); |
|
10 | - } |
|
11 | - } |
|
12 | - |
|
13 | - public static function register_post_types() { |
|
14 | - register_post_type( self::$post_type, array( |
|
15 | - 'label' => __( 'Styles', 'formidable' ), |
|
16 | - 'public' => false, |
|
17 | - 'show_ui' => false, |
|
18 | - 'capability_type' => 'page', |
|
4 | + public static $post_type = 'frm_styles'; |
|
5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
6 | + |
|
7 | + public static function load_pro_hooks() { |
|
8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | + FrmProStylesController::load_pro_hooks(); |
|
10 | + } |
|
11 | + } |
|
12 | + |
|
13 | + public static function register_post_types() { |
|
14 | + register_post_type( self::$post_type, array( |
|
15 | + 'label' => __( 'Styles', 'formidable' ), |
|
16 | + 'public' => false, |
|
17 | + 'show_ui' => false, |
|
18 | + 'capability_type' => 'page', |
|
19 | 19 | 'capabilities' => array( |
20 | 20 | 'edit_post' => 'frm_change_settings', |
21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | 'delete_posts' => 'frm_change_settings', |
26 | 26 | 'read_private_posts' => 'read_private_posts', |
27 | 27 | ), |
28 | - 'supports' => array( |
|
28 | + 'supports' => array( |
|
29 | 29 | 'title', |
30 | - ), |
|
31 | - 'has_archive' => false, |
|
32 | - 'labels' => array( |
|
30 | + ), |
|
31 | + 'has_archive' => false, |
|
32 | + 'labels' => array( |
|
33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,31 +37,31 @@ discard block |
||
37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
39 | 39 | ), |
40 | - ) ); |
|
41 | - } |
|
40 | + ) ); |
|
41 | + } |
|
42 | 42 | |
43 | - public static function menu() { |
|
44 | - add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
45 | - } |
|
43 | + public static function menu() { |
|
44 | + add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
45 | + } |
|
46 | 46 | |
47 | - public static function admin_init() { |
|
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | - return; |
|
50 | - } |
|
47 | + public static function admin_init() { |
|
48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | + return; |
|
50 | + } |
|
51 | 51 | |
52 | - self::load_pro_hooks(); |
|
53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
52 | + self::load_pro_hooks(); |
|
53 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
54 | 54 | |
55 | - $version = FrmAppHelper::plugin_version(); |
|
55 | + $version = FrmAppHelper::plugin_version(); |
|
56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
57 | 57 | |
58 | - wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
58 | + wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
59 | 59 | |
60 | - $style = apply_filters('frm_style_head', false); |
|
61 | - if ( $style ) { |
|
62 | - wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
63 | - } |
|
64 | - } |
|
60 | + $style = apply_filters('frm_style_head', false); |
|
61 | + if ( $style ) { |
|
62 | + wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public static function enqueue_css( $register = 'enqueue' ) { |
67 | 67 | global $frm_vars; |
@@ -128,229 +128,229 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | public static function new_style( $return = '' ) { |
131 | - self::load_styler('default'); |
|
132 | - } |
|
131 | + self::load_styler('default'); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | public static function duplicate() { |
135 | 135 | self::load_styler('default'); |
136 | 136 | } |
137 | 137 | |
138 | 138 | public static function edit( $style_id = false, $message = '' ) { |
139 | - if ( ! $style_id ) { |
|
139 | + if ( ! $style_id ) { |
|
140 | 140 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
141 | - if ( empty($style_id) ) { |
|
142 | - $style_id = 'default'; |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - if ( 'default' == $style_id ) { |
|
147 | - $style = 'default'; |
|
148 | - } else { |
|
149 | - $frm_style = new FrmStyle($style_id); |
|
150 | - $style = $frm_style->get_one(); |
|
151 | - $style = $style->ID; |
|
152 | - } |
|
153 | - |
|
154 | - self::load_styler($style, $message); |
|
155 | - } |
|
156 | - |
|
157 | - public static function save() { |
|
158 | - $frm_style = new FrmStyle(); |
|
159 | - $message = ''; |
|
141 | + if ( empty($style_id) ) { |
|
142 | + $style_id = 'default'; |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + if ( 'default' == $style_id ) { |
|
147 | + $style = 'default'; |
|
148 | + } else { |
|
149 | + $frm_style = new FrmStyle($style_id); |
|
150 | + $style = $frm_style->get_one(); |
|
151 | + $style = $style->ID; |
|
152 | + } |
|
153 | + |
|
154 | + self::load_styler($style, $message); |
|
155 | + } |
|
156 | + |
|
157 | + public static function save() { |
|
158 | + $frm_style = new FrmStyle(); |
|
159 | + $message = ''; |
|
160 | 160 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
161 | 161 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
162 | 162 | |
163 | 163 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
164 | - $id = $frm_style->update($post_id); |
|
165 | - if ( empty($post_id) && ! empty($id) ) { |
|
166 | - // set the post id to the new style so it will be loaded for editing |
|
167 | - $post_id = reset($id); |
|
168 | - } |
|
169 | - // include the CSS that includes this style |
|
164 | + $id = $frm_style->update($post_id); |
|
165 | + if ( empty($post_id) && ! empty($id) ) { |
|
166 | + // set the post id to the new style so it will be loaded for editing |
|
167 | + $post_id = reset($id); |
|
168 | + } |
|
169 | + // include the CSS that includes this style |
|
170 | 170 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
171 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
172 | - } |
|
171 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
172 | + } |
|
173 | 173 | |
174 | - return self::edit($post_id, $message); |
|
175 | - } |
|
174 | + return self::edit($post_id, $message); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | public static function load_styler( $style, $message = '' ) { |
178 | - global $frm_settings; |
|
178 | + global $frm_settings; |
|
179 | 179 | |
180 | - $frm_style = new FrmStyle(); |
|
181 | - $styles = $frm_style->get_all(); |
|
180 | + $frm_style = new FrmStyle(); |
|
181 | + $styles = $frm_style->get_all(); |
|
182 | 182 | |
183 | - if ( is_numeric($style) ) { |
|
184 | - $style = $styles[ $style ]; |
|
185 | - } else if ( 'default' == $style ) { |
|
186 | - $style = $frm_style->get_default_style($styles); |
|
187 | - } |
|
183 | + if ( is_numeric($style) ) { |
|
184 | + $style = $styles[ $style ]; |
|
185 | + } else if ( 'default' == $style ) { |
|
186 | + $style = $frm_style->get_default_style($styles); |
|
187 | + } |
|
188 | 188 | |
189 | - self::add_meta_boxes(); |
|
189 | + self::add_meta_boxes(); |
|
190 | 190 | |
191 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
192 | - } |
|
191 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * @param string $message |
196 | 196 | * @param array|object $forms |
197 | 197 | */ |
198 | 198 | private static function manage( $message = '', $forms = array() ) { |
199 | - $frm_style = new FrmStyle(); |
|
200 | - $styles = $frm_style->get_all(); |
|
201 | - $default_style = $frm_style->get_default_style($styles); |
|
199 | + $frm_style = new FrmStyle(); |
|
200 | + $styles = $frm_style->get_all(); |
|
201 | + $default_style = $frm_style->get_default_style($styles); |
|
202 | 202 | |
203 | - if ( empty($forms) ) { |
|
204 | - $forms = FrmForm::get_published_forms(); |
|
205 | - } |
|
203 | + if ( empty($forms) ) { |
|
204 | + $forms = FrmForm::get_published_forms(); |
|
205 | + } |
|
206 | 206 | |
207 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
208 | - } |
|
207 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
208 | + } |
|
209 | 209 | |
210 | - private static function manage_styles() { |
|
210 | + private static function manage_styles() { |
|
211 | 211 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
212 | 212 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
213 | - return self::manage(); |
|
214 | - } |
|
213 | + return self::manage(); |
|
214 | + } |
|
215 | 215 | |
216 | - global $wpdb; |
|
216 | + global $wpdb; |
|
217 | 217 | |
218 | 218 | $forms = FrmForm::get_published_forms(); |
219 | - foreach ( $forms as $form ) { |
|
220 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
221 | - continue; |
|
222 | - } |
|
219 | + foreach ( $forms as $form ) { |
|
220 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
221 | + continue; |
|
222 | + } |
|
223 | 223 | |
224 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
224 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
225 | 225 | |
226 | 226 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
227 | - unset($form); |
|
228 | - } |
|
227 | + unset($form); |
|
228 | + } |
|
229 | 229 | |
230 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
231 | - return self::manage($message, $forms); |
|
232 | - } |
|
230 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
231 | + return self::manage($message, $forms); |
|
232 | + } |
|
233 | 233 | |
234 | - public static function custom_css( $message = '', $style = null ) { |
|
235 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
236 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
237 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
234 | + public static function custom_css( $message = '', $style = null ) { |
|
235 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
236 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
237 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
238 | 238 | |
239 | - if ( ! isset($style) ) { |
|
240 | - $frm_style = new FrmStyle(); |
|
241 | - $style = $frm_style->get_default_style(); |
|
242 | - } |
|
239 | + if ( ! isset($style) ) { |
|
240 | + $frm_style = new FrmStyle(); |
|
241 | + $style = $frm_style->get_default_style(); |
|
242 | + } |
|
243 | 243 | |
244 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
245 | - } |
|
244 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
245 | + } |
|
246 | 246 | |
247 | - public static function save_css() { |
|
248 | - $frm_style = new FrmStyle(); |
|
247 | + public static function save_css() { |
|
248 | + $frm_style = new FrmStyle(); |
|
249 | 249 | |
250 | - $message = ''; |
|
250 | + $message = ''; |
|
251 | 251 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
252 | 252 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
253 | 253 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
254 | - $frm_style->update($post_id); |
|
255 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
256 | - } |
|
254 | + $frm_style->update($post_id); |
|
255 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
256 | + } |
|
257 | 257 | |
258 | - return self::custom_css($message); |
|
259 | - } |
|
258 | + return self::custom_css($message); |
|
259 | + } |
|
260 | 260 | |
261 | - public static function route() { |
|
261 | + public static function route() { |
|
262 | 262 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
263 | 263 | |
264 | - switch ( $action ) { |
|
265 | - case 'edit': |
|
266 | - case 'save': |
|
267 | - case 'manage': |
|
268 | - case 'manage_styles': |
|
269 | - case 'custom_css': |
|
270 | - case 'save_css': |
|
264 | + switch ( $action ) { |
|
265 | + case 'edit': |
|
266 | + case 'save': |
|
267 | + case 'manage': |
|
268 | + case 'manage_styles': |
|
269 | + case 'custom_css': |
|
270 | + case 'save_css': |
|
271 | 271 | return self::$action(); |
272 | - default: |
|
273 | - do_action( 'frm_style_action_route', $action ); |
|
274 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
275 | - return; |
|
276 | - } |
|
277 | - |
|
278 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
279 | - return self::$action(); |
|
280 | - } |
|
281 | - |
|
282 | - return self::edit(); |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - public static function reset_styling() { |
|
287 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
288 | - |
|
289 | - $frm_style = new FrmStyle(); |
|
290 | - $defaults = $frm_style->get_defaults(); |
|
291 | - |
|
292 | - echo json_encode( $defaults ); |
|
293 | - wp_die(); |
|
294 | - } |
|
295 | - |
|
296 | - public static function change_styling() { |
|
297 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
298 | - |
|
299 | - $frm_style = new FrmStyle(); |
|
300 | - $defaults = $frm_style->get_defaults(); |
|
301 | - |
|
302 | - // remove the # from the colors |
|
303 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
304 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
305 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - echo '<style type="text/css">'; |
|
310 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
311 | - echo '</style>'; |
|
312 | - wp_die(); |
|
313 | - } |
|
314 | - |
|
315 | - private static function add_meta_boxes() { |
|
316 | - |
|
317 | - // setup meta boxes |
|
318 | - $meta_boxes = array( |
|
319 | - 'general' => __( 'General', 'formidable' ), |
|
320 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
321 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
322 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
323 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
324 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
325 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
326 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
327 | - 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
328 | - 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
329 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
330 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
331 | - ); |
|
332 | - |
|
333 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
334 | - add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
335 | - unset($nicename, $name); |
|
336 | - } |
|
337 | - } |
|
272 | + default: |
|
273 | + do_action( 'frm_style_action_route', $action ); |
|
274 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
275 | + return; |
|
276 | + } |
|
277 | + |
|
278 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
279 | + return self::$action(); |
|
280 | + } |
|
281 | + |
|
282 | + return self::edit(); |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + public static function reset_styling() { |
|
287 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
288 | + |
|
289 | + $frm_style = new FrmStyle(); |
|
290 | + $defaults = $frm_style->get_defaults(); |
|
291 | + |
|
292 | + echo json_encode( $defaults ); |
|
293 | + wp_die(); |
|
294 | + } |
|
295 | + |
|
296 | + public static function change_styling() { |
|
297 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
298 | + |
|
299 | + $frm_style = new FrmStyle(); |
|
300 | + $defaults = $frm_style->get_defaults(); |
|
301 | + |
|
302 | + // remove the # from the colors |
|
303 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
304 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
305 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + echo '<style type="text/css">'; |
|
310 | + include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
311 | + echo '</style>'; |
|
312 | + wp_die(); |
|
313 | + } |
|
314 | + |
|
315 | + private static function add_meta_boxes() { |
|
316 | + |
|
317 | + // setup meta boxes |
|
318 | + $meta_boxes = array( |
|
319 | + 'general' => __( 'General', 'formidable' ), |
|
320 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
321 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
322 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
323 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
324 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
325 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
326 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
327 | + 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
328 | + 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
329 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
330 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
331 | + ); |
|
332 | + |
|
333 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
334 | + add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
335 | + unset($nicename, $name); |
|
336 | + } |
|
337 | + } |
|
338 | 338 | |
339 | 339 | public static function include_style_section( $atts, $sec ) { |
340 | - extract($atts); |
|
340 | + extract($atts); |
|
341 | 341 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
342 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
343 | - } |
|
342 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
343 | + } |
|
344 | 344 | |
345 | - public static function load_css() { |
|
346 | - header('Content-type: text/css'); |
|
345 | + public static function load_css() { |
|
346 | + header('Content-type: text/css'); |
|
347 | 347 | |
348 | - $frm_style = new FrmStyle(); |
|
349 | - $defaults = $frm_style->get_defaults(); |
|
348 | + $frm_style = new FrmStyle(); |
|
349 | + $defaults = $frm_style->get_defaults(); |
|
350 | 350 | |
351 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
352 | - wp_die(); |
|
353 | - } |
|
351 | + include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
352 | + wp_die(); |
|
353 | + } |
|
354 | 354 | |
355 | 355 | public static function load_saved_css() { |
356 | 356 | $css = get_transient( 'frmpro_css' ); |
@@ -359,142 +359,142 @@ discard block |
||
359 | 359 | wp_die(); |
360 | 360 | } |
361 | 361 | |
362 | - /** |
|
363 | - * Check if the Formidable styling should be loaded, |
|
364 | - * then enqueue it for the footer |
|
365 | - * @since 2.0 |
|
366 | - */ |
|
367 | - public static function enqueue_style() { |
|
368 | - global $frm_vars; |
|
369 | - |
|
370 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
371 | - // the CSS has already been loaded |
|
372 | - return; |
|
373 | - } |
|
374 | - |
|
375 | - $frm_settings = FrmAppHelper::get_settings(); |
|
376 | - if ( $frm_settings->load_style != 'none' ) { |
|
377 | - wp_enqueue_style( 'formidable' ); |
|
378 | - $frm_vars['css_loaded'] = true; |
|
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - // Get the stylesheets for the form settings page |
|
383 | - public static function get_style_opts() { |
|
384 | - $frm_style = new FrmStyle(); |
|
385 | - $styles = $frm_style->get_all(); |
|
386 | - |
|
387 | - return $styles; |
|
388 | - } |
|
389 | - |
|
390 | - public static function get_form_style( $form = 'default' ) { |
|
391 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
392 | - |
|
393 | - if ( empty( $style ) || 1 == $style ) { |
|
394 | - $style = 'default'; |
|
395 | - } |
|
396 | - |
|
397 | - $frm_style = new FrmStyle( $style ); |
|
398 | - return $frm_style->get_one(); |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * @param string $class |
|
403 | - * @param string $style |
|
404 | - */ |
|
362 | + /** |
|
363 | + * Check if the Formidable styling should be loaded, |
|
364 | + * then enqueue it for the footer |
|
365 | + * @since 2.0 |
|
366 | + */ |
|
367 | + public static function enqueue_style() { |
|
368 | + global $frm_vars; |
|
369 | + |
|
370 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
371 | + // the CSS has already been loaded |
|
372 | + return; |
|
373 | + } |
|
374 | + |
|
375 | + $frm_settings = FrmAppHelper::get_settings(); |
|
376 | + if ( $frm_settings->load_style != 'none' ) { |
|
377 | + wp_enqueue_style( 'formidable' ); |
|
378 | + $frm_vars['css_loaded'] = true; |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + // Get the stylesheets for the form settings page |
|
383 | + public static function get_style_opts() { |
|
384 | + $frm_style = new FrmStyle(); |
|
385 | + $styles = $frm_style->get_all(); |
|
386 | + |
|
387 | + return $styles; |
|
388 | + } |
|
389 | + |
|
390 | + public static function get_form_style( $form = 'default' ) { |
|
391 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
392 | + |
|
393 | + if ( empty( $style ) || 1 == $style ) { |
|
394 | + $style = 'default'; |
|
395 | + } |
|
396 | + |
|
397 | + $frm_style = new FrmStyle( $style ); |
|
398 | + return $frm_style->get_one(); |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * @param string $class |
|
403 | + * @param string $style |
|
404 | + */ |
|
405 | 405 | public static function get_form_style_class( $class, $style ) { |
406 | - if ( 1 == $style ) { |
|
407 | - $style = 'default'; |
|
408 | - } |
|
406 | + if ( 1 == $style ) { |
|
407 | + $style = 'default'; |
|
408 | + } |
|
409 | 409 | |
410 | - $frm_style = new FrmStyle($style); |
|
411 | - $style = $frm_style->get_one(); |
|
410 | + $frm_style = new FrmStyle($style); |
|
411 | + $style = $frm_style->get_one(); |
|
412 | 412 | |
413 | - if ( $style ) { |
|
414 | - $class .= ' frm_style_'. $style->post_name; |
|
415 | - } |
|
413 | + if ( $style ) { |
|
414 | + $class .= ' frm_style_'. $style->post_name; |
|
415 | + } |
|
416 | 416 | |
417 | - return $class; |
|
418 | - } |
|
417 | + return $class; |
|
418 | + } |
|
419 | 419 | |
420 | - /** |
|
421 | - * @param string $val |
|
422 | - */ |
|
420 | + /** |
|
421 | + * @param string $val |
|
422 | + */ |
|
423 | 423 | public static function get_style_val( $val, $form = 'default' ) { |
424 | - $style = self::get_form_style($form); |
|
425 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
426 | - return $style->post_content[ $val ]; |
|
427 | - } |
|
428 | - } |
|
424 | + $style = self::get_form_style($form); |
|
425 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
426 | + return $style->post_content[ $val ]; |
|
427 | + } |
|
428 | + } |
|
429 | 429 | |
430 | 430 | public static function show_entry_styles( $default_styles ) { |
431 | - $frm_style = new FrmStyle('default'); |
|
432 | - $style = $frm_style->get_one(); |
|
433 | - |
|
434 | - if ( ! $style ) { |
|
435 | - return $default_styles; |
|
436 | - } |
|
437 | - |
|
438 | - foreach ( $default_styles as $name => $val ) { |
|
439 | - $setting = $name; |
|
440 | - if ( 'border_width' == $name ) { |
|
441 | - $setting = 'field_border_width'; |
|
442 | - } else if ( 'alt_bg_color' == $name ) { |
|
443 | - $setting = 'bg_color_active'; |
|
444 | - } |
|
445 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
446 | - unset($name, $val); |
|
447 | - } |
|
448 | - |
|
449 | - return $default_styles; |
|
450 | - } |
|
431 | + $frm_style = new FrmStyle('default'); |
|
432 | + $style = $frm_style->get_one(); |
|
433 | + |
|
434 | + if ( ! $style ) { |
|
435 | + return $default_styles; |
|
436 | + } |
|
437 | + |
|
438 | + foreach ( $default_styles as $name => $val ) { |
|
439 | + $setting = $name; |
|
440 | + if ( 'border_width' == $name ) { |
|
441 | + $setting = 'field_border_width'; |
|
442 | + } else if ( 'alt_bg_color' == $name ) { |
|
443 | + $setting = 'bg_color_active'; |
|
444 | + } |
|
445 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
446 | + unset($name, $val); |
|
447 | + } |
|
448 | + |
|
449 | + return $default_styles; |
|
450 | + } |
|
451 | 451 | |
452 | 452 | public static function &important_style( $important, $field ) { |
453 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
454 | - return $important; |
|
455 | - } |
|
453 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
454 | + return $important; |
|
455 | + } |
|
456 | 456 | |
457 | - /** |
|
458 | - * Fallback for WP < 3.6 |
|
459 | - */ |
|
460 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
461 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
462 | - return do_accordion_sections( $screen, $context, $object ); |
|
463 | - } |
|
457 | + /** |
|
458 | + * Fallback for WP < 3.6 |
|
459 | + */ |
|
460 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
461 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
462 | + return do_accordion_sections( $screen, $context, $object ); |
|
463 | + } |
|
464 | 464 | |
465 | - global $wp_meta_boxes; |
|
465 | + global $wp_meta_boxes; |
|
466 | 466 | |
467 | - $screen = 'formidable_page_formidable-styles'; |
|
468 | - $screen = convert_to_screen( $screen ); |
|
467 | + $screen = 'formidable_page_formidable-styles'; |
|
468 | + $screen = convert_to_screen( $screen ); |
|
469 | 469 | |
470 | - $page = $screen->id; |
|
470 | + $page = $screen->id; |
|
471 | 471 | |
472 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
473 | - ?> |
|
472 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
473 | + ?> |
|
474 | 474 | <div id="side-sortables" class="accordion-container"> |
475 | 475 | <?php |
476 | - $i = 0; |
|
477 | - $first_open = false; |
|
478 | - do { |
|
476 | + $i = 0; |
|
477 | + $first_open = false; |
|
478 | + do { |
|
479 | 479 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
480 | 480 | break; |
481 | 481 | } |
482 | 482 | |
483 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
484 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
485 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
486 | - if ( false == $box || ! $box['title'] ) { |
|
487 | - continue; |
|
483 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
484 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
485 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
486 | + if ( false == $box || ! $box['title'] ) { |
|
487 | + continue; |
|
488 | 488 | } |
489 | 489 | |
490 | - $i++; |
|
491 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
490 | + $i++; |
|
491 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
492 | 492 | |
493 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
494 | - $first_open = true; |
|
495 | - } |
|
493 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
494 | + $first_open = true; |
|
495 | + } |
|
496 | 496 | |
497 | - ?> |
|
497 | + ?> |
|
498 | 498 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
499 | 499 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
500 | 500 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -505,13 +505,13 @@ discard block |
||
505 | 505 | </div><!-- .accordion-section-content --> |
506 | 506 | </div><!-- .postbox --> |
507 | 507 | <?php |
508 | - } |
|
509 | - } |
|
510 | - } |
|
511 | - } while ( 0 ); |
|
512 | - ?> |
|
508 | + } |
|
509 | + } |
|
510 | + } |
|
511 | + } while ( 0 ); |
|
512 | + ?> |
|
513 | 513 | </div><!-- .accordion-container --> |
514 | 514 | <?php |
515 | - return $i; |
|
516 | - } |
|
515 | + return $i; |
|
516 | + } |
|
517 | 517 | } |
@@ -1,52 +1,52 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStyle { |
3 | - public $number = false; // Unique ID number of the current instance. |
|
3 | + public $number = false; // Unique ID number of the current instance. |
|
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
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 = pow(36, 6); |
|
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 = pow(36, 6); |
|
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 FrmAppHelper::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,40 +54,40 @@ discard block |
||
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 ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
81 | - //if is a color |
|
81 | + //if is a color |
|
82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
85 | - } |
|
86 | - } |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $all_instances[ $number ] = $new_instance; |
89 | 89 | |
90 | - $action_ids[] = $this->save($new_instance); |
|
90 | + $action_ids[] = $this->save($new_instance); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -96,74 +96,74 @@ discard block |
||
96 | 96 | return $action_ids; |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Create static css file |
|
101 | - */ |
|
99 | + /** |
|
100 | + * Create static css file |
|
101 | + */ |
|
102 | 102 | public function save_settings( $styles ) { |
103 | - $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
103 | + $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
104 | 104 | |
105 | - if ( ! is_file($filename) ) { |
|
106 | - return; |
|
107 | - } |
|
105 | + if ( ! is_file($filename) ) { |
|
106 | + return; |
|
107 | + } |
|
108 | 108 | |
109 | - $defaults = $this->get_defaults(); |
|
110 | - $uploads = wp_upload_dir(); |
|
111 | - $target_path = $uploads['basedir'] .'/formidable'; |
|
112 | - $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
113 | - $dirs_exist = true; |
|
109 | + $defaults = $this->get_defaults(); |
|
110 | + $uploads = wp_upload_dir(); |
|
111 | + $target_path = $uploads['basedir'] .'/formidable'; |
|
112 | + $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
113 | + $dirs_exist = true; |
|
114 | 114 | |
115 | - $saving = true; |
|
116 | - $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
115 | + $saving = true; |
|
116 | + $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
117 | 117 | |
118 | - ob_start(); |
|
119 | - $frm_style = $this; |
|
120 | - include($filename); |
|
118 | + ob_start(); |
|
119 | + $frm_style = $this; |
|
120 | + include($filename); |
|
121 | 121 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
122 | - ob_end_clean(); |
|
122 | + ob_end_clean(); |
|
123 | 123 | |
124 | - $access_type = get_filesystem_method(); |
|
125 | - if ( $access_type === 'direct' ) { |
|
126 | - $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
124 | + $access_type = get_filesystem_method(); |
|
125 | + if ( $access_type === 'direct' ) { |
|
126 | + $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
127 | 127 | } else { |
128 | 128 | $creds = $this->get_ftp_creds( $access_type ); |
129 | 129 | } |
130 | 130 | |
131 | 131 | if ( ! empty( $creds ) ) { |
132 | - // initialize the API |
|
133 | - if ( ! WP_Filesystem( $creds ) ) { |
|
134 | - // any problems and we exit |
|
135 | - $dirs_exist = false; |
|
132 | + // initialize the API |
|
133 | + if ( ! WP_Filesystem( $creds ) ) { |
|
134 | + // any problems and we exit |
|
135 | + $dirs_exist = false; |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( $dirs_exist ) { |
|
139 | - global $wp_filesystem; |
|
138 | + if ( $dirs_exist ) { |
|
139 | + global $wp_filesystem; |
|
140 | 140 | |
141 | - $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
142 | - $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
141 | + $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
142 | + $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
143 | 143 | |
144 | - // Create the directories if need be: |
|
145 | - foreach ( $needed_dirs as $_dir ) { |
|
146 | - // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
|
147 | - if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
148 | - $dirs_exist = false; |
|
149 | - } |
|
150 | - } |
|
144 | + // Create the directories if need be: |
|
145 | + foreach ( $needed_dirs as $_dir ) { |
|
146 | + // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
|
147 | + if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
148 | + $dirs_exist = false; |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - $index_path = $target_path .'/index.php'; |
|
153 | - $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
|
152 | + $index_path = $target_path .'/index.php'; |
|
153 | + $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
|
154 | 154 | |
155 | - // only write the file if the folders exist |
|
156 | - if ( $dirs_exist ) { |
|
157 | - $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | - $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
155 | + // only write the file if the folders exist |
|
156 | + if ( $dirs_exist ) { |
|
157 | + $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | + $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | 162 | |
163 | - update_option('frmpro_css', $css); |
|
163 | + update_option('frmpro_css', $css); |
|
164 | 164 | |
165 | - delete_transient('frmpro_css'); |
|
166 | - set_transient('frmpro_css', $css); |
|
165 | + delete_transient('frmpro_css'); |
|
166 | + set_transient('frmpro_css', $css); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | private function get_ftp_creds( $type ) { |
@@ -217,271 +217,271 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | public function destroy( $id ) { |
220 | - return wp_delete_post($id); |
|
221 | - } |
|
220 | + return wp_delete_post($id); |
|
221 | + } |
|
222 | 222 | |
223 | - public function get_one() { |
|
224 | - if ( 'default' == $this->id ) { |
|
225 | - $style = $this->get_default_style(); |
|
226 | - if ( $style ) { |
|
227 | - $this->id = $style->ID; |
|
228 | - } else { |
|
229 | - $this->id = 0; |
|
230 | - } |
|
231 | - return $style; |
|
232 | - } |
|
223 | + public function get_one() { |
|
224 | + if ( 'default' == $this->id ) { |
|
225 | + $style = $this->get_default_style(); |
|
226 | + if ( $style ) { |
|
227 | + $this->id = $style->ID; |
|
228 | + } else { |
|
229 | + $this->id = 0; |
|
230 | + } |
|
231 | + return $style; |
|
232 | + } |
|
233 | 233 | |
234 | - $style = get_post($this->id); |
|
234 | + $style = get_post($this->id); |
|
235 | 235 | |
236 | - if ( ! $style ) { |
|
237 | - return $style; |
|
238 | - } |
|
236 | + if ( ! $style ) { |
|
237 | + return $style; |
|
238 | + } |
|
239 | 239 | |
240 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
240 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
241 | 241 | |
242 | - $default_values = $this->get_defaults(); |
|
242 | + $default_values = $this->get_defaults(); |
|
243 | 243 | |
244 | - // fill default values |
|
245 | - $style->post_content = $this->override_defaults($style->post_content); |
|
246 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
244 | + // fill default values |
|
245 | + $style->post_content = $this->override_defaults($style->post_content); |
|
246 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
247 | 247 | |
248 | - return $style; |
|
249 | - } |
|
248 | + return $style; |
|
249 | + } |
|
250 | 250 | |
251 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
252 | - $post_atts = array( |
|
251 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
252 | + $post_atts = array( |
|
253 | 253 | 'post_type' => FrmStylesController::$post_type, |
254 | 254 | 'post_status' => 'publish', |
255 | 255 | 'numberposts' => $limit, |
256 | 256 | 'orderby' => $orderby, |
257 | 257 | 'order' => $order, |
258 | - ); |
|
259 | - |
|
260 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | - |
|
262 | - if ( empty($temp_styles) ) { |
|
263 | - global $wpdb; |
|
264 | - // make sure there wasn't a conflict with the query |
|
265 | - $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'); |
|
266 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
267 | - |
|
268 | - if ( empty($temp_styles) ) { |
|
269 | - // create a new style if there are none |
|
270 | - $new = $this->get_new(); |
|
271 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
272 | - $new->menu_order = 1; |
|
273 | - $new = $this->save( (array) $new); |
|
274 | - $this->update('default'); |
|
275 | - |
|
276 | - $post_atts['include'] = $new; |
|
277 | - |
|
278 | - $temp_styles = get_posts( $post_atts ); |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - $default_values = $this->get_defaults(); |
|
283 | - $default_style = false; |
|
284 | - |
|
285 | - $styles = array(); |
|
286 | - foreach ( $temp_styles as $style ) { |
|
287 | - $this->id = $style->ID; |
|
288 | - if ( $style->menu_order ) { |
|
289 | - if ( $default_style ) { |
|
290 | - // only return one default |
|
291 | - $style->menu_order = 0; |
|
292 | - } else { |
|
293 | - // check for a default style |
|
294 | - $default_style = $style->ID; |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | - |
|
300 | - // fill default values |
|
301 | - $style->post_content = $this->override_defaults($style->post_content); |
|
302 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
258 | + ); |
|
259 | + |
|
260 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | + |
|
262 | + if ( empty($temp_styles) ) { |
|
263 | + global $wpdb; |
|
264 | + // make sure there wasn't a conflict with the query |
|
265 | + $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'); |
|
266 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
267 | + |
|
268 | + if ( empty($temp_styles) ) { |
|
269 | + // create a new style if there are none |
|
270 | + $new = $this->get_new(); |
|
271 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
272 | + $new->menu_order = 1; |
|
273 | + $new = $this->save( (array) $new); |
|
274 | + $this->update('default'); |
|
275 | + |
|
276 | + $post_atts['include'] = $new; |
|
277 | + |
|
278 | + $temp_styles = get_posts( $post_atts ); |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + $default_values = $this->get_defaults(); |
|
283 | + $default_style = false; |
|
284 | + |
|
285 | + $styles = array(); |
|
286 | + foreach ( $temp_styles as $style ) { |
|
287 | + $this->id = $style->ID; |
|
288 | + if ( $style->menu_order ) { |
|
289 | + if ( $default_style ) { |
|
290 | + // only return one default |
|
291 | + $style->menu_order = 0; |
|
292 | + } else { |
|
293 | + // check for a default style |
|
294 | + $default_style = $style->ID; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | + |
|
300 | + // fill default values |
|
301 | + $style->post_content = $this->override_defaults($style->post_content); |
|
302 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
303 | 303 | |
304 | 304 | $styles[ $style->ID ] = $style; |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | - if ( ! $default_style ) { |
|
308 | - $default_style = reset($styles); |
|
307 | + if ( ! $default_style ) { |
|
308 | + $default_style = reset($styles); |
|
309 | 309 | $styles[ $default_style->ID ]->menu_order = 1; |
310 | - } |
|
310 | + } |
|
311 | 311 | |
312 | - return $styles; |
|
313 | - } |
|
312 | + return $styles; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | public function get_default_style( $styles = null ) { |
316 | - if ( ! isset($styles) ) { |
|
316 | + if ( ! isset($styles) ) { |
|
317 | 317 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
318 | - } |
|
318 | + } |
|
319 | 319 | |
320 | - foreach ( $styles as $style ) { |
|
321 | - if ( $style->menu_order ) { |
|
322 | - return $style; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
320 | + foreach ( $styles as $style ) { |
|
321 | + if ( $style->menu_order ) { |
|
322 | + return $style; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | 327 | public function override_defaults( $settings ) { |
328 | - if ( ! is_array($settings) ) { |
|
329 | - return $settings; |
|
330 | - } |
|
331 | - |
|
332 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | - |
|
334 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
336 | - $settings['form_desc_color'] = $settings['description_color']; |
|
337 | - $settings['title_color'] = $settings['label_color']; |
|
338 | - } |
|
339 | - |
|
340 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | - $settings['section_color'] = $settings['label_color']; |
|
342 | - $settings['section_border_color'] = $settings['border_color']; |
|
343 | - } |
|
344 | - |
|
345 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
347 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
348 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
349 | - |
|
350 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
351 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
352 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
353 | - } |
|
354 | - |
|
355 | - return $settings; |
|
328 | + if ( ! is_array($settings) ) { |
|
329 | + return $settings; |
|
330 | + } |
|
331 | + |
|
332 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | + |
|
334 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
336 | + $settings['form_desc_color'] = $settings['description_color']; |
|
337 | + $settings['title_color'] = $settings['label_color']; |
|
338 | + } |
|
339 | + |
|
340 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | + $settings['section_color'] = $settings['label_color']; |
|
342 | + $settings['section_border_color'] = $settings['border_color']; |
|
343 | + } |
|
344 | + |
|
345 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
347 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
348 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
349 | + |
|
350 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
351 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
352 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
353 | + } |
|
354 | + |
|
355 | + return $settings; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | public function get_defaults() { |
359 | - return array( |
|
360 | - 'theme_css' => 'ui-lightness', |
|
361 | - 'theme_name' => 'UI Lightness', |
|
359 | + return array( |
|
360 | + 'theme_css' => 'ui-lightness', |
|
361 | + 'theme_name' => 'UI Lightness', |
|
362 | 362 | |
363 | 363 | 'center_form' => '', |
364 | - 'form_width' => '100%', |
|
365 | - 'form_align' => 'left', |
|
366 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
367 | - 'fieldset' => '0px', |
|
368 | - 'fieldset_color' => '000000', |
|
369 | - 'fieldset_padding' => '0 0 15px 0', |
|
370 | - 'fieldset_bg_color' => '', |
|
371 | - |
|
372 | - 'title_size' => '20px', |
|
373 | - 'title_color' => '444444', |
|
364 | + 'form_width' => '100%', |
|
365 | + 'form_align' => 'left', |
|
366 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
367 | + 'fieldset' => '0px', |
|
368 | + 'fieldset_color' => '000000', |
|
369 | + 'fieldset_padding' => '0 0 15px 0', |
|
370 | + 'fieldset_bg_color' => '', |
|
371 | + |
|
372 | + 'title_size' => '20px', |
|
373 | + 'title_color' => '444444', |
|
374 | 374 | 'title_margin_top' => '10px', |
375 | 375 | 'title_margin_bottom' => '10px', |
376 | - 'form_desc_size' => '14px', |
|
377 | - 'form_desc_color' => '666666', |
|
376 | + 'form_desc_size' => '14px', |
|
377 | + 'form_desc_color' => '666666', |
|
378 | 378 | 'form_desc_margin_top' => '10px', |
379 | 379 | 'form_desc_margin_bottom' => '25px', |
380 | 380 | |
381 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
382 | - 'font_size' => '14px', |
|
383 | - 'label_color' => '444444', |
|
384 | - 'weight' => 'bold', |
|
385 | - 'position' => 'none', |
|
386 | - 'align' => 'left', |
|
387 | - 'width' => '150px', |
|
388 | - 'required_color' => 'B94A48', |
|
389 | - 'required_weight' => 'bold', |
|
390 | - 'label_padding' => '0 0 3px 0', |
|
391 | - |
|
392 | - 'description_font_size' => '12px', |
|
393 | - 'description_color' => '666666', |
|
394 | - 'description_weight' => 'normal', |
|
395 | - 'description_style' => 'normal', |
|
396 | - 'description_align' => 'left', |
|
397 | - |
|
398 | - 'field_font_size' => '14px', |
|
399 | - 'field_height' => '32px', |
|
400 | - 'line_height' => 'normal', |
|
401 | - 'field_width' => '100%', |
|
402 | - 'auto_width' => false, |
|
403 | - 'field_pad' => '6px 10px', |
|
404 | - 'field_margin' => '20px', |
|
381 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
382 | + 'font_size' => '14px', |
|
383 | + 'label_color' => '444444', |
|
384 | + 'weight' => 'bold', |
|
385 | + 'position' => 'none', |
|
386 | + 'align' => 'left', |
|
387 | + 'width' => '150px', |
|
388 | + 'required_color' => 'B94A48', |
|
389 | + 'required_weight' => 'bold', |
|
390 | + 'label_padding' => '0 0 3px 0', |
|
391 | + |
|
392 | + 'description_font_size' => '12px', |
|
393 | + 'description_color' => '666666', |
|
394 | + 'description_weight' => 'normal', |
|
395 | + 'description_style' => 'normal', |
|
396 | + 'description_align' => 'left', |
|
397 | + |
|
398 | + 'field_font_size' => '14px', |
|
399 | + 'field_height' => '32px', |
|
400 | + 'line_height' => 'normal', |
|
401 | + 'field_width' => '100%', |
|
402 | + 'auto_width' => false, |
|
403 | + 'field_pad' => '6px 10px', |
|
404 | + 'field_margin' => '20px', |
|
405 | 405 | 'field_weight' => 'normal', |
406 | - 'text_color' => '555555', |
|
407 | - //'border_color_hv' => 'cccccc', |
|
408 | - 'border_color' => 'cccccc', |
|
409 | - 'field_border_width' => '1px', |
|
410 | - 'field_border_style' => 'solid', |
|
411 | - |
|
412 | - 'bg_color' => 'ffffff', |
|
413 | - //'bg_color_hv' => 'ffffff', |
|
406 | + 'text_color' => '555555', |
|
407 | + //'border_color_hv' => 'cccccc', |
|
408 | + 'border_color' => 'cccccc', |
|
409 | + 'field_border_width' => '1px', |
|
410 | + 'field_border_style' => 'solid', |
|
411 | + |
|
412 | + 'bg_color' => 'ffffff', |
|
413 | + //'bg_color_hv' => 'ffffff', |
|
414 | 414 | 'remove_box_shadow' => '', |
415 | - 'bg_color_active' => 'ffffff', |
|
415 | + 'bg_color_active' => 'ffffff', |
|
416 | 416 | 'border_color_active' => '66afe9', |
417 | 417 | 'remove_box_shadow_active' => '', |
418 | - 'text_color_error' => '444444', |
|
419 | - 'bg_color_error' => 'ffffff', |
|
418 | + 'text_color_error' => '444444', |
|
419 | + 'bg_color_error' => 'ffffff', |
|
420 | 420 | 'border_color_error' => 'B94A48', |
421 | 421 | 'border_width_error' => '1px', |
422 | 422 | 'border_style_error' => 'solid', |
423 | - 'bg_color_disabled' => 'ffffff', |
|
424 | - 'border_color_disabled' => 'E5E5E5', |
|
425 | - 'text_color_disabled' => 'A1A1A1', |
|
426 | - |
|
427 | - 'radio_align' => 'block', |
|
428 | - 'check_align' => 'block', |
|
429 | - 'check_font_size' => '13px', |
|
430 | - 'check_label_color' => '444444', |
|
431 | - 'check_weight' => 'normal', |
|
432 | - |
|
433 | - 'section_font_size' => '18px', |
|
434 | - 'section_color' => '444444', |
|
435 | - 'section_weight' => 'bold', |
|
436 | - 'section_pad' => '15px 0 3px 0', |
|
437 | - 'section_mar_top' => '15px', |
|
423 | + 'bg_color_disabled' => 'ffffff', |
|
424 | + 'border_color_disabled' => 'E5E5E5', |
|
425 | + 'text_color_disabled' => 'A1A1A1', |
|
426 | + |
|
427 | + 'radio_align' => 'block', |
|
428 | + 'check_align' => 'block', |
|
429 | + 'check_font_size' => '13px', |
|
430 | + 'check_label_color' => '444444', |
|
431 | + 'check_weight' => 'normal', |
|
432 | + |
|
433 | + 'section_font_size' => '18px', |
|
434 | + 'section_color' => '444444', |
|
435 | + 'section_weight' => 'bold', |
|
436 | + 'section_pad' => '15px 0 3px 0', |
|
437 | + 'section_mar_top' => '15px', |
|
438 | 438 | 'section_mar_bottom' => '12px', |
439 | - 'section_bg_color' => '', |
|
440 | - 'section_border_color' => 'e8e8e8', |
|
441 | - 'section_border_width' => '2px', |
|
442 | - 'section_border_style' => 'solid', |
|
443 | - 'section_border_loc' => '-top', |
|
444 | - 'collapse_icon' => '6', |
|
445 | - 'collapse_pos' => 'after', |
|
446 | - 'repeat_icon' => '1', |
|
447 | - |
|
448 | - 'submit_style' => false, |
|
449 | - 'submit_font_size' => '14px', |
|
450 | - 'submit_width' => 'auto', |
|
451 | - 'submit_height' => 'auto', |
|
452 | - 'submit_bg_color' => 'ffffff', |
|
453 | - 'submit_border_color' => 'cccccc', |
|
454 | - 'submit_border_width' => '1px', |
|
455 | - 'submit_text_color' => '444444', |
|
456 | - 'submit_weight' => 'normal', |
|
457 | - 'submit_border_radius' => '4px', |
|
458 | - 'submit_bg_img' => '', |
|
459 | - 'submit_margin' => '10px', |
|
460 | - 'submit_padding' => '6px 11px', |
|
461 | - 'submit_shadow_color' => 'eeeeee', |
|
462 | - 'submit_hover_bg_color' => 'efefef', |
|
463 | - 'submit_hover_color' => '444444', |
|
464 | - 'submit_hover_border_color' => 'cccccc', |
|
465 | - 'submit_active_bg_color' => 'efefef', |
|
466 | - 'submit_active_color' => '444444', |
|
467 | - 'submit_active_border_color' => 'cccccc', |
|
468 | - |
|
469 | - 'border_radius' => '4px', |
|
470 | - 'error_bg' => 'F2DEDE', |
|
471 | - 'error_border' => 'EBCCD1', |
|
472 | - 'error_text' => 'B94A48', |
|
473 | - 'error_font_size' => '14px', |
|
474 | - |
|
475 | - 'success_bg_color' => 'DFF0D8', |
|
476 | - 'success_border_color' => 'D6E9C6', |
|
477 | - 'success_text_color' => '468847', |
|
478 | - 'success_font_size' => '14px', |
|
479 | - |
|
480 | - 'important_style' => false, |
|
481 | - |
|
482 | - 'custom_css' => '', |
|
483 | - ); |
|
484 | - } |
|
439 | + 'section_bg_color' => '', |
|
440 | + 'section_border_color' => 'e8e8e8', |
|
441 | + 'section_border_width' => '2px', |
|
442 | + 'section_border_style' => 'solid', |
|
443 | + 'section_border_loc' => '-top', |
|
444 | + 'collapse_icon' => '6', |
|
445 | + 'collapse_pos' => 'after', |
|
446 | + 'repeat_icon' => '1', |
|
447 | + |
|
448 | + 'submit_style' => false, |
|
449 | + 'submit_font_size' => '14px', |
|
450 | + 'submit_width' => 'auto', |
|
451 | + 'submit_height' => 'auto', |
|
452 | + 'submit_bg_color' => 'ffffff', |
|
453 | + 'submit_border_color' => 'cccccc', |
|
454 | + 'submit_border_width' => '1px', |
|
455 | + 'submit_text_color' => '444444', |
|
456 | + 'submit_weight' => 'normal', |
|
457 | + 'submit_border_radius' => '4px', |
|
458 | + 'submit_bg_img' => '', |
|
459 | + 'submit_margin' => '10px', |
|
460 | + 'submit_padding' => '6px 11px', |
|
461 | + 'submit_shadow_color' => 'eeeeee', |
|
462 | + 'submit_hover_bg_color' => 'efefef', |
|
463 | + 'submit_hover_color' => '444444', |
|
464 | + 'submit_hover_border_color' => 'cccccc', |
|
465 | + 'submit_active_bg_color' => 'efefef', |
|
466 | + 'submit_active_color' => '444444', |
|
467 | + 'submit_active_border_color' => 'cccccc', |
|
468 | + |
|
469 | + 'border_radius' => '4px', |
|
470 | + 'error_bg' => 'F2DEDE', |
|
471 | + 'error_border' => 'EBCCD1', |
|
472 | + 'error_text' => 'B94A48', |
|
473 | + 'error_font_size' => '14px', |
|
474 | + |
|
475 | + 'success_bg_color' => 'DFF0D8', |
|
476 | + 'success_border_color' => 'D6E9C6', |
|
477 | + 'success_text_color' => '468847', |
|
478 | + 'success_font_size' => '14px', |
|
479 | + |
|
480 | + 'important_style' => false, |
|
481 | + |
|
482 | + 'custom_css' => '', |
|
483 | + ); |
|
484 | + } |
|
485 | 485 | |
486 | 486 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
487 | 487 | return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']'; |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_size') ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_size' ) ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_color') ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_color' ) ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_top') ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_top' ) ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_bottom') ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_bottom' ) ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
18 | 18 | \ No newline at end of file |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_top') ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_top' ) ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_bottom') ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_bottom' ) ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
18 | 18 | \ No newline at end of file |
@@ -1,59 +1,59 @@ |
||
1 | 1 | <p> |
2 | - <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('center_form') ) ?>" id="frm_center_form" value="1" <?php checked($style->post_content['center_form'], 1) ?> /> |
|
2 | + <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'center_form' ) ) ?>" id="frm_center_form" value="1" <?php checked( $style->post_content['center_form'], 1 ) ?> /> |
|
3 | 3 | <?php _e( 'Center form on page', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will center your form on the page where it is published if the form width is less than the available width on the page.', 'formidable' ) ?>" ></span> |
4 | 4 | </label> |
5 | 5 | </p> |
6 | 6 | |
7 | 7 | <div class="field-group clearfix frm-first-row"> |
8 | 8 | <label><?php _e( 'Alignment', 'formidable' ) ?></label> |
9 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('form_align') ) ?>" id="frm_form_align"> |
|
10 | - <option value="left" <?php selected($style->post_content['form_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
11 | - <option value="right" <?php selected($style->post_content['form_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
12 | - <option value="center" <?php selected($style->post_content['form_align'], 'center') ?>><?php _e( 'center', 'formidable' ) ?></option> |
|
9 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'form_align' ) ) ?>" id="frm_form_align"> |
|
10 | + <option value="left" <?php selected( $style->post_content['form_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
11 | + <option value="right" <?php selected( $style->post_content['form_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
12 | + <option value="center" <?php selected( $style->post_content['form_align'], 'center' ) ?>><?php _e( 'center', 'formidable' ) ?></option> |
|
13 | 13 | </select> |
14 | 14 | </div> |
15 | 15 | |
16 | 16 | <div class="field-group clearfix frm-first-row"> |
17 | 17 | <label><?php _e( 'Max Width', 'formidable' ) ?></label> |
18 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_width') ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/> |
|
18 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_width' ) ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/> |
|
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class="field-group clearfix frm-first-row"> |
22 | 22 | <label><?php _e( 'Background', 'formidable' ) ?></label> |
23 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_bg_color') ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" /> |
|
23 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_bg_color' ) ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" /> |
|
24 | 24 | </div> |
25 | 25 | |
26 | 26 | <div class="field-group field-group-border clearfix"> |
27 | 27 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
28 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset') ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" /> |
|
28 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset' ) ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" /> |
|
29 | 29 | </div> |
30 | 30 | |
31 | 31 | <div class="field-group clearfix"> |
32 | 32 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
33 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_color') ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" /> |
|
33 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_color' ) ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" /> |
|
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div class="field-group clearfix"> |
37 | 37 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
38 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_padding') ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" /> |
|
38 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_padding' ) ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" /> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <div id="frm_gen_font_box" class="field-group clearfix"> |
42 | 42 | <label><?php _e( 'Font Family', 'formidable' ) ?></label> |
43 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font') ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>" class="frm_full_width" /> |
|
43 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font' ) ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>" class="frm_full_width" /> |
|
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <div class="field-group clearfix frm-half"> |
47 | 47 | <label><?php _e( 'Direction', 'formidable' ) ?></label> |
48 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('direction') ) ?>" id="frm_direction"> |
|
49 | - <option value="ltr" <?php selected($style->post_content['direction'], 'ltr') ?>><?php _e( 'Left to Right', 'formidable' ) ?></option> |
|
50 | - <option value="rtl" <?php selected($style->post_content['direction'], 'rtl') ?>><?php _e( 'Right to Left', 'formidable' ) ?></option> |
|
48 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'direction' ) ) ?>" id="frm_direction"> |
|
49 | + <option value="ltr" <?php selected( $style->post_content['direction'], 'ltr' ) ?>><?php _e( 'Left to Right', 'formidable' ) ?></option> |
|
50 | + <option value="rtl" <?php selected( $style->post_content['direction'], 'rtl' ) ?>><?php _e( 'Right to Left', 'formidable' ) ?></option> |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | |
54 | 54 | <div class="clear"></div> |
55 | 55 | <p class="frm_no_bottom_margin"> |
56 | - <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('important_style') ) ?>" id="frm_important_style" value="1" <?php checked($style->post_content['important_style'], 1) ?> /> |
|
56 | + <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'important_style' ) ) ?>" id="frm_important_style" value="1" <?php checked( $style->post_content['important_style'], 1 ) ?> /> |
|
57 | 57 | <?php _e( 'Override theme styling', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will add !important to many of the lines in the Formidable styling to make sure it will be used.', 'formidable' ) ?>" ></span> |
58 | 58 | </label> |
59 | 59 | </p> |