Advertisement
emcniece

Latest Custom Post Type Updates - options.php

Jul 31st, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.05 KB | None | 0 0
  1. <?php
  2.  
  3. // set form variables
  4.  
  5. $instance = wp_parse_args(
  6.  
  7.     (array) $instance,
  8.  
  9.     array(
  10.  
  11.         'title' => 'Latest Updates',
  12.  
  13.         'numberposts' => 5,
  14.  
  15.         'post_type' => 'post',
  16.  
  17.         'show_advanced' => 'no',
  18.  
  19.         'taxonomies' => '--'
  20.  
  21.     )
  22.  
  23. );
  24.  
  25. $selected = 'selected="selected"';
  26.  
  27. $checked = 'checked="checked"';
  28.  
  29. ?>
  30.  
  31. <p> <!-- TITLE FOR WIDGET -->
  32.  
  33.     <label  for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label><br/>
  34.  
  35.     <input  id="<?php echo $this->get_field_id('title'); ?>"
  36.  
  37.             name="<?php echo $this->get_field_name('title'); ?>"
  38.  
  39.             type="text"
  40.  
  41.             value="<?php echo $instance['title']; ?>" />
  42.  
  43. </p>
  44.  
  45.  
  46.  
  47. <p> <!-- NUMBER POSTS FOR WIDGET -->
  48.  
  49.     <label  for="<?php echo $this->get_field_id('numberposts'); ?>"><?php _e('Number of posts to show:'); ?></label>
  50.  
  51.     <input  id="<?php echo $this->get_field_id('numberposts'); ?>"
  52.  
  53.             name="<?php echo $this->get_field_name('numberposts'); ?>"
  54.  
  55.             type="text"
  56.  
  57.             value="<?php echo $instance['numberposts']; ?>"
  58.  
  59.             size="3"
  60.  
  61.         />
  62.  
  63. </p>
  64.  
  65.  
  66.  
  67. <p> <!-- ORDER POSTS -->
  68.  
  69.         <label  for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e('Order Posts By:'); ?></label>
  70.    
  71.         <select
  72.  
  73.             name="<?php echo $this->get_field_name('orderby'); ?>"
  74.  
  75.             id="<?php echo $this->get_field_id('orderby'); ?>"
  76.  
  77.             class="<?php echo $this->get_field_id('orderby'); ?> tm_lcptu_orderby">
  78.  
  79.                 <option value="none" <?php if($instance['orderby'] == 'none') echo $selected; ?>>- None -</option>
  80.  
  81.                 <option value="ID" <?php if($instance['orderby'] == 'ID') echo $selected; ?>>ID</option>
  82.  
  83.                 <option value="author" <?php if($instance['orderby'] == 'author') echo $selected; ?>>Author</option>
  84.  
  85.                 <option value="title" <?php if($instance['orderby'] == 'title') echo $selected; ?>>Title</option>
  86.  
  87.                 <option value="date" <?php if($instance['orderby'] == 'date') echo $selected; ?>>Post Date</option>
  88.  
  89.                 <option value="modified" <?php if($instance['orderby'] == 'modified') echo $selected; ?>>Last Modified</option>
  90.  
  91.                 <option value="parent" <?php if($instance['orderby'] == 'parent') echo $selected; ?>>Parent</option>
  92.  
  93.                 <option value="rand" <?php if($instance['orderby'] == 'rand') echo $selected; ?>>Random</option>
  94.  
  95.                 <option value="comment_count" <?php if($instance['orderby'] == 'comment_count') echo $selected; ?>># Of Comments</option>
  96.  
  97.                 <option value="menu_order" <?php if($instance['orderby'] == 'menu_order') echo $selected; ?>>Menu Order</option>
  98.  
  99.         </select>
  100.  
  101. </p>
  102.  
  103.  
  104.  
  105. <p> <!-- ORDER DIRECTION -->
  106.  
  107.         <label  for="<?php echo $this->get_field_id('order'); ?>"><?php _e('Order Direction:'); ?></label>
  108.    
  109.         <select
  110.  
  111.             name="<?php echo $this->get_field_name('order'); ?>"
  112.  
  113.             id="<?php echo $this->get_field_id('order'); ?>"
  114.  
  115.             class="<?php echo $this->get_field_id('order'); ?> tm_lcptu_order">
  116.  
  117.                 <option value="ASC" <?php if($instance['order'] == 'ASC') echo $selected; ?>>Ascending</option>
  118.  
  119.                 <option value="DESC" <?php if($instance['order'] == 'DESC') echo $selected; ?>>Descending</option>
  120.  
  121.         </select>
  122.  
  123. </p>
  124.  
  125.  
  126.  
  127. <p> <!-- TEXT WHEN NO POSTS -->
  128.  
  129.     <label  for="<?php echo $this->get_field_id('empty_display'); ?>"><?php _e('Text to display when there are no posts (defaults to empty):'); ?></label>
  130.  
  131.     <input  id="<?php echo $this->get_field_id('empty_display'); ?>"
  132.  
  133.             name="<?php echo $this->get_field_name('empty_display'); ?>"
  134.  
  135.             type="text"
  136.  
  137.             value="<?php echo $instance['empty_display']; ?>"
  138.  
  139.         />
  140.  
  141. </p>
  142.  
  143.  
  144.  
  145. <p> <!-- CUSTOM CSS CLASS -->
  146.  
  147.     <label  for="<?php echo $this->get_field_id('css_class'); ?>"><?php _e('Custom CSS Class:'); ?></label>
  148.  
  149.     <input  id="<?php echo $this->get_field_id('css_class'); ?>"
  150.  
  151.             name="<?php echo $this->get_field_name('css_class'); ?>"
  152.  
  153.             type="text"
  154.  
  155.             value="<?php echo $instance['css_class']; ?>"
  156.            
  157.             size="20"
  158.  
  159.         />
  160.  
  161. </p>
  162.  
  163.  
  164.    
  165.  
  166. <p> <!-- POST TYPE FOR WIDGET -->
  167.  
  168.     <label  for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Types:'); ?></label>
  169.  
  170.         <?php
  171.  
  172.         // Filter out post types that are internal such as attachments or internal theme post types used for options.
  173.  
  174.         $args = array(
  175.  
  176.             'show_ui' => true,
  177.  
  178.         );
  179.  
  180.         $post_types = get_post_types($args, 'objects');
  181.  
  182.         foreach($post_types as $post_type=>$vars) {
  183.            
  184.             echo '<br /><input type="checkbox"
  185.            
  186.                 name="'.$this->get_field_name('post_type').'[]"
  187.                
  188.                 value="'.$post_type.'"';
  189.  
  190.                 if( in_array($post_type, $instance['post_type'] ) ) echo 'checked="checked"';
  191.  
  192.             echo ' /> '.$vars->labels->name.'';
  193.  
  194.         }
  195.  
  196.         ?>
  197.  
  198.     </select>
  199.  
  200. </p>
  201.  
  202.  
  203.  
  204. <p> <!-- RANDOMIZE POSTS? -->
  205.  
  206.     <label  for="<?php echo $this->get_field_id('randomize'); ?>"><?php _e('Randomize Output:'); ?></label>
  207.  
  208.     <input  id="<?php echo $this->get_field_id('randomize'); ?>"
  209.  
  210.             name="<?php echo $this->get_field_name('randomize'); ?>"
  211.  
  212.             class="tm_lcptu_randomize"
  213.  
  214.             type="checkbox"
  215.  
  216.             value="yes"
  217.  
  218.             <?php if($instance['randomize'] == 'yes') echo $checked; ?>
  219.  
  220.         />
  221.  
  222. </p>
  223.  
  224.  
  225.  
  226. <p> <!-- SHOW THUMBNAILS? -->
  227.  
  228.     <label  for="<?php echo $this->get_field_id('show_thumbnails'); ?>"><?php _e('Show Post Thumbnails:'); ?></label>
  229.  
  230.     <input  id="<?php echo $this->get_field_id('show_thumbnails'); ?>"
  231.  
  232.             name="<?php echo $this->get_field_name('show_thumbnails'); ?>"
  233.  
  234.             class="tm_lcptu_show-thumbnails"
  235.  
  236.             type="checkbox"
  237.  
  238.             value="yes"
  239.  
  240.             size="3"
  241.  
  242.             <?php if($instance['show_thumbnails'] == 'yes') echo $checked; ?>
  243.  
  244.         />
  245.  
  246. </p>
  247.  
  248.  
  249. <div class="<?php echo $this->get_field_id('show_thumbnails'); ?>" style="display: <?php echo ($instance['show_thumbnails'] == 'yes')? 'block' : 'none'; ?>;">
  250.  
  251.     <p> <!-- THUMBNAIL IMAGE FORMAT -->
  252.  
  253.         <label  for="<?php echo $this->get_field_id('thumbnail_format'); ?>"><?php _e('Thumbnail Format:'); ?></label>
  254.    
  255.         <select
  256.  
  257.             name="<?php echo $this->get_field_name('thumbnail_format'); ?>"
  258.  
  259.             id="<?php echo $this->get_field_id('thumbnail_format'); ?>"
  260.  
  261.             class="<?php echo $this->get_field_id('thumbnail_format'); ?> tm_lcptu_thformat">
  262.  
  263.             <option value="0" <?php if($instance['thumbnail_format'] == $size) echo $selected; ?>>- None -</option>
  264.  
  265.             <?php
  266.  
  267.             foreach( get_intermediate_image_sizes() as $size): ?>
  268.  
  269.                 <option value="<?php echo $size; ?>" <?php if($instance['thumbnail_format'] == $size) echo $selected; ?>><?php echo $size; ?></option>
  270.  
  271.             <?php endforeach; ?>
  272.  
  273.         </select>
  274.  
  275.     </p>
  276.  
  277.  
  278.     <p> <!-- THUMBNAIL WIDTH -->
  279.  
  280.         <label  for="<?php echo $this->get_field_id('thumbnail_width'); ?>"><?php _e('Width:'); ?></label>
  281.    
  282.         <input  id="<?php echo $this->get_field_id('thumbnail_width'); ?>"
  283.    
  284.                 name="<?php echo $this->get_field_name('thumbnail_width'); ?>"
  285.    
  286.                 type="text"
  287.    
  288.                 value="<?php echo $instance['thumbnail_width'] ? $instance['thumbnail_width'] : 0; ?>"
  289.    
  290.                 size="3"
  291.    
  292.             />
  293.  
  294.     </p>
  295.    
  296.    
  297.     <p> <!-- THUMBNAIL HEIGHT -->
  298.         <label  for="<?php echo $this->get_field_id('thumbnail_height'); ?>"><?php _e('Height:'); ?></label>
  299.    
  300.         <input  id="<?php echo $this->get_field_id('thumbnail_height'); ?>"
  301.    
  302.                 name="<?php echo $this->get_field_name('thumbnail_height'); ?>"
  303.    
  304.                 type="text"
  305.    
  306.                 value="<?php echo $instance['thumbnail_height'] ? $instance['thumbnail_height'] : 0; ?>"
  307.    
  308.                 size="3"
  309.    
  310.             />
  311.  
  312.     </p>
  313.  
  314.     <p> <!-- DEFAULT IMAGE -->
  315.         <label  for="<?php echo $this->get_field_id('default_image'); ?>"><?php _e('Default Image (URL):'); ?></label>
  316.    
  317.         <input  id="<?php echo $this->get_field_id('default_image'); ?>"
  318.    
  319.                 name="<?php echo $this->get_field_name('default_image'); ?>"
  320.    
  321.                 type="text"
  322.    
  323.                 value="<?php echo $instance['default_image'] ?>"
  324.    
  325.                 size="35"
  326.    
  327.             />
  328.  
  329.     </p>
  330.  
  331. </div>
  332.  
  333.  
  334. <p> <!-- SHOW ADVANCED FILTERING OPTIONS? -->
  335.  
  336.     <label  for="<?php echo $this->get_field_id('show_advanced'); ?>"><?php _e('Show advanced options:'); ?></label>
  337.  
  338.     <input  id="<?php echo $this->get_field_id('show_advanced'); ?>"
  339.  
  340.             name="<?php echo $this->get_field_name('show_advanced'); ?>"
  341.  
  342.             class="tm_lcptu_show-advanced"
  343.  
  344.             type="checkbox"
  345.  
  346.             value="yes"
  347.  
  348.             size="3"
  349.  
  350.             <?php if($instance['show_advanced'] == 'yes') echo $checked; ?>
  351.  
  352.         />
  353.  
  354. </p>
  355.  
  356.  
  357.  
  358. <div class="<?php echo $this->get_field_id('show_advanced'); ?>" style="display: <?php echo ($instance['show_advanced'] == 'yes')? 'block' : 'none'; ?>;">
  359.  
  360.     <p> <!-- TAXONOMIES FOR POST TYPE -->
  361.  
  362.         <label for="<?php echo $this->get_field_id('taxonomies'); ?>"><?php _e('Taxonomy to filter by:'); ?></label>
  363.  
  364.         <select
  365.  
  366.             name="<?php echo $this->get_field_name('taxonomies'); ?>"
  367.  
  368.             id="<?php echo $this->get_field_id('taxonomies'); ?>"
  369.  
  370.             class="<?php echo $this->get_field_id('post_type'); ?> tm_lcptu_tax">
  371.  
  372.             <?php
  373.  
  374.             echo tm_latest_cp_widget::get_post_taxonomies($instance['post_type'], $instance['taxonomies']);
  375.  
  376.             ?>
  377.  
  378.         </select>
  379.  
  380.     </p>
  381.  
  382.     <div class="<?php echo $this->get_field_id('taxonomies'); ?>-container" style="display: <?php echo ($instance['taxonomies'] != '--')? 'block' : 'none'; ?>;">
  383.  
  384.         <p>
  385.  
  386.             <label  for="<?php echo $this->get_field_id('tax_in'); ?>"><?php _e('Only show posts that are '); ?></label><select
  387.  
  388.             name="<?php echo $this->get_field_name('tax_in'); ?>" id="<?php echo $this->get_field_id('tax_in'); ?>">
  389.  
  390.             <option value="in"<?php if($instance['tax_in'] == 'in') echo $selected; ?>>in</option>
  391.  
  392.             <option value="not_in"<?php if($instance['tax_in'] == 'not_in') echo $selected; ?>>not in</option>
  393.  
  394.             <option value="and"<?php if($instance['tax_in'] == 'and') echo $selected; ?>>in all</option>
  395.  
  396.             </select><label for="<?php echo $this->get_field_id('tag_list'); ?>"><?php _e(' the following tags/categories:'); ?></label>
  397.  
  398.         </p>
  399.  
  400.         <div class="<?php echo $this->get_field_id('taxonomies'); ?>" id="<?php echo $this->get_field_name('tag_list'); ?>">
  401.  
  402.             <?php if($instance['taxonomies'] != '--') echo tm_latest_cp_widget::get_taxonomy_list($instance['taxonomies'], $this->get_field_name('tag_list'), $instance['tag_list']); ?>
  403.  
  404.         </div>
  405.  
  406.     </div>
  407.  
  408. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement