1 | <?php |
||
23 | class Give_Settings_Page { |
||
24 | |||
25 | /** |
||
26 | * Setting page id. |
||
27 | * |
||
28 | * @since 1.8 |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $id = ''; |
||
32 | |||
33 | /** |
||
34 | * Setting page label. |
||
35 | * |
||
36 | * @since 1.8 |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $label = ''; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * Default tab. |
||
44 | * |
||
45 | * @since 1.8 |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $default_tab = ''; |
||
49 | |||
50 | /** |
||
51 | * Current setting page. |
||
52 | * |
||
53 | * @since 1.8 |
||
54 | * @var string|null |
||
55 | */ |
||
56 | private $current_setting_page = null; |
||
57 | |||
58 | /** |
||
59 | * Constructor. |
||
60 | */ |
||
61 | public function __construct() { |
||
71 | |||
72 | /** |
||
73 | * Default setting tab. |
||
74 | * |
||
75 | * @since 1.8 |
||
76 | * |
||
77 | * @param $setting_tab |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | function set_default_setting_tab( $setting_tab ) { |
||
84 | |||
85 | /** |
||
86 | * Add this page to settings. |
||
87 | * |
||
88 | * @since 1.8 |
||
89 | * |
||
90 | * @param array $pages Lst of pages. |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | public function add_settings_page( $pages ) { |
||
99 | |||
100 | /** |
||
101 | * Get settings array. |
||
102 | * |
||
103 | * @since 1.8 |
||
104 | * @return array |
||
105 | */ |
||
106 | public function get_settings() { |
||
119 | |||
120 | /** |
||
121 | * Get sections. |
||
122 | * |
||
123 | * @since 1.8 |
||
124 | * @return array |
||
125 | */ |
||
126 | public function get_sections() { |
||
129 | |||
130 | /** |
||
131 | * Output sections. |
||
132 | * |
||
133 | * @since 1.8 |
||
134 | * @return void |
||
135 | */ |
||
136 | public function output_sections() { |
||
170 | |||
171 | /** |
||
172 | * Output the settings. |
||
173 | * |
||
174 | * @since 1.8 |
||
175 | * @return void |
||
176 | */ |
||
177 | public function output() { |
||
182 | |||
183 | /** |
||
184 | * Save settings. |
||
185 | * |
||
186 | * @since 1.8 |
||
187 | * @return void |
||
188 | */ |
||
189 | public function save() { |
||
202 | } |
||
203 | |||
205 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.