コード例 #1
0
ファイル: options.php プロジェクト: jimdough/Roadmaster
/**
 * Xin Options
 * 
 * @package	xincore
 * @since   1.0
 * @author  XinThemes
 * @license GPL v3 or later
 * @link    http://www.xinthemes.com/
 */
function xinwp_option_display($option_name)
{
    global $xinwp_theme_options, $xinwp_options, $xinwp_fonts;
    $theme_option = $xinwp_theme_options[$option_name];
    $options = $xinwp_options;
    $name = XINWP_ID . '_theme_options[' . $theme_option['name'] . ']';
    if ($theme_option['type'] != 'hidden' && empty($theme_option['fieldonly'])) {
        if (isset($theme_option['label'])) {
            echo '<div class="grid_3 alpha">';
            echo '<p><b>' . $theme_option['label'] . '</b></p></div>';
        }
        echo '<div class="grid_9"><p>';
    }
    switch ($theme_option['type']) {
        case 'radio':
            $values = $theme_option['values'];
            foreach ($values as $value) {
                printf('<input id="%1$s_%2$s" name="%1$s" type="radio" value="%2$s" %3$s />', $name, $value['key'], checked($value['key'], $options[$theme_option['name']], false));
                printf('<label class="description" for="%1$s_%2$s">%3$s</label>', $name, $value['key'], esc_attr($value['label']));
            }
            break;
        case 'checkbox':
            printf('<input id="%1$s" name="%1$s" type="checkbox" value="1" %2$s />', $name, checked('1', $options[$theme_option['name']], false));
            printf('<label class="description" for="%1$s">%2$s</label>', $name, esc_attr($theme_option['desc']));
            break;
        case 'url':
        case 'text':
            printf('<input id="%1$s" name="%1$s" type="text" value="%2$s" size="80" />', $name, esc_attr($options[$theme_option['name']]));
            break;
        case 'image':
            printf('<input id="%1$s" name="%1$s" type="text" value="%2$s" size="80" />', $name, esc_attr($options[$theme_option['name']]));
            break;
        case 'color':
            printf('<input name="%1$s" type="text" value="%2$s" class="xin-color-field" />', $name, esc_attr($options[$theme_option['name']]));
            break;
        case 'textarea':
            printf('<textarea name="%1$s" cols="120" rows="%2$s">%3$s</textarea>', $name, $theme_option['row'], esc_textarea($options[$theme_option['name']]));
            break;
        case 'number':
            if (!empty($theme_option['fieldonly']) && !empty($theme_option['label'])) {
                printf('<label class="description">%s</label>', esc_attr($theme_option['label']));
            }
            printf('<input name="%1$s" type="text" value="%2$s" size="4" />', $name, esc_attr($options[$theme_option['name']]));
            if (!empty($theme_option['desc'])) {
                printf('<label class="description">%s</label>', esc_attr($theme_option['desc']));
            }
            echo '&nbsp;&nbsp;&nbsp;&nbsp;';
            break;
        case 'select':
            printf('<select name="%1$s" >', $name);
            foreach ($theme_option['values'] as $value) {
                printf('<option value="%1$s" %2$s>%3$s</option>', $value['key'], selected($options[$theme_option['name']], $value['key'], false), $value['label']);
            }
            echo '</select>';
            break;
        case 'font':
            printf('<select style="font-family:%2$s;font-size:14px;" name="%1$s" >', $name, $xinwp_fonts[$options[$theme_option['name']]]['family']);
            $old_font_type = '';
            foreach ($theme_option['values'] as $value) {
                if ($value['type'] != $old_font_type) {
                    if ($old_font_type != '') {
                        echo '</optgroup>';
                    }
                    printf('<optgroup label="%1$s">', $value['type']);
                }
                printf('<option style="font-family: %4$s;%5$s" value="%1$s" %2$s>%3$s</option>', $value['key'], selected($options[$theme_option['name']], $value['key'], false), $value['label'], $value['family'], empty($value['url']) ? '' : 'color:blue;');
                $old_font_type = $value['type'];
            }
            echo '</optgroup>';
            echo '</select>';
            printf('&nbsp;&nbsp;<span style="font-family:%2$s;font-size:16px;%3$s">%1$s</span>', 'The quick brown fox jumps over the lazy dog.', $xinwp_fonts[$options[$theme_option['name']]]['family'], empty($xinwp_fonts[$options[$theme_option['name']]]['url']) ? '' : 'color:blue;');
            break;
        case 'category':
            printf('<select name="%1$s" >', $name);
            $selected_category = $options[$theme_option['name']];
            printf('<option value="0" %1$s>%2$s</option>', selected($options[$theme_option['name']], 0, false), __('All Categories', 'xinwp'));
            foreach (xinwp_categories() as $option) {
                printf('<option value="%1$s" %2$s>%3$s</option>', $option->term_id, selected($selected_category, $option->term_id, false), $option->name);
            }
            echo '</select>';
            break;
        case 'hidden':
            printf('<input id="%1$s" name="%2$s" type="hidden" value="%3$s" />', $theme_option['name'], $name, esc_attr($options[$theme_option['name']]));
            break;
        default:
            echo __('Not Availavle Yet', 'xinwp');
    }
    if ($theme_option['type'] != 'hidden' && empty($theme_option['fieldonly'])) {
        echo '</p>';
        if (!empty($theme_option['helptext'])) {
            printf('<p><label class="helptext">%s</label></p>', $theme_option['helptext']);
        }
        echo '</div><div class="clear"></div>';
    }
}
コード例 #2
0
ファイル: widgets.php プロジェクト: jimdough/Roadmaster
    function form($instance)
    {
        $instance = wp_parse_args($instance, $this->widget_defaults());
        xinwp_widget_field($this, array('field' => 'title', 'label' => __('Title:', 'xinwp')), $instance['title']);
        xinwp_widget_field($this, array('field' => 'posttype', 'type' => 'select', 'label' => __('Post Type:', 'xinwp'), 'options' => xinwp_post_types(), 'class' => ''), $instance['posttype']);
        xinwp_widget_field($this, array('field' => 'number', 'type' => 'number', 'label' => __('Number of posts to show:', 'xinwp'), 'class' => ''), $instance['number']);
        xinwp_widget_field($this, array('field' => 'random_post', 'type' => 'checkbox', 'desc' => __('Random Posts', 'xinwp'), 'class' => ''), $instance['random_post']);
        xinwp_widget_field($this, array('field' => 'column', 'type' => 'number', 'label' => __('No of Columns (1-4):', 'xinwp'), 'class' => ''), $instance['column']);
        xinwp_widget_field($this, array('field' => 'category', 'type' => 'category', 'label' => __('Category:', 'xinwp'), 'label_all' => __('All Categories', 'xinwp'), 'options' => xinwp_categories()), $instance['category']);
        xinwp_widget_field($this, array('field' => 'sticky_post', 'type' => 'checkbox', 'desc' => __('Include sticky posts in the category', 'xinwp'), 'class' => ''), $instance['sticky_post']);
        xinwp_widget_field($this, array('field' => 'thumbnail', 'type' => 'select', 'label' => __('Thumbnail:', 'xinwp'), 'options' => xinwp_thumbnail_array(), 'class' => ''), $instance['thumbnail']);
        ?>
		<p><?php 
        xinwp_widget_field($this, array('field' => 'thumbnail_x', 'type' => 'number', 'label' => __('Custom size: ', 'xinwp'), 'class' => '', 'ptag' => false), $instance['thumbnail_x']);
        xinwp_widget_field($this, array('field' => 'thumbnail_y', 'type' => 'number', 'label' => __(' x ', 'xinwp'), 'class' => '', 'ptag' => false), $instance['thumbnail_y']);
        ?>
</p>
<?php 
        xinwp_widget_field($this, array('field' => 'display_excerpt', 'type' => 'select', 'label' => __('Intro Text: ', 'xinwp'), 'options' => array(array('key' => '1', 'name' => __('Excerpt', 'xinwp')), array('key' => '2', 'name' => __('Content', 'xinwp')), array('key' => '3', 'name' => __('None', 'xinwp'))), 'class' => ''), $instance['display_excerpt']);
        xinwp_widget_field($this, array('field' => 'entry_meta', 'type' => 'checkbox', 'desc' => __('Display post meta', 'xinwp'), 'class' => ''), $instance['entry_meta']);
        xinwp_widget_field($this, array('field' => 'category_link', 'label' => __('Single category link : ', 'xinwp'), 'class' => ''), $instance['category_link']);
        xinwp_widget_field($this, array('field' => 'customquery', 'label' => __('Custom Query:', 'xinwp')), $instance['customquery']);
    }
コード例 #3
0
ファイル: core-admin.php プロジェクト: jimdough/Roadmaster
function xinwp_meta_display()
{
    global $xinwp_meta_box, $post;
    // Use nonce for verification
    echo '<input type="hidden" name="xinwp_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
    foreach ($xinwp_meta_box[$post->post_type]['fields'] as $field) {
        $meta = get_post_meta($post->ID, $field['id'], true);
        if ('hidden' != $field['type']) {
            $fldid = str_replace(XINWP_ID, "xinwp", $field['id']);
            echo '<p id="p' . $fldid . '"><strong>' . $field['name'] . ' </strong>';
        }
        switch ($field['type']) {
            case 'text':
                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . ($meta ? $meta : $field['default']) . '" size="30" />';
                break;
            case 'hidden':
                echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . ($meta ? $meta : $field['default']) . '" />';
                break;
            case 'textarea':
                echo '<textarea name="' . $field['id'] . '" id="' . $field['id'] . '" cols="60" rows="4" >' . ($meta ? $meta : $field['default']) . '</textarea>' . '<br />' . $field['desc'];
                break;
            case 'number':
                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . ($meta ? $meta : $field['default']) . '" size="4" />';
                break;
            case 'select':
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">';
                foreach ($field['options'] as $option) {
                    echo '<option value="' . $option['key'] . '" ' . ($meta == $option['key'] ? ' selected="selected"' : '') . '>' . $option['name'] . '</option>';
                }
                echo '</select> ' . $field['desc'];
                break;
            case 'category':
                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">';
                echo '<option value="" ' . ($meta ? '' : 'selected="selected"') . '>' . __('All Categories', 'xinwp') . '</option>';
                foreach (xinwp_categories() as $category) {
                    echo '<option value="' . $category->term_id . '" ' . ($meta == $category->term_id ? ' selected="selected"' : '') . '>' . $category->name . '</option>';
                }
                echo '</select>';
                break;
            case 'radio':
                foreach ($field['options'] as $option) {
                    echo '<label class="description"><input type="radio" name="' . $field['id'] . '" value="' . $option['key'] . '"' . ($meta == $option['key'] ? ' checked="checked"' : '') . ' /> ' . $option['name'] . '</label>';
                }
                break;
            case 'checkbox':
                echo '<label class="description"><input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '" value="1"' . ($meta ? ' checked="checked"' : '') . ' /> ' . $field['desc'] . '</label>';
                break;
        }
        echo '</p>';
    }
}