Changeset 293
- Timestamp:
- 03/13/07 17:46:16 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bbpress-latest-discussion-for-wp/tags/0.7/BBpress.php
r284 r293 2 2 /* 3 3 Plugin Name: BBpress Latest Discussions 4 Plugin URI: http://www.atsutane.net/ 4 Plugin URI: http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/ 5 5 Description: Put bbpress Latest Discussions on your wp page. 6 6 Author: Atsutane Shirane 7 Version: 0.7 7 Version: 0.7.2 8 8 Author URI: http://www.atsutane.net/ 9 9 */ 10 11 ### BBpress Latest Discussions Version Number 12 $BbLD_version = '0.7.2'; 10 13 11 14 if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?"); … … 19 22 ### Function: BBpress Latest Discussions Option 20 23 function wp_bb_option() { 21 global $wpdb ;24 global $wpdb,$BbLD_version; 22 25 $ori_url = $_SERVER['REQUEST_URI']; 23 26 if ($_POST['wpbb_save']){ … … 36 39 } 37 40 elseif (get_option('wpbb_path') == FALSE) { 38 $bbpath = '/bbpress'; // Adjust the path to suit your bbpress location. Example: '/forums'41 $bbpath = '/bbpress'; // Adjust the path to suit your bbpress location. Example: '/forums' 39 42 $wpbburl = get_settings('home') . $bbpath; 40 43 update_option('wpbb_path', $wpbburl); … … 71 74 ?> 72 75 <div class="wrap"> 73 <h2> BBpress Latest Discussions</h2>74 <?php if ($update_msg) { echo $update_msg; } ?>75 <p><strong> Plugin Name:</strong> BBpress Latest Discussions<br />76 <strong> Plugin URI:</strong> <a href="http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/">http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/</a><br />77 <strong> Author:</strong> <a href="http://www.atsutane.net/">Atsutane Shirane</a><br />78 <strong> Version:</strong> 0.7</p>79 <p><strong> ToDo List:</strong></p>76 <h2><?php _e('BBpress Latest Discussions'); ?></h2> 77 <?php if ($update_msg) { _e("$update_msg"); } ?> 78 <p><strong><?php _e('Plugin Name:'); ?></strong> <?php _e('BBpress Latest Discussions'); ?><br /> 79 <strong><?php _e('Plugin URI:'); ?></strong> <a href="http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/">http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/</a><br /> 80 <strong><?php _e('Author:'); ?></strong> <a href="http://www.atsutane.net/">Atsutane Shirane</a><br /> 81 <strong><?php _e('Version:'); ?></strong> <?php echo $BbLD_version; ?></p> 82 <p><strong><?php _e('ToDo List:'); ?></strong></p> 80 83 <ul> 81 <li> Add option to exclude some forum.</li>84 <li><?php _e('Add option to exclude some forum.'); ?> <a href="http://www.atsutane.net/bbpress/topic/4"><?php _e('Discuss here.'); ?></a></li> 82 85 </ul> 83 <p> If you have any suggestion or feedback. Feel free to post it <a href="http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/">here</a>.</p>84 <h2> BBpress Option</h2>86 <p><?php _e('If you have any suggestion or feedback. Feel free to post it'); ?> <a href="http://www.atsutane.net/2006/11/bbpress-latest-discussion-for-wordpress/"><?php _e('here'); ?></a>.</p> 87 <h2><?php _e('BBpress Option'); ?></h2> 85 88 <form method="post" action="<?php echo $ori_url; ?>"> 86 89 <p class="submit"> 87 <input type="submit" name="wpbb_save" id="wpbb_save" value=" Update Option »">90 <input type="submit" name="wpbb_save" id="wpbb_save" value="<?php _e('Update Option »'); ?>"> 88 91 </p> 89 92 <table class="optiontable"> 90 93 <tr valign="top"> 91 <th scope="row"> Bbpress URL:</th>94 <th scope="row"><?php _e('Bbpress URL:'); ?></th> 92 95 <td><input name="bburl" type="text" id="bburl" value="<?php echo get_option('wpbb_path'); ?>" size="40" /></td> 93 96 </tr> 94 97 <tr valign="top"> 95 <th scope="row"> Post Limit:</th>96 <td><input name="bblimit" type="text" id="bblimit" value="<?php echo get_option('wpbb_limit'); ?>" size="3" /> posts</td>97 </tr> 98 <tr valign="top"> 99 <th scope="row"> Bbpress DB Prefix:</th>100 <td><input name="bbprefix" type="text" id="bbprefix" value="<?php echo get_option('wpbb_bbprefix'); ?>" size="3" /> Bbpress table prefix<br />Enter the table prefix for your bbPress installation above. The table prefix is found in your bbPress installation's config.php file.</td>98 <th scope="row"><?php _e('Post Limit:'); ?></th> 99 <td><input name="bblimit" type="text" id="bblimit" value="<?php echo get_option('wpbb_limit'); ?>" size="3" /> <?php _e('posts'); ?></td> 100 </tr> 101 <tr valign="top"> 102 <th scope="row"><?php _e('Bbpress DB Prefix:'); ?></th> 103 <td><input name="bbprefix" type="text" id="bbprefix" value="<?php echo get_option('wpbb_bbprefix'); ?>" size="3" /> <?php _e('Bbpress table prefix'); ?><br /><?php _e("Enter the table prefix for your bbPress installation above. The table prefix is found in your bbPress installation's config.php file."); ?></td> 101 104 </tr> 102 105 <tr valign="top"> 103 <th scope="row"> Bbpress Permalink:</th>104 <td><label for="wpbb_permalink"><input name="wpbb_permalink" type="checkbox" id="wpbb_permalink" value="wpbb_permalink" <?php if (get_option('wpbb_permalink')) { echo('checked="checked"'); } ?> /> Use Bbpress Permalink</label><br />Only use this if you already enable permalink inside Bbpress config.php</td>106 <th scope="row"><?php _e('Bbpress Permalink:'); ?></th> 107 <td><label for="wpbb_permalink"><input name="wpbb_permalink" type="checkbox" id="wpbb_permalink" value="wpbb_permalink" <?php if (get_option('wpbb_permalink')) { echo('checked="checked"'); } ?> /> <?php _e('Use Bbpress Permalink'); ?></label><br /><?php _e('Only use this if you already enable permalink inside Bbpress config.php'); ?></td> 105 108 </tr> 106 109 <tr valign="top"> 107 <th scope="row"> Wordpress/Bbpress Integration:</th>108 <td><label for="wpbb_intergrated"><input name="wpbb_intergrated" type="checkbox" id="wpbb_intergrated" value="wpbb_intergrated" <?php if (get_option('wpbb_intergrated')) { echo('checked="checked"'); } ?> /> Intergrated with Wordpress</label><br />Check this option if you intergrated your wordpress installation with bbpress installation.</td>110 <th scope="row"><?php _e('Wordpress/Bbpress Integration:'); ?></th> 111 <td><label for="wpbb_intergrated"><input name="wpbb_intergrated" type="checkbox" id="wpbb_intergrated" value="wpbb_intergrated" <?php if (get_option('wpbb_intergrated')) { echo('checked="checked"'); } ?> /> <?php _e('Intergrated with Wordpress'); ?></label><br /><?php _e('Check this option if you intergrated your wordpress installation with bbpress installation.'); ?></td> 109 112 </tr> 110 113 <tr valign="top"> 111 <th scope="row"> External DB:</th>112 <td><label for="use_outdb"><input name="use_outdb" type="checkbox" id="use_outdb" value="use_outdb" <?php if (get_option('wpbb_exdb')) { echo('checked="checked"'); } ?> /> Use Different DB</label><br />Only enable this option if your Bbpress database is not the same as Wordpress database.</td>113 </tr> 114 <tr valign="top"> 115 <th scope="row"> Bbpress DB User:</th>114 <th scope="row"><?php _e('External DB:'); ?></th> 115 <td><label for="use_outdb"><input name="use_outdb" type="checkbox" id="use_outdb" value="use_outdb" <?php if (get_option('wpbb_exdb')) { echo('checked="checked"'); } ?> /> <?php _e('Use Different DB'); ?></label><br /><?php _e('Only enable this option if your Bbpress database is not the same as Wordpress database.'); ?></td> 116 </tr> 117 <tr valign="top"> 118 <th scope="row"><?php _e('Bbpress DB User:'); ?></th> 116 119 <td><input name="bbuser" type="text" id="bbuser" value="<?php echo get_option('wpbb_dbuser'); ?>" size="40" /> 117 120 </tr> 118 121 <tr valign="top"> 119 <th scope="row"> Bbpress DB Pass:</th>122 <th scope="row"><?php _e('Bbpress DB Pass:'); ?></th> 120 123 <td><input name="bbpass" type="text" id="bbpass" value="<?php echo get_option('wpbb_dbpass'); ?>" size="40" /> 121 124 </tr> 122 125 <tr valign="top"> 123 <th scope="row"> Bbpress DB Name:</th>126 <th scope="row"><?php _e('Bbpress DB Name:'); ?></th> 124 127 <td><input name="bbname" type="text" id="bbname" value="<?php echo get_option('wpbb_dbname'); ?>" size="40" /> 125 128 </tr> 126 129 <tr valign="top"> 127 <th scope="row"> Bbpress DB Host:</th>130 <th scope="row"><?php _e('Bbpress DB Host:'); ?></th> 128 131 <td><input name="bbhost" type="text" id="bbhost" value="<?php echo get_option('wpbb_dbhost'); ?>" size="40" /> 129 132 </tr> 130 133 </table> 131 134 <p class="submit"> 132 <input type="submit" name="wpbb_save" id="wpbb_save" value=" Update Option »">135 <input type="submit" name="wpbb_save" id="wpbb_save" value="<?php _e('Update Option »'); ?>"> 133 136 </p> 134 137 </form> … … 140 143 global $table_prefix,$wpdb; 141 144 $forum_slimit = get_option('wpbb_limit'); 142 $wpbburl = get_option('wpbb_path');143 $bbpress_table = get_option('wpbb_bbprefix') . "topics";144 $wordpress_table = $table_prefix . "users";145 145 if (get_option('wpbb_exdb')) { 146 146 $exbbdb = new wpdb(get_option('wpbb_dbuser'), get_option('wpbb_dbpass'), get_option('wpbb_dbname'), get_option('wpbb_dbhost')); 147 $bbtopic = $exbbdb->get_results("SELECT * FROM $bbpress_tableWHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit");147 $bbtopic = $exbbdb->get_results("SELECT * FROM ".get_option('wpbb_bbprefix')."topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit"); 148 148 } 149 149 else { 150 $bbtopic = $wpdb->get_results("SELECT * FROM $bbpress_tableWHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit");150 $bbtopic = $wpdb->get_results("SELECT * FROM ".get_option('wpbb_bbprefix')."topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit"); 151 151 } 152 152 if ($bbtopic) { 153 echo "154 <div id= \"discussions\">155 <h2> Discussion Forum</h2>156 <table id= \"latest\">153 echo ' 154 <div id="discussions"> 155 <h2>' . __("Discussion Forum") . '</h2> 156 <table id="latest"> 157 157 <tr> 158 <th> Topic</th>159 <th> Posts</th>160 <th> Last Poster</th>158 <th>' . __("Topic") . '</th> 159 <th>' . __("Posts") . '</th> 160 <th>' . __("Last Poster") . '</th> 161 161 </tr> 162 ";162 '; 163 163 foreach ( $bbtopic as $bbtopic ) { 164 164 echo " … … 166 166 "; 167 167 if (get_option('wpbb_permalink')) { 168 echo "<td><a href=\"$wpbburl/topic/$bbtopic->topic_id\">$bbtopic->topic_title</a></td>"; 169 } 170 else { 171 echo "<td><a href=\"$wpbburl/topic.php?id=$bbtopic->topic_id\">$bbtopic->topic_title</a></td>"; 172 } 173 echo " 174 <td class=\"num\">$bbtopic->topic_posts</td> 175 "; 168 echo '<td><a href="' . get_option('wpbb_path') . '/topic/' . $bbtopic->topic_id . '">' . __("$bbtopic->topic_title") . '</a></td>'; 169 } 170 else { 171 echo '<td><a href="' . get_option('wpbb_path') . '/topic.php?id=' . $bbtopic->topic_id . '">' . __("$bbtopic->topic_title") . '</a></td>'; 172 } 173 echo '<td class="num">' . __("$bbtopic->topic_posts") . '</td>'; 176 174 if (get_option('wpbb_intergrated')) { 177 $wpuid = $wpdb->get_row("SELECT * FROM $wordpress_tableWHERE user_login = '$bbtopic->topic_last_poster_name'");175 $wpuid = $wpdb->get_row("SELECT * FROM ".$table_prefix."users WHERE user_login = '$bbtopic->topic_last_poster_name'"); 178 176 if ($wpuid) { 179 177 $user_forum_data = "$bbtopic->topic_last_poster_name"; 180 178 $user_forum_data = get_userdata($wpuid->ID); 181 echo "<td class=\"num\">$user_forum_data->display_name</td>";179 echo '<td class="num">' . __("$user_forum_data->display_name") . '</td>'; 182 180 } 183 181 else { 184 echo "<td class=\"num\">$bbtopic->topic_last_poster_name</td>";185 } 186 } 187 else { 188 echo "<td class=\"num\">$bbtopic->topic_last_poster_name</td>";182 echo '<td class="num">' . __("$bbtopic->topic_last_poster_name") . '</td>'; 183 } 184 } 185 else { 186 echo '<td class="num">' . __("$bbtopic->topic_last_poster_name") . '</td>'; 189 187 } 190 188 echo " … … 198 196 function wp_bb_get_discuss_sidebar() { 199 197 global $table_prefix,$wpdb; 200 $bbpress_table = get_option('wpbb_bbprefix') . "topics";201 $wordpress_table = $table_prefix . "users";202 198 $forum_slimit = get_option('wpbb_limit'); 203 $wpbburl = get_option('wpbb_path');204 199 if (get_option('wpbb_exdb')) { 205 200 $exbbdb = new wpdb(get_option('wpbb_dbuser'), get_option('wpbb_dbpass'), get_option('wpbb_dbname'), get_option('wpbb_dbhost')); 206 $bbtopic = $exbbdb->get_results("SELECT * FROM $bbpress_tableWHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit");201 $bbtopic = $exbbdb->get_results("SELECT * FROM ".get_option('wpbb_bbprefix')."topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit"); 207 202 } 208 203 else { 209 $bbtopic = $wpdb->get_results("SELECT * FROM $bbpress_tableWHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit");204 $bbtopic = $wpdb->get_results("SELECT * FROM ".get_option('wpbb_bbprefix')."topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT $forum_slimit"); 210 205 } 211 206 if ($bbtopic) { 212 echo "213 <h2> Last $forum_slimit Discussions</h2>207 echo ' 208 <h2>' . __("Last $forum_slimit Discussions") . '</h2> 214 209 <ul> 215 ";210 '; 216 211 foreach ( $bbtopic as $bbtopic ) { 212 if (get_option('wpbb_exdb')) { 213 $bbforum = $exbbdb->get_row("SELECT * FROM ".get_option('wpbb_bbprefix')."forums WHERE forum_id = '$bbtopic->forum_id'"); 214 } 215 else { 216 $bbforum = $wpdb->get_row("SELECT * FROM ".get_option('wpbb_bbprefix')."forums WHERE forum_id = '$bbtopic->forum_id'"); 217 } 217 218 if (get_option('wpbb_permalink')) { 218 echo "<li><a href=\"$wpbburl/topic/$bbtopic->topic_id\">$bbtopic->topic_title</a><br />"; 219 } 220 else { 221 echo "<li><a href=\"$wpbburl/topic.php?id=$bbtopic->topic_id\">$bbtopic->topic_title</a><br />"; 219 echo '<li><a href="' . get_option('wpbb_path') . '/topic/' . $bbtopic->topic_id . '">' . __("$bbtopic->topic_title") . '</a><br />'; 220 $forum_url = get_option('wpbb_path') . '/forum/' . $bbtopic->forum_id; 221 } 222 else { 223 echo '<li><a href="' . get_option('wpbb_path') . '/topic.php?id=' . $bbtopic->topic_id . '">' . __("$bbtopic->topic_title") . '</a><br />'; 224 $forum_url = get_option('wpbb_path') . '/forum.php?id=/' . $bbtopic->forum_id; 222 225 } 223 226 if (get_option('wpbb_intergrated')) { 224 $wpuid = $wpdb->get_row("SELECT * FROM $wordpress_tableWHERE user_login = '$bbtopic->topic_last_poster_name'");227 $wpuid = $wpdb->get_row("SELECT * FROM ".$table_prefix."users WHERE user_login = '$bbtopic->topic_last_poster_name'"); 225 228 if ($wpuid) { 226 229 $user_forum_data = "$bbtopic->topic_last_poster_name"; 227 230 $user_forum_data = get_userdata($wpuid->ID); 228 echo "<small>Last Post By: $user_forum_data->display_name</small></li>";231 echo '<small>' . __('Last Post By: ') . $user_forum_data->display_name . '<br />' . __('Inside: ') . '<a href="'.$forum_url.'">' . __("$bbforum->forum_name") . '</a></small></li>'; 229 232 } 230 233 else { 231 echo "<small>Last Post By: $bbtopic->topic_last_poster_name</small></li>";234 echo '<small>' . __('Last Post By: ') . $bbtopic->topic_last_poster_name . '<br />' . __('Inside: ') . '<a href="'.$forum_url.'">' . __("$bbforum->forum_name") . '</a></small></li>'; 232 235 } 233 236 } 234 237 else { 235 echo "<small>Last Post By: $bbtopic->topic_last_poster_name</small></li>";238 echo '<small>' . __('Last Post By: ') . $bbtopic->topic_last_poster_name . '<br />' . __('Inside: ') . '<a href="'.$forum_url.'">' . __("$bbforum->forum_name") . '</a></small></li>'; 236 239 } 237 240 } bbpress-latest-discussion-for-wp/tags/0.7/readme.txt
r284 r293 1 1 === Bbpress Latest Discussion === 2 2 Tags: bbpress, wordpress, latest, discussion 3 Contributors: Atsutane Shirane3 Contributors: Atsutane 4 4 Requires at least: 0.8 5 5 Tested up to: 0.8 6 Stable Tag: 0. 86 Stable Tag: 0.7 7 7 8 8 This plugin will generates Latest Discussion list from your bbpress forum into your wordpress page. 9 10 Discuss about option to exclude or include forum at http://www.atsutane.net/bbpress/topic/4 9 11 10 12 == Description == … … 32 34 33 35 == Version History == 36 37 Version 0.7.2 (2007-03-12): 38 39 * Add Category link in sidebar list. 40 * Optimize the code a little. 41 42 Version 0.7.1 (2007-03-11): 43 44 * Add Multi Lang Support. 34 45 35 46 Version 0.7 (2007-03-09):
