abstract-wc-integration.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * Abstract Integration class
  4. *
  5. * Extension of the Settings API which in turn gets extended
  6. * by individual integrations to offer additional functionality.
  7. *
  8. * @class WC_Settings_API
  9. * @version 2.6.0
  10. * @package WooCommerce/Abstracts
  11. */
  12. if ( ! defined( 'ABSPATH' ) ) {
  13. exit;
  14. }
  15. /**
  16. * Abstract Integration Class
  17. *
  18. * Extended by individual integrations to offer additional functionality.
  19. *
  20. * @class WC_Integration
  21. * @extends WC_Settings_API
  22. * @version 2.6.0
  23. * @package WooCommerce/Abstracts
  24. */
  25. abstract class WC_Integration extends WC_Settings_API {
  26. /**
  27. * Yes or no based on whether the integration is enabled.
  28. *
  29. * @var string
  30. */
  31. public $enabled = 'yes';
  32. /**
  33. * Integration title.
  34. *
  35. * @var string
  36. */
  37. public $method_title = '';
  38. /**
  39. * Integration description.
  40. *
  41. * @var string
  42. */
  43. public $method_description = '';
  44. /**
  45. * Return the title for admin screens.
  46. *
  47. * @return string
  48. */
  49. public function get_method_title() {
  50. return apply_filters( 'woocommerce_integration_title', $this->method_title, $this );
  51. }
  52. /**
  53. * Return the description for admin screens.
  54. *
  55. * @return string
  56. */
  57. public function get_method_description() {
  58. return apply_filters( 'woocommerce_integration_description', $this->method_description, $this );
  59. }
  60. /**
  61. * Output the gateway settings screen.
  62. */
  63. public function admin_options() {
  64. echo '<h2>' . esc_html( $this->get_method_title() ) . '</h2>';
  65. echo wp_kses_post( wpautop( $this->get_method_description() ) );
  66. echo '<div><input type="hidden" name="section" value="' . esc_attr( $this->id ) . '" /></div>';
  67. parent::admin_options();
  68. }
  69. /**
  70. * Init settings for gateways.
  71. */
  72. public function init_settings() {
  73. parent::init_settings();
  74. $this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
  75. }
  76. }