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

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

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