/** * Sanitize and validate form input. Accepts an array, return a sanitized array. * * @see buttercream_theme_options_init() * @todo set up Reset Options action * */ function buttercream_theme_options_validate($input) { $output = $defaults = buttercream_get_default_theme_options(); // The sample Theme Styles value must be in our array of Theme Styles values if (isset($input['theme_style']) && array_key_exists($input['theme_style'], buttercream_theme_style())) { $output['theme_style'] = $input['theme_style']; } // The Support field should either be on or off if (!isset($input['support'])) { $input['support'] = 'off'; } $output['support'] = $input['support'] == 'on' ? 'on' : 'off'; // The Custom CSS must be safe text with the allowed tags for posts if (isset($input['custom_css'])) { $output['custom_css'] = wp_filter_nohtml_kses($input['custom_css']); } return apply_filters('buttercream_theme_options_validate', $output, $input, $defaults); }
function buttercream_is_a_default_header() { $buttercream_styles = buttercream_theme_style(); $buttercream_default_headers = array(); $buttercream_header_image = get_header_image(); foreach ($buttercream_styles as $buttercream_style) { $buttercream_default_headers[] = $buttercream_style['defaults']['default-header-image']; } if (empty($buttercream_header_image) || !in_array($buttercream_header_image, $buttercream_default_headers)) { return false; } return true; }