PHP Class MC4WP_MailChimp

Exibir arquivo Open project: dannyvankooten/mailchimp-for-wordpress Class Usage Examples

Public Properties

Property Type Description
$api MC4WP_API_v3
$error_code string
$error_message string

Public Methods

Method Description
__construct ( ) MC4WP_MailChimp constructor.
empty_cache ( ) Empty the Lists cache
fetch_lists ( ) : array
get_cached_lists ( boolean $force = false ) : array Get MailChimp lists from cache.
get_error_code ( ) : string
get_error_message ( ) : string
get_list ( integer $list_id ) : MC4WP_MailChimp_List Get a given MailChimp list
get_lists ( ) : array Get MailChimp lists, from cache or remote API.
get_subscriber_count ( array | string $list_ids ) : integer Returns number of subscribers on given lists.
get_subscriber_counts ( ) : array Get an array of list_id => number of subscribers
has_error ( ) : boolean
list_has_subscriber ( string $list_id, string $email_address ) : boolean Checks if an email address is on a given list with status "subscribed"
list_subscribe ( string $list_id, string $email_address, array $args = [], boolean $update_existing = false, boolean $replace_interests = true ) : object TODO: Force re-sending double opt-in email by deleting pending subscribers from list first.
list_unsubscribe ( string $list_id, string $email_address ) : boolean
reset_error ( ) Resets error properties.

Private Methods

Method Description
fetch_list ( string $list_id ) : MC4WP_MailChimp_List

Method Details

__construct() public method

MC4WP_MailChimp constructor.
public __construct ( )

empty_cache() public method

Empty the Lists cache
public empty_cache ( )

fetch_lists() public method

public fetch_lists ( ) : array
return array

get_cached_lists() public method

Get MailChimp lists from cache.
public get_cached_lists ( boolean $force = false ) : array
$force boolean Force a result, by hitting remote API.
return array

get_error_code() public method

public get_error_code ( ) : string
return string

get_error_message() public method

public get_error_message ( ) : string
return string

get_list() public method

Get a given MailChimp list
public get_list ( integer $list_id ) : MC4WP_MailChimp_List
$list_id integer
return MC4WP_MailChimp_List

get_lists() public method

The following data sources are tried in the following order. - Transient Cache (5 days) - Remote MailChimp API - Option Cache (forever)
public get_lists ( ) : array
return array

get_subscriber_count() public method

Returns number of subscribers on given lists.
public get_subscriber_count ( array | string $list_ids ) : integer
$list_ids array | string Array of list ID's, or single string.
return integer Total # subscribers for given lists.

get_subscriber_counts() public method

Get an array of list_id => number of subscribers
public get_subscriber_counts ( ) : array
return array

has_error() public method

public has_error ( ) : boolean
return boolean

list_has_subscriber() public method

Checks if an email address is on a given list with status "subscribed"
public list_has_subscriber ( string $list_id, string $email_address ) : boolean
$list_id string
$email_address string
return boolean

list_subscribe() public method

Sends a subscription request to the MailChimp API
public list_subscribe ( string $list_id, string $email_address, array $args = [], boolean $update_existing = false, boolean $replace_interests = true ) : object
$list_id string The list id to subscribe to
$email_address string The email address to subscribe
$args array
$update_existing boolean Update information if this email is already on list?
$replace_interests boolean Replace interest groupings, only if update_existing is true.
return object

list_unsubscribe() public method

public list_unsubscribe ( string $list_id, string $email_address ) : boolean
$list_id string
$email_address string
return boolean

reset_error() public method

Resets error properties.
public reset_error ( )

Property Details

$api public_oe property

public MC4WP_API_v3 $api
return MC4WP_API_v3

$error_code public_oe property

public string $error_code
return string

$error_message public_oe property

public string $error_message
return string