2012-04-30 19:50:35 +00:00
|
|
|
<?php
|
2018-03-05 11:34:38 +00:00
|
|
|
/**
|
|
|
|
* Abstract Integration class
|
|
|
|
*
|
|
|
|
* Extension of the Settings API which in turn gets extended
|
|
|
|
* by individual integrations to offer additional functionality.
|
|
|
|
*
|
|
|
|
* @class WC_Settings_API
|
|
|
|
* @version 2.6.0
|
|
|
|
* @package WooCommerce/Abstracts
|
|
|
|
*/
|
2013-02-20 17:14:46 +00:00
|
|
|
|
2014-09-20 18:39:49 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2015-11-03 18:20:08 +00:00
|
|
|
exit;
|
2014-09-20 18:39:49 +00:00
|
|
|
}
|
2013-02-20 17:14:46 +00:00
|
|
|
|
2012-04-30 19:50:35 +00:00
|
|
|
/**
|
2015-11-03 18:20:08 +00:00
|
|
|
* Abstract Integration Class
|
2012-08-15 18:15:06 +00:00
|
|
|
*
|
2012-04-30 19:50:35 +00:00
|
|
|
* Extended by individual integrations to offer additional functionality.
|
|
|
|
*
|
2015-11-03 18:20:08 +00:00
|
|
|
* @class WC_Integration
|
|
|
|
* @extends WC_Settings_API
|
2015-12-14 14:03:46 +00:00
|
|
|
* @version 2.6.0
|
2015-11-03 18:20:08 +00:00
|
|
|
* @package WooCommerce/Abstracts
|
2012-04-30 19:50:35 +00:00
|
|
|
*/
|
2012-12-31 18:25:09 +00:00
|
|
|
abstract class WC_Integration extends WC_Settings_API {
|
2012-08-15 18:15:06 +00:00
|
|
|
|
2012-04-30 19:50:35 +00:00
|
|
|
/**
|
2018-03-05 11:34:38 +00:00
|
|
|
* Yes or no based on whether the integration is enabled.
|
|
|
|
*
|
2015-12-14 14:03:46 +00:00
|
|
|
* @var string
|
2012-04-30 19:50:35 +00:00
|
|
|
*/
|
2015-12-14 14:03:46 +00:00
|
|
|
public $enabled = 'yes';
|
2012-08-15 18:15:06 +00:00
|
|
|
|
2015-12-14 14:03:46 +00:00
|
|
|
/**
|
|
|
|
* Integration title.
|
2018-03-05 11:34:38 +00:00
|
|
|
*
|
2015-12-14 14:03:46 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $method_title = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Integration description.
|
2018-03-05 11:34:38 +00:00
|
|
|
*
|
2015-12-14 14:03:46 +00:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $method_description = '';
|
2012-08-15 18:15:06 +00:00
|
|
|
|
2015-12-14 14:03:46 +00:00
|
|
|
/**
|
|
|
|
* Return the title for admin screens.
|
2018-03-05 11:34:38 +00:00
|
|
|
*
|
2015-12-14 14:03:46 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_method_title() {
|
|
|
|
return apply_filters( 'woocommerce_integration_title', $this->method_title, $this );
|
|
|
|
}
|
2012-08-15 18:15:06 +00:00
|
|
|
|
2015-12-14 14:03:46 +00:00
|
|
|
/**
|
|
|
|
* Return the description for admin screens.
|
2018-03-05 11:34:38 +00:00
|
|
|
*
|
2015-12-14 14:03:46 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_method_description() {
|
|
|
|
return apply_filters( 'woocommerce_integration_description', $this->method_description, $this );
|
|
|
|
}
|
2012-08-15 18:15:06 +00:00
|
|
|
|
2015-12-14 14:03:46 +00:00
|
|
|
/**
|
|
|
|
* Output the gateway settings screen.
|
|
|
|
*/
|
|
|
|
public function admin_options() {
|
|
|
|
echo '<h2>' . esc_html( $this->get_method_title() ) . '</h2>';
|
|
|
|
echo wp_kses_post( wpautop( $this->get_method_description() ) );
|
|
|
|
echo '<div><input type="hidden" name="section" value="' . esc_attr( $this->id ) . '" /></div>';
|
|
|
|
parent::admin_options();
|
|
|
|
}
|
2012-08-15 18:15:06 +00:00
|
|
|
|
2015-12-14 14:03:46 +00:00
|
|
|
/**
|
|
|
|
* Init settings for gateways.
|
|
|
|
*/
|
|
|
|
public function init_settings() {
|
|
|
|
parent::init_settings();
|
2019-12-20 17:21:08 +00:00
|
|
|
$this->enabled = ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? 'yes' : 'no';
|
2012-04-30 19:50:35 +00:00
|
|
|
}
|
2014-08-31 05:49:58 +00:00
|
|
|
}
|