PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.3.6
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.3.6
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 / settings.php

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

132 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class ConvertKitSettings {
4 public $api;
5 public $sections = array();
6
7 public $settings_key = WP_ConvertKit::SETTINGS_PAGE_SLUG;
8
9 public function __construct() {
10 $general_options = get_option($this->settings_key);
11 $api_key = $general_options && array_key_exists("api_key", $general_options) ? $general_options['api_key'] : null;
12 $this->api = new ConvertKitAPI($api_key);
13
14 add_action('admin_menu', array($this, 'add_settings_page'));
15 add_action('admin_init', array($this, 'register_sections'));
16 }
17
18 /**
19 * Add the options page
20 */
21 public function add_settings_page() {
22 $settings = add_options_page(
23 __('ConvertKit'),
24 __('ConvertKit'),
25 'manage_options',
26 $this->settings_key,
27 array($this, 'display_settings_page')
28 );
29
30 add_action('admin_print_styles', array($this, 'admin_styles'));
31 }
32
33 /**
34 * Options page callback
35 */
36 public function display_settings_page() {
37 $active_section = (isset($_GET['tab'])) ? $_GET['tab'] : $this->sections[0]->name;
38
39 ?>
40 <div class="wrap convertkit-settings-wrap">
41 <?php
42 screen_icon();
43 if(count($this->sections) > 1) {
44 $this->display_section_nav($active_section);
45 } else {
46 ?>
47 <h2><?php _e('ConvertKit', 'wp_convertkit'); ?></h2>
48 <?php
49 }
50 ?>
51
52 <form method="post" action="options.php">
53 <?php
54 foreach($this->sections as $section):
55 if ($active_section == $section->name):
56 $section->render();
57 endif;
58 endforeach;
59 ?>
60 <p class="description">
61 If you have questions or problems, please contact
62 <a href="mailto:support@convertkit.com">support@convertkit.com</a>
63 </p>
64 </form>
65 </div>
66 <?php
67 }
68
69 /**
70 * Queue up the admin styles
71 */
72 public function admin_styles() {
73 wp_enqueue_style('wp-convertkit-admin');
74 }
75
76 /**
77 * Render a tab for each section
78 *
79 * @param string $active_section The currently active section
80 */
81 public function display_section_nav($active_section) {
82 ?>
83 <h2 class="nav-tab-wrapper">
84 <span class="nav-tab-title">
85 <?php _e('ConvertKit', 'wp_convertkit'); ?>
86 </span>
87 <?php
88 foreach($this->sections as $section):
89 printf(
90 '<a href="?page=%s&tab=%s" class="nav-tab right %s">%s</a>',
91 $this->settings_key,
92 $section->name,
93 $active_section == $section->name ? 'nav-tab-active' : '',
94 esc_html($section->tab_text)
95 );
96 endforeach;
97 ?>
98 </h2>
99 <?php
100 }
101
102 /**
103 * Adds a section to be displayed
104 *
105 * @param string $section A section class name
106 */
107 public function register_section($section) {
108 $section_instance = new $section();
109
110 if ($section_instance->is_registerable) {
111 array_push($this->sections, $section_instance);
112 }
113 }
114
115 /**
116 * Register each section
117 */
118 public function register_sections() {
119 wp_register_style( 'wp-convertkit-admin', plugins_url('../resources/backend/wp-convertkit.css', __FILE__) );
120
121 $this->register_section('ConvertKitSettingsGeneral');
122 $this->register_section('ConvertKitSettingsWishlistMember');
123 }
124 }
125
126 if( is_admin() ) {
127 $convertkit_settings = new ConvertKitSettings();
128
129 include 'section/general.php';
130 include 'section/wishlist_member.php';
131 }
132