1 <?php
2 /**
3 * Admin Page Framework
4 *
5 * http://en.michaeluno.jp/admin-page-framework/
6 * Copyright (c) 2013-2014 Michael Uno; Licensed MIT
7 *
8 */
9 if ( ! class_exists( 'AdminPageFramework_Setting' ) ) :
10 /**
11 * Provides public methods to add form elements with WordPress Settings API.
12 *
13 * @abstract
14 * @since 2.0.0
15 * @extends AdminPageFramework_Setting_Validation
16 * @package AdminPageFramework
17 * @subpackage Page
18 * @var array $aFieldErrors stores the settings field errors.
19 */
20 abstract class AdminPageFramework_Setting extends AdminPageFramework_Setting_Validation {
21
22
23 /**
24 * Adds the given form section items into the property.
25 *
26 * The passed section array must consist of the following keys.
27 *
28 * <h4>Example</h4>
29 * <code>$this->addSettingSections(
30 * array(
31 * 'section_id' => 'text_fields',
32 * 'page_slug' => 'first_page',
33 * 'tab_slug' => 'textfields',
34 * 'title' => 'Text Fields',
35 * 'description' => 'These are text type fields.',
36 * 'order' => 10,
37 * ),
38 * array(
39 * 'section_id' => 'selectors',
40 * 'page_slug' => 'first_page',
41 * 'tab_slug' => 'selectors',
42 * 'title' => 'Selectors and Checkboxes',
43 * 'description' => 'These are selector type options such as dropdown lists, radio buttons, and checkboxes',
44 * )</code>
45 *
46 * @since 2.0.0
47 * @since 3.0.0 Changed the scope to public from protected.
48 * @access public
49 * @remark Accepts variadic parameters; the number of accepted parameters are not limited to three.
50 * @remark The actual registration will be performed in the <em>_replyToRegisterSettings()</em> method with the <em>admin_menu</em> hook.
51 * @remark The target section tab slug and the target tab slug will be reset once the method returns.
52 * @param array|string the section array or the target page slug. If the target page slug is set, the next section array can omit the page slug key.
53 * <strong>Section Array</strong>
54 * <ul>
55 * <li><strong>section_id</strong> - ( required, string ) the section ID. Avoid using non-alphabetic characters except underscore and numbers.</li>
56 * <li><strong>page_slug</strong> - ( optional, string ) the page slug that the section belongs to. If the target page slug is set, it can be omitted.</li>
57 * <li><strong>tab_slug</strong> - ( optional, string ) the tab slug that the section belongs to. The tab here refers to in-page tabs.</li>
58 * <li><strong>section_tab_slug</strong> - ( optional, string ) [3.0.0+] the section tab slug that the section are grouped into. The tab here refers to section tabs.</li>
59 * <li><strong>title</strong> - ( optional, string ) the title of the section.</li>
60 * <li><strong>capability</strong> - ( optional, string ) the <a href="http://codex.wordpress.org/Roles_and_Capabilities">access level</a> of the section. If the page visitor does not have sufficient capability, the section will be invisible to them.</li>
61 * <li><strong>if</strong> - ( optional, boolean ) if the passed value is false, the section will not be registered.</li>
62 * <li><strong>order</strong> - ( optional, integer ) the order number of the section. The higher the number is, the lower the position it gets.</li>
63 * <li><strong>help</strong> - ( optional, string ) the help description added to the contextual help tab.</li>
64 * <li><strong>help_aside</strong> - ( optional, string ) the additional help description for the side bar of the contextual help tab.</li>
65 * <li><strong>repeatable</strong> - ( optional, boolean|array ) [3.0.0+] Indicates whether or not the section is repeatable. To set a minimum/maximum number of sections, pass an array with the key, <em>min</em>, and <em>max</em>. e.g. <em>array( 'min' => 3, 'max' => 10 )</em></li>
66 * </ul>
67 * @param array ( optional ) another section array.
68 * @param array ( optional ) add more section array to the next parameters as many as necessary.
69 * @return void
70 */
71 public function addSettingSections( $aSection1, $aSection2=null, $_and_more=null ) {
72
73 foreach( func_get_args() as $asSection ) $this->addSettingSection( $asSection );
74
75 // reset the stored target tab slug and the target section tab slug
76 $this->_sTargetTabSlug = null;
77 $this->_sTargetSectionTabSlug = null;
78
79 }
80
81 /**
82 * A singular form of the adSettingSections() method which takes only a single parameter.
83 *
84 * This is useful when adding section arrays in loops.
85 *
86 * @since 2.1.2
87 * @since 3.0.0 Changed the scope to public from protected.
88 * @access public
89 * @remark The actual registration will be performed in the <em>_replyToRegisterSettings()</em> method with the <em>admin_menu</em> hook.
90 * @param array|string the section array. If a string is passed, it is considered as a target page slug that will be used as a page slug element from the next call so that the element can be ommited.
91 * @return void
92 */
93 public function addSettingSection( $asSection ) {
94
95 if ( ! is_array( $asSection ) ) {
96 $this->_sTargetPageSlug = is_string( $asSection ) ? $asSection : $this->_sTargetPageSlug;
97 return;
98 }
99
100 $aSection = $asSection;
101 $this->_sTargetPageSlug = isset( $aSection['page_slug'] ) ? $aSection['page_slug'] : $this->_sTargetPageSlug;
102 $this->_sTargetTabSlug = isset( $aSection['tab_slug'] ) ? $aSection['tab_slug'] : $this->_sTargetTabSlug;
103 $this->_sTargetSectionTabSlug = isset( $aSection['section_tab_slug'] ) ? $aSection['section_tab_slug'] : $this->_sTargetSectionTabSlug;
104 $aSection = $this->oUtil->uniteArrays(
105 $aSection,
106 array(
107 'page_slug' => $this->_sTargetPageSlug ? $this->_sTargetPageSlug : null, // checking the value allows the user to reset the internal target manually
108 'tab_slug' => $this->_sTargetTabSlug ? $this->_sTargetTabSlug : null,
109 'section_tab_slug' => $this->_sTargetSectionTabSlug ? $this->_sTargetSectionTabSlug : null,
110 )
111 ); // avoid undefined index warnings.
112
113 $aSection['page_slug'] = $aSection['page_slug'] ? $this->oUtil->sanitizeSlug( $aSection['page_slug'] ) : ( $this->oProp->sDefaultPageSlug ? $this->oProp->sDefaultPageSlug : null );
114 $aSection['tab_slug'] = $this->oUtil->sanitizeSlug( $aSection['tab_slug'] );
115 $aSection['section_tab_slug'] = $this->oUtil->sanitizeSlug( $aSection['section_tab_slug'] );
116
117 if ( ! $aSection['page_slug'] ) return; // The page slug is necessary.
118 $this->oForm->addSection( $aSection );
119
120 }
121
122 /**
123 * Removes the given section(s) by section ID.
124 *
125 * This accesses the property storing the added section arrays and removes the specified ones.
126 *
127 * <h4>Example</h4>
128 * <code>$this->removeSettingSections( 'text_fields', 'selectors', 'another_section', 'yet_another_section' );
129 * </code>
130 *
131 * @since 2.0.0
132 * @since 3.0.0 Changed the scope to public from protected.
133 * @access public
134 * @remark Accepts variadic parameters; the number of accepted parameters are not limited to three.
135 * @remark The actual registration will be performed in the <em>_replyToRegisterSettings()</em> method with the <em>admin_menu</em> hook.
136 * @param string the section ID to remove.
137 * @param string ( optional ) another section ID to remove.
138 * @param string ( optional ) add more section IDs to the next parameters as many as necessary.
139 * @return void
140 */
141 public function removeSettingSections( $sSectionID1=null, $sSectionID2=null, $_and_more=null ) {
142
143 foreach( func_get_args() as $_sSectionID )
144 $this->oForm->removeSection( $_sSectionID );
145
146 }
147
148 /**
149 * Adds the given field array items into the field array property by the given field definition array(s).
150 *
151 * The field definition array requires specific keys. Refer to the parameter section of this method.
152 *
153 * <h4>Example</h4>
154 * <code>$this->addSettingFields(
155 * array(
156 * 'field_id' => 'text',
157 * 'section_id' => 'text_fields',
158 * 'title' => __( 'Text', 'admin-page-framework-demo' ),
159 * 'description' => __( 'Type something here.', 'admin-page-framework-demo' ),
160 * 'type' => 'text',
161 * 'order' => 1,
162 * 'default' => 123456,
163 * 'size' => 40,
164 * ),
165 * array(
166 * 'field_id' => 'text_multiple',
167 * 'section_id' => 'text_fields',
168 * 'title' => 'Multiple Text Fields',
169 * 'description' => 'These are multiple text fields.',
170 * 'type' => 'text',
171 * 'order' => 2,
172 * 'default' => 'Hello World',
173 * 'label' => 'First Item',
174 * 'attributes' => array(
175 * 'size' => 30
176 * ),
177 * array(
178 * 'label' => 'Second Item',
179 * 'default' => 'Foo bar',
180 * 'attributes' => array(
181 * 'size' => 60,
182 * ),
183 * ),
184 * array(
185 * 'label' => 'Third Item',
186 * 'default' => 'Yes, we can.',
187 * 'attributes' => array(
188 * 'size' => 90,
189 * ),
190 * ),
191 * )
192 * );</code>
193 *
194 * @since 2.0.0
195 * @since 3.0.0 Changed the scope to public from protected.
196 * @access public
197 * @remark Accepts variadic parameters; the number of accepted parameters are not limited to three.
198 * @remark The actual registration will be performed in the <em>_replyToRegisterSettings()</em> method with the <em>admin_menu</em> hook.
199 * @param array the field definition array.
200 * <h4>Built-in Field Types</h4>
201 * <ul>
202 * <li><strong>text</strong> - a normal field to enter text input.</li>
203 * <li><strong>text</strong> - a masked text input field.</li>
204 * <li><strong>textarea</strong> - a text input field with multiple lines. It supports rich text editor.</li>
205 * <li><strong>radio</strong> - a set of radio buttons that lets the user pick an option.</li>
206 * <li><strong>checkbox</strong> - a check box that lets the user enable/disable an item.</li>
207 * <li><strong>select</strong> - a drop-down list that lest the user pick one or more item(s) from a list.</li>
208 * <li><strong>hidden</strong> - a hidden field that will be useful to insert invisible values.</li>
209 * <li><strong>file</strong> - a file uploader that lets the user upload files.</li>
210 * <li><strong>image</strong> - a custom text field with the image uploader script that lets the user set the image URL.</li>
211 * <li><strong>media</strong> - a custom text field with the media uploader script that lets the user set the file URL.</li>
212 * <li><strong>color</strong> - a custom text field with the color picker script.</li>
213 * <li><strong>submit</strong> - a submit button that lets the user send the form.</li>
214 * <li><strong>export</strong> - a custom submit field that lets the user export the stored data.</li>
215 * <li><strong>import</strong> - a custom combination field of the file and the submit fields that let the user import data.</li>
216 * <li><strong>posttype</strong> - a check-list of post types enabled on the site.</li>
217 * <li><strong>taxonomy</strong> - a set of check-lists of taxonomies enabled on the site in a tabbed box.</li>
218 * <li><strong>size</strong> - a combination field of the text and the select fields that let the user set sizes with a selectable unit.</li>
219 * <li><strong>section_title</strong> - [3.0.0+] a text field type that will be placed in the section title so that it lets the user set the section title. Note that only one field with this field type is allowed per a section.</li>
220 * </ul>
221 * <h4>Field Definition Array</h4>
222 * <ul>
223 * <li><strong>field_id</strong> - ( required, string ) the field ID. Avoid using non-alphabetic characters except underscore and numbers.</li>
224 * <li><strong>type</strong> - ( required, string ) the type of the field. The supported types are listed below.</li>
225 * <li><strong>section_id</strong> - ( optional, string ) the section ID that the field belongs to. If not set, the internal <em>_default</em> section ID will be assigned.</li>
226 * <li><strong>title</strong> - ( optional, string ) the title of the section.</li>
227 * <li><strong>description</strong> - ( optional, string ) the description of the field which is inserted into the after the input field tag.</li>
228 * <li><strong>tip</strong> - ( optional, string ) the tip for the field which is displayed when the mouse is hovered over the field title.</li>
229 * <li><strong>capability</strong> - ( optional, string ) the http://codex.wordpress.org/Roles_and_Capabilities">access level of the section. If the page visitor does not have sufficient capability, the section will be invisible to them.</li>
230 * <li><strong>error_message</strong> - ( optional, string ) the error message to display above the input field.</li>
231 * <li><strong>before_field</strong> - ( optional, string ) the HTML string to insert before the input field output.</li>
232 * <li><strong>after_field</strong> - ( optional, string ) the HTML string to insert after the input field output.</li>
233 * <li><strong>if</strong> - ( optional, boolean ) if the passed value is false, the section will not be registered.</li>
234 * <li><strong>order</strong> - ( optional, integer ) the order number of the section. The higher the number is, the lower the position it gets.</li>
235 * <li><strong>label</strong> - ( optional, string ) the text label(s) associated with and displayed along with the input field. Some input types can ignore this key.</li>
236 * <li><strong>default</strong> - ( optional, string|array ) the default value(s) assigned to the input tag's value attribute.</li>
237 * <li><strong>value</strong> - ( optional, string|array ) the value(s) assigned to the input tag's <em>value</em> attribute to override the default and the stored value.</li>
238 * <li><strong>delimiter</strong> - ( optional, string ) the HTML string that delimits multiple elements. This is available if the <var>label</var> key is passed as array. It will be enclosed in inline-block elements so the passed HTML string should not contain block elements.</li>
239 * <li><strong>before_input</strong> - ( optional, string ) the HTML string inserted right before the input tag. It will be enclosed in the <code>label</code> tag so the passed HTML string should not contain block elements.</li>
240 * <li><strong>after_input</strong> - ( optional, string ) the HTML string inserted right after the input tag. It will be enclosed in the <code>label</code> tag so the passed HTML string should not contain block elements.</li>
241 * <li><strong>label_min_width</strong> - ( optional, string ) the inline style property of the <em>min-width</em> of the label tag for the field. If the unit is not specified, 'px' is applied. Default: <code>120</code>. e.g. <code>100%</code></li>
242 * <li><strong>help</strong> - ( optional, string ) the help description added to the contextual help tab.</li>
243 * <li><strong>help_aside</strong> - ( optional, string ) the additional help description for the side bar of the contextual help tab.</li>
244 * <li><strong>repeatable</strong> - [3.0.0+] ( optional, array|boolean ) whether the fields should be repeatable. If it yields true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields. Optionally an setting array can be passed.
245 * <h5>Repeatable Fields Setting Array</h5>
246 * <ul>
247 * <li><strong>max</strong> - the allowed maximum number of fields to be repeated.</li>
248 * <li><strong>min</string> - the allowed minimum number of fields to be repeated.</li>
249 * </ul>
250 * </li>
251 * <li><strong>sortable</strong> - [3.0.0+] ( optional, boolean ) whether the fields should be sortable. If it yields true, the fields will be enclosed in a draggable box.
252 * <li><strong>attributes</strong> - [3.0.0+] ( optional, array ) holds key-value pairs representing the attribute and its property. Note that some field types have specific keys in the first dimensions. e.g.<em>array( 'class' => 'my_custom_class_selector', 'style' => 'background-color:#777', 'size' => 20, )</em></li>
253 * <li><strong>show_title_column</strong> - [3.0.0+] ( optional, boolean ) If true, the field title column will be omitted from the output.</li>
254 * <li><strong>hidden</strong> - [3.0.0+] ( optional, boolean ) If true, the entire field row output will be invisible with the inline style attribute of <em>style="display:none"</em>.</li>
255 * </ul>
256 *
257 * <h4>Field Type Specific Keys</h4>
258 * <p>Each field type uses specific array keys.</p>
259 * <ul>
260 * <li><strong>text</strong> - a text input field which allows the user to type text.</li>
261 * <li><strong>password</strong> - a password input field which allows the user to type text.</li>
262 * <li><strong>number, range</strong> - HTML5 input field types. Some browsers do not support these.</li>
263 * <li><strong>textarea</strong> - a textarea input field. The following array keys are supported.
264 * <ul>
265 * <li><strong>rich</strong> - [2.1.2+]( optional, array ) to make it a rich text editor pass a non-empty value. It accept a setting array of the <code>_WP_Editors</code> class defined in the core.
266 * For more information, see the argument section of <a href="http://codex.wordpress.org/Function_Reference/wp_editor" target="_blank">this page</a>.
267 * </li>
268 * </ul>
269 * </li>
270 * <li><strong>radio</strong> - a radio button input field.</li>
271 * <li><strong>checkbox</strong> - a check box input field.</li>
272 * <li><strong>select</strong> - a drop-down input field.
273 * <ul>
274 * <li><strong>is_multiple</strong> - ( optional, boolean ) if this is set to true, the <em>multiple</em> attribute will be inserted into the field input tag, which enables the multiple selections for the user.</li>
275 * </ul>
276 * </li>
277 * <li><strong>size</strong> - a size input field. This is a combination of number and select fields.
278 * <ul>
279 * <li>
280 * <strong>units</strong> - ( optional, array ) defines the units to show. e.g. <em>array( 'px' => 'px', '%' => '%', 'em' => 'em' )</em>
281 * Default: <em>array( 'px' => 'px', '%' => '%', 'em' => 'em', 'ex' => 'ex', 'in' => 'in', 'cm' => 'cm', 'mm' => 'mm', 'pt' => 'pt', 'pc' => 'pc' )</em>
282 * </li>
283 * <li><strong>is_multiple</strong> - ( optional, boolean ) if this is set to true, the <em>multiple</em> attribute will be inserted into the field input tag, which enables the multiple selections for the user.</li>
284 * <li><strong>attributes</strong> - [3.0.0+] ( optional, array ) The attributes array of this field type has four initial keys: size, unit, optgroup, and option and they have a regular attribute array in each.</li>
285 * </ul>
286 * </li>
287 * <li><strong>hidden</strong> - a hidden input field.</li>
288 * <li><strong>file</strong> - a file upload input field.</li>
289 * <li><strong>submit</strong> - a submit button input field.
290 * <ul>
291 * <li><strong>href</strong> - ( optional, string ) the url(s) linked to the submit button.</li>
292 * <li><strong>redirect_url</strong> - ( optional, string ) the url(s) redirected to after submitting the input form.</li>
293 * <li><strong>reset</strong> - [2.1.2+] ( optional, boolean ) the option key to delete. Set 1 for the entire option.</li>
294 * </ul>
295 * </li>
296 * <li><strong>import</strong> - an import input field. This is a custom file and submit field.
297 * <ul>
298 * <li><strong>option_key</strong> - ( optional, string ) the option table key to save the importing data.</li>
299 * <li><strong>format</strong> - ( optional, string ) the import format. json, or array is supported. Default: array</li>
300 * <li><strong>is_merge</strong> - ( optional, boolean ) [2.0.5+] determines whether the imported data should be merged with the existing options.</li>
301 * </ul>
302 * </li>
303 * <li><strong>export</strong> - an export input field. This is a custom submit field.
304 * <ul>
305 * <li><strong>file_name</strong> - ( optional, string ) the file name to download.</li>
306 * <li><strong>format</strong> - ( optional, string ) the format type. array, json, or text is supported. Default: array.</li>
307 * <li><strong>data</strong> - ( optional, string|array|object ) the data to export.</li>
308 * </ul>
309 * </li>
310 * <li><strong>image</strong> - an image input field. This is a custom text field with an attached JavaScript script.
311 * <ul>
312 * <li><strong>show_preview</strong> - ( optional, boolean ) if this is set to false, the image preview will be disabled.</li>
313 * <li><strong>attributes_to_store</strong> - [2.1.3+] ( optional, array ) the array of the attribute names of the image to save. If this is set, the field will be an array with the specified attributes. The supported attributes are, 'title', 'alt', 'width', 'height', 'caption', 'id', 'align', and 'link'. Note that for external URLs, ID will not be captured. e.g. <em>'attributes_to_store' => array( 'id', 'caption', 'description' )</em></li>
314 * <li><strong>allow_external_source</strong> - [2.1.3+] ( optional, boolean ) whether external URL can be set via the uploader.</li>
315 * <li><strong>attributes</strong> - [3.0.0+] ( optional, array ) The attributes array of this field type has three keys: input, button, and preview and they have a regular attribute array in each.</li>
316 * </ul>
317 * </li>
318 * <li><strong>media</strong> - [2.1.3+] a media input field. This is a custom text field with an attached JavaScript script.
319 * <ul>
320 * <li><strong>attributes_to_store</strong> - [2.1.3+] ( optional, array ) the array of the attribute names of the image to save. If this is set, the field will be an array with the specified attributes. The supported attributes are, 'id', 'caption', and 'description'. Note that for external URLs, ID will not be captured. e.g. <em>'attributes_to_store' => array( 'id', 'caption', 'description' )</em></li>
321 * <li><strong>allow_external_source</strong> - [2.1.3+] ( optional, boolean ) whether external URL can be set via the uploader.</li>
322 * </ul>
323 * </li>
324 * <li><strong>color</strong> - a color picker input field. This is a custom text field with a JavaScript script.</li>
325 * <li><strong>taxonomy</strong> - a taxonomy check list. This is a set of check boxes listing a specified taxonomy. This does not accept to create multiple fields by passing an array of labels.
326 * <ul>
327 * <li><strong>taxonomy_slugs</strong> - ( optional, array ) the taxonomy slug to list.</li>
328 * <li><strong>max_width</strong> - ( optional, string ) the inline style property value of <em>max-width</em> of this element. Include the unit such as px, %. Default: 100%</li>
329 * <li><strong>height</strong> - ( optional, string ) the inline style property value of <em>height</em> of this element. Include the unit such as px, %. Default: 250px</li>
330 * </ul>
331 * </li>
332 * <li><strong>posttype</strong> - a post-type check list. This is a set of check boxes listing post type slugs.
333 * <ul>
334 * <li><strong>slugs_to_remove</strong> - ( optional, array ) the post type slugs not to be listed. e.g.<em>array( 'revision', 'attachment', 'nav_menu_item' )</em></li>
335 * </ul>
336 * </li>
337 * </ul>
338 * @param array ( optional ) another field array.
339 * @param array ( optional ) add more field arrays to the next parameters as many as necessary.
340 * @return void
341 */
342 public function addSettingFields( $aField1, $aField2=null, $_and_more=null ) {
343 foreach( func_get_args() as $aField ) $this->addSettingField( $aField );
344 }
345 /**
346 * Adds the given field array items into the field array property.
347 *
348 * Identical to the addSettingFields() method except that this method does not accept enumerated parameters.
349 *
350 * @since 2.1.2
351 * @since 3.0.0 Changed the scope to public from protected.
352 * @access public
353 * @param array|string the field array or the target section ID. If the target section ID is set, the section_id key can be omitted from the next passing field array.
354 * @return void
355 */
356 public function addSettingField( $asField ) {
357 $this->oForm->addField( $asField );
358 }
359
360 /**
361 * Removes the given field(s) by field ID.
362 *
363 * This accesses the property storing the added field arrays and removes the specified ones.
364 *
365 * <h4>Example</h4>
366 * <code>$this->removeSettingFields( 'fieldID_A', 'fieldID_B', 'fieldID_C', 'fieldID_D' );
367 * </code>
368 *
369 * @since 2.0.0
370 * @since 3.0.0 Changed the scope to public from protected.
371 * @access public
372 * @remark Accepts variadic parameters; the number of accepted parameters are not limited to three.
373 * @remark The actual registration will be performed in the <em>_replyToRegisterSettings()</em> method with the <em>admin_menu</em> hook.
374 * @param string the field ID to remove.
375 * @param string ( optional ) another field ID to remove.
376 * @param string ( optional ) add more field IDs to the next parameters as many as necessary.
377 * @return void
378 */
379 public function removeSettingFields( $sFieldID1, $sFieldID2=null, $_and_more ) {
380
381 foreach( func_get_args() as $_sFieldID ) $this->oForm->removeField( $_sFieldID );
382
383 }
384
385 /**
386 * Retrieves the specified field value stored in the options by field ID.
387 *
388 * @since 2.1.2
389 * @since 3.0.0 Changed the scope to public from protected. Dropped the sections. Made it return a default value even if it's not saved in the database.
390 * @access public
391 * @param string The field ID.
392 * @return array|string|null If the field ID is not set in the saved option array, it will return null. Otherwise, the set value.
393 * If the user has not submitted the form, the framework will try to return the default value set in the field definition array.
394 */
395 public function getFieldValue( $sFieldID, $sSectionID='' ) {
396
397 $_aOptions = $this->oUtil->uniteArrays( $this->oProp->aOptions, $this->oProp->getDefaultOptions( $this->oForm->aFields ) );
398
399 /* If it's saved, return it */
400 if ( ! $sSectionID ) {
401 if ( array_key_exists( $sFieldID, $_aOptions ) )
402 return $_aOptions[ $sFieldID ];
403
404 // loop through section elements
405 foreach( $_aOptions as $aOptions ) {
406 if ( array_key_exists( $sFieldID, $aOptions ) )
407 return $aOptions[ $sFieldID ];
408 }
409
410 }
411 if ( $sSectionID )
412 if ( array_key_exists( $sSectionID, $_aOptions ) && array_key_exists( $sFieldID, $_aOptions[ $sSectionID ] ) )
413 return $_aOptions[ $sSectionID ][ $sFieldID ];
414
415 return null;
416
417 }
418
419 }
420 endif;