Advertisement
Guest User

Untitled

a guest
Oct 20th, 2011
208
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Plugin Name: BBpress extra shortcode
  4. Description: Adds extra shortcodes for bbprss forums
  5. Version: 0.1
  6. Author: Kit Barnes
  7. License: GPL2
  8. */
  9. /*  Copyright 2011  Kit Barnes  (email : barnes.kit@gmail.com)
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License, version 2, as
  13.     published by the Free Software Foundation.
  14.  
  15.     This program is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.     GNU General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU General Public License
  21.     along with this program; if not, write to the Free Software
  22.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  23. */
  24.  
  25. add_shortcode("bbp-forum-site-index", "display_forum_index_from_site");
  26. add_shortcode("bbp-forum-header", "display_forum_header");
  27. add_shortcode("bbp-forum-footer", "display_forum_footer");
  28.  
  29.  
  30. function display_forum_index_from_site( $attr, $content = '' ) {
  31.     if (!empty( $attr['id'] ))
  32.     {
  33.             //Switch to supplied blog
  34.             switch_to_blog($attr['id']);
  35.     }
  36.     if ( !empty( $content ) || !is_numeric( $attr['id'] ) )
  37.         return $content;
  38.         if ( bbp_has_forums() )
  39.         {?>
  40.             <tbody>
  41.                 <?php while ( bbp_forums() ) : bbp_the_forum(); ?>
  42.                     <?php bbp_get_template_part( 'bbpress/loop', 'single-forum' ); ?>
  43.                 <?php endwhile; ?>
  44.             </tbody>
  45.         <?php }                        
  46. }
  47.  
  48.  
  49. function display_forum_header() {
  50.     do_action( 'bbp_template_before_forums_loop' ); ?>
  51.     <table class="bbp-forums">
  52.         <thead>
  53.             <tr>
  54.                 <th class="bbp-forum-info"><?php _e( 'Forum', 'bbpress' ); ?></th>
  55.                 <th class="bbp-forum-topic-count"><?php _e( 'Topics', 'bbpress' ); ?></th>
  56.                 <th class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></th>
  57.                 <th class="bbp-forum-freshness"><?php _e( 'Freshness', 'bbpress' ); ?></th>
  58.             </tr>
  59.         </thead>
  60. <?php
  61. }
  62.  
  63. function display_forum_footer() {
  64.         ?>
  65.          <tfoot>
  66.             <tr><td colspan="4">&nbsp;</td></tr>
  67.         </tfoot>
  68.     </table>
  69.     <?php do_action( 'bbp_template_after_forums_loop' );
  70. }
  71.  
  72. ?>
  73.  
  74.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement