WordPress Template Modification Tips for Non-Programmers - RobustnessDecember 27th, 2005 Several WordPress plugins ask you to add certain code to the WordPress theme template files to make them work. If you are not a PHP developer or you don't have time to code review the plugin and you decide to activate the plugin then the plugin can very easily cause your site to crash or worse.
How To Add Functions To Javascript onload Over Third Party Scripts; Playing NiceFebruary 7th, 2007 As a javascript developer using onload often you will find that other script authors too love to use onload. Unfortunately onload accepts a function name and your reassigning will prevent others from using onload.
One Reason Why WordPress Plugin Activation Causes Fatal ErrorJanuary 29th, 2008 When you declare a function in your plugin code which has already been declared previously in either WordPress code or in one of the plugins. To prevent this you should declare your functions like this:
if(!function_exists('your_function_name')) {
function your_function_name() {
//....
Little Painful Javascript QuirkMay 14th, 2006 Why doesn't document.getElementById('location').value work as function parameter in Javascript?
What does work is:
var temp = document.getElementById('location');
temp.value works fine as function parameter. Apparently javascript doesn't like referencing fields directly on functions as in getElementById('location').value as a function parameter.
How To Process MySQL Timestamp in PHPMay 27th, 2006 Many of us do not realize that MySQL's Timestamp is not the timestamp which PHP date() understands. In fact if you try to use MySQL timestamp directly in php date() function then you will get totally wrong dates.
WordPress WYSIWYG Editor is a DisasterSeptember 3rd, 2006 I just had quite some experience using WordPress 2.x's new WYSIWYG editor based on Tiny MCE, while publishing documentation for 3 column Anaconda Theme for WordPress. Two word summary of WYSIWYG editor: it sucks.
Post Processing Limitations in PHPSeptember 18th, 2005 In PHP you can register a function to be executed when script processing is complete using register_shutdown_function. In PHP 4.0.6 and below the registered shutdown functions are called after the request has been completed, including sending any output buffers.
How To Debug Execution Path in PHP...Equivalent of printStackTrace() in JavaMarch 1st, 2007 While programming in PHP often you will find that a simple echo or log statement is not sufficient. You have found out where a problem is happening but you have no clue why it is executing that code in the first place.
How To Use SAJAX (AJAX Framework) from HTMLMay 15th, 2006 Sajax is an useful ajax framework to simplify ajax based development for languages like PHP, Ruby etc. Not many realize Sajax can be used equally well from plain old html pages (as in .html or .htm).
Mambo / Joomla Password - How to Reset / RecoverMarch 2nd, 2006 Mambo / Joomla passwords cannot be recovered as they are set using a one-way hash function (MD5). However they can be reset to new values.
Developing Clean AJAX / Javascript Driven Websites; Say No To Tag-SoupNovember 13th, 2005 Behaviour promotes itself as "the missing link for your AJAX apps". It allows you to use CSS selectors (like id or class) to apply Javascript behaviors to your HTML elements.
SAJAXian QuirkMay 14th, 2006 Playing with SAJAX (AJAX framework for php, ruby etc.) I found an interesting quirk. Keep this in mind while using SAJAX (unless you have already found it (or want to find) the hard way).
How To Get Subversion Revision ID From PHPJanuary 24th, 2007 First of all identify the file(s) for which you want to know the revision number from PHP. Then add a property to the file as follows:
svn propset svn:keywords Revision file_name.php
Now add the following function within php blocks:
/** Returns revision number */
function getSCID() {
$svnid = '$Rev: 43 $';
$scid = substr($svnid, 6);
return intval(substr($scid, 0, strlen($scid) - 2));
}
You can now access the revision number of this file from PHP by calling getSCID().
How To Add Trim Functionality To Javascript StringAugust 12th, 2007 Trim is a useful function available in languages like Java & PHP which removes the leading and traling whitespace(s) from a String. Unfortunately Javascript doesn't natively provide trim functionality to the String object.
How To Accept Multiple Parameters in WordPress FiltersApril 15th, 2006 This is for WordPress Plugin and Theme developers. Don't read further if you are not one of them.
March 14th, 2009 at 6:08 pm
This works good for me, returns a string of 1000 characters separated by an underscore, more then enough to work with.
$text = file_get_contents($url);$text = strtolower($text);
$text = preg_replace(
array(
'@]*?>.*?@siu',
'@]*?>.*?@siu’,
‘@]*?>.*?@siu’,
‘@]*?>.*?@siu’,
‘@]*?>.*?@siu’,
‘@]*?>.*?@siu’,
‘@]*?>.*?@siu’,
‘@]*?>.*?@siu’,
‘@]*?.*?@siu’,
‘@]*?.*?@siu’,
‘@]*?.*?@siu’,
‘@]*?.*?@siu’,
‘@]*?.*?@siu’,
‘@]*?.*?@siu’,
‘@]*?.*?@siu’,
),
array(
‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘,
‘ ‘,’ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘),
$text );
$text = strip_tags($text);
$text = preg_replace(’/[^0-9^a-z^A-Z^]/’, ‘ ‘, $text);
$parts = explode(’ ‘,$text);
$unique = array_unique($parts);
$str = implode(’_',$unique);
$str = substr($str, 0, 1000);
echo $str;