Completed
Push — master ( 3860cc...10e837 )
by Stephanie
9s
created

FrmStylesController::get_form_style()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 2
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
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',
19
			'capabilities' => array(
20
				'edit_post'		=> 'frm_change_settings',
21
				'edit_posts'	=> 'frm_change_settings',
22
				'edit_others_posts' => 'frm_change_settings',
23
				'publish_posts' => 'frm_change_settings',
24
				'delete_post'	=> 'frm_change_settings',
25
				'delete_posts'	=> 'frm_change_settings',
26
				'read_private_posts' => 'read_private_posts',
27
			),
28
            'supports' => array(
29
				'title',
30
            ),
31
            'has_archive' => false,
32
            'labels' => array(
33
				'name' => __( 'Styles', 'formidable' ),
34
				'singular_name' => __( 'Style', 'formidable' ),
35
				'menu_name' => __( 'Style', 'formidable' ),
36
				'edit' => __( 'Edit' ),
37
				'add_new_item' => __( 'Create a New Style', 'formidable' ),
38
				'edit_item'    => __( 'Edit Style', 'formidable' ),
39
			),
40
        ) );
41
    }
42
43
    public static function menu() {
44
		add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' );
45
    }
46
47
    public static function admin_init() {
48
        if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) {
49
            return;
50
        }
51
52
        self::load_pro_hooks();
53
54
		$style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
55
		if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) {
56
			// we only need to load these styles/scripts on the styler page
57
			return;
58
		}
59
60
        wp_enqueue_script('jquery-ui-datepicker');
61
62
        $version = FrmAppHelper::plugin_version();
63
		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
64
		wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker' . $suffix . '.js', array( 'jquery' ), $version );
65
66
		wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) );
67
68
        $style = apply_filters('frm_style_head', false);
69
        if ( $style ) {
70
			wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) );
71
        }
72
    }
73
74
	public static function enqueue_css( $register = 'enqueue' ) {
75
		global $frm_vars;
76
77
		$register_css = ( $register == 'register' );
78
79
		if ( ( $frm_vars['load_css'] || $register_css ) && ! FrmAppHelper::is_admin() ) {
80
			$frm_settings = FrmAppHelper::get_settings();
81
			if ( $frm_settings->load_style == 'none' ) {
82
				return;
83
			}
84
85
			$css = apply_filters( 'get_frm_stylesheet', self::custom_stylesheet() );
86
87
			if ( ! empty( $css ) ) {
88
				$version = FrmAppHelper::plugin_version();
89
90
				foreach ( (array) $css as $css_key => $file ) {
91
					if ( $register_css ) {
92
						$this_version = self::get_css_version( $css_key, $version );
93
						wp_register_style( $css_key, $file, array(), $this_version );
94
					}
95
96
					if ( 'all' == $frm_settings->load_style || $register != 'register' ) {
97
						wp_enqueue_style( $css_key );
98
					}
99
					unset( $css_key, $file );
100
				}
101
102
				if ( $frm_settings->load_style == 'all' ) {
103
					$frm_vars['css_loaded'] = true;
104
				}
105
			}
106
			unset( $css );
107
108
			add_filter( 'style_loader_tag', 'FrmStylesController::add_tags_to_css', 10, 2 );
109
		}
110
	}
111
112
	public static function custom_stylesheet() {
113
		global $frm_vars;
114
		$stylesheet_urls = array();
115
		self::maybe_enqueue_jquery_css();
116
117
		if ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) {
118
			//include css in head
119
			self::get_url_to_custom_style( $stylesheet_urls );
120
		}
121
122
		return $stylesheet_urls;
123
	}
124
125
	private static function get_url_to_custom_style( &$stylesheet_urls ) {
126
		$uploads = FrmStylesHelper::get_upload_base();
127
		$saved_css_path = '/formidable/css/formidablepro.css';
128
		if ( is_readable( $uploads['basedir'] . $saved_css_path ) ) {
129
			$url = $uploads['baseurl'] . $saved_css_path;
130
		} else {
131
			$url = admin_url( 'admin-ajax.php?action=frmpro_css' );
132
		}
133
		$stylesheet_urls['formidable'] = $url;
134
	}
135
136
	private static function get_css_version( $css_key, $version ) {
137
		if ( 'formidable' == $css_key ) {
138
			$this_version = get_option( 'frm_last_style_update' );
139
			if ( ! $this_version ) {
140
				$this_version = $version;
141
			}
142
		} else {
143
			$this_version = $version;
144
		}
145
		return $this_version;
146
	}
147
148
	private static function maybe_enqueue_jquery_css() {
149
		global $frm_vars;
150
		if ( isset( $frm_vars['datepicker_loaded'] ) && ! empty( $frm_vars['datepicker_loaded'] ) ) {
151
			FrmStylesHelper::enqueue_jquery_css();
152
		}
153
	}
154
155
	public static function add_tags_to_css( $tag, $handle ) {
156
		if ( ( 'formidable' == $handle || 'jquery-theme' == $handle ) && strpos( $tag, ' property=' ) === false ) {
157
			$frm_settings = FrmAppHelper::get_settings();
158
			if ( $frm_settings->use_html ) {
159
				$tag = str_replace( ' type="', ' property="stylesheet" type="', $tag );
160
			}
161
		}
162
		return $tag;
163
	}
164
165
	public static function new_style( $return = '' ) {
0 ignored issues
show
Unused Code introduced by
The parameter $return is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
166
        self::load_styler('default');
167
    }
168
169
	public static function duplicate() {
170
		self::load_styler('default');
171
	}
172
173
	public static function edit( $style_id = false, $message = '' ) {
174
        if ( ! $style_id ) {
175
			$style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' );
176
            if ( empty($style_id) ) {
177
                $style_id = 'default';
178
            }
179
        }
180
181
        if ( 'default' == $style_id ) {
182
            $style = 'default';
183
        } else {
184
            $frm_style = new FrmStyle($style_id);
185
            $style = $frm_style->get_one();
186
            $style = $style->ID;
187
        }
188
189
        self::load_styler($style, $message);
190
    }
191
192
    public static function save() {
193
        $frm_style = new FrmStyle();
194
        $message = '';
195
		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' );
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
196
		$style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' );
197
198
		if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) {
199
            $id = $frm_style->update($post_id);
0 ignored issues
show
Bug introduced by
It seems like $post_id defined by \FrmAppHelper::get_post_...alse, 'sanitize_title') on line 195 can also be of type array; however, FrmStyle::update() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
200
            if ( empty($post_id) && ! empty($id) ) {
201
                // set the post id to the new style so it will be loaded for editing
202
                $post_id = reset($id);
203
            }
204
            // include the CSS that includes this style
205
			echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />';
206
            $message = __( 'Your styling settings have been saved.', 'formidable' );
207
        }
208
209
        return self::edit($post_id, $message);
210
    }
211
212
	public static function load_styler( $style, $message = '' ) {
213
        global $frm_settings;
214
215
        $frm_style = new FrmStyle();
216
        $styles = $frm_style->get_all();
217
218
        if ( is_numeric($style) ) {
219
            $style = $styles[ $style ];
220
        } else if ( 'default' == $style ) {
221
            $style = $frm_style->get_default_style($styles);
222
        }
223
224
        self::add_meta_boxes();
225
226
		include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' );
227
    }
228
229
	/**
230
	 * @param string $message
231
	 * @param array|object $forms
232
	 */
233
	private static function manage( $message = '', $forms = array() ) {
234
        $frm_style = new FrmStyle();
235
        $styles = $frm_style->get_all();
236
        $default_style = $frm_style->get_default_style($styles);
237
238
        if ( empty($forms) ) {
239
            $forms = FrmForm::get_published_forms();
240
        }
241
242
		include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' );
243
    }
244
245
    private static function manage_styles() {
246
		$style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' );
247
		if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) {
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
248
            return self::manage();
249
        }
250
251
        global $wpdb;
252
253
		$forms = FrmForm::get_published_forms();
254
        foreach ( $forms as $form ) {
255
            if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) {
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
introduced by
Detected usage of a non-validated input variable: $_POST
Loading history...
256
                continue;
257
            }
258
259
            $form->options['custom_style'] = $_POST['style'][ $form->id ];
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
260
261
			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
262
            unset($form);
263
        }
264
265
        $message = __( 'Your form styles have been saved.', 'formidable' );
266
        return self::manage($message, $forms);
267
    }
268
269
    public static function custom_css( $message = '', $style = null ) {
270
        wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css');
271
        wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7');
272
        wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' );
273
274
        if ( ! isset($style) ) {
275
            $frm_style = new FrmStyle();
276
            $style = $frm_style->get_default_style();
277
        }
278
279
		include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' );
280
    }
281
282
    public static function save_css() {
283
        $frm_style = new FrmStyle();
284
285
        $message = '';
286
		$post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' );
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
287
		$nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' );
288
		if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) {
289
            $frm_style->update($post_id);
0 ignored issues
show
Bug introduced by
It seems like $post_id defined by \FrmAppHelper::get_post_... 'sanitize_text_field') on line 286 can also be of type array; however, FrmStyle::update() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
290
            $message = __( 'Your styling settings have been saved.', 'formidable' );
291
        }
292
293
        return self::custom_css($message);
294
    }
295
296
    public static function route() {
297
		$action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
298
299
        switch ( $action ) {
300
            case 'edit':
301
            case 'save':
302
            case 'manage':
303
            case 'manage_styles':
304
            case 'custom_css':
305
            case 'save_css':
306
				return self::$action();
307
            default:
308
            	do_action( 'frm_style_action_route', $action );
309
            	if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) {
310
                	return;
311
            	}
312
313
                if ( 'new_style' == $action || 'duplicate' == $action ) {
314
                    return self::$action();
315
                }
316
317
                return self::edit();
318
        }
319
    }
320
321 View Code Duplication
    public static function reset_styling() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
322
		FrmAppHelper::permission_check('frm_change_settings');
323
        check_ajax_referer( 'frm_ajax', 'nonce' );
324
325
        $frm_style = new FrmStyle();
326
        $defaults = $frm_style->get_defaults();
327
328
        echo json_encode( $defaults );
329
        wp_die();
330
    }
331
332
    public static function change_styling() {
333
        check_ajax_referer( 'frm_ajax', 'nonce' );
334
335
        $frm_style = new FrmStyle();
336
        $defaults = $frm_style->get_defaults();
337
		$style = '';
338
339
        // remove the # from the colors
340
        foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) {
341
            if ( ! is_array($v) && strpos($v, '#') === 0 ) {
342
                $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v );
343
            }
344
        }
345
346
        echo '<style type="text/css">';
347
		include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
348
        echo '</style>';
349
        wp_die();
350
    }
351
352
    private static function add_meta_boxes() {
353
354
        // setup meta boxes
355
        $meta_boxes = array(
356
            'general'           => __( 'General', 'formidable' ),
357
            'form-title'        => __( 'Form Title', 'formidable' ),
358
            'form-description'  => __( 'Form Description', 'formidable' ),
359
            'field-labels'      => __( 'Field Labels', 'formidable' ),
360
            'field-description' => __( 'Field Description', 'formidable' ),
361
            'field-colors'      => __( 'Field Colors', 'formidable' ),
362
            'field-sizes'       => __( 'Field Settings', 'formidable' ),
363
            'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ),
364
            'buttons'           => __( 'Buttons', 'formidable' ),
365
            'form-messages'     => __( 'Form Messages', 'formidable' ),
366
        );
367
368
		/**
369
		 * Add custom boxes to the styling settings
370
		 * @since 2.3
371
		 */
372
		$meta_boxes = apply_filters( 'frm_style_boxes', $meta_boxes );
373
374
        foreach ( $meta_boxes as $nicename => $name ) {
375
			add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename );
376
            unset($nicename, $name);
377
        }
378
    }
379
380
	public static function include_style_section( $atts, $sec ) {
381
        extract($atts);
0 ignored issues
show
introduced by
extract() usage is highly discouraged, due to the complexity and unintended issues it might cause.
Loading history...
382
		$current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' );
383
		$file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php';
384
385
		/**
386
		 * Set the location of custom styling settings right before
387
		 * loading onto the page. If your style box was named "progress",
388
		 * this hook name will be frm_style_settings_progress.
389
		 *
390
		 * @since 2.3
391
		 */
392
		$file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name );
393
394
		include( $file_name );
395
    }
396
397 View Code Duplication
    public static function load_css() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
398
        header('Content-type: text/css');
399
400
        $frm_style = new FrmStyle();
401
        $defaults = $frm_style->get_defaults();
402
		$style = '';
403
404
		include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
405
        wp_die();
406
    }
407
408
	public static function load_saved_css() {
409
		$css = get_transient( 'frmpro_css' );
410
411
		include( FrmAppHelper::plugin_path() . '/css/custom_theme.css.php' );
412
		wp_die();
413
	}
414
415
    /**
416
     * Check if the Formidable styling should be loaded,
417
     * then enqueue it for the footer
418
     * @since 2.0
419
     */
420
    public static function enqueue_style() {
421
        global $frm_vars;
422
423
        if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) {
424
            // the CSS has already been loaded
425
            return;
426
        }
427
428
        $frm_settings = FrmAppHelper::get_settings();
429
        if ( $frm_settings->load_style != 'none' ) {
430
            wp_enqueue_style( 'formidable' );
431
            $frm_vars['css_loaded'] = true;
432
        }
433
    }
434
435
    // Get the stylesheets for the form settings page
436
    public static function get_style_opts() {
437
        $frm_style = new FrmStyle();
438
        $styles = $frm_style->get_all();
439
440
        return $styles;
441
    }
442
443
    public static function get_form_style( $form = 'default' ) {
444
        $style = FrmFormsHelper::get_form_style( $form );
445
446
        if ( empty( $style ) || 1 == $style ) {
447
            $style = 'default';
448
        }
449
450
        $frm_style = new FrmStyle( $style );
451
        return $frm_style->get_one();
452
    }
453
454
    /**
455
     * @param string $class
456
     * @param string $style
457
     */
458
	public static function get_form_style_class( $class, $style ) {
459
        if ( 1 == $style ) {
460
            $style = 'default';
461
        }
462
463
        $frm_style = new FrmStyle($style);
464
        $style = $frm_style->get_one();
465
466
        if ( $style ) {
467
			$class .= ' frm_style_' . $style->post_name;
468
        }
469
470
        return $class;
471
    }
472
473
    /**
474
     * @param string $val
475
     */
476
	public static function get_style_val( $val, $form = 'default' ) {
477
        $style = self::get_form_style($form);
478
        if ( $style && isset( $style->post_content[ $val ] ) ) {
479
            return $style->post_content[ $val ];
480
        }
481
    }
482
483
	public static function show_entry_styles( $default_styles ) {
484
        $frm_style = new FrmStyle('default');
485
        $style = $frm_style->get_one();
486
487
        if ( ! $style ) {
488
            return $default_styles;
489
        }
490
491
        foreach ( $default_styles as $name => $val ) {
492
            $setting = $name;
493
            if ( 'border_width' == $name ) {
494
                $setting = 'field_border_width';
495
            } else if ( 'alt_bg_color' == $name ) {
496
                $setting = 'bg_color_active';
497
            }
498
            $default_styles[ $name ] = $style->post_content[ $setting ];
499
            unset($name, $val);
500
        }
501
502
        return $default_styles;
503
    }
504
505
	public static function &important_style( $important, $field ) {
0 ignored issues
show
Unused Code introduced by
The parameter $important is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
506
        $important = self::get_style_val('important_style', $field['form_id']);
507
        return $important;
508
    }
509
510
    /**
511
     * Fallback for WP < 3.6
512
     */
513
    public static function do_accordion_sections( $screen, $context, $object ) {
514
        if ( function_exists( 'do_accordion_sections' ) ) {
515
            return do_accordion_sections( $screen, $context, $object );
516
        }
517
518
    	global $wp_meta_boxes;
519
520
        $screen = 'formidable_page_formidable-styles';
521
        $screen = convert_to_screen( $screen );
522
523
    	$page = $screen->id;
524
525
    	$hidden = get_hidden_meta_boxes( $screen );
526
    	?>
527
    	<div id="side-sortables" class="accordion-container">
528
    	<?php
529
    	$i = 0;
530
    	$first_open = false;
531
    	do {
532
			if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
533
				break;
534
			}
535
536
    		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
537
    			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
538
    				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
539
    					if ( false == $box || ! $box['title'] ) {
540
    						continue;
541
						}
542
543
    					$i++;
544
    					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
545
546
    					if ( ! $first_open && empty( $hidden_class ) ) {
547
    						$first_open = true;
548
    					}
549
550
    					?>
551
						<div class="postbox <?php echo esc_attr( $box['id'] ); ?>">
552
						<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div>
553
                        <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3>
554
                            <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
555
                                <div class="inside">
556
    								<?php call_user_func( $box['callback'], $object, $box ); ?>
557
    							</div><!-- .inside -->
558
    						</div><!-- .accordion-section-content -->
559
    					</div><!-- .postbox -->
560
    					<?php
561
    				}
562
    			}
563
    		}
564
    	} while ( 0 );
565
    	?>
566
    	</div><!-- .accordion-container -->
567
    	<?php
568
    	return $i;
569
    }
570
}
571