PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.3.5
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.3.5
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.3.5, at admin/section/general.php

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