Нет описания

class-fields.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Load the field types.
  4. *
  5. * @since 1.0.0
  6. */
  7. class WPForms_Fields {
  8. /**
  9. * Primary class constructor.
  10. *
  11. * @since 1.0.0
  12. */
  13. public function __construct() {
  14. $this->init();
  15. }
  16. /**
  17. * Load and init the base field class.
  18. *
  19. * @since 1.2.8
  20. */
  21. public function init() {
  22. // Parent class template.
  23. require_once WPFORMS_PLUGIN_DIR . 'includes/fields/class-base.php';
  24. // Load default fields on WP init.
  25. add_action( 'init', array( $this, 'load' ) );
  26. }
  27. /**
  28. * Load default field types.
  29. *
  30. * @since 1.0.0
  31. */
  32. public function load() {
  33. $fields = apply_filters(
  34. 'wpforms_load_fields',
  35. array(
  36. 'text',
  37. 'textarea',
  38. 'select',
  39. 'radio',
  40. 'checkbox',
  41. 'divider',
  42. 'entry-preview',
  43. 'email',
  44. 'url',
  45. 'hidden',
  46. 'html',
  47. 'name',
  48. 'password',
  49. 'address',
  50. 'phone',
  51. 'date-time',
  52. 'number',
  53. 'page-break',
  54. 'rating',
  55. 'file-upload',
  56. 'payment-single',
  57. 'payment-multiple',
  58. 'payment-checkbox',
  59. 'payment-dropdown',
  60. 'payment-credit-card',
  61. 'payment-total',
  62. 'number-slider',
  63. 'richtext',
  64. )
  65. );
  66. // Include GDPR Checkbox field if GDPR enhancements are enabled.
  67. if ( wpforms_setting( 'gdpr', false ) ) {
  68. $fields[] = 'gdpr-checkbox';
  69. }
  70. foreach ( $fields as $field ) {
  71. if ( file_exists( WPFORMS_PLUGIN_DIR . 'includes/fields/class-' . $field . '.php' ) ) {
  72. require_once WPFORMS_PLUGIN_DIR . 'includes/fields/class-' . $field . '.php';
  73. } elseif ( wpforms()->pro && file_exists( WPFORMS_PLUGIN_DIR . 'pro/includes/fields/class-' . $field . '.php' ) ) {
  74. require_once WPFORMS_PLUGIN_DIR . 'pro/includes/fields/class-' . $field . '.php';
  75. }
  76. }
  77. new \WPForms_Field_Email();
  78. }
  79. }
  80. new WPForms_Fields();