function enlightenment_font_options($args, $echo = true) { $defaults = array('class' => '', 'id' => '', 'description' => ''); $args = wp_parse_args($args, $defaults); if (!isset($args['name']) || empty($args['name'])) { _doing_it_wrong(__FUNCTION__, __('Please specify a name attribute for your font options.', 'enlightenment'), ''); return; } $fonts = enlightenment_available_fonts(); $font_family_args = array('name' => $args['name'] . '_font_family', 'class' => 'font_family' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_family' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_family' : '', 'options' => array()); foreach ($fonts as $name => $font) { // $font_family_args['options'][$name] = ( isset( $font['family'] ) ? str_replace( '"', '', $font['family'] ) : $name ) . ', ' . $font['category']; $font_family_args['options'][$name] = str_replace('"', '', $font['family']) . ', ' . $font['category']; } $font_size_args = array('name' => $args['name'] . '_font_size', 'class' => 'font_size' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_size' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_size' : '', 'options' => array()); $min_font_size = apply_filters('enlightenment_min_font_size', 10); $max_font_size = apply_filters('enlightenment_max_font_size', 48); $font_size_inc = apply_filters('enlightenment_font_size_inc', 1); $font_size_unit = apply_filters('enlightenment_font_size_unit', 'px'); for ($i = $min_font_size; $i <= $max_font_size; $i = $i + $font_size_inc) { $font_size_args['options'][$i] = intval($i) . ' ' . esc_attr($font_size_unit); } $font_style_args = array('name' => $args['name'] . '_font_style', 'class' => 'font_style' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_style' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_style' : '', 'options' => enlightenment_font_styles()); $color_picker_args = array('name' => $args['name'] . '_font_color', 'class' => 'font_color' . (!empty($args['class']) ? ' ' . $args['class'] . '_font_color' : ''), 'id' => !empty($args['id']) ? $args['id'] . '_font_color' : ''); $output = enlightenment_open_tag('fieldset', 'font-options'); $output .= enlightenment_select_box($font_family_args, false); $output .= enlightenment_select_box($font_size_args, false); $output .= enlightenment_select_box($font_style_args, false); $output .= enlightenment_color_picker($color_picker_args, false); $output .= enlightenment_close_tag('fieldset'); $output .= empty($args['description']) ? '' : '<p class="description">' . strip_tags($args['description'], '<a><abbr><img>') . '</p>'; $output = apply_filters('enlightenment_font_options', $output, $args); if (!$echo) { return $output; } echo $output; }
function enlightenment_validate_font_style($input, $default = false) { if (array_key_exists($input, enlightenment_font_styles())) { return $input; } return $default; }