説明なし

class-wc-integrations.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * WooCommerce Integrations class
  4. *
  5. * Loads Integrations into WooCommerce.
  6. *
  7. * @version 3.9.0
  8. * @package WooCommerce\Classes\Integrations
  9. */
  10. defined( 'ABSPATH' ) || exit;
  11. /**
  12. * Integrations class.
  13. */
  14. class WC_Integrations {
  15. /**
  16. * Array of integrations.
  17. *
  18. * @var array
  19. */
  20. public $integrations = array();
  21. /**
  22. * Initialize integrations.
  23. */
  24. public function __construct() {
  25. do_action( 'woocommerce_integrations_init' );
  26. $load_integrations = array(
  27. 'WC_Integration_MaxMind_Geolocation',
  28. );
  29. $load_integrations = apply_filters( 'woocommerce_integrations', $load_integrations );
  30. // Load integration classes.
  31. foreach ( $load_integrations as $integration ) {
  32. $load_integration = new $integration();
  33. $this->integrations[ $load_integration->id ] = $load_integration;
  34. }
  35. }
  36. /**
  37. * Return loaded integrations.
  38. *
  39. * @return array
  40. */
  41. public function get_integrations() {
  42. return $this->integrations;
  43. }
  44. /**
  45. * Return a desired integration.
  46. *
  47. * @since 3.9.0
  48. * @param string $id The id of the integration to get.
  49. * @return mixed|null The integration if one is found, otherwise null.
  50. */
  51. public function get_integration( $id ) {
  52. if ( isset( $this->integrations[ $id ] ) ) {
  53. return $this->integrations[ $id ];
  54. }
  55. return null;
  56. }
  57. }