PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.4.1
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.4.1
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / admin / section / general.php

general.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 1.4.1, at admin/section/general.php

139 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once "base.php";
4
5 /**
6 * Class ConvertKitSettingsGeneral
7 */
8 class ConvertKitSettingsGeneral extends ConvertKitSettingsSection {
9
10 /**
11 * Constructor
12 */
13 public function __construct() {
14 $this->settings_key = WP_ConvertKit::SETTINGS_PAGE_SLUG;
15 $this->name = 'general';
16 $this->title = 'General Settings';
17 $this->tab_text = 'General';
18
19 parent::__construct();
20 }
21
22 /**
23 * Register and add settings
24 */
25 public function register_fields() {
26 add_settings_field(
27 'api_key',
28 'API Key',
29 array($this, 'api_key_callback'),
30 $this->settings_key,
31 $this->name
32 );
33
34 add_settings_field(
35 'api_secret',
36 'API Secret',
37 array($this, 'api_secret_callback'),
38 $this->settings_key,
39 $this->name
40 );
41
42 add_settings_field(
43 'default_form',
44 'Default Form',
45 array($this, 'default_form_callback'),
46 $this->settings_key,
47 $this->name,
48 $this->api->get_resources('forms')
49 );
50 }
51
52 /**
53 * Prints help info for this section
54 */
55 public function print_section_info() {
56 ?>
57 <p>
58 Choosing a default form will embed it at the bottom of every post or page
59 (in single view only) across your site. If you wish to turn off form
60 embedding or select a different form for an individual post or page, you
61 can do so within the ConvertKit meta box on the editing form.
62 </p>
63 <p>
64 The default form can be inserted into the middle of post or page content
65 by using the <code>[convertkit]</code> shortcode.
66 </p>
67 <?php
68 }
69
70 /**
71 * Renders the input for api key entry
72 */
73 public function api_key_callback() {
74 $html = sprintf(
75 '<input type="text" class="regular-text code" id="api_key" name="%s[api_key]" value="%s" />',
76 $this->settings_key,
77 isset($this->options['api_key']) ? esc_attr($this->options['api_key']) : ''
78 );
79
80 $html .= '<p class="description"><a href="https://app.convertkit.com/account/edit" target="_blank">Get your ConvertKit API Key</a></p>';
81
82 echo $html;
83 }
84
85 /**
86 * Renders the input for api key entry
87 */
88 public function api_secret_callback() {
89 $html = sprintf(
90 '<input type="text" class="regular-text code" id="api_key" name="%s[api_secret]" value="%s" />',
91 $this->settings_key,
92 isset($this->options['api_secret']) ? esc_attr($this->options['api_secret']) : ''
93 );
94
95 $html .= '<p class="description"><a href="https://app.convertkit.com/account/edit" target="_blank">Get your ConvertKit API Secret.</a> This setting is required to unsubscribe subscribers.</p>';
96
97 echo $html;
98 }
99
100 /**
101 * Renders the form select list
102 *
103 * @param array $forms Form listing
104 */
105 public function default_form_callback($forms) {
106 $html = sprintf('<select id="default_form" name="%s[default_form]">', $this->settings_key);
107 $html .= '<option value="default">None</option>';
108 foreach ( $forms as $form ) {
109 $html .= sprintf(
110 '<option value="%s" %s>%s</option>',
111 esc_attr( $form['id'] ),
112 selected( $this->options['default_form'], $form['id'], false ),
113 esc_html( $form['name'] )
114 );
115 }
116 $html .= '</select>';
117
118 if (empty($forms)) {
119 $html .= '<p class="description">Enter your API Key above to get your available forms.</p>';
120 }
121
122 echo $html;
123 }
124
125 /**
126 * Sanitizes the settings
127 *
128 * @param array $settings The settings fields submitted
129 * @return array Sanitized settings
130 */
131 public function sanitize_settings($settings) {
132 return shortcode_atts(array(
133 'api_key' => '',
134 'api_secret' => '',
135 'default_form' => 0
136 ), $settings);
137 }
138 }
139