class-fl-builder-service.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Base class for third party services.
*
* @since 1.5.4
*/
abstract class FLBuilderService {
/**
* The ID for this service such as aweber or mailchimp.
*
* @since 1.5.4
* @var string $id
*/
public $id = '';
/**
* Test the API connection.
*
* @since 1.5.4
* @param array $fields
* @return array{
* @type bool|string $error The error message or false if no error.
* @type array $data An array of data used to make the connection.
* }
*/
abstract public function connect( $fields = array() );
/**
* Renders the markup for the connection settings.
*
* @since 1.5.4
* @return string The connection settings markup.
*/
abstract public function render_connect_settings();
/**
* Render the markup for service specific fields.
*
* @since 1.5.4
* @param string $account The name of the saved account.
* @param object $settings Saved module settings.
* @return array {
* @type bool|string $error The error message or false if no error.
* @type string $html The field markup.
* }
*/
abstract public function render_fields( $account, $settings );
/**
* Get the saved data for a specific account.
*
* @since 1.5.4
* @param string $account The account name.
* @return array|bool The account data or false if it doesn't exist.
*/
public function get_account_data( $account )
{
$saved_services = FLBuilderModel::get_services();
if ( isset( $saved_services[ $this->id ] ) && isset( $saved_services[ $this->id ][ $account ] ) ) {
return $saved_services[ $this->id ][ $account ];
}
return false;
}
}