Advertisement
Guest User

Untitled

a guest
May 13th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Show Team ID
  4. Plugin URI: http://blog.ashfame.com/?p=876
  5. Description: Provides a shortcode to show team id.
  6. Author: Ashfame
  7. Author URI: http://blog.ashfame.com/
  8. License: GPL
  9. Usage:
  10. */
  11.  
  12. add_shortcode ( 'show_recent_comments_results', 'show_recent_comments_results_handler' );
  13.  
  14. function show_recent_comments_results_handler( $atts, $content = null )
  15. {
  16. extract( shortcode_atts( array(
  17. "count" => 10,
  18. "theid" => $post_id = $GLOBALS['post']->ID,
  19. "pretty_permalink" => 0
  20. ), $atts ));
  21.  
  22. $output = ''; // this holds the output
  23.  
  24. if ( is_user_logged_in() )
  25. {
  26. global $current_user;
  27. get_currentuserinfo();
  28.  
  29. $args = array(
  30. 'post_id' => $theid, // the id
  31. 'user_id' => $current_user->ID,
  32. 'number' => $count, // how many comments to retrieve
  33. 'status' => 'approve'
  34.  
  35. );
  36.  
  37. $comments = get_comments( $args );
  38. if ( $comments )
  39. {
  40. $output.= "<ul>\n";
  41. foreach ( $comments as $c )
  42. {
  43. $output.= "";
  44. if ( $pretty_permalink ) // uses a lot more queries (not recommended)
  45. $output.= '<a href="'.get_comment_link( $c->comment_ID ).'"></a>';
  46. else
  47. $output.= 'ID: ';
  48.  
  49. $output.= apply_filters('comment_ID',$c-> comment_ID);
  50.  
  51.  
  52.  
  53.  
  54. if ( $pretty_permalink ) $output.= '<a href="'.get_settings('siteurl').'/?page_id='.$c->comment_post_ID.'#comment-'.$c->comment_ID.'">Go to team.</a>';
  55. $output.= "\n";
  56. }
  57. $output.= '</ul>';
  58.  
  59.  
  60. }
  61. else
  62. {
  63. $output.= "<ul>";
  64. $output.= "";
  65. }
  66. }
  67. else
  68. {
  69. $output.= "";
  70. }
  71. return $output;
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement