public static function uninstall() { //loading data lib require_once self::get_base_path() . "/data.php"; if (!GFMailChimp::has_access("gravityforms_mailchimp_uninstall")) { die(__("You don't have adequate permission to uninstall MailChimp Add-On.", "gravityformsmailchimp")); } //droping all tables GFMailChimpData::drop_tables(); //removing options delete_option("gf_mailchimp_settings"); delete_option("gf_mailchimp_version"); //Deactivating plugin $plugin = "gravityformsmailchimp/mailchimp.php"; deactivate_plugins($plugin); update_option('recently_activated', array($plugin => time()) + (array) get_option('recently_activated')); }
private function get_api() { if (self::$api) { return self::$api; } $settings = $this->get_plugin_settings(); $api = null; if (!empty($settings['apiKey'])) { if (!class_exists('Mailchimp')) { require_once 'api/Mailchimp.php'; } $apikey = $settings['apiKey']; $this->log_debug(__METHOD__ . '(): Retrieving API Info for key ' . $apikey); try { $api = new Mailchimp(trim($apikey), null); } catch (Exception $e) { $this->log_error(__METHOD__ . '(): Failed to set up the API.'); $this->log_error(__METHOD__ . '(): ' . $e->getCode() . ' - ' . $e->getMessage()); return null; } } else { $this->log_debug(__METHOD__ . '(): API credentials not set.'); return null; } if (!is_object($api)) { $this->log_error(__METHOD__ . '(): Failed to set up the API.'); return null; } $this->log_debug(__METHOD__ . '(): Successful API response received.'); self::$api = $api; return self::$api; }
function gf_mailchimp() { return GFMailChimp::get_instance(); }
private function addGFEntry($leadUserInfo, $gFormId) { // add entry $entry = array("form_id" => $gFormId); foreach ($leadUserInfo['field_data'] as $leadField) { if (null != ($mappedFieldId = $this->getMappedFieldId($leadField['name'], $gFormId))) { $entry[$mappedFieldId] = $leadField['values'][0]; } } // Adding hidden fields with default values presented $gfForm = GFAPI::get_form($gFormId); if (!empty($gfForm['fields'])) { foreach ($gfForm['fields'] as $field) { if ($field->type == 'hidden' && $field->defaultValue != '') { $entry[$field->id] = $field->defaultValue; } } } $entryId = GFAPI::add_entry($entry); // Force trigger MailChimp plugin if (class_exists('GFMailChimp')) { $mailchimp = GFMailChimp::get_instance(); $gfForm = GFAPI::get_form($gFormId); $mailchimp->maybe_process_feed($entry, $gfForm); } // Force trigger Zapier plugin if (class_exists('GFZapier')) { $gfForm = GFAPI::get_form($gFormId); GFZapier::send_form_data_to_zapier($entry, $gfForm); } // send notifications $this->sendNotifications($gFormId, $entryId); }