whyisjake

Jake Spurlock

Jan 26th, 2010
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.30 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' 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.                 echo $tmp_title_before;
  63.                 if ( $tmp_show_avatars == 'yes' ) {
  64.                     if ( $tmp_title_link == 'no' ) {
  65.                         echo get_avatar( $tmp_post['post_author'], $tmp_avatar_size, $default_avatar) . ' ' . substr($tmp_post['post_title'],0,$tmp_title_characters);             
  66.                     } else {
  67.                         echo get_avatar( $tmp_post['post_author'], $tmp_avatar_size, $default_avatar) . ' <a href="' . $tmp_post['post_permalink'] . '" style="text-decoration:none;">' . substr($tmp_post['post_title'],0,$tmp_title_characters) . '</a>';
  68.                     }
  69.                 } else {
  70.                     if ( $tmp_title_link == 'no' ) {
  71.                         echo substr($tmp_post['post_title'],0,$tmp_title_characters);              
  72.                     } else {
  73.                         echo '<a href="' . $tmp_post['post_permalink'] . '" style="text-decoration:none;">' . substr($tmp_post['post_title'],0,$tmp_title_characters) . '</a>';
  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.             echo $tmp_after;
  83.         }
  84.         echo $tmp_global_after;
  85.     }
  86. }
  87.  
  88.  
  89. //------------------------------------------------------------------------//
  90. //---Page Output Functions------------------------------------------------//
  91. //------------------------------------------------------------------------//
  92.  
  93. //------------------------------------------------------------------------//
  94. //---Support Functions----------------------------------------------------//
  95. //------------------------------------------------------------------------//
  96.  
  97. ?>
Advertisement
Add Comment
Please, Sign In to add comment