Introducing LINICKX LifeStream V0.1

UPDATE: This Plugin has been updated, the below links to the new file, but please comment on the new post, thanks.

I’m proud to share with the WordPress community my new plugin, LINICKX LifeStream :)

I’ve been trying to get more LifeStreaming into LINICKX.com for a while, as I’ve struggled to find an appropriate solution I’ve decided to write my own.

Plug-in Features:

  • Stream Any Feed.
    Most internet services like digg, twitter, lastfm and the like support RSS feeds of your activity, so you can stream any service even if I haven’t heard about it yet!
  • Posts are created from the feeds/stream.
    Each Feed item creates a new post, you can tag & categorise your posts to give each stream a different look & feel in your WordPress templates.
  • No dependencies.
    LINICKX LifeStream uses WordPress functions to do it’s work, so yes it’ll work on PHP4 & PHP5 and you don’t need to update simplepie or an-other dependancy.
  • Flexible updating.
    By default LINICKX LifeStream should just work, WordPress will fetch the feeds every 5 minutes and store them in the WP Database, but you can change that. If you want to cron your updates every 1 minute you can, if you want the DB store in a file not in MySQL that’s not a problem either.

LINICKX Lifestream is currently feeding both my Digg & Google Reader posts; in general I’m pretty poor at updating my plug-ins as this is a hobby, but since this project is part of my website and not a favour for a friend (like the others) I’m hoping to do a better job.

I’m looking for help too!
The admin interface is a bit “clunky”, the reason being I don’t know javascript, if you do please consider writing a patch :)
I also think this plugin would work well for WordPresMU users, but I don’t use it so if you do what changes need to be made to make this work for you?

You can download the source from here: http://plugins.svn.wordpress.org/linickx-lifestream/ or Browse Trac

Disclaimer
As with my other plug-ins this is a hobby, I have a full time job that takes priority. Feel free to leave comments here but ask support questions to the WordPress community. I will update this plugin as and when I need features to improve linickx.com but will consider any patches submitted and any good ideas you have.

If this plugin has been some use to you, please consider donating as I give this code away for free and giving something back will make you feel good :cool:

UPDATE(s):

  • Pushed version 0.1.1 as the directory path changed when wordpress.org created their .zip file… all should be working again.
  • Pushed version 0.1.2 to fix error in dashboard reported by Markus below.
  • Pushed Version 0.1.3 more bug fixes; 0.1.2 broke auto updates, so 0.1.3 fixes it again!
    linickx.com was having execution timeout issues, so theres a patch to fix that for other users
    I’ve also introduced a config.php so that upgrades do not overwrite $WPDIR set by users.

Get ready for LINICKX LifeStream!

Colleagues have noticed that in my spare time at work I’ve been “getting my geek on!” the definition being a vi window of code on one screen and google open in the other ;)

Linickx LifeStream will be a new WordPress plugin which allows you to life stream ANY feed. I’ve been having issues with FeedWordPress and to be honest it didn’t really do what I wanted; now there are already may wordpress lifestream plug-ins, but mine will be different.

Difference 1: The plug-in isn’t service dependant… i.e. you don’t stream your twitter account or your LastFM account, you stream the feed. What this means is that when tomorrows-wizzy-new-service is launched you don’t have to wait for me to update the plug-in. It also means you can stream odd stuff, such as I’m going to stream my commits to the WordPress plug-in repo ;)

Difference 2: No Requirements. The requirements for this are the same as the WordPress requirements. What this means is yes it works on PHP4 and no you don’t need a separate installation of simplepie.

Difference 3: No Lifestream Pages, extra databases or tables. LifeStream feeds get created as “normal” WordPress posts, so if you digg something a post is created and you can do all the normal things like tag & categorize the post.

I’m in the process of finishing the package and installing the plug-in here on linickx.com but when it’s ready you’ll be able to…

Download LINICKX LifeStream Here

With a little luck I’ll be able to remove this annoyance and directly stream delicious and get google reader working again.

phpbb_recent_topics_0.5.3

0.5.3 is a minor update which fixes this issue whereby some users got this error in their admin screens


Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/phpbb-recent-topics/display/admin-options.php on line 144

If you don’t have this issue upgrading is optional, download from the usual place!

Follow plug-in development progress

The WordPress plugin trac is a really cool resource, one of my favourite features is the commit log.

Development progress of linickx plugins is always going to be slow because I have a day job but when I find the time to develop updates I try to commit them to the community as often as I can so users can stay in the loop…. The thing is users don’t necessarily know the log is there, so here’s a couple of links for you…

If you want test drive my development versions on your blog you can download them from wordpress.org here and here respectively, feel free to submit patches to fix bugs or implement features, I’m always open to suggestions and work is always accredited appropriately.

Introducing root cookie 1.5 now with subdomain support!

UPDATE: This Plugin has been updated, please see the new post, comments here are now closed.

A long time ago Sc0ttClark came to me and suggested that his cookie subdomains plug-in & my cookie path plug-in should be merged…. well I’ve finally done it!

There was a little delay in the release as the initial code only worked for top level .com, .net & .org style domains but a simple “manual” option in the admin screen now allows you to set the domain name, so longer domains like .co.uk can be supported!

All previous functionality is supported, just by enabling the plug-in the path is stripped out you only need to go into the admin page if you want to change the subdomain of the cookie.

The admin page now has a “News & Tutorials” feed (subscribe) my plan is to post articles on how to use root-cookie.

You can download the plugin from wordpress.org, and there is a discussion forum to get community support.

Twitter Tools is for Twitter Tools

Those with a keen eye may have noticed that my tweets / status updates didn’t start with “is” until recently that’s because posts that appeared here on my blog would look stupid and out of context, who starts a post “is” ???

To solve the problem attached is a small plugin for Alex Kings Twitter Tools, it’s a simple WordPress filter which prepends posts which begin with “is” with the author name, example:

is testing his new WP plugin.

becomes

Nick is testing his new WP plugin.

If I get some positive feedback I might publish this in WP’s plugin directory.

Installation is easy, rename twitter-tools-is.txt to twitter-tools-is.php and save it in your wp-content/plugins directory, enable the plug-in the “normal” way and job done, no further configuration required!

WordPress Plug-in Order

Whilst playing with my bad-behavior callback function, I noticed something quite crucial; plug-ins load in alphabetical order!.

I noticed that every time a new version of BB is released / upgraded I had to re-paste my callback function into bad-behavior-wordpress.php – DOH!

To get around this I decided to create a new plug-in called linickx-bb-callback.php, but I noted that the counter wasn’t increasing. Changing the file name to aaa_linickx-bb-callback.php fixed the issue, sweeeeet!

Bad Behaviour and Akismet Blocked Counters for WordPress

The Bad Behaviour plug-in for WordPress comes with a weekly counter in the admin dashboard, but do you want a wicked footer like mine?

106,386 dodgy geezas have been blocked by Bad Behaviour and 36,926 spams were eaten by Akismet.

Akismet comes with a counter you can use in themes/plugins…


$akcount = get_option('akismet_spam_count');
$akcount = number_format($akcount);
echo $akcount;

But with Bad Behaviour you have to do a little more work. To start with you need to get BB to record in the database each time it blocks someone, this is done by adding a function to ~/wp-content/plugins/bad-behavior/bad-behavior-wordpress.php , add the following code…..

// Bad Behavior callback functions.
function  bb2_banned_callback() {

        $counter = get_option('bad_behavior_spam_count');
        $counter = $counter + 1;
        update_option( 'bad_behavior_spam_count', $counter );

}

Now BB will store an incrementing number in the WP database for you to use in your theme..


$bbcount = get_option('bad_behavior_spam_count');
$bbcount = number_format($bbcount);
echo $bbcount;

Now you can track how many inter-twats your blocking!

phpbb_recent_topics version 0.4.1

UPDATE: This Plugin has been updated, please download the update from http://wordpress.org/extend/plugins/phpbb-recent-topics/, and please comment on the new post, thanks.

This is a small update, it incorporates the patch submitted by toni to fix the widget, thanks toni :)

The old information still applies…

phpBB Recent Topics Admin interface in WordPress
Admin GUI

If you’re happy with v0.4 and have it running fine then don’t bother, in fact edit phpbb_recent_topics.php so that WordPress stops complaining about finding a newer version.

Download phpBB_Recent_Topics_0.4.1 from wordpress.org

What’s New?

  • The widget patch mentioned above!

What’s Old?

  • Most importantly I have tested this plugin with phpBB3 and WP2.5 so I’ve updated the readme.txt to reflect this.
  • I finally quashed the install bug where by phpbb-recent-topics was confused with phpbb_recent_topics.
  • Sidebar Widget, yus for all you non-php people you have a widget to play with.
  • Edit the Time & Date layout – leave blank to remove it completely

The Installation

  • Unzip phpbb_recent_topics.tgz in your `/wp-content/plugins/` directory. (You’ll have a new directory, with this plugin in /wp-content/plugins/phpbb_recent_topics)
  • Activate the plugin through the ‘Plugins’ menu in WordPress
  • Configure the plugin, you need to tell wordpress about phpbb, this is done in the wordpress menu ‘Settings’ -> ‘phpBB Recent Topics’
    The following Settings are required:

    • * The name of your phpBB database (e.g phpbb)
    • * The name of the table where topics are held (the default is phpbb_topics )
    • * The full url of your forum for links (e.g. http://www.mydomain.com/forum)
    • * The number of topics to show. (If left blank you get 5)
    • * The Date Formatting, i.e. “d/M/y – g:i a” similar to the WordPress “General Settings”
  • Hit ‘Update Options”
  • To output the list of topics in a page or post…
    • * create a new page/post, type {phpbb_recent_topics} , hit ‘Publish’ or ‘Create new page’

    To output the list of topics in your theme sidebar using the widget…

    • * click “design” in the dashboard
    • * click “widgets”
    • * next to phpBB Recent Topics click “add”
    • * click “save changes”

    To output the list of topics in your theme sidebar using a template tag…

    • * edit sidebar.php and inside <div id=”sidebar”> type…
      <?php
      if (function_exists('phpbb_topics')) {
      phpbb_topics();
      }
      ?>

A bit about Database configuration.
If wordpress & phpBB share a DB already then set $PHPBBDB to DB_NAME and everything will be fine, else you’re going to need to GRANT the wordpress user read access to phpBB.

How to GRANT wordpress read only access to phpBB ?
If you don’t know it already you need to find your wordpress mysql user id, it’ll be in wp-config.php

define('DB_USER', 'wp_user');     // Your MySQL username

and you should have already found your phpbb database & table for the above.
You need to type the following syntax into your mysql database

GRANT SELECT ON phpbb_database.phpbb_topics TO wp_user@localhost;

this can be achieved by logging into phpmyadmin as your phpbb user, selecting SQL and pasting the correct GRANT into the text box.

Frequently Asked Questions

  • Is phpbb3 supported?
    • yes.
  • Can I output 10 Topics in my Page, and 3 Topics in my Sidebar ?
    • Yes ! In the WordPress menu ‘Options’ -> ‘phpBB Recent Topics’, set ‘The number of topics to show’ to 10, and then in your sidebar include…<?php
      if (function_exists(‘phpbb_topics’)) {
      phpbb_topics(3);
      }
      ?>
  • Can I exclude a certain forum from the list ?
    • In this version, the only way to do that is to hack /wp-content/plugins/phpbb_recent_topics/display/display.php, change
      $results = $wpdb->get_results("SELECT * FROM $TOPIC_TABLE ORDER BY topic_time DESC LIMIT $LIMIT");

      to

      $results = $wpdb->get_results("SELECT * FROM $TOPIC_TABLE WHERE forum_id != 1 ORDER BY topic_time DESC LIMIT $LIMIT");

      to exclude forum 1 from the list. I plan to setup a proper solution to this in the next version.

  • Why is the date config under settings not in the widget configuration?
    • The date settings effect both the template tag and the widget :)

Support
I’ve always been honest about support, there isn’t any. Basically I write this for my own needs and then publish it for you to use for free. You’re more than welcome to post comments here and if you tag wordpress forum posts with “phpbb-recent-topics” I’ll reply to you there, but we all have busy lives and I make no promises on how quickly I’ll reply to you.

Link for posting in the correct phpbb-recent-topics forum

Finally Subversion
You also might be interested to know that I’ve been getting to grips with the wordpress plug-ins svn, so you can get work directly from here; and when wordpress.org re-crawls my readme the latest version will also be available on wordpress.org/extend/plugins/ :cool:

Root Cookie for WP 2.6

UPDATE: This Plugin has been updated, please comment on the new post, thanks.

Thanks to Scott Kingsley Clark for giving me the kick I needed, but I’ve finally gotten around to updating my root Cookie plugin for WordPress, we’re now at Version 1.3 !!

The point of the plugin is to strip out the path from the cookie so that it can be referenced by other applications; wordpress 2.6 has a whole new cookie structure and this broke the old version, but I’ve been so swamped recently that it wasn’t maintained.

Scott is one of the very few nice people in the world who instead of grumbling offered up a patched plugin, actually I’ve done it a different way but I appreciate his support anyway.

You can download the plugin from wordpress.org, and there is a discussion forum to get community support.

Enjoy!

Missing argument 1 for phpbb_topics()

I thought I’d write a post about this error message as it’s pretty much the main reason that I ever receive comments or e-mails from the WordPress community. Sadly the complaints I receive from the community out weigh the complements, but I guess that’s life ;)

Thank you to all those who have downloaded and enjoyed my plug-in and all those who have taken to say something nice.

The problem with this error message Missing argument 1 for phpbb_topics() is that I don’t actually know how to fix it. If you look in the source code you’ll see that I’ve tried to trap “empty variables”…

if (is_null($LIMIT)) {
                $LIMIT = 5;
}

Now this approach seems to work on my server(s), and works for some people, but there are a number of people whom is doesn’t work for; unfortunately the majority of the WP community are no more technical than myself and I have never received any feedback on how to fix this.

I’m not a programmer, I’ve never claimed to be a PHP guru; as I don’t know how to fix this problem in the latest version of phpbb-recent-topics I tried to combat the problem by introducing a widget. The widget it aimed at people who don’t know php, it allows you to “drag” the list of recent topics into your sidebar, but for some reason people still prefer to edit their sidebar.php :confused:

I would to remind all readers that it quite clearly states on my announcement :

Support
I’ve always been honest about support, there isn’t any. Basically I write this for my own needs and then publish it for you to use for free. You’re more than welcome to post comments here and if you tag wordpress forum posts with “phpbb-recent-topics” I’ll reply to you there, but we all have busy lives and I make no promises on how quickly I’ll reply to you.

Currently the only solution I can offer to anyone suffering from this error message is to replace phpbb_topics() with phpbb_topics(”5″), if that doesn’t work then please accept my apologies.

If anyone would like to offer a patch for my plugin I would gladly include it and accredit appropriately.

Thanks for Reading!

Recent phpBB Topics on WordPress Plugin v0.4

UPDATE: This Plugin has been updated, please download the update from http://wordpress.org/extend/plugins/phpbb-recent-topics/, and please comment on the new post, thanks.

phpBB Recent Topics Admin interface in WordPress
Admin GUI

It’s been a year since the last release so perhaps this version should be called “about time!” v0.4 has primarily been released as a bugfix version, if you’re happy with v0.3 and have it running fine then don’t bother, in fact edit phpbb_recent_topics.php so that WordPress stops complaining about finding a newer version.

Download phpBB_Recent_Topics_0.4 from wordpress.org

What’s New?

  • Most importantly I have tested this plugin with phpBB3 and WP2.5 so I’ve updated the readme.txt to reflect this.
  • I finally quashed the install bug where by phpbb-recent-topics was confused with phpbb_recent_topics.
  • Sidebar Widget, yus for all you non-php people you have a widget to play with.
  • Edit the Time & Date layout – leave blank to remove it completely

What’s Old? – aka: Installation

  • Unzip phpbb_recent_topics.tgz in your `/wp-content/plugins/` directory. (You’ll have a new directory, with this plugin in /wp-content/plugins/phpbb_recent_topics)
  • Activate the plugin through the ‘Plugins’ menu in WordPress
  • Configure the plugin, you need to tell wordpress about phpbb, this is done in the wordpress menu ‘Settings’ -> ‘phpBB Recent Topics’
    The following Settings are required:

    • * The name of your phpBB database (e.g phpbb)
    • * The name of the table where topics are held (the default is phpbb_topics )
    • * The full url of your forum for links (e.g. http://www.mydomain.com/forum)
    • * The number of topics to show. (If left blank you get 5)
    • * The Date Formatting, i.e. “d/M/y – g:i a” similar to the WordPress “General Settings”
  • Hit ‘Update Options”
  • To output the list of topics in a page or post…
    • * create a new page/post, type {phpbb_recent_topics} , hit ‘Publish’ or ‘Create new page’

    To output the list of topics in your theme sidebar using the widget…

    • * click “design” in the dashboard
    • * click “widgets”
    • * next to phpBB Recent Topics click “add”
    • * click “save changes”

    To output the list of topics in your theme sidebar using a template tag…

    • * edit sidebar.php and inside <div id=”sidebar”> type…
      <?php
      if (function_exists('phpbb_topics')) {
      phpbb_topics();
      }
      ?>

A bit about Database configuration.
If wordpress & phpBB share a DB already then set $PHPBBDB to DB_NAME and everything will be fine, else you’re going to need to GRANT the wordpress user read access to phpBB.

How to GRANT wordpress read only access to phpBB ?
If you don’t know it already you need to find your wordpress mysql user id, it’ll be in wp-config.php

define('DB_USER', 'wp_user');     // Your MySQL username

and you should have already found your phpbb database & table for the above.
You need to type the following syntax into your mysql database

GRANT SELECT ON phpbb_database.phpbb_topics TO wp_user@localhost;

this can be achieved by logging into phpmyadmin as your phpbb user, selecting SQL and pasting the correct GRANT into the text box.

Frequently Asked Questions

  • Is phpbb3 supported?
    • yes.
  • Can I output 10 Topics in my Page, and 3 Topics in my Sidebar ?
    • Yes ! In the WordPress menu ‘Options’ -> ‘phpBB Recent Topics’, set ‘The number of topics to show’ to 10, and then in your sidebar include…<?php
      if (function_exists(‘phpbb_topics’)) {
      phpbb_topics(3);
      }
      ?>
  • Can I exclude a certain forum from the list ?
    • In this version, the only way to do that is to hack /wp-content/plugins/phpbb_recent_topics/display/display.php, change
      $results = $wpdb->get_results("SELECT * FROM $TOPIC_TABLE ORDER BY topic_time DESC LIMIT $LIMIT");

      to

      $results = $wpdb->get_results("SELECT * FROM $TOPIC_TABLE WHERE forum_id != 1 ORDER BY topic_time DESC LIMIT $LIMIT");

      to exclude forum 1 from the list. I plan to setup a proper solution to this in the next version.

  • Why is the date config under settings not in the widget configuration?
    • The date settings effect both the template tag and the widget :)

Support
I’ve always been honest about support, there isn’t any. Basically I write this for my own needs and then publish it for you to use for free. You’re more than welcome to post comments here and if you tag wordpress forum posts with “phpbb-recent-topics” I’ll reply to you there, but we all have busy lives and I make no promises on how quickly I’ll reply to you.

EDIT: Found a link for posting in the correct phpbb-recent-topics forum

Finally Subversion
You also might be interested to know that I’ve been getting to grips with the wordpress plug-ins svn, so you can get work directly from here; and when wordpress.org re-crawls my readme the latest version will also be available on wordpress.org/extend/plugins/ :cool:

Call to undefined function: register_sidebar_widget

So WP2.5 is out, and I figured it was about time I squashed that load bug on phpbb_recent_topics, while I’m at it I figure I’ll wigetize it.

The problem is that the example on the automattic site doesn’t actually work! If you paste…

function widget_myuniquewidget($args) {
    extract($args);
?>
        <?php echo $before_widget; ?>
            <?php echo $before_title
                . 'My Unique Widget'
                . $after_title; ?>
            Hello, World!
        <?php echo $after_widget; ?>
<?php
}
register_sidebar_widget('My Unique Widget','widget_myuniquewidget');

Into a blank plugin you get this in your logs…

PHP Fatal error:  Call to undefined function:  register_sidebar_widget()

Now I’ve not been bothered to dig out the exact reason why yet, something to do with the sidebar loading, but you need to wrap the whole lot up in an init function, so try this instead…

function widget_init_myuniquewidget() {
	// Check for required functions
	if (!function_exists('register_sidebar_widget'))
		return;

	function widget_myuniquewidget($args) {
	    extract($args);
	?>
	        <?php echo $before_widget; ?>
	            <?php echo $before_title
	                . 'My Unique Widget'
	                . $after_title; ?>
	            Hello, World!
	        <?php echo $after_widget; ?>
	<?php
	}
}

// Delay plugin execution until sidebar is loaded
add_action('widgets_init', 'widget_init_myuniquewidget');

I just need to work out now, how to add wiget options to the wp-admin panel and the next verions of my plugin will be done :)

PHP – Simple Validate E-Mail function.

I found this by accident, but thought it was useful to take a note as my regular expression knowledge is basic to say the least…


function ValidateEmail($e,$v=-1) {
global $verbose;
/*
Return codes:
0: appears to be a valid email
1: didn't match pattern of a valid email
*/
if ($v==-1) { $v=$verbose; }
if (!preg_match("/^[a-z0-9.+-_]+@([a-z0-9-]+(.[a-z0-9-]+)+)$/i", $e, $grab)) {
return 1;
}
return 0;
}

Usage is simple….


if(!(empty($_POST['email']))){
$email = ValidateEmail($_POST['email'],$v=-1);
}
// check E-Mail Syntax
if ($email == 1) {
echo "Incorrect Email Address Submitted.
";
}

Thanks Shane Marriott :)