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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
namespace AutomateWoo;
use AutomateWoo\Notifications\CampaignMonitorCheck;
defined( 'ABSPATH' ) || exit;
/** * Settings_Tab_Campaign_Monitor class. */ class Settings_Tab_Campaign_Monitor extends Admin_Settings_Tab_Abstract {
/** * Constructor. */ public function __construct() { $this->id = 'campaign-monitor'; $this->name = __( 'Campaign Monitor', 'automatewoo' ); }
/** * Get tab settings. * * @return array */ public function get_settings() {
$tip = __( 'To find your API key or client ID, sign in to your Campaign Monitor account and click your profile image at the top right, then select Account settings, then API keys.', 'automatewoo' );
return [ [ 'type' => 'title', 'id' => 'automatewoo_campaign_monitor_integration', 'desc' => __( 'Enabling the Campaign Monitor integration makes actions available for use when creating workflows. These actions can be used to automate adding and removing members from lists.', 'automatewoo' ), ], [ 'title' => __( 'Enable integration', 'automatewoo' ), 'id' => 'automatewoo_campaign_monitor_enabled', 'autoload' => false, 'type' => 'checkbox', ], [ 'title' => __( 'API key', 'automatewoo' ), 'id' => 'automatewoo_campaign_monitor_api_key', 'tooltip' => $tip, 'type' => 'password', 'autoload' => false, ], [ 'title' => __( 'Client ID', 'automatewoo' ), 'id' => 'automatewoo_campaign_monitor_client_id', 'tooltip' => $tip, 'type' => 'text', 'autoload' => false, ], [ 'type' => 'sectionend', 'id' => 'automatewoo_campaign_monitor_integration', ], ]; }
/** * Save settings. * * @param array $fields Which fields to save. If empty, all fields will be saved. * * @return void */ public function save( $fields = array() ): void { Integrations::campaign_monitor()->clear_cache_data(); parent::save();
$campaign_monitor = Integrations::campaign_monitor(); if ( $campaign_monitor && $campaign_monitor->test_integration() ) { // If a notification exists relating to a Campaign Monitor integration error, delete it. CampaignMonitorCheck::possibly_delete_note(); } } }
return new Settings_Tab_Campaign_Monitor();
|