SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 36
  1. #1
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bbPress theme project: Functionality

    Welcome to the "Adding plugin-like functionality" phase of the official SitePoint bbPress theme development project. For this stage of the development, we need to make some decisions about what sort of functionality we would like in the theme. The existing themes available for bbPress tend to be super-skinny and not have many features standard in other forum softwares. We can also potentially include functionality which is more commonly seen in plugins.

    If you have any opinions on what sort of functionality should be added and the best way to go about adding it, then please post your comments below. Feel free to list out all of the features you think should be added to the new theme. Once we have compiled opinions from everyone and determined whether the various options suggested are possible then we can plow straight into the development of the new functionality.

    I have crudely added some functionality into the demo site to demonstrate the sorts of changes which can be added directly to the theme. Most of the code used was simply copy and pasted from existing bbPress plugins and could probably be done a lot better, this was purely for demonstration purposes.

    Some of the extra functionality currently added to our demo site are:
    • Forum signatures
    • BB code support
    • Report post button
    • Resolved/unresolved/non-support button
    • Simple anti-spam check: Human tester
    • List of members online
    • Smilies
    • Polls
    • Forum stats
    • Images in posts
    • Hidden Forums
    • Read-Only forums



    SitePoint member rhysboy84 has also created a series of bbPress plugins which could potentially be included within the new theme.
    Quote Originally Posted by http://www.gospelrhys.co.uk/plugins/bbpress-plugins
    reCAPTCHA bbPress - Prevent spam registrations with reCAPTCHA technology.

    Show Top Posters - Increase visitor participation by showing the top posters on your sidebar.

    Image Resizer - Resize posted images on the fly with this plugin.

  2. #2
    SitePoint Evangelist rhysboy84's Avatar
    Join Date
    May 2007
    Location
    Colwyn Bay, North Wales, UK
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems like a great list. Furthermore a lot of it is kinda half there with plugins already (I know that a lot of plugins that mimic that functionality are compatible with 0.9, rather than 1.0). I will suggest this:-

    • Forum Stats - Personally speaking do we need this? I know _ck_ (a prolific bbPress plugin) wrote a piece of software on it, but she stated that it's quite resource intensive. Then again, I'm not hugely familiar with this plugin, so if not, it could be useful.
    • Private Messaging - I think this should be included as well. There is a plugin that does this already, however there is a massive security hole in it regarding email, that will have to be written.
    • Hidden Forums - I think this should be included as well. There is a plugin on this (again, written by _ck_), however it isn't the most user friendly. Adding in some admin functionality could be worthwhile for this project as well


    Anyway those are just my thoughts on what should be included, as well as pitfalls. I'm assuming we're using prewritten plugins & implementing them directly into the theme (with attribution)?

    Looking forward to hear everybody elses thoughts.
    I'm Rhys Wynne & I blog at Winwar Media
    WP Email Capture: Free Email/Ebook Marketing Wordpress Plugin
    UK Based SEO? Tweet Your Location to #ukseohere!
    | My Brand New Brand | Twitter |

  3. #3
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rhysboy84 View Post
    Forum Stats - Personally speaking do we need this? I know _ck_ (a prolific bbPress plugin) wrote a piece of software on it, but she stated that it's quite resource intensive. Then again, I'm not hugely familiar with this plugin, so if not, it could be useful.
    This is the stats plugin by _CK_:
    http://bbpress.org/plugins/topic/mini-stats/

    What if the forum stats were displayed on a separate page instead of on the forum index? This would reduce the server load issue so that it only applied to a single page.

    Quote Originally Posted by rhysboy84 View Post
    Private Messaging - I think this should be included as well. There is a plugin that does this already, however there is a massive security hole in it regarding email, that will have to be written.
    Yes, this was suggested multiple times during discussions about the theme before the project was launched. I had trouble getting the existing plugins working inside a theme, but I'm sure it could be done I just didn't spend much time on it.

    Quote Originally Posted by rhysboy84 View Post
    [*]Hidden Forums - I think this should be included as well. There is a plugin on this (again, written by _ck_), however it isn't the most user friendly.
    Sounds reasonable. I think this one could be deemed more suitable as a plugin though. Would most people use this functionality? I know I would, but I'm not sure if the majority actually would. And since it is something which isn't really theme related and I'm not 100% convinced adding it to a theme is necessary.

    Quote Originally Posted by rhysboy84 View Post
    Adding in some admin functionality could be worthwhile for this project as well
    Yep, that will definitely be necessary.

    Quote Originally Posted by rhysboy84 View Post
    Anyway those are just my thoughts on what should be included, as well as pitfalls. I'm assuming we're using prewritten plugins & implementing them directly into the theme (with attribution)?
    If that is the best approach, then yep, otherwise they could be rewritten. Some parts of the plugins would need to be modified to work with the theme, I'm particularly thinking of bbCode buttons for that.[/QUOTE]

  4. #4
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The things which I'd like to see included are:
    • Forum signatures
    • BB code support
    • List of members online
    • Smilies
    • Polls
    • Images in posts


    Forum signatures are very important IMO. That sort of functionality is fundamental to the way a forum theme is designed. If it needs to be added via a plugin, then that plugin would need to be able to add the forum in the exact place that it is required in the theme and be able to be styled and theme directly from the theme, ie: you would need to be able to control the markup for the signatures from the theme. I can't see how you could do that with a plugin, or at least not without making a plugin to accompany your theme.

    I find the lack of BB Code support in bbPress bizarre. The BB Code needs to be controllable via the theme. Like the forum signature issue, I can't see it being very convenient to add this sort of functionality via a plugin. Likewise for smilies. The code necessary to add these features is fairly straightforward, literally just a matter of copy and paste from existing plugins.

    Quick quote functionality should also be added IMO, ie: a javascripted system so that when you click the quote button on a post it automatically adds the quoted text/BB code to the quick reply box on the page.

    Images in posts is definitely plugin functionality, but the code required to get it working in a theme is negligible anyway so I think that should be added (I've already got that working perfectly on the demo site).


    I'm not sure that adding a captcha or other anti-bot tools is necessary or a good idea. That is the sort of thing which users will want to individualise anyway and there are multiple ways of doing it.

    Report post button's are quite specific and could easily be added via a plugin anyway.

    "Resolved/unresolved/non-support button" seems quite specific too. I wouldn't have a use for that on any forums I use.

    I like the idea of adding some basic forum stats. That's not even really 'plugin-like' functionality IMO. It just happens to be that it is usually done with a plugin. It's something to output directly to the front end, so adding it to a theme seems entirely sensible to me. rhysboy84 mentioned that it may add overheard to the pages though.

    The styling for polls needs to be coded into the theme, otherwise you have no way to modify the markup for it without hacking whatever plugin you are using. So perhaps that should be included too?



    Anyone else with opinions on these issues?

  5. #5
    SitePoint Evangelist rhysboy84's Avatar
    Join Date
    May 2007
    Location
    Colwyn Bay, North Wales, UK
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    Forum signatures are very important IMO. That sort of functionality is fundamental to the way a forum theme is designed. If it needs to be added via a plugin, then that plugin would need to be able to add the forum in the exact place that it is required in the theme and be able to be styled and theme directly from the theme, ie: you would need to be able to control the markup for the signatures from the theme. I can't see how you could do that with a plugin, or at least not without making a plugin to accompany your theme.

    I find the lack of BB Code support in bbPress bizarre. The BB Code needs to be controllable via the theme. Like the forum signature issue, I can't see it being very convenient to add this sort of functionality via a plugin. Likewise for smilies. The code necessary to add these features is fairly straightforward, literally just a matter of copy and paste from existing plugins.
    Agreed.

    Quote Originally Posted by ryanhellyer View Post
    Images in posts is definitely plugin functionality, but the code required to get it working in a theme is negligible anyway so I think that should be added (I've already got that working perfectly on the demo site).
    I'm surprised how quickly you got that to work tbh! I know "Allow Images" is 0.9 compatible. Did you write it yourself or a hack of the "Allow Images" plugin?

    Quote Originally Posted by ryanhellyer View Post
    I'm not sure that adding a captcha or other anti-bot tools is necessary or a good idea. That is the sort of thing which users will want to individualise anyway and there are multiple ways of doing it.
    What does vBulletin do? Does it come with captcha within the software itself or is it an add on? If the latter, I'd be tempted to ignore it (Wordpress itself doesn't have captcha on it)

    Quote Originally Posted by ryanhellyer View Post
    I like the idea of adding some basic forum stats. That's not even really 'plugin-like' functionality IMO. It just happens to be that it is usually done with a plugin. It's something to output directly to the front end, so adding it to a theme seems entirely sensible to me. rhysboy84 mentioned that it may add overheard to the pages though.
    I got confused here . I don't think Ministats has that big an overhead. So yeah, stick that in.

    Quote Originally Posted by ryanhellyer View Post
    Yes, this was suggested multiple times during discussions about the theme before the project was launched. I had trouble getting the existing plugins working inside a theme, but I'm sure it could be done I just didn't spend much time on it.
    The issue with private messaging is that it requires extra files to be put in the root directory of the installation. If you can get it working from within the theme directory, and only the theme directory, that's fine. Otherwise we can't do this.

    I think the list you put is ideal, with possibly adding Image Resizer if I may to the Images in Posts (so that any that are too big are automatically resized). If there are no further objections, thoughts, I think we should start with those and then see if we need anything else.
    I'm Rhys Wynne & I blog at Winwar Media
    WP Email Capture: Free Email/Ebook Marketing Wordpress Plugin
    UK Based SEO? Tweet Your Location to #ukseohere!
    | My Brand New Brand | Twitter |

  6. #6
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Guys, given that b5 pushed bbpress from it's past level of "the suck" to its current level of "quite useful", it might be helpful to leverage some of the plugins b5's been releasing, modifying, etc...
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  7. #7
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rhysboy84 View Post
    I'm surprised how quickly you got that to work tbh! I know "Allow Images" is 0.9 compatible. Did you write it yourself or a hack of the "Allow Images" plugin?
    It was just a matter of copy and pasting from an existing plugin (I can't remember which one). It's a fairly small script, nothing fancy going on inside it and it seems to be working fine in 1.0.

    You can see it in use here ... http://bbtheme.net/topic/another-test-topic

    The demo site hasn't been updated to the latest 1.0 release yet, but I'm assuming it will work fine in that too.

  8. #8
    SitePoint Evangelist rhysboy84's Avatar
    Join Date
    May 2007
    Location
    Colwyn Bay, North Wales, UK
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    It was just a matter of copy and pasting from an existing plugin (I can't remember which one). It's a fairly small script, nothing fancy going on inside it and it seems to be working fine in 1.0.
    Cool. I suspect that there were template structure changes between 0.9 and 1.0, as I've been unable to get it to work.

    Quote Originally Posted by Jeremy W. View Post
    Guys, given that b5 pushed bbpress from it's past level of "the suck" to its current level of "quite useful", it might be helpful to leverage some of the plugins b5's been releasing, modifying, etc...
    Is there a full list of the plugins released by b5? It may be useful
    I'm Rhys Wynne & I blog at Winwar Media
    WP Email Capture: Free Email/Ebook Marketing Wordpress Plugin
    UK Based SEO? Tweet Your Location to #ukseohere!
    | My Brand New Brand | Twitter |

  9. #9
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rhysboy84 View Post
    Is there a full list of the plugins released by b5? It may be useful
    I tried Googling it, but didn't turn anything up. I didn't search very hard though.

  10. #10
    SitePoint Addict hiddenpearls's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i also want to get involved in this project but how ?
    i myself good in php and wordpress. have done projects like wordpress themes and used wordpress as a CMS.
    here it is sample of my work http://whizbangsolutions.com/ourwork/avudu/

  11. #11
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for offering to help

    Once we've sorted out what sort of functionality we require then it would be great if you could volunteer to implement any of the functionality.

    We don't have a clear plan set out for how this will all work, but I guess the idea would be to have people volunteer for various jobs and report back once they're done. If we don't hear back from anyone then the job could be taken up by someone else.

    Once the code is provided, we can all test it, critique it and if it's up to scratch whoever is in charge of maintaining the code (currently me) will implement it into the core theme on the demo site.

    At this stage it's just a jerry rigged version of Kakumei. I'll post a download file for the crude job I've done so far tomorrow so that you guys can see how it works. Most of it will need to be redone though and some of it is extraordinarily buggy, ie: the admin pages don't work at all. Plus some of the functionality is presumably not wanted anyway.

  12. #12
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Based on what is posted above, we've so far got:
    Mini-stats
    Forum signatures
    BB code support
    List of members online
    Smilies
    Polls
    Images in posts
    Image Resizer


    There's also quick-quotes (ie: when you click the quote button on a post it automatically adds the quoted text/BB code to the quick reply box on the page) which I think should be added, although I'm not sure I'd call that a plugin. That's just a simple javascript script and I'm surprised it was ever a plugin.


    Plus private messaging if it can be done without modifying/adding core files. I can't see why you could do it via a basic plugin-type functionality though. I'd have thought it was just require some extra database entries to store everything. I wouldn't be comfortable writing something like that myself though so we would need a volunteer who knows what they're doing. This seems like it would be one of the more complicated features to add, particularly since there doesn't seem to be any suitable off-the-shelf plugins available which haven't been reported to have serious problems.

  13. #13
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rhysboy84 View Post
    What does vBulletin do? Does it come with captcha within the software itself or is it an add on? If the latter, I'd be tempted to ignore it (Wordpress itself doesn't have captcha on it)
    vBulletin comes with a custom captcha as do pretty much every other forum software out there. I'm guessing bbPress is the only that doesn't.

    SMF2 has the best system I've seen so far, but that's one heck of a complicated system and I don't think adding something like that into a theme would be a good idea.


    My opinion is that a Captcha type system should be in the core, and if not it would be better suited as a plugin. There isn't really a one-stop solution for Captcha unless you create something really complicated, so chances are you would need to install a plugin to customise it anyway or the spam-bots will find ways around it anyway.

  14. #14
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the code I used to allow the use of the <img> tag in forum posts. The plugin it came from () says it's only compatible up to 0.7.3, but it seems to work fine in version 1.0.

    I just added it as a separate file and it included it via the functions.php file.

    Code PHP:
    <?php
    /*
    Plugin Name: Allow Images
    Plugin URI: [url]http://bbpress.org/#[/url]
    Description: Allows <img /> tags to be posted in your forums.  The image must be a png, gif or jpeg.
    Author: Michael D Adams
    Author URI: [url]http://blogwaffe.com/[/url]
    Version: 0.7.1
    */
     
    // You can add more tags here
    function allow_images_allowed_tags( $tags ) {
    	$tags['img'] = array('src' => array(), 'title' => array(), 'alt' => array());
    	return $tags;
    }
     
    function allow_images_encode_bad( $text ) {
    	$text = wp_specialchars( $text );
    	$text = preg_replace('|&lt;br /&gt;|', '<br />', $text);
    	foreach ( bb_allowed_tags() as $tag => $args ) {
    		if ( 'br' == $tag )
    			continue;
    		if ( $args )
    			$text = preg_replace("|&lt;(/?$tag.*?)&gt;|", '<$1>', $text);
    		else
    			$text = preg_replace("|&lt;(/?$tag)&gt;|", '<$1>', $text);
    	}
     
    	$text = preg_replace("|`(.*?)`|se", "'<code>' . encodeit('$1') . '</code>'", $text);
     
    	return $text;
    }
     
    function allow_images( $text ) {
    	if ( preg_match_all('/<img(.+?)src=("|\')(.+?)\\2(.+?)>/i', $text, $matches, PREG_SET_ORDER ) )
    		foreach( $matches as $match )
    			if (
    				preg_match('/src=/i', $match[4]) // multiple src = someone's trying to cheat
    			   ||
    				!in_array(substr($match[3], -4), array('.png', '.jpg', '.gif'))  // only match .jpg, .gif, .png
    			   &&
    				'.jpeg' != substr($match[3], -5) // and .jpeg
    			)
    				$text = str_replace($match[0], '', $text);
    	return $text;
    }
     
    remove_filter( 'pre_post', 'encode_bad' );
    add_filter( 'pre_post', 'allow_images_encode_bad', 9 );
    add_filter( 'pre_post', 'allow_images', 52 );
    add_filter( 'bb_allowed_tags', 'allow_images_allowed_tags' );
     
    ?>

  15. #15
    SitePoint Addict hiddenpearls's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    Thanks for offering to help

    Once we've sorted out what sort of functionality we require then it would be great if you could volunteer to implement any of the functionality.

    We don't have a clear plan set out for how this will all work, but I guess the idea would be to have people volunteer for various jobs and report back once they're done. If we don't hear back from anyone then the job could be taken up by someone else.
    i would love to work on this !

  16. #16
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just noticed in the BBcode Lite plugin by _ck_ that it has the following text so I'm assuming that if we included that plugin then it would fix the IMG tag issue for us automatically (assuming it works in 1.0):
    // to force allowing images without extra plugins like "allow images" uncomment the following line:
    // $bbcode_lite['complex']['img'] = array('img','src');

  17. #17
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, that other method of adding images works perfectly too. So no need for the other plugin if we incorporate BBcode Lite.

  18. #18
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a zip file with the theme currently running on the demo site.

    There's a bunch of plugin files strewn through the folder which are included via the functions.php file.
    http://bbtheme.net/ryan/sitepoint.zip

    They're not very well organised and many of them would need modified quite a bit or totally rewritten for the final theme.


    There is a Google Code repository which I need to update too. But in the mean time I thought I'd post that in case any of you are interested in seeing how I hacked together this existing theme.

  19. #19
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ryan, maybe grab me on skype over the next few days and I can download a lot of our learning to you. But you can see the bbpress installs up @ www.splendicity.com/community, and many of these features (and many others) are in there.

    I'm happy to help out with this, just so busy that I can't be involved daily right now (and wifi access is limited this week)... but I'm a huge fan of bbpress, just also a huge fan of folk not duplicating effort, y'know?
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  20. #20
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jeremy, I'll try to track down your Skype address (searching for "Jeremy Wright" didn't show up anyone from Canada).

    And yeah, duplicating effort would be silly.

  21. #21
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    Thanks Jeremy, I'll try to track down your Skype address (searching for "Jeremy Wright" didn't show up anyone from Canada).

    And yeah, duplicating effort would be silly.
    Really? Odd: jeremy_wright
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  22. #22
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I found it on your personal blog just before you posted. I've now added you on Skype.

  23. #23
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I met with Sam Bauers the other weekend and discussed this side of the project with him. He seemed quite supportive of our intention to add some plugin-like functionality to the theme as it allows us to provide a convenient way for people to setup a bbPress site with a suite of extra features but without bloating the bbPress core in the process.

    So it looks like the following features are what we will be adding. If anyone objects, please speak up now
    Mini-stats
    Forum signatures
    BB code support
    List of members online
    Smilies
    Polls
    Images in posts
    Image Resizer
    Quick-quotes
    Private messaging (if it can be done without modifying/adding core files)

    As Jeremy W pointed out, B4 Media has done a lot of customisation of their bbPress setup, but they don't seem to have released any of the code for the rest of us to use.


    If you are interested in helping to implement these features please volunteer
    Here's the zip file containing what I've done so far ... http://bbtheme.net/ryan/sitepoint.zip. You can find the various chunks of code via the functions.php file.

  24. #24
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like there are no objections to the above set of suggestions, so I've started implementing some of the PHP code.

    The first thing I've done is to make a copy of the new Kakumei theme released with the final bbPress 1.0 release. Then I added a functions.php file to it (which loads automatically on page loads just like functions.php in WordPress):

    And in the the functions.php file I added this:
    Code PHP:
    <?php
     
    // Add the "BBcode Lite" plugin by _ck_ () ([url]http://bbpress.org/plugins/topic/93[/url])
    require('functionality/BBcode-lite.php');
     
    ?>

    Which loads the "BBcode Lite" plugin file from _ck_. I made a few modifications to the code to make it more readable, adding indents etc. etc. Feel free to critique and rewrite where appropriate (post your changes below).

    Code PHP:
    <?php
    /*
    Adapted from the "BBcode Lite" plugin by _ck_ ([url]http://bbpress.org/plugins/topic/93[/url])
     
    Description: A lightweight alternative to allow BBcode on your forum.
    Author: _ck_
    Author URI: [url]http://bbShowcase.org[/url]
    Version: 1.0.3
     
    License: CC-GNU-GPL [url]http://creativecommons.org/licenses/GPL/2.0/[/url]
    Donate: [url]http://amazon.com/paypage/P2FBORKDEFQIVM[/url]
    */
     
    // Allow images without extra plugins
    $bbcode_lite['complex']['img'] = array('img','src');
     
    // Add filters
    add_filter('bb_init','bbcode_lite_init');
    add_filter('post_text', 'bbcode_lite',7);	//  to store bbcode as html permanently,  change 'post_text' to 'pre_post' which is faster but harder for users to edit
    add_filter('pm_text', 'bbcode_lite',7);	// support private message plugin
    add_filter( 'bb_allowed_tags', 'bbcode_lite_extra_tags' );	 // unfortunately to make bbcode fast we need to allow some extra tags like "font"
     
    //
    function bbcode_lite_init() {		// speed up by defining variables only once - also allows us to deactivate tags not allowed
    	global $bbcode_lite;
    	$tags = bb_allowed_tags();
    	$bbcode_lite['complex']['url'] = array('a','href');
    	if (isset($tags['img'])) {
    		$bbcode_lite['complex']['img'] = array('img','src');
    	}
    	$bbcode_lite['wrap'] = array('color' => array('font','color'),'size' => array('font','size'),'url' => array('a','href'), 'list' => array('ol','type'));
    	$bbcode_lite['simple'] = array('pre'=>'pre','b' => 'strong','i' => 'em','u' => 'u','center'=>'center','quote' => 'blockquote','strike' => 'strike','s' => 'strike','list' => 'ul', 'code' => 'code');
    }
     
    function bbcode_lite_extra_tags( $tags ) {   // Add some extra html tags to support - though in theory it bypasses all restrictions when using post_text hook
    	$tags=array_merge(array("BBcode"=>array()),$tags);	 // Trick bbPress to show BBcode in the list of allowed tags and give users a clue
    	$new_tags=array('font','strike','center','u','blockquote','pre','hr');
    	// Add a few allowed tags for more robust bbCode support
    	foreach ($new_tags as $tag) {
    		$tags[$tag]=array();
    	}
    	return $tags;
    }
     
    function bbcode_lite ($text) {
    	global $bbcode_lite;
    	$counter=0;  // Filter out all backtick code first
    	if (preg_match_all("|\<code\>(.*?)\<\/code\>|sim", $text, $backticks)) {
    		foreach ($backticks[0] as $backtick) {
    			++$counter;
    			$text=str_replace($backtick,"_bbcode_lite_".$counter."_",$text);
    		}
    	}
     
    	$text=preg_replace('/(\<br \/\>|[\s])*?\[(\*|li)\](.+?)(\<br \/\>|[\s])*?(\[\/(\*|li)\](\<br \/\>|[\s])*?|(?=(\[(\*|li)\](\<br \/\>|[\s])*?|\[\/list\])))/sim','<li>$3</li>',$text); // * = li, a very special case since they may not be closed
    	foreach($bbcode_lite['wrap'] as $bbcode=>$html) {
    		$text = preg_replace('/\['.$bbcode.'=(.+?)\](.+?)\[\/'.$bbcode.'\]/is','<'.$html[0].' '.$html[1].'="$1">$2</'.$html[0].'>',$text);
    	}
    	foreach($bbcode_lite['simple'] as $bbcode=>$html) {
    		$text = preg_replace('/\['.$bbcode.'\](.+?)\[\/'.$bbcode.'\]/is','<'.$html.'>$1</'.$html.'>',$text);
    	}
    	foreach($bbcode_lite['complex'] as $bbcode=>$html) {
    		if($bbcode!='url') {
    			$text = preg_replace('/\['.$bbcode.'\](.+?)\[\/'.$bbcode.'\]/is','<'.$html[0].' '.$html[1].'="$1">',$text);
    		}
    		else {
    			$text = preg_replace('/\['.$bbcode.'\](.+?)\[\/'.$bbcode.'\]/is','<'.$html[0].' '.$html[1].'="$1">$1</'.$html[0].'>',$text);
    		}
    	}
     
    	if ($counter) {
    		$counter=0; foreach ($backticks[0] as $backtick)  {
    			++$counter;
    			$text=str_replace("_bbcode_lite_".$counter."_",$backtick,$text);
    		}
    	}	// undo backticks
     
    return $text;
    }
     
    ?>

    You can see the code in action on the demo site ... http://bbtheme.net/topic/another-test-topic


    Since I've started from scratch the various functionalities which were present on the site before have now been removed.

  25. #25
    SitePoint Evangelist rhysboy84's Avatar
    Join Date
    May 2007
    Location
    Colwyn Bay, North Wales, UK
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool. I'm keeping an eye on this topic, please don't take the lack of response as "not caring"
    I'm Rhys Wynne & I blog at Winwar Media
    WP Email Capture: Free Email/Ebook Marketing Wordpress Plugin
    UK Based SEO? Tweet Your Location to #ukseohere!
    | My Brand New Brand | Twitter |


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •