| Enfernikus |
10-27-2008 09:24 PM |
Simple Wordpress plugin for developers
Well I run a blog to talk about things php and my life and views and such things and I sometimes can't be arsed to write a hyperlink to a function on php, so I wrote a quick plugin to do it for me. Thought someone might find it useful.
PHP Code:
<?php
/*
**************************************************************************
Plugin Name: PHPFunctionsToLinks Version: 1.0 Description: For developer's blogs, it turns [function]strstr()[/function] into a hyper link onto php.net's site
**************************************************************************
*/ class BBToPHPLinks { function BBToPHPLinks() { add_action( 'the_content', array(&$this, 'ParseBB') ); } function ParseBB( $content ) { //First check to see if there IS BBCode to parse if( !(stristr($content, '[function]') && stristr($content, '[/function]')) ) { return $content; } //There is BBCode, parse it all out and return return preg_replace('/\[function\](.*?)\[\\/function\]/si', '<a href="http://php.net/$1">$1</a>', $content); } }
$BBToPHPLinks = new BBToPHPLinks();
?>
|