Classipress 3.3 custom payment gateway plugin error

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Classipress 3.3 custom payment gateway plugin error

team
Hi all

I have written a custom gateway plugin for WP 3.6.
I followed instructions on the article
http://docs.appthemes.com/developers/creating-a-payment-gateway/

So my-plugin-gateway.php is:

//-------------
class My_Gateway extends APP_Gateway{
 

}
appthemes_register_gateway( 'My_Gateway' );
//--------------

and my-plugin.php is :

//--------------
add_action( 'init', 'my_plugin_setup' );
function my_plugin_setup(){
    include 'my-plugin-gateway.php';
}
//--------------

Pretty simple, yeah?

But when I tried to install it or use it I got the following error:
Fatal error: Class 'APP_Gateway' not found in my-plugin-gateway.php

I solved it by adding the following to the top of the
my-plugin-gateway.php :

require_once ABSPATH . 'wp-content/themes/classipress/includes/payments/gateways/gateway-class.php';
require_once ABSPATH . 'wp-content/themes/classipress/includes/payments/gateways/boomerang-class.php';
require_once ABSPATH . 'wp-content/themes/classipress/includes/payments/gateways/gateway-registry.php';
require_once ABSPATH . 'wp-content/themes/classipress/includes/payments/gateways/gateway-functions.php';

But after that I got the following error:

Fatal error: Cannot redeclare class APP_Gateway in wp-content\themes\classipress\includes\payments\gateways\gateway-class.php on line 6

To fix it I had to replace in the file
wp-content\themes\classipress\includes\payments\load.php the
following code on line 43

/// Gateways
require dirname( __FILE__ ) . '/gateways/gateway-class.php';
require dirname( __FILE__ ) . '/gateways/boomerang-class.php';
require dirname( __FILE__ ) . '/gateways/gateway-registry.php';
require dirname( __FILE__ ) . '/gateways/gateway-functions.php';

to this one:

/// Gateways
require_once dirname( __FILE__ ) . '/gateways/gateway-class.php';
require_once dirname( __FILE__ ) . '/gateways/boomerang-class.php';
require_once dirname( __FILE__ ) . '/gateways/gateway-registry.php';
require_once dirname( __FILE__ ) . '/gateways/gateway-functions.php';

I wonder if I did the right thing. Maybe there is some other way to
avoid those errors without having to modify classipress core?

Thank you!


Best regards

Taras

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Classipress 3.3 custom payment gateway plugin error

Andrew Bartel
Did you put the comments that declare the plugin in my-plugin-gateway.php
or my-plugin.php?  According to the docs I believe you need it in
my-plugin.php.  Whatever file the plugin declaration is in is loaded by
WordPress, so if that's your gateway file, that class will be included,
throwing the error.

-Andrew


On Thu, Aug 15, 2013 at 11:32 AM, <[hidden email]> wrote:

> Hi all
>
> I have written a custom gateway plugin for WP 3.6.
> I followed instructions on the article
> http://docs.appthemes.com/developers/creating-a-payment-gateway/
>
> So my-plugin-gateway.php is:
>
> //-------------
> class My_Gateway extends APP_Gateway{
>
>
> }
> appthemes_register_gateway( 'My_Gateway' );
> //--------------
>
> and my-plugin.php is :
>
> //--------------
> add_action( 'init', 'my_plugin_setup' );
> function my_plugin_setup(){
>     include 'my-plugin-gateway.php';
> }
> //--------------
>
> Pretty simple, yeah?
>
> But when I tried to install it or use it I got the following error:
> Fatal error: Class 'APP_Gateway' not found in my-plugin-gateway.php
>
> I solved it by adding the following to the top of the
> my-plugin-gateway.php :
>
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/gateway-class.php';
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/boomerang-class.php';
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/gateway-registry.php';
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/gateway-functions.php';
>
> But after that I got the following error:
>
> Fatal error: Cannot redeclare class APP_Gateway in
> wp-content\themes\classipress\includes\payments\gateways\gateway-class.php
> on line 6
>
> To fix it I had to replace in the file
> wp-content\themes\classipress\includes\payments\load.php the
> following code on line 43
>
> /// Gateways
> require dirname( __FILE__ ) . '/gateways/gateway-class.php';
> require dirname( __FILE__ ) . '/gateways/boomerang-class.php';
> require dirname( __FILE__ ) . '/gateways/gateway-registry.php';
> require dirname( __FILE__ ) . '/gateways/gateway-functions.php';
>
> to this one:
>
> /// Gateways
> require_once dirname( __FILE__ ) . '/gateways/gateway-class.php';
> require_once dirname( __FILE__ ) . '/gateways/boomerang-class.php';
> require_once dirname( __FILE__ ) . '/gateways/gateway-registry.php';
> require_once dirname( __FILE__ ) . '/gateways/gateway-functions.php';
>
> I wonder if I did the right thing. Maybe there is some other way to
> avoid those errors without having to modify classipress core?
>
> Thank you!
>
>
> Best regards
>
> Taras
>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Classipress 3.3 custom payment gateway plugin error

Nikola Nikolov
In reply to this post by team
Hi Taras,

I don't have the Classipress theme, so I can't actually look in the source
code, but I can take a guess here:

#1 Add a priority to your add_action call, like so:
add_action( 'init', 'my_plugin_setup', 1000 );

#2 If that doesn't work for you, try changing 'init' to one of the other
action hooks described here -
http://codex.wordpress.org/Plugin_API/Action_Reference

That's as far as I my guesses go. I simply assume that the gateway class is
initialized(included) later on compared to when your my_plugin_setup()
function is being called.

Nikola


On Thu, Aug 15, 2013 at 9:32 PM, <[hidden email]> wrote:

> Hi all
>
> I have written a custom gateway plugin for WP 3.6.
> I followed instructions on the article
> http://docs.appthemes.com/developers/creating-a-payment-gateway/
>
> So my-plugin-gateway.php is:
>
> //-------------
> class My_Gateway extends APP_Gateway{
>
>
> }
> appthemes_register_gateway( 'My_Gateway' );
> //--------------
>
> and my-plugin.php is :
>
> //--------------
> add_action( 'init', 'my_plugin_setup' );
> function my_plugin_setup(){
>     include 'my-plugin-gateway.php';
> }
> //--------------
>
> Pretty simple, yeah?
>
> But when I tried to install it or use it I got the following error:
> Fatal error: Class 'APP_Gateway' not found in my-plugin-gateway.php
>
> I solved it by adding the following to the top of the
> my-plugin-gateway.php :
>
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/gateway-class.php';
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/boomerang-class.php';
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/gateway-registry.php';
> require_once ABSPATH .
> 'wp-content/themes/classipress/includes/payments/gateways/gateway-functions.php';
>
> But after that I got the following error:
>
> Fatal error: Cannot redeclare class APP_Gateway in
> wp-content\themes\classipress\includes\payments\gateways\gateway-class.php
> on line 6
>
> To fix it I had to replace in the file
> wp-content\themes\classipress\includes\payments\load.php the
> following code on line 43
>
> /// Gateways
> require dirname( __FILE__ ) . '/gateways/gateway-class.php';
> require dirname( __FILE__ ) . '/gateways/boomerang-class.php';
> require dirname( __FILE__ ) . '/gateways/gateway-registry.php';
> require dirname( __FILE__ ) . '/gateways/gateway-functions.php';
>
> to this one:
>
> /// Gateways
> require_once dirname( __FILE__ ) . '/gateways/gateway-class.php';
> require_once dirname( __FILE__ ) . '/gateways/boomerang-class.php';
> require_once dirname( __FILE__ ) . '/gateways/gateway-registry.php';
> require_once dirname( __FILE__ ) . '/gateways/gateway-functions.php';
>
> I wonder if I did the right thing. Maybe there is some other way to
> avoid those errors without having to modify classipress core?
>
> Thank you!
>
>
> Best regards
>
> Taras
>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Classipress 3.3 custom payment gateway plugin error

team
Hi Nikola

The first guess is the right one, thank you! :)
I tried it before. But it have worked only after I removed
plugin completely, reloaded WP and then replaced the code with

add_action( 'init', 'online_naira_setup', 1000 );

Thanks a lot!


NN> Hi Taras,

NN> I don't have the Classipress theme, so I can't actually look in the source
NN> code, but I can take a guess here:

NN> #1 Add a priority to your add_action call, like so:
NN> add_action( 'init', 'my_plugin_setup', 1000 );

NN> #2 If that doesn't work for you, try changing 'init' to one of the other
NN> action hooks described here -
NN> http://codex.wordpress.org/Plugin_API/Action_Reference

NN> That's as far as I my guesses go. I simply assume that the gateway class is
NN> initialized(included) later on compared to when your my_plugin_setup()
NN> function is being called.

NN> Nikola


NN> On Thu, Aug 15, 2013 at 9:32 PM, <[hidden email]> wrote:

>> Hi all
>>
>> I have written a custom gateway plugin for WP 3.6.
>> I followed instructions on the article
>> http://docs.appthemes.com/developers/creating-a-payment-gateway/
>>
>> So my-plugin-gateway.php is:
>>
>> //-------------
>> class My_Gateway extends APP_Gateway{
>>
>>
>> }
>> appthemes_register_gateway( 'My_Gateway' );
>> //--------------
>>
>> and my-plugin.php is :
>>
>> //--------------
>> add_action( 'init', 'my_plugin_setup' );
>> function my_plugin_setup(){
>>     include 'my-plugin-gateway.php';
>> }
>> //--------------
>>
>> Pretty simple, yeah?
>>
>> But when I tried to install it or use it I got the following error:
>> Fatal error: Class 'APP_Gateway' not found in my-plugin-gateway.php
>>
>> I solved it by adding the following to the top of the
>> my-plugin-gateway.php :
>>
>> require_once ABSPATH .
>> 'wp-content/themes/classipress/includes/payments/gateways/gateway-class.php';
>> require_once ABSPATH .
>> 'wp-content/themes/classipress/includes/payments/gateways/boomerang-class.php';
>> require_once ABSPATH .
>> 'wp-content/themes/classipress/includes/payments/gateways/gateway-registry.php';
>> require_once ABSPATH .
>> 'wp-content/themes/classipress/includes/payments/gateways/gateway-functions.php';
>>
>> But after that I got the following error:
>>
>> Fatal error: Cannot redeclare class APP_Gateway in
>> wp-content\themes\classipress\includes\payments\gateways\gateway-class.php
>> on line 6
>>
>> To fix it I had to replace in the file
>> wp-content\themes\classipress\includes\payments\load.php the
>> following code on line 43
>>
>> /// Gateways
>> require dirname( __FILE__ ) . '/gateways/gateway-class.php';
>> require dirname( __FILE__ ) . '/gateways/boomerang-class.php';
>> require dirname( __FILE__ ) . '/gateways/gateway-registry.php';
>> require dirname( __FILE__ ) . '/gateways/gateway-functions.php';
>>
>> to this one:
>>
>> /// Gateways
>> require_once dirname( __FILE__ ) . '/gateways/gateway-class.php';
>> require_once dirname( __FILE__ ) . '/gateways/boomerang-class.php';
>> require_once dirname( __FILE__ ) . '/gateways/gateway-registry.php';
>> require_once dirname( __FILE__ ) . '/gateways/gateway-functions.php';
>>
>> I wonder if I did the right thing. Maybe there is some other way to
>> avoid those errors without having to modify classipress core?
>>
>> Thank you!
>>
>>
>> Best regards
>>
>> Taras
>>
>> _______________________________________________
>> wp-hackers mailing list
>> [hidden email]
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
NN> _______________________________________________
NN> wp-hackers mailing list
NN> [hidden email]
NN> http://lists.automattic.com/mailman/listinfo/wp-hackers



Best regards

Taras

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Classipress 3.3 custom payment gateway plugin error

bnimbhal
This post has NOT been accepted by the mailing list yet.
In reply to this post by team
Hi,

WP theme companies are not provide good support now a days.

I am running a job website (http://questionpaper.org) and running jobrooler theme of appthemes, few days back i have created a ticket and many customers are also facing the same problem but even after 1 week still no solution.

If you are planing to purchase any theme form appthemes then plz check their support forum first.

Thanks