I'm trying to write a plugin and I'm trying to define an API key and initiate a new class that my other functions can use. I want this to be initiated all the time (even after my plugin is already registered). I tried the following code:
if ( !class_exists( 'Mailchimp' ) )
{
require_once 'src/Mailchimp.php';
}
function init() {
$apiKey = '1234';
$api = new Mailchimp( $apiKey );
}
However, I have another function later that looks like this:
function rb_mailchimp_options() {
$types = array('user'=>true, 'base'=>true);
$filters = array('include_inactive'=>true, 'include_drag_and_drop'=>true);
$templates = $api->templates->getList($filters);
}
I'm getting an error message because it's saying Call to a member function getList() on a non-object so it doesn't recognize the $api variable that I tried to initialize earlier. Any suggestions would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire