Tag "PHP"

Among many new excit­ing fea­tures, Word­Press 2.6 released the abil­ity to store each and every revi­sion of your posts, like an elab­o­rate update his­tory. Now this can be a pretty use­ful fea­ture if you are only mak­ing sub­stan­tive changes to your arti­cles, but if you change a "the" or a prepo­si­tion, this can be overkill.

The sug­gested workaround to dis­able this revi­sion func­tion is to enter a vari­able in your wp_config.php file. But this takes away the func­tion­al­ity from the entire blog.

Revision Control plugin for WordPress

Revi­sion Con­trol plu­gin for WordPress

I dis­cov­ered a superb plu­gin today that makes this process very sim­ple. It allows you to define the set­ting from the Word­Press amin­is­tra­tion inter­face on a Global basis. That is, to

  • Dis­able All revi­sions for all posts/pages
  • And over­ride on a per-page/post basis.

For exam­ple, I can set Revi­sions to Dis­abled glob­ally, and then enable it to store say 5 revi­sions for a Spe­cific page(Without affect­ing any other pages).

You'll find some Info ( & Down­load link) on it here:

This is not MU com­pat­i­ble yet (untested).

Read More

Sim­ple lit­tle trick to get to the lat­est version.

Most Cpanel/WHM servers come with PHP and Zend installed. With the recent (and impor­tant) update of PHP 5.2.1, the Zend Opti­mizer that is installed by default (ver­sion 3.0.1 as of this writ­ing) breaks.

You might begin to see a mes­sage like this:

[26-Apr-2007 10:32:49] PHP Warn­ing: Zend Opti­mizer does not sup­port this ver­sion of PHP — please upgrade to the lat­est ver­sion of Zend Opti­mizer in Unknown on line

To fix this, sim­ply login to your SSH as root and exe­cute the fol­low­ing com­mand to upgrade Zend Optimiser:

/scripts/installzendopt 3.2.8

Note that if you skip the ver­sion num­ber, Zend Opti­mizer 3.0.1 will be installed by default. The trick is to spec­ify the ver­sion as above. This will also work in the future, so as long as you know the lat­est released ver­sion of Zend Opti­mizer, just replace the red text above with that number.

Read More

Here is some sam­ple code that allows you to cre­ate a thumb­nail auto­mat­i­cally (assum­ing ImageMag­ick is already installed and func­tional) (based on the imag­ick PEAR module).

Code for dynamic thumb­nails using PHP


// Specify your file details
$current_file = 'image.jpg';
$max_width = '150';

// Get the current info on the file
$current_size = getimagesize($current_file);
$current_img_width = $current_size[0];
$current_img_height = $current_size[1];
$image_base = explode('.', $current_file);

// This part gets the new thumbnail name
$image_basename = $image_base[0];
$image_ext = $image_base[1];
$thumb_name = $image_basename.'-th.'.$image_ext;

// Determine if the image actually needs to be resized
// and if it does, get the new height for it
if ($current_img_width > $max_width)
$too_big_diff_ratio = $current_img_width/$max_width;
$new_img_width = $max_width;
$new_img_height = round($current_img_height/$too_big_diff_ratio);
// Convert the file
$make_magick = system("convert -geometry $new_img_width x $new_img_height $current_file $thumb_name", $retval);
// Did it work?
if (!($retval)) {
echo 'Thumbnail created: <img src="/' .$thumb_name .'">';
else {
echo 'Error: Please try again.';
echo 'No need to resize.';


Read More