| 1 |
<div class="wefroms-form-templates"> |
| 2 |
<wpuf-modal :show.sync="show" :onClose="onClose"> |
| 3 |
<h2 slot="header"> |
| 4 |
<?php _e( 'Select a Template', 'weforms' ); ?> |
| 5 |
<small><?php printf( __( 'Select from a pre-defined template or from a <a href="#" %s>blank form</a>', 'weforms' ), '@click.prevent="blankForm()"' ); ?></small> |
| 6 |
|
| 7 |
<span class="choose-form-categroy"> |
| 8 |
<?php _e( 'Select Category', 'weforms' ); ?> |
| 9 |
<select v-model="category"> |
| 10 |
<option value="all">All</option> |
| 11 |
<?php |
| 12 |
$registry = weforms()->templates->get_templates(); |
| 13 |
$categories = weforms_get_form_template_categories(); |
| 14 |
$colors = weforms_get_flat_ui_colors(); |
| 15 |
|
| 16 |
foreach ( $categories as $key => $category ) { |
| 17 |
printf( '<option value="%s">%s</option>', $key, $category['name'] ); |
| 18 |
} |
| 19 |
?> |
| 20 |
</select> |
| 21 |
</span> |
| 22 |
</h2> |
| 23 |
|
| 24 |
<div slot="body"> |
| 25 |
|
| 26 |
<?php |
| 27 |
|
| 28 |
// remove the blank form from index as it's handled separately |
| 29 |
if ( array_key_exists( 'blank', $registry ) ) { |
| 30 |
unset( $registry['blank'] ); |
| 31 |
} |
| 32 |
|
| 33 |
foreach ( $categories as $category_id => $category ) { |
| 34 |
?> |
| 35 |
<div class="clearfix" v-if="category=='<?php echo $category_id; ?>' || category=='all'"> |
| 36 |
|
| 37 |
<?php |
| 38 |
|
| 39 |
printf( '<h2><i class="%s" style="color: %s"></i> %s</h2> <ul class="clearfix">', $category['icon'], $colors[array_rand( $colors )], $category['name'] ); |
| 40 |
|
| 41 |
if ( $category_id == 'default' ) { |
| 42 |
?> |
| 43 |
|
| 44 |
<li class="blank-form"> |
| 45 |
<h3><?php _e( 'Blank Form', 'weforms' ); ?></h3> |
| 46 |
|
| 47 |
<div class="blank-form-text"> |
| 48 |
<span class="dashicons dashicons-plus"></span> |
| 49 |
<div class="title"><?php _e( 'Blank Form', 'weforms' ); ?></div> |
| 50 |
</div> |
| 51 |
|
| 52 |
<div class="form-create-overlay"> |
| 53 |
|
| 54 |
<div class="title"><?php _e( 'Blank Form', 'weforms' ); ?></div> |
| 55 |
<br> |
| 56 |
<button class="button button-primary" @click.prevent="blankForm($event.target)" title="<?php echo esc_attr( 'Blank Form' ); ?>"> |
| 57 |
<?php _e( 'Create Form', 'weforms' ); ?> |
| 58 |
</button> |
| 59 |
</div> |
| 60 |
</li> |
| 61 |
|
| 62 |
<?php |
| 63 |
} |
| 64 |
|
| 65 |
foreach ( $registry as $key => $template ) { |
| 66 |
if ( $category_id !== $template->category ) { |
| 67 |
continue; |
| 68 |
} |
| 69 |
|
| 70 |
$is_available = true; |
| 71 |
$class = 'template-active'; |
| 72 |
$title = $template->title; |
| 73 |
$image = $template->image ? $template->image : ''; |
| 74 |
|
| 75 |
if ( !$template->is_enabled() ) { |
| 76 |
$title = __( 'This integration is not installed.', 'weforms' ); |
| 77 |
$class = 'template-inactive'; |
| 78 |
$is_available = false; |
| 79 |
} ?> |
| 80 |
|
| 81 |
<li class="<?php echo $class; ?>"> |
| 82 |
<h3><?php _e( $title, 'weforms' ); ?></h3> |
| 83 |
|
| 84 |
<?php if ( $image ) { |
| 85 |
printf( '<img src="%s" alt="%s">', $image, $title ); |
| 86 |
} ?> |
| 87 |
|
| 88 |
<div class="form-create-overlay"> |
| 89 |
|
| 90 |
<div class="title"><?php echo $template->get_title(); ?></div> |
| 91 |
<div class="description"><?php echo $template->get_description(); ?></div> |
| 92 |
<br> |
| 93 |
|
| 94 |
<button class="button button-primary" @click.prevent="createForm('<?php echo $key; ?>', $event.target)" title="<?php echo esc_attr( $title ); ?>" <?php echo $is_available ? '' : 'disabled="disabled"'; ?>> |
| 95 |
<?php if ( $is_available ) { ?> |
| 96 |
<?php _e( 'Create Form', 'weforms' ); ?> |
| 97 |
<?php } else { ?> |
| 98 |
<?php _e( 'Require Pro Upgrade', 'weforms' ); ?> |
| 99 |
<?php } ?> |
| 100 |
</button> |
| 101 |
</div> |
| 102 |
</li> |
| 103 |
<?php |
| 104 |
} ?> |
| 105 |
|
| 106 |
</ul></div> |
| 107 |
|
| 108 |
<?php |
| 109 |
} |
| 110 |
?> |
| 111 |
</div> |
| 112 |
</wpuf-modal> |
| 113 |
</div> |