[wp-hackers] Classipress 3.3 custom payment gateway plugin error

team at sdv.com.ua team at sdv.com.ua
Thu Aug 15 18:32:37 UTC 2013


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



More information about the wp-hackers mailing list