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-fields.php
99 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Load the field types. |
| 9 | * |
| 10 | * @since 1.0.0 |
| 11 | */ |
| 12 | class WPForms_Fields { |
| 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 | * Initialize hooks. |
| 26 | * |
| 27 | * @since 1.2.8 |
| 28 | * @since 1.8.2 Moved base class loading to \WPForms\WPForms::includes. |
| 29 | */ |
| 30 | public function init() { |
| 31 | |
| 32 | $this->hooks(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Hooks. |
| 37 | * |
| 38 | * @since 1.7.7 |
| 39 | */ |
| 40 | private function hooks() { |
| 41 | |
| 42 | // Load default fields on WP init. |
| 43 | add_action( 'init', [ $this, 'load' ] ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Load default field types. |
| 48 | * |
| 49 | * @since 1.0.0 |
| 50 | * @since 1.9.4 Removed Pro fields from the list. They loaded in the main Loader class. |
| 51 | */ |
| 52 | public function load() { |
| 53 | |
| 54 | $fields = [ |
| 55 | 'text', |
| 56 | 'textarea', |
| 57 | 'select', |
| 58 | 'radio', |
| 59 | 'checkbox', |
| 60 | 'email', |
| 61 | 'name', |
| 62 | 'number', |
| 63 | 'number-slider', |
| 64 | 'internal-information', |
| 65 | ]; |
| 66 | |
| 67 | // Include GDPR Checkbox field if GDPR enhancements are enabled. |
| 68 | if ( wpforms_setting( 'gdpr' ) ) { |
| 69 | $fields[] = 'gdpr-checkbox'; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Filters array of fields to be loaded. |
| 74 | * |
| 75 | * @since 1.0.0 |
| 76 | * |
| 77 | * @param array $fields Field types. |
| 78 | */ |
| 79 | $fields = (array) apply_filters( // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName |
| 80 | 'wpforms_load_fields', |
| 81 | $fields |
| 82 | ); |
| 83 | |
| 84 | foreach ( $fields as $field ) { |
| 85 | |
| 86 | $file = WPFORMS_PLUGIN_DIR . 'includes/fields/class-' . $field . '.php'; |
| 87 | |
| 88 | if ( file_exists( $file ) ) { |
| 89 | require_once $file; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // We have to put it here due to tests for restricted emails. |
| 94 | new WPForms_Field_Email(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | new WPForms_Fields(); |
| 99 |