How I have solved the “The plugin generated xxxx characters of unexpected output during activation” problem

Recently this problem troubled me a lot. All time I try to activate my plugin, I get the following error:

The plugin generated 1186 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

After several attempts of debugging, I failed to understand why it is coming. The mysterious thing was that, this error was not coming for all WordPress installations!

Today, I decided to read the core files those are responsible for activating and/or deactivating the plugins. When I was reading wp-admin/includes/plugin.php, I saw a action hook ‘activated_plugin’ is available just before throwing the error. I believed, if I monitor what is happening here, I can know the reason of the error. So I wrote a small function to save the errors like:

Continue reading →

How to avoid or skip Trash in WordPress

If you come to this post, it is highly possible that yo are already annoyed by the Trash feature of WordPress that was introduced in its version 2.9.

I personally find it very helpful in live sites but I believe no one than me is annoyed most by it on development site. However, WordPress is always sweet and its programmers has longer nose. So they put a configurable option to adjust it.

All you need is to add a line in wp-config.php file. You will need to add a constant like:

define('EMPTY_TRASH_DAYS', 0);

That’s it. The trash button from your WordPress will just elope and your old loving Delete button will come back:).

One more thing, by default WordPress keeps stuffs in trash for 30 days. So if you want to keep the posts in Trash for 3 days, write like:

define('EMPTY_TRASH_DAYS', 3);

Tips for WordPress Cron functions

WordPress provides some nice APIs for executing unattended scheduled tasks without relying on any external cron! Usually, we need to create a cron from our control panel / systems! However, if you implement built in cron features of WordPress, you gain better portability of your WordPress site!

However, it has a great limitation! This cron fully relies on site hits! WordPress triggers its cron functions after someone visits the site! When anyone visits your site, WP checks if any cron are supposed to be executed on or earlier of that moment! If no one visits your site, WordPress will fail to execute your tasks!

In this blog, I am going to show two tips that may be helpful while you work with wp-cron functions!

Continue reading →

Show RSS Feed within a WordPress Post – In Post RSS Feed plugin

This idea, showing a relevant RSS Feed at the end of the post, came to my mind day before yesterday. That time, I had to install the wp-exec plugin that can handle PHP codes inside the post. Using that, I have included an RSS Feed at the end of the post to show live contents from external site.

However, that is not suitable for all. All wordpress users don’t know PHP. Moreover, it is not simply process. if you make a syntax error, you take a lots of trouble. So, I thought, I will make it simple. And yes, the initial version is done. I have plan to release an low-cost premium version with many customizable features that I have in my mind.

How it works?

After you install the plugin, you configure it from WP-Admin -> Settings -> In Post RSS link and set the number of items to show and show/hide Feed Title that is given by you as you see in the screenshot below:

Continue reading →

Header Image Rotator for Twenty Ten theme of WordPress 3.0

WordPress 3.0 is still in RC1. I have already upgraded this blog to this version. I can’t but  simply love the new theme ‘Twenty Ten’ which is default in WordPress 3.0. It is super simple theme.

In this theme, there is option to use custom header image. From the admin panel you can select the header image. However, all of the default banners looked interesting to me and I have also uploaded some of my own shots. I wanted to show them all.

Keeping that in mind, I made this simple plugin, Twenty Ten Image Rotator. Having this plugin installed, you can show all images on the header. Single banner each selected randomly on each page load.

I believe if you love Twenty Ten theme, you will love this plugin too :).

Download from WordPress Plugin Repo