WP E-commerce coolness

I was pretty damn pleased with myself this week when I managed to track down a performance error that’s been causing everyone using Instinct‘s e-commerce plugin gray hair for some time now. Lucky for me the first plugin I wrote (which I’ve yet to polish and publish), I based on this plugin (as I had no clue about how to go about writing a plugin), and ran into the same problem. Eventually, whilst working on the survey plugin (which I’ve yet to polish and publish ;P) I came across the solution, although I didn’t realize at the time that this would also help with the e-commerce plugin.

So this week Ashley was pulling out his hair due to the fact that the plugin was causing the latest fossil-line (that’s worse than a deadline) project to constantly crash and asked me to have a look. After buggering about for a while I suddenly remembered what I described above, implemented it, and suddenly it was all better! Pretty cool huh?

Well, everyone else thought so too (he says modestly).

So here’s the solution for all those who have been salivating for it whilst having to read through all my crap :

search for

add_action(‘init’, ‘nzshpcrt_install’);

and

add_action(‘init’, ‘wpsc_auto_update’);

and replace it with

register_activation_hook(__FILE__, ‘nzshpcrt_install’);

and

register_activation_hook(__FILE__, ‘wpsc_auto_update’);

respectively.

Alternatively, although I’ve not tested this, I think the if statement is just seriously flawed and should look like this:

if(isset($_GET['activate']) && ($_GET['activate'] == 'true')) {
	if(($current_version_number < WPSC_VERSION ) || (($current_version_number == WPSC_VERSION ) && (get_option('wpsc_minor_version') <= WPSC_MINOR_VERSION))) {
		include_once("install_and_update.php");
		add_action('init', 'wpsc_auto_update');
	} else {
		include_once("install_and_update.php");
		add_action('init', 'nzshpcrt_install');
	}
}

In the event of using this if statement either register_activation_hook or add_action('init',...) should work fine.

Enjoy!

Comments are closed.

Archives