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']); }
function xinwp_meta_box() { global $xinwp_meta_box; $prefix = '_' . XINWP_ID; //Prefix for theme $xinwp_meta_box['page'] = array('id' => 'xinwp-page-meta', 'title' => __('Template Options', 'xinwp'), 'context' => 'side', 'priority' => 'low', 'fields' => array(array('name' => __('Post Category :', 'xinwp'), 'desc' => '', 'id' => $prefix . '_category', 'type' => 'category', 'default' => ''), array('name' => __('Posts per page :', 'xinwp'), 'desc' => '', 'id' => $prefix . '_postperpage', 'type' => 'number', 'default' => ''), array('name' => __('Page Title :', 'xinwp'), 'desc' => __('check to hide page title', 'xinwp'), 'id' => $prefix . '_title', 'type' => 'checkbox', 'default' => ''), array('name' => __('Sidebar :', 'xinwp'), 'desc' => __('check to display sidebar', 'xinwp'), 'id' => $prefix . '_sidebar', 'type' => 'checkbox', 'default' => ''), array('name' => __('Layout :', 'xinwp'), 'desc' => __('Columns', 'xinwp'), 'id' => $prefix . '_column', 'type' => 'select', 'default' => '', 'options' => array(array('key' => '1', 'name' => '1'), array('key' => '2', 'name' => '2'), array('key' => '', 'name' => '3'), array('key' => '4', 'name' => '4'))), array('name' => __('Image Size : ', 'xinwp'), 'desc' => '', 'id' => $prefix . '_thumbnail', 'type' => 'select', 'default' => '', 'options' => xinwp_thumbnail_array()), array('name' => __('Custom Size (Width) :', 'xinwp'), 'desc' => '', 'id' => $prefix . '_size_x', 'type' => 'number', 'default' => ''), array('name' => __('Custom Size (Height) :', 'xinwp'), 'desc' => '', 'id' => $prefix . '_size_y', 'type' => 'number', 'default' => ''), array('name' => __('Intro Text : <br />', 'xinwp'), 'desc' => '', 'id' => $prefix . '_intro', 'type' => 'radio', 'default' => '', 'options' => array(array('key' => '', 'name' => __('Excerpt<br />', 'xinwp')), array('key' => '2', 'name' => __('Content<br />', 'xinwp')), array('key' => '3', 'name' => __('None<br />', 'xinwp')))), array('name' => __('Post Meta :', 'xinwp'), 'desc' => __('check to display post meta', 'xinwp'), 'id' => $prefix . '_disp_meta', 'type' => 'checkbox', 'default' => ''), array('name' => 'Data', 'desc' => 'Data', 'id' => $prefix . '_pt_data', 'type' => 'hidden', 'default' => ''))); $xinwp_meta_box['post'] = array('id' => 'xinwp-post-meta', 'title' => __('Post Options', 'xinwp'), 'context' => 'side', 'priority' => 'high', 'fields' => array(array('name' => __('Layout :', 'xinwp'), 'desc' => '', 'id' => $prefix . '_layout', 'type' => 'select', 'default' => '', 'options' => array(array('key' => '', 'name' => __('Default', 'xinwp')), array('key' => '1', 'name' => __('Fullwidth', 'xinwp')), array('key' => '2', 'name' => __('Fullscreen', 'xinwp')))), array('name' => '', 'desc' => __('Featured Post', 'xinwp'), 'id' => $prefix . '_featured', 'type' => 'checkbox', 'default' => ''), array('name' => __('Read More Label :', 'xinwp'), 'desc' => '', 'id' => $prefix . '_readmore', 'type' => 'text', 'default' => ''))); foreach ($xinwp_meta_box as $post_type => $value) { add_meta_box($value['id'], $value['title'], 'xinwp_meta_display', $post_type, $value['context'], $value['priority']); } }