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

128 lines 3.2 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 $this->api = new ConvertKitAPI( $api_key, $api_secret );
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 <div class="wrap convertkit-settings-wrap">
40 <?php
41 if(count($this->sections) > 1) {
42 $this->display_section_nav($active_section);
43 } else {
44 ?>
45 <h2><?php _e('ConvertKit', 'wp_convertkit'); ?></h2>
46 <?php
47 }
48 ?>
49
50 <form method="post" action="options.php">
51 <?php
52 foreach($this->sections as $section):
53 if ($active_section == $section->name):
54 $section->render();
55 endif;
56 endforeach;
57 ?>
58 <p class="description">
59 If you have questions or problems, please contact
60 <a href="mailto:support@convertkit.com">support@convertkit.com</a>
61 </p>
62 </form>
63 </div>
64 <?php
65 }
66
67 /**
68 * Queue up the admin styles
69 */
70 public function admin_styles() {
71 wp_enqueue_style('wp-convertkit-admin');
72 }
73
74 /**
75 * Render a tab for each section
76 *
77 * @param string $active_section The currently active section
78 */
79 public function display_section_nav($active_section) {
80 ?>
81 <h1> <?php _e('ConvertKit', 'wp_convertkit'); ?></h1>
82 <h2 class="nav-tab-wrapper">
83 <?php
84 foreach($this->sections as $section):
85 printf(
86 '<a href="?page=%s&tab=%s" class="nav-tab right %s">%s</a>',
87 $this->settings_key,
88 $section->name,
89 $active_section == $section->name ? 'nav-tab-active' : '',
90 esc_html($section->tab_text)
91 );
92 endforeach;
93 ?>
94 </h2>
95 <?php
96 }
97
98 /**
99 * Adds a section to be displayed
100 *
101 * @param string $section A section class name
102 */
103 public function register_section($section) {
104 $section_instance = new $section();
105
106 if ($section_instance->is_registerable) {
107 array_push($this->sections, $section_instance);
108 }
109 }
110
111 /**
112 * Register each section
113 */
114 public function register_sections() {
115 wp_register_style( 'wp-convertkit-admin', plugins_url('../resources/backend/wp-convertkit.css', __FILE__) );
116
117 $this->register_section('ConvertKitSettingsGeneral');
118 $this->register_section('ConvertKitSettingsWishlistMember');
119 }
120 }
121
122 if( is_admin() ) {
123 $convertkit_settings = new ConvertKitSettings();
124
125 include 'section/general.php';
126 include 'section/wishlist_member.php';
127 }
128