PHP Класс MC4WP_API

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$api_key The API key to use
$api_url The URL to the MailChimp API
$connected Boolean indicating whether the user is connected with MailChimp
$error_code The error code of the last API request (if any)
$error_message The error message of the latest API request (if any)
$last_response The full response object of the latest API call

Открытые методы

Метод Описание
__construct ( string $api_key ) Constructor
add_ecommerce_order ( array $order_data ) : boolean
call ( string $method, array $data = [] ) : object Calls the MailChimp API
delete_ecommerce_order ( string $store_id, string $order_id ) : boolean
get_error_code ( ) : integer Gets the most recent error code
get_error_message ( ) : string Gets the most recent error message
get_last_response ( ) : object Get the most recent response object
get_list_groupings ( integer $list_id ) : array | boolean Gets the Groupings for a given List
get_lists ( array $list_ids = [] ) : boolean
get_lists_for_email ( array | string $email ) : array Get the lists an email address is subscribed to
get_lists_with_merge_vars ( array $list_ids ) : array | boolean Get lists with their merge_vars for a given array of list id's
get_subscriber_info ( string $list_id, array $emails ) : array Gets the member info for one or multiple emails on a list
has_error ( ) : boolean Checks if an error occured in the most recent request
is_connected ( ) : boolean Pings the MailChimp API to see if we're connected
list_has_subscriber ( string $list_id, string $email ) : boolean Checks if an email address is on a given list
subscribe ( string $list_id, string $email, array $merge_vars = [], string $email_type = 'html', boolean $double_optin = true, boolean $update_existing = false, boolean $replace_interests = true, boolean $send_welcome = false ) : boolean | string Sends a subscription request to the MailChimp API
unsubscribe ( string $list_id, array | string $struct, boolean $send_goodbye = true, boolean $send_notification = false, boolean $delete_member = false ) : boolean Unsubscribes the given email or luid from the given MailChimp list
update_subscriber ( string $list_id, array | string $email, array $merge_vars = [], string $email_type = 'html', boolean $replace_interests = false ) : boolean

Приватные методы

Метод Описание
empty_last_response ( ) Empties all data from previous response
get_headers ( ) : array Get the request headers to send to the MailChimp API
parse_response ( array | WP_Error $response ) : object
show_connection_error ( $message ) : boolean
show_error ( string $message ) : boolean Show an error message to administrators

Описание методов

__construct() публичный Метод

Constructor
public __construct ( string $api_key )
$api_key string

add_ecommerce_order() публичный Метод

См. также: https://apidocs.mailchimp.com/api/2.0/ecomm/order-add.php
public add_ecommerce_order ( array $order_data ) : boolean
$order_data array
Результат boolean

call() публичный Метод

Calls the MailChimp API
public call ( string $method, array $data = [] ) : object
$method string
$data array
Результат object

delete_ecommerce_order() публичный Метод

См. также: https://apidocs.mailchimp.com/api/2.0/ecomm/order-del.php
public delete_ecommerce_order ( string $store_id, string $order_id ) : boolean
$store_id string
$order_id string
Результат boolean

get_error_code() публичный Метод

Gets the most recent error code
public get_error_code ( ) : integer
Результат integer

get_error_message() публичный Метод

Gets the most recent error message
public get_error_message ( ) : string
Результат string

get_last_response() публичный Метод

Get the most recent response object
public get_last_response ( ) : object
Результат object

get_list_groupings() публичный Метод

Gets the Groupings for a given List
public get_list_groupings ( integer $list_id ) : array | boolean
$list_id integer
Результат array | boolean

get_lists() публичный Метод

public get_lists ( array $list_ids = [] ) : boolean
$list_ids array Array of ID's of the lists to fetch. (optional)
Результат boolean

get_lists_for_email() публичный Метод

Get the lists an email address is subscribed to
public get_lists_for_email ( array | string $email ) : array
$email array | string
Результат array

get_lists_with_merge_vars() публичный Метод

Get lists with their merge_vars for a given array of list id's
public get_lists_with_merge_vars ( array $list_ids ) : array | boolean
$list_ids array
Результат array | boolean

get_subscriber_info() публичный Метод

Gets the member info for one or multiple emails on a list
public get_subscriber_info ( string $list_id, array $emails ) : array
$list_id string
$emails array
Результат array

has_error() публичный Метод

Checks if an error occured in the most recent request
public has_error ( ) : boolean
Результат boolean

is_connected() публичный Метод

The result is cached to ensure a maximum of 1 API call per page load
public is_connected ( ) : boolean
Результат boolean

list_has_subscriber() публичный Метод

Checks if an email address is on a given list
public list_has_subscriber ( string $list_id, string $email ) : boolean
$list_id string
$email string
Результат boolean

subscribe() публичный Метод

Sends a subscription request to the MailChimp API
public subscribe ( string $list_id, string $email, array $merge_vars = [], string $email_type = 'html', boolean $double_optin = true, boolean $update_existing = false, boolean $replace_interests = true, boolean $send_welcome = false ) : boolean | string
$list_id string The list id to subscribe to
$email string The email address to subscribe
$merge_vars array Array of extra merge variables
$email_type string The email type to send to this email address. Possible values are `html` and `text`.
$double_optin boolean Should this email be confirmed via double opt-in?
$update_existing boolean Update information if this email is already on list?
$replace_interests boolean Replace interest groupings, only if update_existing is true.
$send_welcome boolean Send a welcome e-mail, only if double_optin is false.
Результат boolean | string True if success, 'error' if error

unsubscribe() публичный Метод

Unsubscribes the given email or luid from the given MailChimp list
public unsubscribe ( string $list_id, array | string $struct, boolean $send_goodbye = true, boolean $send_notification = false, boolean $delete_member = false ) : boolean
$list_id string
$struct array | string
$send_goodbye boolean
$send_notification boolean
$delete_member boolean
Результат boolean

update_subscriber() публичный Метод

public update_subscriber ( string $list_id, array | string $email, array $merge_vars = [], string $email_type = 'html', boolean $replace_interests = false ) : boolean
$list_id string
$email array | string
$merge_vars array
$email_type string
$replace_interests boolean
Результат boolean

Описание свойств

$api_key защищенное свойство

The API key to use
protected $api_key

$api_url защищенное свойство

The URL to the MailChimp API
protected $api_url

$connected защищенное свойство

Boolean indicating whether the user is connected with MailChimp
protected $connected

$error_code защищенное свойство

The error code of the last API request (if any)
protected $error_code

$error_message защищенное свойство

The error message of the latest API request (if any)
protected $error_message

$last_response защищенное свойство

The full response object of the latest API call
protected $last_response