2013-07-26 14:36:28 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-11-03 13:53:50 +00:00
|
|
|
* WooCommerce Integration Settings
|
2013-07-26 14:36:28 +00:00
|
|
|
*
|
2021-03-14 00:08:20 +00:00
|
|
|
* @package WooCommerce\Admin
|
|
|
|
* @version 2.1.0
|
2013-07-26 14:36:28 +00:00
|
|
|
*/
|
|
|
|
|
2020-01-29 05:21:29 +00:00
|
|
|
use Automattic\Jetpack\Constants;
|
|
|
|
|
2021-03-16 14:42:28 +00:00
|
|
|
defined( 'ABSPATH' ) || exit;
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2017-02-16 11:46:01 +00:00
|
|
|
if ( ! class_exists( 'WC_Settings_Integrations', false ) ) :
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
/**
|
2018-03-05 18:59:17 +00:00
|
|
|
* WC_Settings_Integrations.
|
2013-07-26 14:36:28 +00:00
|
|
|
*/
|
2018-03-05 18:59:17 +00:00
|
|
|
class WC_Settings_Integrations extends WC_Settings_Page {
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
$this->id = 'integration';
|
|
|
|
$this->label = __( 'Integration', 'woocommerce' );
|
|
|
|
|
|
|
|
if ( isset( WC()->integrations ) && WC()->integrations->get_integrations() ) {
|
|
|
|
parent::__construct();
|
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
/**
|
|
|
|
* Get sections.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_sections() {
|
|
|
|
global $current_section;
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
$sections = array();
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2020-01-29 05:21:29 +00:00
|
|
|
if ( ! Constants::is_defined( 'WC_INSTALLING' ) ) {
|
2018-03-05 18:59:17 +00:00
|
|
|
$integrations = WC()->integrations->get_integrations();
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
if ( ! $current_section && ! empty( $integrations ) ) {
|
|
|
|
$current_section = current( $integrations )->id;
|
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2021-03-16 14:42:28 +00:00
|
|
|
if ( count( $integrations ) > 1 ) {
|
2018-03-05 18:59:17 +00:00
|
|
|
foreach ( $integrations as $integration ) {
|
|
|
|
$title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title;
|
|
|
|
$sections[ strtolower( $integration->id ) ] = esc_html( $title );
|
|
|
|
}
|
2015-01-23 13:05:35 +00:00
|
|
|
}
|
2014-10-16 14:53:09 +00:00
|
|
|
}
|
2018-03-05 18:59:17 +00:00
|
|
|
|
|
|
|
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
/**
|
|
|
|
* Output the settings.
|
|
|
|
*/
|
|
|
|
public function output() {
|
|
|
|
global $current_section;
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
$integrations = WC()->integrations->get_integrations();
|
2013-07-26 14:36:28 +00:00
|
|
|
|
2018-03-05 18:59:17 +00:00
|
|
|
if ( isset( $integrations[ $current_section ] ) ) {
|
|
|
|
$integrations[ $current_section ]->admin_options();
|
|
|
|
}
|
2017-03-07 20:24:24 +00:00
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
endif;
|
|
|
|
|
2014-05-19 05:57:34 +00:00
|
|
|
return new WC_Settings_Integrations();
|