Geen omschrijving

class-providers.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Load the providers.
  4. *
  5. * @since 1.3.6
  6. */
  7. class WPForms_Providers {
  8. /**
  9. * Primary class constructor.
  10. *
  11. * @since 1.3.6
  12. */
  13. public function __construct() {
  14. $this->init();
  15. }
  16. /**
  17. * Load and init the base provider class.
  18. *
  19. * @since 1.3.6
  20. */
  21. public function init() {
  22. // Parent class template.
  23. require_once WPFORMS_PLUGIN_DIR . 'includes/providers/class-base.php';
  24. // Load default templates on WP init.
  25. add_action( 'wpforms_loaded', [ $this, 'load' ] );
  26. }
  27. /**
  28. * Load default marketing providers.
  29. *
  30. * @since 1.3.6
  31. */
  32. public function load() {
  33. $providers = [
  34. 'constant-contact',
  35. ];
  36. $providers = (array) apply_filters( 'wpforms_load_providers', $providers );
  37. foreach ( $providers as $provider ) {
  38. $provider = sanitize_file_name( $provider );
  39. $path = WPFORMS_PLUGIN_DIR . 'includes/providers/class-' . $provider . '.php';
  40. if ( file_exists( $path ) ) {
  41. require_once $path;
  42. }
  43. /**
  44. * Allow third-party plugins to load their own providers.
  45. *
  46. * @since 1.7.0
  47. */
  48. do_action( "wpforms_load_{$provider}_provider" );
  49. }
  50. }
  51. }
  52. new WPForms_Providers();