1 <?php
 2 /**
 3  * WooCommerce Integration Settings
 4  *
 5  * @author      WooThemes
 6  * @category    Admin
 7  * @package     WooCommerce/Admin
 8  * @version     2.1.0
 9  */
10 
11 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12 
13 if ( ! class_exists( 'WC_Settings_Integrations' ) ) :
14 
15 /**
16  * WC_Settings_Integrations
17  */
18 class WC_Settings_Integrations extends WC_Settings_Page {
19 
20     /**
21      * Constructor.
22      */
23     public function __construct() {
24         $this->id    = 'integration';
25         $this->label = __( 'Integration', 'woocommerce' );
26 
27         if ( isset( WC()->integrations ) && WC()->integrations->get_integrations() ) {
28             add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
29             add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
30             add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
31             add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
32         }
33     }
34 
35     /**
36      * Get sections
37      *
38      * @return array
39      */
40     public function get_sections() {
41         global $current_section;
42 
43         $sections = array();
44 
45         $integrations = WC()->integrations->get_integrations();
46 
47         if ( ! $current_section && ! empty( $integrations ) )
48             $current_section = current( $integrations )->id;
49 
50         foreach ( $integrations as $integration ) {
51             $title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title;
52 
53             $sections[ strtolower( $integration->id ) ] = esc_html( $title );
54         }
55 
56         return $sections;
57     }
58 
59     /**
60      * Output the settings
61      */
62     public function output() {
63         global $current_section;
64 
65         $integrations = WC()->integrations->get_integrations();
66 
67         if ( isset( $integrations[ $current_section ] ) )
68             $integrations[ $current_section ]->admin_options();
69     }
70 }
71 
72 endif;
73 
74 return new WC_Settings_Integrations();
75 
WooCommerce API documentation generated by ApiGen 2.8.0