antispam
3 years ago
fullscreen
2 years ago
notifications
2 years ago
payment
1 year ago
revisions
2 years ago
themes
10 months ago
field-context-menu.php
2 years ago
help.php
3 years ago
templates-item.php
2 years ago
templates-item.php
131 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Panel Setup (form templates). |
| 4 | * Form templates list item template. |
| 5 | * |
| 6 | * @since 1.6.8 |
| 7 | * @since 1.8.4 Added subcategories attribute. |
| 8 | * @since 1.8.6 Added fields attribute. |
| 9 | * @since 1.8.8 Added edit button attributes. |
| 10 | * |
| 11 | * @var bool $selected Is template selected. |
| 12 | * @var string $license_class License class (in the case of higher license needed). |
| 13 | * @var string $categories Categories, coma separated. |
| 14 | * @var string $subcategories Subcategories, comma separated. |
| 15 | * @var string $fields Fields, comma separated. |
| 16 | * @var string $badge_text Badge text. |
| 17 | * @var string $demo_url Template demo URL. |
| 18 | * @var string $template_id Template ID (Slug or ID if available). |
| 19 | * @var string $education_class Education class (in the case of higher license needed). |
| 20 | * @var string $education_attributes Education attributes. |
| 21 | * @var string $addons_attributes Required addons attributes. |
| 22 | * @var array $template Template data. |
| 23 | * @var string $action_text Template action button text. |
| 24 | * @var string $create_url User template creation URL. |
| 25 | * @var string $edit_url User template edit URL. |
| 26 | * @var string $edit_action_text User template edit button text. |
| 27 | * @var string $badge_class Badge class in case if there is any badge text exists. |
| 28 | * @var bool $can_create Capability to create forms. |
| 29 | * @var bool $can_edit Capability to edit forms (more granular for template - own, others). |
| 30 | * @var bool $can_delete Capability to delete forms (more granular for template - own, others). |
| 31 | * @var bool $is_open Is user template currently open in the builder. |
| 32 | * @var int $post_id Post ID. |
| 33 | */ |
| 34 | |
| 35 | use WPForms\Admin\Education\Helpers; |
| 36 | |
| 37 | if ( ! defined( 'ABSPATH' ) ) { |
| 38 | exit; |
| 39 | } |
| 40 | |
| 41 | $user_template_class = $template['source'] === 'wpforms-user-template' ? ' wpforms-user-template' : ''; |
| 42 | |
| 43 | ?> |
| 44 | <div class="wpforms-template<?php echo esc_attr( $user_template_class ); ?><?php echo esc_attr( $license_class ); ?><?php echo esc_attr( $badge_class ); ?>" |
| 45 | id="wpforms-template-<?php echo sanitize_html_class( $template['slug'] ); ?>" |
| 46 | <?php echo $template['source'] === 'wpforms-user-template' ? 'data-template-id="' . esc_attr( $post_id ) . '"' : ''; ?>> |
| 47 | |
| 48 | <div class="wpforms-template-thumbnail"> |
| 49 | <?php if ( empty( $template['thumbnail'] ) ) { ?> |
| 50 | <div class="wpforms-template-thumbnail-placeholder"> |
| 51 | <?php if ( $template['slug'] === 'blank' ) { ?> |
| 52 | <img src="<?php echo esc_url( WPFORMS_PLUGIN_URL . 'assets/images/icon-file.svg' ); ?>" alt="Blank Form Template" loading="lazy" /> |
| 53 | <?php } elseif ( $template['source'] === 'wpforms-user-template' ) { ?> |
| 54 | <img src="<?php echo esc_url( WPFORMS_PLUGIN_URL . 'assets/images/icon-user-template.svg' ); ?>" alt="User Form Template" loading="lazy" /> |
| 55 | <?php } else { ?> |
| 56 | <img src="<?php echo esc_url( WPFORMS_PLUGIN_URL . 'assets/images/icon-wpforms.svg' ); ?>" alt="Customizable Form Template" loading="lazy" /> |
| 57 | <?php } ?> |
| 58 | </div> |
| 59 | <?php } else { ?> |
| 60 | <img src="<?php echo esc_url( $template['thumbnail'] ); ?>" alt="<?php echo esc_attr( $template['name'] ); ?> Template" loading="lazy" /> |
| 61 | <?php } ?> |
| 62 | </div> |
| 63 | |
| 64 | <!-- As requirement for Lists.js library data attribute slug is used in classes list. --> |
| 65 | <h3 class="wpforms-template-name categories has-access favorite slug subcategories fields" |
| 66 | data-categories="<?php echo esc_attr( $categories ); ?>" |
| 67 | data-subcategories="<?php echo esc_attr( $subcategories ); ?>" |
| 68 | data-fields="<?php echo esc_attr( $fields ); ?>" |
| 69 | data-has-access="<?php echo esc_attr( $template['has_access'] ); ?>" |
| 70 | data-favorite="<?php echo esc_attr( $template['favorite'] ); ?>" |
| 71 | data-slug="<?php echo esc_attr( $template['slug'] ); ?>" |
| 72 | > |
| 73 | <?php echo esc_html( $template['name'] ); ?> |
| 74 | </h3> |
| 75 | |
| 76 | <?php if ( $template['source'] === 'wpforms-user-template' && $can_delete ) : ?> |
| 77 | <span class="wpforms-template-remove" data-template="<?php echo esc_attr( $post_id ); ?>"> |
| 78 | <i class="fa fa-trash-o" title="<?php esc_attr_e( 'Delete', 'wpforms-lite' ); ?>"></i> |
| 79 | </span> |
| 80 | <?php elseif ( $template['source'] !== 'wpforms-user-template' ) : ?> |
| 81 | <span class="wpforms-template-favorite"> |
| 82 | <?php if ( $can_create ) : ?> |
| 83 | <i class="fa fa-heart <?php echo $template['favorite'] ? '' : 'wpforms-hidden'; ?>" title="<?php esc_attr_e( 'Remove from Favorites', 'wpforms-lite' ); ?>"></i> |
| 84 | <i class="fa fa-heart-o <?php echo $template['favorite'] ? 'wpforms-hidden' : ''; ?>" title="<?php esc_attr_e( 'Mark as Favorite', 'wpforms-lite' ); ?>"></i> |
| 85 | <?php endif; ?> |
| 86 | </span> |
| 87 | <?php endif; ?> |
| 88 | |
| 89 | <?php |
| 90 | if ( ! empty( $badge_text ) && ! $selected ) { |
| 91 | Helpers::print_badge( $badge_text, 'sm', 'corner', 'steel', 'rounded-bl' ); |
| 92 | } |
| 93 | ?> |
| 94 | |
| 95 | <p class='wpforms-template-desc'> |
| 96 | <?php echo esc_html( $template['description'] ); ?> |
| 97 | </p> |
| 98 | |
| 99 | <?php if ( $can_create ) : ?> |
| 100 | <div class="wpforms-template-buttons"> |
| 101 | <a href="#" class="wpforms-template-select wpforms-btn wpforms-btn-md wpforms-btn-orange<?php echo esc_attr( $education_class ); ?>" |
| 102 | data-template-name-raw="<?php echo esc_attr( $template['name'] ); ?>" |
| 103 | data-template="<?php echo esc_attr( $template_id ); ?>" |
| 104 | data-slug="<?php echo esc_attr( $template['slug'] ); ?>" |
| 105 | data-create-url="<?php echo esc_url( $create_url ); ?>" |
| 106 | <?php echo $education_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 107 | <?php echo $addons_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| 108 | <?php echo esc_html( $action_text ); ?> |
| 109 | </a> |
| 110 | |
| 111 | <?php if ( $template['url'] !== '' ) : ?> |
| 112 | <a class="wpforms-template-demo wpforms-btn wpforms-btn-md wpforms-btn-light-grey" |
| 113 | href="<?php echo esc_url( $demo_url ); ?>" |
| 114 | target="_blank" rel="noopener noreferrer"> |
| 115 | <?php esc_html_e( 'View Demo', 'wpforms-lite' ); ?> |
| 116 | </a> |
| 117 | <?php endif; ?> |
| 118 | |
| 119 | <?php if ( ! empty( $edit_url ) && $can_edit ) : ?> |
| 120 | <a class="wpforms-template-edit wpforms-btn wpforms-btn-md wpforms-btn-light-grey" |
| 121 | href="<?php echo esc_url( $edit_url ); ?>"> |
| 122 | <?php echo esc_html( $edit_action_text ); ?> |
| 123 | </a> |
| 124 | <?php endif; ?> |
| 125 | </div> |
| 126 | <?php else : ?> |
| 127 | <span class="wpforms-template-select" data-template="<?php echo esc_attr( $template_id ); ?>"></span> |
| 128 | <?php endif; ?> |
| 129 | |
| 130 | </div> |
| 131 |