admin
6 days ago
emails
4 months ago
fields
6 days ago
functions
6 days ago
providers
10 months ago
templates
4 months ago
class-db.php
1 year ago
class-fields.php
1 year ago
class-form.php
6 days ago
class-install.php
1 year ago
class-process.php
4 months ago
class-providers.php
1 year ago
class-templates.php
2 years ago
class-widget.php
1 year ago
deprecated.php
8 months ago
functions-list.php
3 years ago
functions.php
11 months ago
integrations.php
4 months ago
class-templates.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Pre-configured packaged templates. |
| 9 | * |
| 10 | * @since 1.0.0 |
| 11 | */ |
| 12 | class WPForms_Templates { |
| 13 | |
| 14 | /** |
| 15 | * Primary class constructor. |
| 16 | * |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | public function __construct() { |
| 20 | |
| 21 | $this->init(); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Load and init the base form template class. |
| 26 | * |
| 27 | * @since 1.2.8 |
| 28 | */ |
| 29 | public function init() { |
| 30 | |
| 31 | // Parent class template. |
| 32 | require_once WPFORMS_PLUGIN_DIR . 'includes/templates/class-base.php'; |
| 33 | |
| 34 | // Load default templates on WP init. |
| 35 | add_action( 'init', [ $this, 'load' ] ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Load default form templates. |
| 40 | * |
| 41 | * @since 1.0.0 |
| 42 | */ |
| 43 | public function load() { |
| 44 | |
| 45 | $templates = apply_filters( |
| 46 | 'wpforms_load_templates', |
| 47 | [ |
| 48 | 'blank', |
| 49 | 'simple-contact-form', |
| 50 | ] |
| 51 | ); |
| 52 | |
| 53 | foreach ( $templates as $template ) { |
| 54 | |
| 55 | $template = sanitize_file_name( $template ); |
| 56 | |
| 57 | if ( file_exists( WPFORMS_PLUGIN_DIR . 'includes/templates/class-' . $template . '.php' ) ) { |
| 58 | require_once WPFORMS_PLUGIN_DIR . 'includes/templates/class-' . $template . '.php'; |
| 59 | } elseif ( file_exists( WPFORMS_PLUGIN_DIR . 'pro/includes/templates/class-' . $template . '.php' ) && wpforms()->is_pro() ) { |
| 60 | require_once WPFORMS_PLUGIN_DIR . 'pro/includes/templates/class-' . $template . '.php'; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | new WPForms_Templates; |
| 67 |