Category Archives: Code

bbPress Plugin

Enhanced Tag Heat Map is my latest plugin for bbPress.. its been a long time since my work on bbpress. but schools taking a lot of my time. I’ll be releasing a few themes and a couple of plugins soon for wordpress 2.5 and bbpress 0.9

here is the plugin though

IntegratePress – Part II – Live Search

Another one of the plugins that i tried to integrated with my redesign was Addicted Live Search. The plugin is a really nice and simple plugin for wordpress. All I wanted to do with this is have the results show results from both forum and my blog. The first step was to integrated both bbpress and WordPress. Second step hack the plugin.

Installation Basics

First thing that you will need to do is install Addicted Live Search and make sure its working on your blog. Note: that this plugin adds the prototype javascript to the header. If you already are using the prototype package, comment our line 12 from live_search.php which says

echo '<script type="text/javascript" src="' . get_bloginfo('siteurl') . '/wp-content/plugins/addicted_live_search/js/prototype.js"></script>' . "\n";

To complete the hack you will also need to have the following things.

  1. – The web path to the files in the plugin directory and the files in it
  2. – Basics of XHTML, PHP, JS

You can download the changed files from here. If you need explanation on the changes or customization. Read on.

Plugin Basics

The live search plugin has three files that are needed to be hacked
search_results.php - integrate bbpress
js\live_search.js - fix a couple of quirks
css\live_search.css - if you want to customize the plugin

Lets start with search_results.php

Hack the Results

Lets open search_results.php. Between lines 13 and 33, bbPress will fetch the titles matching the query, titles with recent posts matching the query and topics of relevant posts with matching content. If you don’t want any of these to show up in the results just comment out the respective query. Meat of the search is in here.

After retrieving the topics, they are displayed by the topics loop between lines 50 and 61. You can also show the results individually for titles, recent posts and relevant posts. For that adjust the queries on lines 13 and 23 and then run a loop for them.

Uncomment the lines between lines 63 and 65 to show a close results link under the results. In some cases, the results fluctuate before disappearing. If you are having that problem, replace

onclick="ls.close(); return false;"

with

onclick="Field.clear('s'); return false;"

Showing the Results

The plugin by default adds the results under the search box. But sometimes thats not where you would want the results to be. To place it anywhere else comment out the line 10 from js/live_search.js which looks like this

<code>new Insertion.Bottom(ls.search_form, '<div id="addicted_results"></div>');</code>

Now just place the following div tag anywhere you want.

<div id="addicted_results"></div>

Customizing the Results Display

Edit the css/live_search.css file to customize your display.

Adding links to Blog Search and Forum Search

You can add links to blog search and forum search on the search results. here is the code that you will add to get the link to the blog results.

<a href="<?php bb_option('uri'); ?>search.php?q=<?php echo $_GET['s']; ?>">» more results</a>

And here is the code to get the link to the forum results.

<a href="<?php bloginfo('home'); ?>/?s=<?php echo $_GET['s']; ?>">» more results</a>

integratePress – Part I

UPDATE: These steps are valid for previous version of BBPress. May not work with WP 2.6.X and BBpress Alpha.

With the redesign of my site I have taken the integration of wordpress and bbpress a step beyond theme integration. This time I wanted to reuse the plugins for wordpress and also have forums showup with wordpress. I received requests from many of you about how to do it. Also the previous post about the integration is sort outdated because of the consequent releases of bbpress.

For the purpose of this article I am assuming that the bbpress installed in a subdirectory of wordpress

File: bbpress/config.php

Add the following code to the top of config.php

define('WP_BB', true);
if ( !defined('DB_NAME') ) {
require_once( dirname(__FILE__) . '/../wp-config.php');
}

Define the following variables.


$bb->wp_table_prefix = 'wp__'; // your wordpress db prefix is
$bb->wp_home = 'http://www.yourwebsite.com';
$bb->wp_siteurl = 'http://www.yourwebsite.com';

File: wordpress/wp-config.php

In this file the last statement is which says

require_once(ABSPATH.'wp-settings.php');

After this statement (before the php closing tag – ?>) add the following statements

if ( !defined('BBDB_NAME') )
require_once(ABSPATH.'bbpress/bb-load.php');

replace bbpress with whatever the directory bbPress is in.

bbPress Plugin: Display Name

This plugin ensures that the name shown is the display name from the wordpress rather than the username.
Download, Upload and activate this plugin in bbPress.

bbPress Plugin: WordPress Integration

This plugin ensures that your existing wordpress users can log into your bbPress install.
Download, Upload and activate this plugin in bbPress.

WordPress Plugin: bbPress Integration

This plugin makes suer that the users created in wordpress have valid roles in bbpress.
Download, Upload and activate this plugin in wordpress. After activating this plugin, go to Plugins » bbPress and enter the bbPress database prefix and update.

Theme: Template Integration

Download this file and drop the created directory in your my-templates directory. All this theme does is takes that header and footer from the wordpress theme and uses it.

Note 1: You will still need to add some more css styling for the forum contents.
Note 2: This theme does assumes that the footer and header will bring in any sidebar that you need automatically. If thats not the case you will have to add get_sidebar(); wherever needed.

Enjoy the bliss

That should do it. Now all your plugins and functions in wordpress should work with bbPress and also all the functions in bbpress should work with wordpress. You can all any of the bbpress functions in the wordpress themes.

BBpress Plugin Browser!

Finally the secret is out!!

BBPress: Release Notes 0.74

BBPress 0.74 will be released today. The release is consists for some small feature additions, new hooks and bug fixes. Here is a quick overview of the changes to the system.

  • More ‘stylable’ and ‘pluggable’ Tag Heat Map: The heat map is now in a div to move around and has hooks to plug into.
  • Nuke the Users: Users are being deleted from the system – and i mean deleted, not just marked as deleted
  • Spam Schmam: Better Spam Post handling. Delete the links to the spam posts.
  • Login vs Login: ‘login’ is username and ‘login’ is ‘log in’. there is a difference.
  • Better Installation: Easy and durable.Added sanity check to installation.
  • Ajax improvements: Better Error handling and Performance Tweaks.
  • Template improvements: New template for topic Tags. More customizable Forum and Topic templates.
  • THE BIGGIE: Facility to store options to database through bb_get_option. Deprecate option().
  • Hang ‘em: Numerous new hooks. I’ll document all the new hooks soon.

To get a complete list of changes, read on…

More

bbPress & WP Theme Integration

Update: I have written an updated article after the new releases and it can be found here.
http://www.adityanaik.com/integratepress-part-i/

I have been working on bbPress for quiet sometime now. Since most of use using both wordpress and bbPress integrated them and create similar themes, I thought I’ll add support for the bbPress forum Themes to all the wordpress themes that I create from now onwards.

Here is primer for integrating WordPress and bbPress Themes:

bbPress Configuration

$bb->wp_table_prefix = 'wp_';

You can find this information in the wp-config.php file in the wordpress installation directory.

$bb->wp_home = 'http://www.<your_website>.com/ <your_blog_directory>';
$bb->wp_siteurl = 'http://www.<your_website>.com/ <your_wp_installation_directory>';

You can find these information in wordpress admin page. Go to Administration > Options and you will find these values under the ‘General Options’ Tab. If you are installing bbPress in a folder other that subfolder of the wordpress installation, you might run into some cookie trouble. Have a look at this and fix the cookie definitions.

define('WP_BB', true);

Set this value in the config file so the functions defined in WordPress are not redefined.

require_once( '/path/to/wordpress/config/file/wp-config.php');

Update: Add the above statement to the config.php in bbPress. Note that this statement goes on top of the file before everything!. This will get all the functions from WordPress into bbPress.

Plugins

You will have to install two plugins one for wordpress and one for bbpress. So that whenever a user signs up on either of the softwares it will add permissions for the other forum and the second one to manage how the name is displayed.

Download the WordPress plugin from here and the bbPress Plugin from here

And now you are all set.

Integrating the themes is done. now you can just drop this template (Update Note: the template is outdated. You can download the latest file from here http://www.adityanaik.com/integratepress-part-i/) in my-template folder and the template is wordpress ready! All this template does is call get_header from wordpress rather that bb_get_header from bbpress. this way any change you make in wordpress template reflects in bbpress immediately.

BBpress plugin for WP Search

I created a plugin which would search the wordpress blogs when a search is performed in the bbpress forum.

you can see the details here

Prototype Error

I was working with the sandbox examples of prototype and I’m in a fix with the following error.

Error: missing ; before statement
Source File: <website>/js/prototype.js
Line: 143, Column: 5
Source Code:
Objec!.extend(String.prototype, {

the wired part is i get this error only with mozilla firefox! help anyone?

NuSOAP Hack

I was using the NuSOAP and i saw a typical problem. I uploaded the code to a webserver and it worked fine. But when I tested it on my localhost it bombed. The error was

“Cannot redeclare class soapclient”

I found the hack on oreillynet

There seems to be a clash of PHP5 build-in soap class and the nusoap class. Simply rename all occurences of “soapclient” in all 10 nusoap files into “soapclientw” (or whatever instead of “w”) and for me it worked.
This is a workaround/ hack. Backup your files before trying it.

Ha! Hibernation

Its been a loooooooooooooong time :)

i was busy shifting setting my new pad. yup. I shifted recently my base to New Jersey. The place I have now is a nice small and cozy – AND SAFE. we have the police station in the next compound :). any time I have a problem, i’ll open the windows and shout instead of calling 911!!

Also i have been working on the webDEMS which is a Diabetes Electornic Management System for a while now. Finally managed to release it last week.

You can read about it here.