Hook params not defined within PHP class
-
Hi.
Firstly thanks for this plugin.
I’m developing a plugin for handling Paypal payments.
In the main plugin’s file i have code like this:require 'classes/class.server.php'; add_action('plugins_loaded', array('CRPP_IPN_Server_Class', 'init'));
and in the class.server.php I’ve set up code like this
class CRPP_IPN_Server_Class extends WP_Plugin_Class { /** * Class' instance * * @access public * @var class instance */ static $instance; /** * Init() * * Class' instance initialization * * @access public * @return instance * @author Raffaele Candeliere */ static function init() { is_null( self::$instance ) AND self::$instance = new self; return self::$instance; } /** * __construct() * * Class' constructor * * @access public * @return void * @author Raffaele Candeliere */ function __construct() { /* . . . */ add_action( 'paypal_ipn_for_wordpress_payment_status_completed', array($this, 'ipn_payment_status_confirmed_handler'), 10, 1); } public function ipn_payment_status_confirmed_handler($posted) { error_log(var_export($posted, true)); }
Well, the problem is that if I define the hook like this, the $posted parameter doesn’t get populated. I do receive the notification but the $posted var is empty.
Viceversa, if i hook into your plugin directly in my main’s plugin file, like this:add_action('plugins_loaded', 'crpp_init'); function crpp_init() { add_action( 'paypal_ipn_for_wordpress_payment_status_completed', 'crpp_ipn_payment_satus_confirmed', 10, 1); } function crpp_ipn_payment_satus_confirmed($posted) { error_log(var_export($posted, true)); }
then the $posted param is populated!
I’d like to stick with my (standardized) programming pattern where i confine each functional block of code in the relevant class.
What am I doing wrong in using/registering, calling your hook?
Thanks
- The topic ‘Hook params not defined within PHP class’ is closed to new replies.