| @@ -7,19 +7,21 @@ | ||
| 7 | 7 | // It is accessed from /wp-admin/admin.php?page=formidable-styles&form=782 |
| 8 | 8 | |
| 9 | 9 | $frm_settings = FrmAppHelper::get_settings(); |
| 10 | 10 | $globally_disabled = 'none' === $frm_settings->load_style; |
| 11 | -$enabled = '0' !== $form->options['custom_style'] && ! $globally_disabled; | |
| 11 | +$enabled = ( ! is_array( $form->options ) || 0 !== (int) $form->options['custom_style'] ) && ! $globally_disabled; | |
| 12 | 12 | $card_helper = new FrmStylesCardHelper( $active_style, $default_style, $form->id, $enabled ); |
| 13 | 13 | $styles = $card_helper->get_styles(); |
| 14 | 14 | $custom_styles = $card_helper->filter_custom_styles( $styles ); |
| 15 | 15 | $sidebar_params = array( |
| 16 | 16 | 'id' => 'frm_style_sidebar', |
| 17 | - 'class' => 'frm-right-panel frm-p-6 frm_wrap', // Make sure not to put .frm_wrap on the whole container because it will cause admin styles to apply to style cards. | |
| 17 | + // Make sure not to put .frm_wrap on the whole container because it will cause admin styles to apply to style cards. | |
| 18 | + 'class' => 'frm-right-panel frm-p-6 frm_wrap', | |
| 18 | 19 | ); |
| 19 | 20 | $toggle_input_html = array(); |
| 21 | + | |
| 20 | 22 | if ( $globally_disabled ) { |
| 21 | - $sidebar_params['class'] .= ' frm-styles-globally-disabled'; | |
| 23 | + $sidebar_params['class'] .= ' frm-styles-globally-disabled'; | |
| 22 | 24 | $toggle_input_html['disabled'] = 'disabled'; |
| 23 | 25 | } |
| 24 | 26 | ?> |
| 25 | 27 | <div <?php FrmAppHelper::array_to_html_params( $sidebar_params, true ); ?>> |
| @@ -25,11 +27,12 @@ | ||
| 25 | 27 | <div <?php FrmAppHelper::array_to_html_params( $sidebar_params, true ); ?>> |
| 26 | 28 | <?php |
| 27 | 29 | $can_create_styles = class_exists( 'FrmProStylesPreviewHelper' ); |
| 28 | 30 | $trigger_params = array( |
| 29 | - 'id' => 'frm_new_style_trigger', | |
| 31 | + 'id' => 'frm_new_style_trigger', | |
| 30 | 32 | 'href' => '#', |
| 31 | 33 | ); |
| 34 | + | |
| 32 | 35 | if ( $can_create_styles ) { |
| 33 | 36 | $trigger_params['data-new-style-url'] = esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=new_style' ) ); |
| 34 | 37 | } else { |
| 35 | 38 | $trigger_params['class'] = 'frm_noallow'; |
| @@ -37,9 +40,11 @@ | ||
| 37 | 40 | $trigger_params['data-message'] = __( 'Upgrade to create and manage as many form styles as you need.', 'formidable' ); |
| 38 | 41 | $trigger_params['data-image'] = 'styles-upsell.svg'; |
| 39 | 42 | } |
| 40 | 43 | ?> |
| 41 | - <?php // This form isn't visible. It's just used for assigning the selected style id to the target form. ?> | |
| 44 | + <?php | |
| 45 | + // This form isn't visible. It's just used for assigning the selected style id to the target form. | |
| 46 | + ?> | |
| 42 | 47 | <form id="frm_style_list_form" method="post" action="<?php echo esc_url( FrmStylesHelper::get_list_url( $form->id ) ); ?>"> |
| 43 | 48 | <input type="hidden" name="style_id" value="<?php echo absint( $enabled ? $active_style->ID : 0 ); ?>" /> |
| 44 | 49 | <input type="hidden" name="form_id" value="<?php echo absint( $form->id ); ?>" /> |
| 45 | 50 | <input type="hidden" name="frm_action" value="assign_style" /> |
| @@ -44,9 +49,9 @@ | ||
| 44 | 49 | <input type="hidden" name="form_id" value="<?php echo absint( $form->id ); ?>" /> |
| 45 | 50 | <input type="hidden" name="frm_action" value="assign_style" /> |
| 46 | 51 | <?php wp_nonce_field( 'frm_save_form_style_nonce', 'frm_save_form_style' ); ?> |
| 47 | 52 | </form> |
| 48 | - <div class="frm-mb-sm frm-flex-justify"> | |
| 53 | + <div class="frm-mb-sm frm-flex-justify frm-style-component"> | |
| 49 | 54 | <?php |
| 50 | 55 | FrmHtmlHelper::toggle( |
| 51 | 56 | 'frm_enable_styling', |
| 52 | 57 | 'frm_enable_styling', |
| @@ -54,9 +59,9 @@ | ||
| 54 | 59 | 'checked' => $enabled, |
| 55 | 60 | 'on_label' => __( 'Enable Formidable styling', 'formidable' ), |
| 56 | 61 | 'show_labels' => true, |
| 57 | 62 | 'echo' => true, |
| 58 | - 'input_html' => $toggle_input_html, | |
| 63 | + 'input_html' => $toggle_input_html, | |
| 59 | 64 | ) |
| 60 | 65 | ); |
| 61 | 66 | ?> |
| 62 | 67 | <div id="frm_new_style_trigger_wrapper"> |
| @@ -80,9 +85,12 @@ | ||
| 80 | 85 | </div> |
| 81 | 86 | <?php $card_helper->echo_card_wrapper( 'frm_custom_style_cards_wrapper', $custom_styles ); ?> |
| 82 | 87 | <?php } ?> |
| 83 | 88 | |
| 84 | - <div class="frm_form_settings"> | |
| 85 | - <h2><?php esc_html_e( 'Formidable Styles', 'formidable' ); ?></h2> | |
| 86 | - </div> | |
| 87 | - <?php $card_helper->echo_card_wrapper( 'frm_template_style_cards_wrapper', $card_helper->get_template_info() ); ?> | |
| 89 | + <?php $style_templates = array_filter( $card_helper->get_template_info(), 'is_array' ); ?> | |
| 90 | + <?php if ( $style_templates ) { ?> | |
| 91 | + <div class="frm_form_settings"> | |
| 92 | + <h2><?php esc_html_e( 'Formidable Styles', 'formidable' ); ?></h2> | |
| 93 | + </div> | |
| 94 | + <?php $card_helper->echo_card_wrapper( 'frm_template_style_cards_wrapper', $style_templates ); ?> | |
| 95 | + <?php } ?> | |
| 88 | 96 | </div> |