File: /home/slfopp7cb1df/www/home/wp-content/plugins/mailoptin/src/connections/SendFoxConnect/Connect.php
<?php
namespace MailOptin\SendFoxConnect;
use MailOptin\Core\Connections\ConnectionInterface;
class Connect extends AbstractSendFoxConnect implements ConnectionInterface
{
/**
* @var string key of connection service. its important all connection name ends with "Connect"
*/
public static $connectionName = 'SendFoxConnect';
public function __construct()
{
ConnectSettingsPage::get_instance();
add_filter('mailoptin_registered_connections', array($this, 'register_connection'));
parent::__construct();
}
public static function features_support()
{
return [
self::OPTIN_CAMPAIGN_SUPPORT
];
}
/**
* Register Constant Contact Connection.
*
* @param array $connections
*
* @return array
*/
public function register_connection($connections)
{
$connections[self::$connectionName] = __('SendFox', 'mailoptin');
return $connections;
}
/**
* Replace placeholder tags with actual SendFox tags.
*
* {@inheritdoc}
*/
public function replace_placeholder_tags($content, $type = 'html')
{
return [];
}
/**
* {@inherit_doc}
*
* Return array of email list
*
* @return mixed
*/
public function get_email_list()
{
try {
$response = $this->sendfox_instance()->make_request('lists');
$response = $response['body'];
$lists_array = [];
if (isset($response['data']) && is_array($response['data'])) {
foreach ($response['data'] as $list) {
$lists_array[$list['id']] = $list['name'];
}
}
return $lists_array;
} catch (\Exception $e) {
self::save_optin_error_log($e->getMessage(), 'sendfox');
return [];
}
}
/**
* {@inherit_doc}
*
* Return array of email list
*
* @return mixed
*/
public function get_optin_fields($list_id = '')
{
return [];
}
/**
*
* {@inheritdoc}
*
* @param int $email_campaign_id
* @param int $campaign_log_id
* @param string $subject
* @param string $content_html
* @param string $content_text
*
* @return array
* @throws \Exception
*
*/
public function send_newsletter($email_campaign_id, $campaign_log_id, $subject, $content_html, $content_text)
{
return [];
}
/**
* @param string $email
* @param string $name
* @param string $list_id ID of email list to add subscriber to
* @param mixed|null $extras
*
* @return mixed
*/
public function subscribe($email, $name, $list_id, $extras = null)
{
return (new Subscription($email, $name, $list_id, $extras))->subscribe();
}
/**
* Singleton poop.
*
* @return Connect|null
*/
public static function get_instance()
{
static $instance = null;
if (is_null($instance)) {
$instance = new self();
}
return $instance;
}
}