[wp-hackers] register_activation_hook() problem
Chris Jean
gaarai at gaarai.com
Tue Jul 28 15:54:43 UTC 2009
Your error is caused by the fact that the thumbs_install function is
being redeclared, not by your use of the global declaration. You can
only define a function once, attempting to do so again will result in an
error.
Chris Jean
http://gaarai.com/
http://wp-roadmap.com/
http://dnsyogi.com/
Adam Taylor wrote:
> On Tue, Jul 28, 2009 at 2:55 PM, Jennifer Hodgdon <yahgrp at poplarware.com>wrote:
>
>
>> Austin Matzko wrote:
>> It is definitely true that you need the global declaration inside your
>> function. But specifically for activation, you may need to also leave the
>> global declaration outside the function block as well. I've run into
>> problems with activation in WP, and needed to do things like this in the
>> main body of the plugin:
>> global $wpdb;
>> global $mymodulevariable = 12234;
>> in order to get activation functions to work correctly.
>>
>> --Jennifer
>>
>>
>
> I've tried:
>
> global $thumbs;
> $thumbs = new ThumbsUp();
>
> function thumbs_install() {
>
> //$thumbs = new ThumbsUp();
> $thumbs->installThumbsUp();
> }
>
> global $thumbs;
>
> function thumbs_install() {
>
> $thumbs = new ThumbsUp();
> $thumbs->installThumbsUp();
> }
>
> And
>
>
> function thumbs_install() {
>
> global $thumbs;
>
> $thumbs = new ThumbsUp();
> $thumbs->installThumbsUp();
> }
>
> And they *all* produce the same error:
>
> *Fatal error*: Cannot redeclare thumbs_install() (previously declared in
> /dev/site/wp-content/plugins/thumbs-up/thumbs-up.php:163) in *
> /dev/site/wp-content/plugins/thumbs-up/thumbs-up.php* on line *164*
>
> Saying that it does still activate the plugin.
>
More information about the wp-hackers
mailing list