I am using WP v3.3.1, and I am trying to make a plugin. I have gotten it semi-working. It initiated, and add_action works, but for some reason my filters don't get triggered. When I googled around, I saw I was supposed to do it like this, but it is not working. I also tried including it outside of the class, which didn't work either. The error log is written to from the constructor, but not the xmlAddMethod
. I tested the xmlrpc call in a single file, and it worked, but having problems making classes.
//DOESN'T WORK HERE
add_filter( 'xmlrpc_methods', array( &$this, 'xmlAddMethod') );
class TargetDomain extends Domain
{
public function __construct()
{
error_log('TARGET: __construct');
//DOESN'T WORK HERE EITHER
add_filter( 'xmlrpc_methods', array( &$this, 'xmlAddMethod') );
parent::__construct();
}
function xmlAddMethod( $methods )
{
error_log('TARGET: xml_add_method');
$methods['myBlog.publishPost'] = 'publishMyPost';
return $methods;
}
Change this:
add_filter( 'xmlrpc_methods', array( &$this, 'xmlAddMethod') );
To:
add_filter( 'xmlrpc_methods', array( 'TargetDomain', 'xmlAddMethod') );
You can also use php's magic __CLASS__ constant.
add_filter( 'xmlrpc_methods', array( __CLASS__, 'xmlAddMethod') );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With