| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
// This partial view is used in the visual styler sidebar in "list" view. |
| 6 |
// It lists all styles and allows the user to select and assign a style to a target form. |
| 7 |
// It is accessed from /wp-admin/admin.php?page=formidable-styles&form=782 |
| 8 |
|
| 9 |
$frm_settings = FrmAppHelper::get_settings(); |
| 10 |
$globally_disabled = 'none' === $frm_settings->load_style; |
| 11 |
$enabled = ( ! is_array( $form->options ) || 0 !== (int) $form->options['custom_style'] ) && ! $globally_disabled; |
| 12 |
$card_helper = new FrmStylesCardHelper( $active_style, $default_style, $form->id, $enabled ); |
| 13 |
$styles = $card_helper->get_styles(); |
| 14 |
$custom_styles = $card_helper->filter_custom_styles( $styles ); |
| 15 |
$sidebar_params = array( |
| 16 |
'id' => 'frm_style_sidebar', |
| 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', |
| 19 |
); |
| 20 |
$toggle_input_html = array(); |
| 21 |
if ( $globally_disabled ) { |
| 22 |
$sidebar_params['class'] .= ' frm-styles-globally-disabled'; |
| 23 |
$toggle_input_html['disabled'] = 'disabled'; |
| 24 |
} |
| 25 |
?> |
| 26 |
<div <?php FrmAppHelper::array_to_html_params( $sidebar_params, true ); ?>> |
| 27 |
<?php |
| 28 |
$can_create_styles = class_exists( 'FrmProStylesPreviewHelper' ); |
| 29 |
$trigger_params = array( |
| 30 |
'id' => 'frm_new_style_trigger', |
| 31 |
'href' => '#', |
| 32 |
); |
| 33 |
if ( $can_create_styles ) { |
| 34 |
$trigger_params['data-new-style-url'] = esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=new_style' ) ); |
| 35 |
} else { |
| 36 |
$trigger_params['class'] = 'frm_noallow'; |
| 37 |
$trigger_params['data-upgrade'] = __( 'You are currently limited to 1 style template', 'formidable' ); |
| 38 |
$trigger_params['data-message'] = __( 'Upgrade to create and manage as many form styles as you need.', 'formidable' ); |
| 39 |
$trigger_params['data-image'] = 'styles-upsell.svg'; |
| 40 |
} |
| 41 |
?> |
| 42 |
<?php |
| 43 |
// This form isn't visible. It's just used for assigning the selected style id to the target form. |
| 44 |
?> |
| 45 |
<form id="frm_style_list_form" method="post" action="<?php echo esc_url( FrmStylesHelper::get_list_url( $form->id ) ); ?>"> |
| 46 |
<input type="hidden" name="style_id" value="<?php echo absint( $enabled ? $active_style->ID : 0 ); ?>" /> |
| 47 |
<input type="hidden" name="form_id" value="<?php echo absint( $form->id ); ?>" /> |
| 48 |
<input type="hidden" name="frm_action" value="assign_style" /> |
| 49 |
<?php wp_nonce_field( 'frm_save_form_style_nonce', 'frm_save_form_style' ); ?> |
| 50 |
</form> |
| 51 |
<div class="frm-mb-sm frm-flex-justify"> |
| 52 |
<?php |
| 53 |
FrmHtmlHelper::toggle( |
| 54 |
'frm_enable_styling', |
| 55 |
'frm_enable_styling', |
| 56 |
array( |
| 57 |
'checked' => $enabled, |
| 58 |
'on_label' => __( 'Enable Formidable styling', 'formidable' ), |
| 59 |
'show_labels' => true, |
| 60 |
'echo' => true, |
| 61 |
'input_html' => $toggle_input_html, |
| 62 |
) |
| 63 |
); |
| 64 |
?> |
| 65 |
<div id="frm_new_style_trigger_wrapper"> |
| 66 |
<a <?php FrmAppHelper::array_to_html_params( $trigger_params, true ); ?>> |
| 67 |
<?php |
| 68 |
FrmAppHelper::icon_by_class( 'frmfont frm_plus_icon' ); |
| 69 |
esc_html_e( 'New Style', 'formidable' ); |
| 70 |
?> |
| 71 |
</a> |
| 72 |
</div> |
| 73 |
</div> |
| 74 |
|
| 75 |
<div class="frm_form_settings"> |
| 76 |
<h2><?php esc_html_e( 'Default Style', 'formidable' ); ?></h2> |
| 77 |
</div> |
| 78 |
<?php $card_helper->echo_card_wrapper( 'frm_default_style_cards_wrapper', array( $default_style ) ); ?> |
| 79 |
|
| 80 |
<?php if ( $custom_styles ) { ?> |
| 81 |
<div class="frm_form_settings"> |
| 82 |
<h2><?php esc_html_e( 'Custom Styles', 'formidable' ); ?></h2> |
| 83 |
</div> |
| 84 |
<?php $card_helper->echo_card_wrapper( 'frm_custom_style_cards_wrapper', $custom_styles ); ?> |
| 85 |
<?php } ?> |
| 86 |
|
| 87 |
<?php $style_templates = array_filter( $card_helper->get_template_info(), 'is_array' ); ?> |
| 88 |
<?php if ( $style_templates ) { ?> |
| 89 |
<div class="frm_form_settings"> |
| 90 |
<h2><?php esc_html_e( 'Formidable Styles', 'formidable' ); ?></h2> |
| 91 |
</div> |
| 92 |
<?php $card_helper->echo_card_wrapper( 'frm_template_style_cards_wrapper', $style_templates ); ?> |
| 93 |
<?php } ?> |
| 94 |
</div> |
| 95 |
|