whyisjake

Jake Spurlock

Mar 11th, 2010
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.32 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Recent Posts
  4. Plugin URI:
  5. Description:
  6. Author: Andrew Billits (Incsub)
  7. Version: 1.0.1
  8. Author URI:
  9. */
  10.  
  11. /*
  12. Copyright 2007-2009 Incsub (http://incsub.com)
  13.  
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
  16. the Free Software Foundation.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  26. */
  27.  
  28. /*
  29. Usage:
  30. display_recent_posts(NUMBER,TITLE_CHARACTERS,CONTENT_CHARACTERS,TITLE_CONTENT_DIVIDER,TITLE_BEFORE,TITLE_AFTER,GLOBAL_BEFORE,GLOBAL_AFTER,BEFORE,AFTER,TITLE_LINK,SHOW_AVATARS,AVATAR_SIZE);
  31.  
  32. Ex:
  33. display_recent_posts(10,40,150,'<br />','<strong>','</strong>','<ul>','</ul>','<li>','</li>','yes','yes',16);
  34. */
  35. //------------------------------------------------------------------------//
  36. //---Config---------------------------------------------------------------//
  37. //------------------------------------------------------------------------//
  38.  
  39. //------------------------------------------------------------------------//
  40. //---Hook-----------------------------------------------------------------//
  41. //------------------------------------------------------------------------//
  42.  
  43. //------------------------------------------------------------------------//
  44. //---Functions------------------------------------------------------------//
  45. //------------------------------------------------------------------------//
  46.  
  47. //------------------------------------------------------------------------//
  48. //---Output Functions-----------------------------------------------------//
  49. //------------------------------------------------------------------------//
  50.  
  51. function display_recent_posts($tmp_number,$tmp_title_characters = 0,$tmp_content_characters = 0,$tmp_title_content_divider = '<br />',$tmp_title_before,$tmp_title_after,$tmp_global_before,$tmp_global_after,$tmp_before,$tmp_after,$tmp_title_link = 'no',$tmp_show_avatars = 'yes', $tmp_avatar_size = 90){
  52.     global $wpdb;
  53.     $query = "SELECT * FROM " . $wpdb->base_prefix . "site_posts WHERE blog_public = '1' AND blog_id!=1 ORDER BY post_published_stamp DESC LIMIT " . $tmp_number;
  54.     $tmp_posts = $wpdb->get_results( $query, ARRAY_A );
  55.    
  56.     if (count($tmp_posts) > 0){
  57.         echo $tmp_global_before;
  58.         $default_avatar = get_option('default_avatar');
  59.         foreach ($tmp_posts as $tmp_post){
  60.             echo $tmp_before;
  61.             if ( $tmp_title_characters > 0 ) {
  62.                
  63.                 if ( $tmp_show_avatars == 'yes' ) {
  64.                    
  65.                         echo get_avatar( $tmp_post['post_author'], $tmp_avatar_size, $default_avatar);
  66.                
  67.                 }
  68.                 echo $tmp_title_before;
  69.                     if ( $tmp_title_link == 'no' ) {
  70.                         echo '<h3>'.substr($tmp_post['post_title'],0,$tmp_title_characters).'</h3>';               
  71.                     } else {
  72.                         echo '<h3><a href="' . $tmp_post['post_permalink'] . '" style="text-decoration:none;color: rgb(242, 123, 33);font-family: Georgia, serif;font-weight: 400;">' . substr($tmp_post['post_title'],0,$tmp_title_characters) . '</a></h3>';
  73.                         echo '<div class="small"><p>By ' . $author_name = get_userdata($tmp_post['post_author'])->display_name . '</p></div>';
  74.                     }
  75.                
  76.                 echo $tmp_title_after;
  77.             }
  78.             echo $tmp_title_content_divider;
  79.             if ( $tmp_content_characters > 0 ) {
  80.                 echo substr($tmp_post['post_content_stripped'],0,$tmp_content_characters);
  81.             }
  82.             if ( $tmp_title_link != 'no' ) {
  83.                 echo '<div class="right_a"><a href="' . $tmp_post['post_permalink'] . '" >Read More</a></div>';
  84.             }
  85.             echo $tmp_after;
  86.         }
  87.         echo $tmp_global_after;
  88.     }
  89. }
  90.  
  91.  
  92. //------------------------------------------------------------------------//
  93. //---Page Output Functions------------------------------------------------//
  94. //------------------------------------------------------------------------//
  95.  
  96. //------------------------------------------------------------------------//
  97. //---Support Functions----------------------------------------------------//
  98. //------------------------------------------------------------------------//
  99.  
  100. ?>
Add Comment
Please, Sign In to add comment