woocommerce/includes/admin/settings/class-wc-settings-integrati...

82 lines
2.0 KiB
PHP
Raw Normal View History

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
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
2013-07-26 14:36:28 +00:00
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
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
/**
2015-11-03 13:31:20 +00:00
* WC_Settings_Integrations.
2013-07-26 14:36:28 +00:00
*/
class WC_Settings_Integrations extends WC_Settings_Page {
/**
* Constructor.
*/
public function __construct() {
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' ) );
}
}
/**
2015-11-03 13:31:20 +00:00
* Get sections.
2013-07-26 14:36:28 +00:00
*
* @return array
*/
public function get_sections() {
global $current_section;
$sections = array();
if ( ! defined( 'WC_INSTALLING' ) ) {
$integrations = WC()->integrations->get_integrations();
2013-07-26 14:36:28 +00:00
if ( ! $current_section && ! empty( $integrations ) ) {
$current_section = current( $integrations )->id;
}
2013-07-26 14:36:28 +00:00
if ( sizeof( $integrations ) > 1 ) {
foreach ( $integrations as $integration ) {
$title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title;
$sections[ strtolower( $integration->id ) ] = esc_html( $title );
}
}
2013-07-26 14:36:28 +00:00
}
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
2013-07-26 14:36:28 +00:00
}
/**
2015-11-03 13:31:20 +00:00
* Output the settings.
2013-07-26 14:36:28 +00:00
*/
public function output() {
global $current_section;
$integrations = WC()->integrations->get_integrations();
if ( isset( $integrations[ $current_section ] ) )
$integrations[ $current_section ]->admin_options();
}
}
endif;
return new WC_Settings_Integrations();