WC_Settings_Integrations

WC_Settings_Integrations.

Defined (1)

The class is defined in the following location(s).

/includes/admin/settings/class-wc-settings-integrations.php  
  1. class WC_Settings_Integrations extends WC_Settings_Page { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct() { 
  7.  
  8. $this->id = 'integration'; 
  9. $this->label = __( 'Integration', 'woocommerce' ); 
  10.  
  11. if ( isset( WC()->integrations ) && WC()->integrations->get_integrations() ) { 
  12. add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); 
  13. add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) ); 
  14. add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) ); 
  15. add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) ); 
  16.  
  17. /** 
  18. * Get sections. 
  19. * @return array 
  20. */ 
  21. public function get_sections() { 
  22. global $current_section; 
  23.  
  24. $sections = array(); 
  25.  
  26. if ( ! defined( 'WC_INSTALLING' ) ) { 
  27. $integrations = WC()->integrations->get_integrations(); 
  28.  
  29. if ( ! $current_section && ! empty( $integrations ) ) { 
  30. $current_section = current( $integrations )->id; 
  31.  
  32. if ( sizeof( $integrations ) > 1 ) { 
  33. foreach ( $integrations as $integration ) { 
  34. $title = empty( $integration->method_title ) ? ucfirst( $integration->id ) : $integration->method_title; 
  35. $sections[ strtolower( $integration->id ) ] = esc_html( $title ); 
  36.  
  37. return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections ); 
  38.  
  39. /** 
  40. * Output the settings. 
  41. */ 
  42. public function output() { 
  43. global $current_section; 
  44.  
  45. $integrations = WC()->integrations->get_integrations(); 
  46.  
  47. if ( isset( $integrations[ $current_section ] ) ) 
  48. $integrations[ $current_section ]->admin_options();