web_buis_categ

The Business Responsive web buis categ class.

Defined (1)

The class is defined in the following location(s).

/admin/widgets/widget-category.php  
  1. class web_buis_categ extends WP_Widget 
  2. function web_buis_categ() { 
  3. $widget_ops = array('description' => 'Displays Categories Posts'); 
  4. $control_ops = array('width' => '', 'height' => ''); 
  5. parent::WP_Widget(false, $name='Categories Posts', $widget_ops, $control_ops); 
  6.  
  7. /** Displays the Widget in the front-end */ 
  8. function widget($args, $instance) { 
  9. extract($args); 
  10. $title = esc_html( $instance['title']); 
  11. $categ_id = empty( $instance['categ_id'] ) ? '' : $instance['categ_id']; 
  12. $post_count = empty( $instance['post_count'] ) ? '' : $instance['post_count']; 
  13.  
  14. echo $before_widget; 
  15.  
  16. if ( $title ) 
  17. echo $before_title . $title . $after_title; ?> 
  18.  
  19. <style> 
  20. .cat_widg img { 
  21. float:left; 
  22. margin: 0 10px 10px 0; 
  23. }  
  24. .cat_widg { 
  25. padding-bottom: 10px; 
  26. border-bottom: 1px dotted #C5C9D8; 
  27. float: left; 
  28. }  
  29. .cat_widg img { 
  30. margin-top: 0; 
  31. }  
  32. .widget_web_buis_categ div:last-child div{ 
  33. border-bottom:none !important; 
  34. }  
  35. .cat_widg_cont {  
  36. float: left; 
  37. width: 100%; 
  38. .cat_widg_cont h3{ 
  39. margin-top: 0; 
  40. line-height: 15px; 
  41. margin-bottom: 15px; 
  42. .cat_widg_cont h3 a{ 
  43. font-size:20px !important; 
  44. .widget-title{ 
  45. margin-bottom: 0; 
  46. </style>  
  47. <?php  
  48.  
  49. $wp_query= null; 
  50. $wp_query = new WP_Query(); 
  51. if(!isset($post_count)) 
  52. $post_count =0; 
  53. $wp_query->query('showposts='.$post_count.'&cat='.$categ_id); 
  54.  
  55. while ($wp_query->have_posts()) : $wp_query->the_post(); 
  56.  
  57. ?> 
  58.  
  59. <div class="cat_widg_cont"> 
  60. <h3> 
  61. <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
  62. </h3> 
  63. <div style="clear:both;"></div> 
  64. <div class="cat_widg">  
  65. <?php 
  66. echo web_dor_display_thumbnail(110, 110);  
  67. echo web_dor_the_excerpt_max_charlength(100);  
  68. ?> 
  69. <a href="<?php the_permalink(); ?>" style="text-decoration: underline;"><span><?php echo __('More', 'sp_webBusiness'); ?></span></a> 
  70. </div>  
  71. </div> 
  72.  
  73. <?php endwhile;  
  74.  
  75.  
  76.  
  77.  
  78. echo $after_widget; 
  79.  
  80.  
  81. /**Saves the settings. */ 
  82. function update($new_instance, $old_instance) { 
  83.  
  84. $instance = $old_instance; 
  85. $instance['title'] = sanitize_text_field( $new_instance['title'] ); 
  86. $instance['categ_id'] = wp_filter_post_kses( addslashes($new_instance['categ_id'])); 
  87. $instance['post_count'] = wp_filter_post_kses( addslashes($new_instance['post_count'])); 
  88.  
  89. return $instance; 
  90.  
  91.  
  92. /**Creates the form for the widget in the back-end. */ 
  93. function form($instance) { 
  94. //Defaults 
  95. $instance = wp_parse_args( (array) $instance, array( 'title'=>'Categories Posts', 'categ_id'=>'0', 'post_count'=>'3' ) ); 
  96.  
  97. $title = esc_attr( $instance['title'] ); 
  98. $categ_id = esc_attr( $instance['categ_id'] );  
  99. $post_count = esc_attr( $instance['post_count'] )?> 
  100.  
  101. <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p> 
  102.  
  103.  
  104. <p><label for="<?php echo $this->get_field_id('categ_id'); ?>">Select Category:</label> 
  105. <select name="<?php echo $this->get_field_name('categ_id'); ?>" id="<?php echo $this->get_field_id('categ_id') ?>" style="font-size:12px" class="inputbox"> 
  106. <option value="0">Select Category</option> 
  107. <?php $categories=get_categories(); 
  108. $category_count=count($categories); 
  109. for($i=0;$i<$category_count;$i++) { 
  110. ?> 
  111. <option value="<?php echo $categories[$i]->term_id?>" <?php if($instance['categ_id']==$categories[$i]->term_id) echo 'selected="selected"'; ?>><?php echo $categories[$i]->name ?></option> 
  112. <?php 
  113. ?> 
  114. </select></p> 
  115. <p><label for="<?php echo $this->get_field_id('post_count'); ?>">Number of Posts:</label><input id="<?php echo $this->get_field_id('post_count'); ?>" name="<?php echo $this->get_field_name('post_count'); ?>" type="text" value="<?php echo $post_count; ?>" size="6"/></p> 
  116. <?php  
  117.  
  118. }// end web_buis_categ class