예제 #1
0
파일: admin.php 프로젝트: alphadc/xiuxing
/**
 * Single section settings
 */
function dp_home_section_item($number = null, $item = array())
{
    $default_item = array('post_type' => 'post', 'cat' => '', 'view' => '', 'orderby' => '', 'order' => '', 'taxonomies' => '', 'tax_query' => array(), 'post__in' => '', 'posts_per_page' => '', 'title' => '', 'link' => '', 'before' => '', 'after' => '');
    $item = wp_parse_args($item, $default_item);
    if ($number === null) {
        $number = '##';
    }
    $dropdown_view_types = dp_dropdown_view_types(array('echo' => 0, 'name' => 'dp_home_sections[' . $number . '][view]', 'selected' => !empty($item['view']) ? $item['view'] : 'grid-small'));
    $dropdown_sort_types = dp_dropdown_sort_types(array('echo' => 0, 'name' => 'dp_home_sections[' . $number . '][orderby]', 'selected' => $item['orderby']));
    $dropdown_order_types = dp_dropdown_order_types(array('echo' => 0, 'name' => 'dp_home_sections[' . $number . '][order]', 'selected' => $item['order']));
    $dropdown_views_timing = dp_dropdown_views_timing(array('echo' => 0, 'name' => 'dp_home_sections[' . $number . '][views_timing]', 'selected' => $item['views_timing']));
    $dropdown_post_types = dp_dropdown_post_types(array('echo' => 0, 'name' => 'dp_home_sections[' . $number . '][post_type]', 'selected' => $item['post_type']));
    $taxonomies = get_taxonomies(array('public' => true), 'objects');
    $multi_dropdown_terms = dp_multi_dropdown_terms(array('echo' => 0, 'name' => 'dp_home_sections[' . $number . '][taxonomies]', 'selected' => $item['taxonomies']));
    $section_title = __('Section Box', 'dp');
    $section_title .= !empty($item['title']) ? ': <spanc class="in-widget-title">' . $item['title'] . '</span>' : '';
    $html = '
	<li rel="' . $number . '">
		<div class="section-box closed">
		<div class="section-handlediv" title="Click to toggle"><br></div><h3 class="section-hndle"><span>' . $section_title . '</span></h3>
		
		<div class="section-inside">
		
		<table class="item-table">
			<tr>

				<td>
					<table class="item-table">';
    if ($dropdown_post_types) {
        $html .= '<tr>
				<th><label>' . __('Post Type', 'dp') . '</label></th>
					<td>
						' . $dropdown_post_types . '
					</td>
				</tr>';
    }
    $html .= '
						<tr>
							<th>' . __('Taxomoy Query', 'dp') . '</th>
							<td>
								' . $multi_dropdown_terms . '
							</td>
						</tr>
						<tr>
							<th>' . __('Sort', 'dp') . '</th>
							<td>
								<label>' . __('Order by:', 'dp') . '</label> ' . $dropdown_sort_types . '&nbsp;&nbsp;
								<label>' . __('Order:', 'dp') . '</label> ' . $dropdown_order_types . '&nbsp;&nbsp;
								<label>' . __('Views Timing:', 'dp') . '</label> ' . $dropdown_views_timing . '
							</td>
						</tr>
						<tr>
							<th><label>' . __('Number of Posts:', 'dp') . ' </label></th>
							<td>
								<input class="small-text" type="text" value="' . $item['posts_per_page'] . '" name="dp_home_sections[' . $number . '][posts_per_page]" />&nbsp;&nbsp;
							</td>
						</tr>
						<tr>
							<th><label>' . __('Includes', 'dp') . '</label></th> 
							<td>
								<input class="widefat" type="text" value="' . $item['post__in'] . '" name="dp_home_sections[' . $number . '][post__in]" />
								<p class="description">' . __('If you want to display specific posts, enter post ids to here, separate ids with commas, (e.g. 1,2,3,4). <br />if this field is not empty, category will be ignored. <br/>If you want to display posts sort by the order of your enter IDs, set "Sort" field as <strong>Includes</strong>.', 'dp') . '</p>
							</td>
						</tr>
						<tr>
							<th><label>' . __('View', 'dp') . '</label></th> 
							<td>' . $dropdown_view_types . '</td>
						</tr>
						<tr>
							<th><label>' . __('Title', 'dp') . '</label></th> 
							<td>
								<input class="widefat" type="text" value="' . $item['title'] . '" name="dp_home_sections[' . $number . '][title]" />
								<p class="description">' . __('If you specify a category, the default title is the category name, and you can still fill in this field to override it.', 'dp') . '</p>
							</td>
						</tr>
						<tr>
							<th><label>' . __('Link', 'dp') . '</label></th> 
							<td>
								<input class="widefat" type="text" value="' . $item['link'] . '" name="dp_home_sections[' . $number . '][link]" />
								<p class="description">' . __('If you specified a category, the default link is the category link, and you can still fill in this field to override it.', 'dp') . '</p>
							</td>
						</tr>
						<tr>
							<th><label>' . __('Before', 'dp') . '</label></th> 
							<td>
								<textarea rows="5" class="widefat" name="dp_home_sections[' . $number . '][before]">' . $item['before'] . '</textarea>
								<p class="description">' . __('Maybe you want to insert something before this section, such as your ad code. (support html and shortcode).', 'dp') . '</p>
							</td>
						</tr>
						<tr>
							<th><label>' . __('After', 'dp') . '</label></th> 
							<td>
								<textarea rows="5" class="widefat" name="dp_home_sections[' . $number . '][after]">' . $item['after'] . '</textarea>
								<p class="description">' . __('Maybe you want to insert something after this section, such as your ad code. (support html and shortcode).', 'dp') . '</p>
							</td>
						</tr>
					</table>
				</td>
				
				<td style="width:50px;">
					<a href="#" class="button delete-item">' . __('Delete', 'dp') . '</a>
				</td>
			</tr>
		</table>
		</div>
		</div>
	</li>
	';
    return $html;
}
예제 #2
0
    function form($instance)
    {
        $defaults = array('title' => __('Related Posts', 'dp'), 'posts_per_page' => 6, 'orderby' => 'date', 'order' => 'desc', 'style' => 'list', 'cat' => '', 'current_cat' => true, 'current_author' => true, 'post__in' => '', 'style' => 'list');
        $instance = wp_parse_args((array) $instance, $defaults);
        // Styles
        $styles = array('list' => __('List with Thumbnail', 'dp'), 'list-full' => __('List with Full Width Thumbnail', 'dp'), 'grid-2' => __('2 Columns Grid', 'dp'), 'grid-3' => __('3 Columns Grid', 'dp'));
        $dropdown_categories = wp_dropdown_categories(array('echo' => 0, 'name' => $this->get_field_name('cat'), 'selected' => $instance['cat'], 'show_option_all' => __('All', 'dp'), 'class' => 'widefat'));
        $dropdown_sort_types = dp_dropdown_sort_types(array('echo' => 0, 'name' => $this->get_field_name('orderby'), 'selected' => $instance['orderby'], 'class' => 'widefat'));
        $dropdown_order_types = dp_dropdown_order_types(array('echo' => 0, 'name' => $this->get_field_name('order'), 'selected' => $instance['order'], 'class' => 'widefat'));
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'dp');
        ?>
</label>
			<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo $instance['title'];
        ?>
" />
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('posts_per_page');
        ?>
"><?php 
        _e('Number:', 'dp');
        ?>
</label>
			<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('posts_per_page');
        ?>
" name="<?php 
        echo $this->get_field_name('posts_per_page');
        ?>
" value="<?php 
        echo $instance['posts_per_page'];
        ?>
" />
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('style');
        ?>
"><?php 
        _e('Style:', 'dp');
        ?>
</label> 
			<select class="widefat" id="<?php 
        echo $this->get_field_id('style');
        ?>
" name="<?php 
        echo $this->get_field_name('style');
        ?>
">
				<?php 
        foreach ($styles as $option_value => $option_label) {
            ?>
					<option value="<?php 
            echo $option_value;
            ?>
" <?php 
            selected($instance['style'], $option_value);
            ?>
><?php 
            echo $option_label;
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>
		
	<?php 
    }
예제 #3
0
    function form($instance)
    {
        $defaults = array('title' => __('Recent Posts', 'dp'), 'posts_per_page' => 6, 'orderby' => 'date', 'order' => 'desc', 'style' => 'list', 'cat' => '', 'current_cat' => true, 'current_author' => true, 'post__in' => '', 'views_timing' => '', 'style' => 'list');
        $instance = wp_parse_args((array) $instance, $defaults);
        // Styles
        $styles = array('list' => __('List with Thumbnail', 'dp'), 'list-full' => __('List with Full Width Thumbnail', 'dp'), 'grid-2' => __('2 Columns Grid', 'dp'), 'grid-3' => __('3 Columns Grid', 'dp'));
        $views_timings = dp_views_timings();
        $dropdown_categories = wp_dropdown_categories(array('echo' => 0, 'name' => $this->get_field_name('cat'), 'selected' => $instance['cat'], 'show_option_all' => __('All', 'dp'), 'class' => 'widefat'));
        $dropdown_sort_types = dp_dropdown_sort_types(array('echo' => 0, 'name' => $this->get_field_name('orderby'), 'selected' => $instance['orderby'], 'class' => 'widefat'));
        $dropdown_order_types = dp_dropdown_order_types(array('echo' => 0, 'name' => $this->get_field_name('order'), 'selected' => $instance['order'], 'class' => 'widefat'));
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'dp');
        ?>
</label>
			<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo $instance['title'];
        ?>
" />
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('posts_per_page');
        ?>
"><?php 
        _e('Number:', 'dp');
        ?>
</label>
			<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('posts_per_page');
        ?>
" name="<?php 
        echo $this->get_field_name('posts_per_page');
        ?>
" value="<?php 
        echo $instance['posts_per_page'];
        ?>
" />
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('orderby');
        ?>
"><?php 
        _e('Orderby:', 'dp');
        ?>
</label> 
			<?php 
        echo $dropdown_sort_types;
        ?>
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('order');
        ?>
"><?php 
        _e('Order:', 'dp');
        ?>
</label> 
				<?php 
        echo $dropdown_order_types;
        ?>
		</p>
		
		<?php 
        if (function_exists('baw_pvc_main')) {
            ?>
		<p>
		<label for="<?php 
            echo $this->get_field_id('views_timing');
            ?>
"><?php 
            _e('Views Timing:', 'dp');
            ?>
</label>
			<select class="widefat" id="<?php 
            echo $this->get_field_id('views_timing');
            ?>
" name="<?php 
            echo $this->get_field_name('views_timing');
            ?>
">
				<?php 
            foreach ($views_timings as $option_value => $option_label) {
                ?>
					<option value="<?php 
                echo $option_value;
                ?>
" <?php 
                selected($instance['views_timing'], $option_value);
                ?>
><?php 
                echo $option_label;
                ?>
</option>
				<?php 
            }
            ?>
			</select>
		</p>
		<?php 
        }
        ?>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('cat');
        ?>
"><?php 
        _e('Category:', 'dp');
        ?>
</label> 
			<?php 
        echo $dropdown_categories;
        ?>
		</p>
		<p><input id="<?php 
        echo $this->get_field_id('current_cat');
        ?>
" name="<?php 
        echo $this->get_field_name('current_cat');
        ?>
" type="checkbox" <?php 
        checked(!empty($instance['current_cat']) ? $instance['current_cat'] : 0);
        ?>
 />&nbsp;<label for="<?php 
        echo $this->get_field_id('current_cat');
        ?>
"><?php 
        _e('Limit posts by current category on category archive pages?', 'dp');
        ?>
</label></p>
		
		<p><input id="<?php 
        echo $this->get_field_id('current_author');
        ?>
" name="<?php 
        echo $this->get_field_name('current_author');
        ?>
" type="checkbox" <?php 
        checked(!empty($instance['current_author']) ? $instance['current_author'] : 0);
        ?>
 />&nbsp;<label for="<?php 
        echo $this->get_field_id('current_author');
        ?>
"><?php 
        _e('Limit posts by current author on author archive pages?', 'dp');
        ?>
</label></p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('post__in');
        ?>
"><?php 
        _e('Includes:', 'dp');
        ?>
</label>
			<input type="text" class="widefat" id="<?php 
        echo $this->get_field_id('post__in');
        ?>
" name="<?php 
        echo $this->get_field_name('post__in');
        ?>
" value="<?php 
        echo $instance['post__in'];
        ?>
" />
		</p>
		<p class="description">
			<?php 
        _e('If you want to display specific posts, enter post ids to here, separate ids with commas, (e.g. 1,2,3,4). <br />if this field is not empty, category will be ignored. <br/>If you want to display posts sort by the order of your enter IDs, set "Sort" field as <strong>None</strong>.', 'dp');
        ?>
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('style');
        ?>
"><?php 
        _e('Style:', 'dp');
        ?>
</label> 
			<select class="widefat" id="<?php 
        echo $this->get_field_id('style');
        ?>
" name="<?php 
        echo $this->get_field_name('style');
        ?>
">
				<?php 
        foreach ($styles as $option_value => $option_label) {
            ?>
					<option value="<?php 
            echo $option_value;
            ?>
" <?php 
            selected($instance['style'], $option_value);
            ?>
><?php 
            echo $option_label;
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>
		
	<?php 
    }