1 <?php
2 3 4 5 6 7 8 9
10
11 if ( ! defined( 'ABSPATH' ) ) exit;
12
13 if ( ! class_exists( 'WC_Settings_Page' ) ) :
14
15 16 17
18 class WC_Settings_Page {
19
20 protected $id = '';
21 protected $label = '';
22
23 24 25
26 public function add_settings_page( $pages ) {
27 $pages[ $this->id ] = $this->label;
28
29 return $pages;
30 }
31
32 33 34 35 36
37 public function get_settings() {
38 return array();
39 }
40
41 42 43 44 45
46 public function get_sections() {
47 return array();
48 }
49
50 51 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 . '§ion=' . 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 73
74 public function output() {
75 $settings = $this->get_settings();
76
77 WC_Admin_Settings::output_fields( $settings );
78 }
79
80 81 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;