/**
     * Display a plugin settings form element
     *
     * @param 	string|array 	$setting{
     *
     *		Use string for simple fields. Array will contain information about the
     *		setting that we'll use to create the form element
     *
     *		@type 	string 			$label 		Required. The label for the form element	 
     * 		@type 	string 			$name 		Optional. The HTML name attribute. Will be auto-generated from label if empty
     * 		@type 	string 			$id 		Optional. The HTML `id` attribute for the form element. Will be auto-generated from label if empty
     *		@type 	string 			$type 		Optional. The type of form element to display (text|textarea|checkbox|select|single-image|radio) (Default: 'text')
     * 		@type 	string 			$value 		Optional. The value of the HTML `value` attribute
     * 		@type 	array|string 	$choices 	Optional. The choices for the form element (for select, radio, checkbox)
     * }
     *
     * @since 	1.0.0
     */
    public static function do_settings_field($setting)
    {
        # auto-complete the setting keys that may not be set
        $setting = RO3::get_field_array($setting);
        extract(RO3_Options::$options);
        # call one of several functions based on what type of field we have
        switch ($setting['type']) {
            case "textarea":
                self::textarea_field($setting);
                break;
            case "checkbox":
                self::checkbox_field($setting);
                break;
            case 'select':
                self::select_field($setting);
                break;
            case "single-image":
                self::image_field($setting);
                break;
            case "radio":
                self::radio_field($setting);
                break;
            default:
                self::text_field($setting);
        }
        # field description
        if (array_key_exists('description', $setting)) {
            ?>
			<p class='description'><?php 
            echo $setting['description'];
            ?>
</p>
		<?php 
        }
        # preview for different RO3 styles
        if ($setting['name'] == 'style') {
            ?>
			<div id="ro3-preview">		
			<?php 
            foreach ($setting['choices'] as $a) {
                $choice = $a['value'];
                ?>
				<div 
					id="preview-<?php 
                echo $choice;
                ?>
"
					style="display: <?php 
                echo $style == $choice ? 'block' : 'none';
                ?>
"
				>
					<?php 
                if ('nested' == $choice) {
                    ?>
						<p><em>Note: this choice works best with a short description</em></p>
					<?php 
                }
                ?>
					<img src="<?php 
                echo ro3_url('/images/' . $choice . '.jpg');
                ?>
" />
				</div>			
				<?php 
            }
            ?>
			</div>
		<?php 
        }
        # Subcontent for 'Existing Content' radio buttons
        if (strpos($setting['name'], 'post_type') === 0) {
            # get the section number
            $section = $setting['section'];
            # 'Clear' link
            ?>
			<a href="javascript:void(0)" class='clear-post-type-select' data-section="<?php 
            echo $section;
            ?>
">Clear</a>
		<?php 
            # Post select area for specific post type
            ?>
			<div 
				id="post-select-<?php 
            echo $section;
            ?>
"
				class='post-select' 
				style="display: <?php 
            echo !empty(RO3_Options::$options['post_type' . $section]) ? 'block' : 'none';
            ?>
;"
			><?php 
            RO3::select_post_for_type(RO3_Options::$options['post_type' . $section], $section);
            ?>
			</div>
		<?php 
        }
        # Child fields (for conditional logic)
        if (array_key_exists('choices', $setting)) {
            $choices = RO3::get_choice_array($setting);
            # keep track of which fields we've displayed (in case two choices have the same child)
            $aKids = array();
            # Loop through choices and display and children
            foreach ($choices as $choice) {
                if (array_key_exists('children', $choice)) {
                    foreach ($choice['children'] as $child_setting) {
                        # add this child to the array of completed child settings
                        if (!in_array($child_setting['name'], $aKids)) {
                            $aKids[] = $child_setting['name'];
                            # note the child field div is hidden unless the parent option is selected
                            ?>
<div 
							id="child_field_<?php 
                            echo $child_setting['name'];
                            ?>
"
							style="display: <?php 
                            echo RO3_Options::$options[$setting['name']] == $choice['value'] ? 'block' : 'none';
                            ?>
"
						>
							<h4><?php 
                            echo $child_setting['label'];
                            ?>
</h4>
							<?php 
                            self::do_settings_field($child_setting);
                            ?>
						</div>
						<?php 
                        }
                    }
                }
                # end if: choice has children
            }
            # end foreach: choices
        }
        # end if: setting has choices
    }