/**
 * Callback for get_settings_field()
 */
function upfw_setting_callback($option)
{
    global $upfw_custom_callbacks;
    $upfw_options = (array) upfw_get_options();
    $option_parameters = upfw_get_option_parameters();
    $optionname = $option['name'];
    $optiontitle = $option['title'];
    $optiondescription = $option['description'];
    $fieldtype = $option['type'];
    $fieldname = "theme_" . upfw_get_current_theme_id() . "_options[{$optionname}]";
    $attr = $option_parameters[$option['name']];
    $value = $upfw_options[$optionname];
    //Determine the type of input field
    switch ($fieldtype) {
        //Render Text Input
        case 'text':
            upfw_text($value, $attr);
            break;
            //Render textarea options
        //Render textarea options
        case 'textarea':
            upfw_textarea($value, $attr);
            break;
            //Render wordpress editor options
        //Render wordpress editor options
        case 'editor':
            upfw_editor($value, $attr);
            break;
            //Render select dropdowns
        //Render select dropdowns
        case 'select':
            upfw_select($value, $attr);
            break;
            //Render radio image dropdowns
        //Render radio image dropdowns
        case 'radio':
            upfw_radio($value, $attr);
            break;
            //Render radio image dropdowns
        //Render radio image dropdowns
        case 'radio_image':
            upfw_radio_image($value, $attr);
            break;
            //Render checkboxes
        //Render checkboxes
        case 'multicheck':
            upfw_multicheck($value, $attr);
            break;
            //Render color picker
        //Render color picker
        case 'color':
            upfw_color($value, $attr);
            break;
            //Render upload image
        //Render upload image
        case 'image':
            upfw_upload($value, $attr);
            break;
            //Render upload
        //Render upload
        case 'upload':
            upfw_upload($value, $attr);
            break;
        default:
            break;
    }
    // Check if there is a callback to envoke for custom fields
    if (isset($upfw_custom_callbacks[$fieldtype])) {
        $custom_field_name = 'theme_' . upfw_get_current_theme_id() . '_options[' . $attr['name'] . ']';
        call_user_func($upfw_custom_callbacks[$fieldtype], $value, $attr, $custom_field_name);
    }
}
        public function render_content()
        {
            ?>

			<label>
				<span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
				<textarea rows="6" cols="25" id="<?php 
            echo esc_html($this->id);
            ?>
" class="image-radio" type="radio" name="<?php 
            echo esc_html($this->id);
            ?>
" data-customize-setting-link="theme_<?php 
            echo upfw_get_current_theme_id();
            ?>
_options[<?php 
            echo esc_html($this->id);
            ?>
]"><?php 
            echo esc_attr($value);
            ?>
</textarea>
			</label>
			<?php 
        }
/**
 * Outputs a media upload field option type.
 *
 * @param 	string 	$value 	The current value for this option.
 * @param 	array 	$attr 	An array of attributes for this theme option defined by the theme creator in the options array.
 */
function upfw_upload($value, $attr)
{
    ?>

	<div id="<?php 
    echo esc_html($attr['name']);
    ?>
_container" class="imageWrapper">
		<input type="text" class="upfw-open-media" id="<?php 
    echo esc_attr($attr['name']);
    ?>
" name="theme_<?php 
    echo esc_attr(upfw_get_current_theme_id());
    ?>
_options[<?php 
    echo esc_attr($attr['name']);
    ?>
]" value="<?php 
    echo esc_attr($value);
    ?>
">
		<input class="upfw-open-media button button-primary" type="submit" value="<?php 
    esc_attr_e('Upload or Select a File', 'upfw');
    ?>
" />
		<div class="image_preview"></div>
	</div>
<?php 
    if ($attr['description']) {
        echo '<div><em>' . $attr['description'] . '</em></div>';
    }
}
Beispiel #4
0
/**
 * Get Theme Options
 *
 * Array that holds all of the defined values
 * for upfw Theme options. If the user
 * has not specified a value for a given Theme
 * option, then the option's default value is
 * used instead.
 *
 * @uses	upfw_get_option_defaults()	defined in options.php
 *
 * @uses	get_option()
 * @uses	wp_parse_args()
 *
 * @return	array	$upfw_options	current values for all Theme options
 */
function upfw_get_options()
{
    // Get the option defaults
    $option_defaults = upfw_get_option_defaults();
    // Globalize the variable that holds the Theme options
    global $up_options;
    // Parse the stored options with the defaults
    $up_options = (object) wp_parse_args(get_option("theme_" . upfw_get_current_theme_id() . "_options", array()), $option_defaults);
    // Return the parsed array
    return $up_options;
}