1 <?php
 2 /**
 3  * WooCommerce Settings Page/Tab
 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_Page' ) ) :
14 
15 /**
16  * WC_Settings_Page
17  */
18 class WC_Settings_Page {
19 
20     protected $id    = '';
21     protected $label = '';
22 
23     /**
24      * Add this page to settings
25      */
26     public function add_settings_page( $pages ) {
27         $pages[ $this->id ] = $this->label;
28 
29         return $pages;
30     }
31 
32     /**
33      * Get settings array
34      *
35      * @return array
36      */
37     public function get_settings() {
38         return array();
39     }
40 
41     /**
42      * Get sections
43      *
44      * @return array
45      */
46     public function get_sections() {
47         return array();
48     }
49 
50     /**
51      * Output sections
52      */
53     public function output_sections() {
54         global $current_section;
55 
56         $sections = $this->get_sections();
57 
58         if ( empty( $sections ) )
59             return;
60 
61         echo '<ul class="subsubsub">';
62 
63         $array_keys = array_keys( $sections );
64 
65         foreach ( $sections as $id => $label )
66             echo '<li><a href="' . admin_url( 'admin.php?page=wc-settings&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>';
67 
68         echo '</ul><br class="clear" />';
69     }
70 
71     /**
72      * Output the settings
73      */
74     public function output() {
75         $settings = $this->get_settings();
76 
77         WC_Admin_Settings::output_fields( $settings );
78     }
79 
80     /**
81      * Save settings
82      */
83     public function save() {
84         global $current_section;
85 
86         $settings = $this->get_settings();
87         WC_Admin_Settings::save_fields( $settings );
88 
89          if ( $current_section )
90             do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
91     }
92 }
93 
94 endif;
WooCommerce API documentation generated by ApiGen 2.8.0