Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.44 KB | None | 0 0
  1. if($_REQUEST['popup']!=''){
  2. $postObj = get_post( $_REQUEST['pid'] );
  3. echo $postObj->post_content;
  4. exit;
  5. }
  6.  
  7. if($_REQUEST['popup']!=''){
  8.  
  9. $postObj = $_POST['pid'];
  10. $content_post = get_post($$postObj);
  11. $content = $content_post->post_content;
  12. $content = apply_filters('the_content', $content);
  13. $content = str_replace(']]>', ']]>', $content);
  14. echo $content;
  15. exit;
  16. }
  17.  
  18. $content = apply_filters('the_content', $content);
  19.  
  20. if($_REQUEST['popup']!=''){
  21.  
  22. $postObj = $_POST['pid'];
  23. $content_post = get_post($$postObj);
  24. $content = $content_post->post_content;
  25. $content = apply_filters('the_content', $content);
  26. $content = str_replace(']]>', ']]>', $content);
  27. echo $content;
  28. }
  29.  
  30. class spbc_showPostsWidget extends WP_Widget{
  31.  
  32. function spbc_showPostsWidget() {
  33. $options = array('description' => 'Show posts from selected categories.');
  34. parent::WP_Widget(false, $name = 'Show Posts By Category', $options);
  35. }
  36. /*-----------------------------------------------------------*/
  37. function widget($args, $instance) {
  38. extract($args, EXTR_SKIP);
  39.  
  40. $ost_title = empty($instance['ost_title']) ? ' ' : apply_filters('widget_title', $instance['ost_title']);
  41. $ost_limit = (is_numeric($instance['ost_limit'])) ? $instance['ost_limit'] : 5;
  42. $ost_orderby = ($instance['ost_orderby']) ? $instance['ost_orderby'] : 'date';
  43. $ost_order = ($instance['ost_order']) ? $instance['ost_order'] : 'desc';
  44. $ost_exclude = ($instance['ost_exclude'] != '') ? $instance['ost_exclude'] : 0;
  45. $ost_excludeposts = ($instance['ost_excludeposts'] != '') ? $instance['ost_excludeposts'] : 0;
  46. $ost_category_id = $instance['ost_categoryid'];
  47. $ost_showdate = ($instance['ost_show_date'] == 'on') ? 'yes' : 'no';
  48. $ost_thumbnail = ($instance['ost_thumbnail'] == 'on') ? 'yes' : 'no';
  49. $ost_thumbnail_size = ($instance['ost_thumbnail_size']) ? $instance['ost_thumbnail_size'] : 'thumbnail';
  50.  
  51. echo $before_widget;
  52.  
  53. $this->spbc_showWidget($instance);
  54. echo $after_widget;
  55. }
  56. /*-----------------------------------------------------------*/
  57. public static function get_UrlFromText($content,$url='Y'){
  58.  
  59. if($url=='Y'){
  60. $imgpattern = '/src=['"]?([^'" >]+)['" >]/';
  61. preg_match($imgpattern, $content, $article_image);
  62. }else{
  63. preg_match_all('/<img[^>]+>/i',$content, $article_image);
  64. }
  65. return $article_image;
  66. }
  67.  
  68. /*-----------------------------------------------------------*/
  69. function spbc_showWidget($instance){
  70. global $post;
  71. $query = array(
  72. 'posts_per_page' => $instance['ost_limit'],
  73. 'cat' => $instance['ost_categoryid'],
  74. 'orderby' => $instance['ost_orderby'],
  75. 'order' => $instance['ost_order'],
  76. 'category__not_in' => array($instance['ost_exclude']),
  77. 'post__not_in' => array($instance['ost_excludeposts'])
  78. );
  79.  
  80. $wp_query = new WP_Query($query);
  81.  
  82. if ($wp_query->have_posts()):
  83.  
  84. echo '
  85. <div class="list-posts-by-category">
  86. <ul>';
  87. while ($wp_query->have_posts()):
  88. $wp_query->the_post();
  89. $image_id = get_post_thumbnail_id();
  90.  
  91.  
  92. if(!empty($instance['ost_thumbnail'])){
  93. if ( in_array($instance['ost_thumbnail_size'],array('thumbnail', 'medium', 'large', 'full'))) {
  94. $ost_thumb_size = $instance['ost_thumbnail_size'];
  95. }elseif ($instance['ost_thumbnail_size']){
  96. $ost_thumb_size = array($instance['ost_thumbnail_size']);
  97. }else {
  98. $ost_thumb_size = 'thumbnail';
  99. }
  100. $ost_thumbnail = get_the_post_thumbnail($post->ID, $ost_thumb_size);
  101. }else{
  102. $ost_thumbnail = "";
  103. }
  104. ?>
  105.  
  106. <li>
  107. <a class="ostlightbox" href="<?php echo get_site_url().'/index.php?pid='.$post->ID.'&popup=Y'; ?>" title="<?php echo the_title_attribute(); ?>">
  108. <?php echo '<div class="ostoverlay"></div>'; ?>
  109. <?php echo '<div class="titleconthidden"><p class="osttitle">'.$post->post_title.'</p></div>'; ?>
  110. <?php echo '<div class="titlecont"></div>'; ?>
  111.  
  112.  
  113. <?php
  114.  
  115. echo $ost_thumbnail;
  116.  
  117. ?>
  118. </a>
  119. <?php if(!empty($instance['ost_show_date'])){ ?><span><?php echo get_the_time('F jS, Y'); ?></span><?php } ?>
  120. </li><?php
  121. endwhile;
  122. echo '
  123. </ul>
  124. </div>';
  125. endif;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement