1 | <?php |
||
18 | abstract class Admin_Page { |
||
19 | |||
20 | /** |
||
21 | * Admin page ID. |
||
22 | * |
||
23 | * @access public |
||
24 | * @var string |
||
25 | */ |
||
26 | public $id = ''; |
||
27 | |||
28 | /** |
||
29 | * Option group. |
||
30 | * |
||
31 | * @access public |
||
32 | * @var string |
||
33 | */ |
||
34 | public $option_group = ''; |
||
35 | |||
36 | /** |
||
37 | * Admin Page label. |
||
38 | * |
||
39 | * @access public |
||
40 | * @var string |
||
41 | */ |
||
42 | public $label = ''; |
||
43 | |||
44 | /** |
||
45 | * Admin Page description. |
||
46 | * |
||
47 | * @access public |
||
48 | * @var string |
||
49 | */ |
||
50 | public $description = ''; |
||
51 | |||
52 | /** |
||
53 | * Amdin Page settings sections. |
||
54 | * |
||
55 | * @access public |
||
56 | * @var array Associative array with section id (key) and section name (value) |
||
57 | */ |
||
58 | public $sections; |
||
59 | |||
60 | /** |
||
61 | * Admin Page settings fields. |
||
62 | * |
||
63 | * @access public |
||
64 | * @var array |
||
65 | */ |
||
66 | public $fields; |
||
67 | |||
68 | /** |
||
69 | * Saved values. |
||
70 | * |
||
71 | * @access protected |
||
72 | * @var array |
||
73 | */ |
||
74 | protected $values = array(); |
||
75 | |||
76 | /** |
||
77 | * Get admin page settings. |
||
78 | * |
||
79 | * @since 3.0.0 |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | public function get_settings() { |
||
109 | |||
110 | /** |
||
111 | * Get option value. |
||
112 | * |
||
113 | * @since 3.0.0 |
||
114 | * @access protected |
||
115 | * |
||
116 | * @param string $section |
||
117 | * @param string $setting |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | protected function get_option_value( $section, $setting ) { |
||
131 | |||
132 | /** |
||
133 | * Add sections for this page. |
||
134 | * |
||
135 | * @since 3.0.0 |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | abstract public function add_sections(); |
||
140 | |||
141 | /** |
||
142 | * Get settings fields. |
||
143 | * |
||
144 | * @since 3.0.0 |
||
145 | * |
||
146 | * @return array |
||
147 | */ |
||
148 | abstract public function add_fields(); |
||
149 | |||
150 | /** |
||
151 | * Default basic callback for page sections. |
||
152 | * |
||
153 | * @since 3.0.0 |
||
154 | * |
||
155 | * @param array $section |
||
156 | * |
||
157 | * @return string |
||
|
|||
158 | */ |
||
159 | public function add_settings_section_callback( $section ) { |
||
168 | |||
169 | /** |
||
170 | * Register setting callback. |
||
171 | * |
||
172 | * Callback function for sanitizing and validating options before they are updated. |
||
173 | * |
||
174 | * @since 3.0.0 |
||
175 | * |
||
176 | * @param array $settings Settings inputs. |
||
177 | * |
||
178 | * @return array Sanitized settings. |
||
179 | */ |
||
180 | public function validate( $settings ) { |
||
194 | |||
195 | } |
||
196 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.