2013-07-26 14:36:28 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce Integration Settings
|
|
|
|
*
|
2014-08-31 08:22:03 +00:00
|
|
|
* @author WooThemes
|
|
|
|
* @category Admin
|
|
|
|
* @package WooCommerce/Admin
|
2013-07-26 14:36:28 +00:00
|
|
|
* @version 2.1.0
|
|
|
|
*/
|
|
|
|
|
2014-09-20 19:55:47 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit; // Exit if accessed directly
|
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
if ( ! class_exists( 'WC_Settings_Integrations' ) ) :
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_Settings_Integrations
|
|
|
|
*/
|
|
|
|
class WC_Settings_Integrations extends WC_Settings_Page {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
2014-08-31 08:22:03 +00:00
|
|
|
|
2013-07-26 14:36:28 +00:00
|
|
|
$this->id = 'integration';
|
|
|
|
$this->label = __( 'Integration', 'woocommerce' );
|
|
|
|
|
|
|
|
if ( isset( WC()->integrations ) && WC()->integrations->get_integrations() ) {
|
|
|
|
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
|
|
|
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
|
|
|
|
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
|
|
|
|
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get sections
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_sections() {
|
|
|
|
global $current_section;
|
|
|
|
|
|
|
|
$sections = array();
|
|
|
|
|
|
|
|
$integrations = WC()->integrations->get_integrations();
|
|
|
|
|
2014-08-31 08:22:03 +00:00
|
|
|
if ( ! $current_section && ! empty( $integrations ) ) {
|
2013-07-26 14:36:28 +00:00
|
|
|
$current_section = current( $integrations )->id;
|
2014-08-31 08:22:03 +00:00
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
foreach ( $integrations as $integration ) {
|
2013-10-25 15:44:17 +00:00
|
|
|
$title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title;
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
$sections[ strtolower( $integration->id ) ] = esc_html( $title );
|
|
|
|
}
|
|
|
|
|
2014-02-17 14:30:37 +00:00
|
|
|
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output the settings
|
|
|
|
*/
|
|
|
|
public function output() {
|
|
|
|
global $current_section;
|
|
|
|
|
|
|
|
$integrations = WC()->integrations->get_integrations();
|
|
|
|
|
|
|
|
if ( isset( $integrations[ $current_section ] ) )
|
|
|
|
$integrations[ $current_section ]->admin_options();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
endif;
|
|
|
|
|
2014-05-19 05:57:34 +00:00
|
|
|
return new WC_Settings_Integrations();
|