PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 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 All 196 releases
convertkit / includes / integrations / wishlist / class-convertkit-wishlist-admin-section.php

class-convertkit-wishlist-admin-section.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at includes/integrations/wishlist/class-convertkit-wishlist-admin-section.php

212 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ConvertKit Wishlist Admin Settings class.
4 *
5 * @package ConvertKit
6 * @author ConvertKit
7 */
8
9 /**
10 * Registers Wishlist Settings that can be edited at Settings > Kit > Wishlist.
11 *
12 * @package ConvertKit
13 * @author ConvertKit
14 */
15 class ConvertKit_Wishlist_Admin_Section extends ConvertKit_Admin_Section_Base {
16
17 /**
18 * Constructor.
19 *
20 * @since 1.9.6
21 */
22 public function __construct() {
23
24 // Define the class that reads/writes settings.
25 $this->settings = new ConvertKit_Wishlist_Settings();
26
27 // Define the settings key.
28 $this->settings_key = $this->settings::SETTINGS_NAME;
29
30 // Define the programmatic name, Title and Tab Text.
31 $this->name = 'wishlist-member';
32 $this->title = __( 'WishList Member Integration Settings', 'convertkit' );
33 $this->tab_text = __( 'WishList Member', 'convertkit' );
34
35 // Define settings sections.
36 $this->settings_sections = array(
37 'general' => array(
38 'title' => $this->title,
39 'callback' => array( $this, 'print_section_info' ),
40 'wrap' => false,
41 ),
42 );
43
44 parent::__construct();
45
46 }
47
48 /**
49 * Prints help info for this section.
50 *
51 * @since 1.9.6
52 */
53 public function print_section_info() {
54
55 ?>
56 <p>
57 <?php
58 esc_html_e( 'Kit seamlessly integrates with WishList Member to let you capture all of your WishList Membership registrations within your Kit forms.', 'convertkit' );
59 ?>
60 </p>
61 <p>
62 <?php esc_html_e( 'Each membership level has the following Kit options:', 'convertkit' ); ?>
63 <br />
64 <code><?php esc_html_e( 'Do not subscribe', 'convertkit' ); ?></code>: <?php esc_html_e( 'Do not subscribe the email address to Kit', 'convertkit' ); ?>
65 <br />
66 <code><?php esc_html_e( 'Subscribe', 'convertkit' ); ?></code>: <?php esc_html_e( 'Subscribes the email address to Kit', 'convertkit' ); ?>
67 <br />
68 <code><?php esc_html_e( 'Unsubscribe', 'convertkit' ); ?></code>: <?php esc_html_e( 'Unsubscribes the email address from Kit', 'convertkit' ); ?>
69 <br />
70 <code><?php esc_html_e( 'Form', 'convertkit' ); ?></code>: <?php esc_html_e( 'Subscribes the email address to Kit, and adds the subscriber to the Kit form', 'convertkit' ); ?>
71 <br />
72 <code><?php esc_html_e( 'Tag', 'convertkit' ); ?></code>: <?php esc_html_e( 'Subscribes the email address to Kit, tagging the subscriber', 'convertkit' ); ?>
73 <br />
74 <code><?php esc_html_e( 'Sequence', 'convertkit' ); ?></code>: <?php esc_html_e( 'Subscribes the email address to Kit, and adds the subscriber to the Kit sequence', 'convertkit' ); ?>
75 </p>
76 <?php
77
78 }
79
80 /**
81 * Returns the URL for the ConvertKit documentation for this setting section.
82 *
83 * @since 2.0.8
84 *
85 * @return string Documentation URL.
86 */
87 public function documentation_url() {
88
89 return 'https://help.kit.com/en/articles/2502591-how-to-set-up-the-kit-plugin-on-your-wordpress-website';
90
91 }
92
93 /**
94 * Outputs the section as a WP_List_Table of WishList Member Levels, with options to choose
95 * a ConvertKit Form and Tag mapping for each.
96 *
97 * @since 1.9.6
98 */
99 public function render() {
100
101 // Render opening container.
102 $this->render_container_start();
103
104 do_settings_sections( $this->settings_key );
105
106 // Get WishList Member Levels.
107 $wlm_levels = $this->get_wlm_levels();
108
109 // Bail with an error if no WishList Member Levels exist.
110 if ( ! $wlm_levels ) {
111 $this->output_error( __( 'No WishList Member Levels exist in the WishList Member Plugin.', 'convertkit' ) );
112 $this->render_container_end();
113 return;
114 }
115
116 // Setup WP_List_Table.
117 $table = new ConvertKit_WP_List_Table();
118 $table->add_column( 'title', __( 'WishList Membership Level', 'convertkit' ), true );
119 $table->add_column( 'add', __( 'Assign to member', 'convertkit' ), false );
120 $table->add_column( 'remove', __( 'Remove from member', 'convertkit' ), false );
121
122 // Iterate through WishList Member Levels, building table array.
123 $table_rows = array();
124 foreach ( $wlm_levels as $wlm_level ) {
125 $table_rows[] = array(
126 'title' => $wlm_level['name'],
127 'add' => convertkit_get_subscription_dropdown_field(
128 '_wp_convertkit_integration_wishlistmember_settings[' . $wlm_level['id'] . '_add]',
129 (string) $this->settings->get_convertkit_add_setting_by_wishlist_member_level_id( $wlm_level['id'] ),
130 '_wp_convertkit_integration_wishlistmember_settings_' . $wlm_level['id'] . '_add',
131 'widefat',
132 'wlm'
133 ),
134 'remove' => convertkit_get_subscription_dropdown_field(
135 '_wp_convertkit_integration_wishlistmember_settings[' . $wlm_level['id'] . '_remove]',
136 (string) $this->settings->get_convertkit_remove_setting_by_wishlist_member_level_id( $wlm_level['id'] ),
137 '_wp_convertkit_integration_wishlistmember_settings_' . $wlm_level['id'] . '_remove',
138 'widefat',
139 'wlm',
140 array(
141 'unsubscribe' => __( 'Unsubscribe', 'convertkit' ),
142 )
143 ),
144 );
145 }
146
147 // Sort table rows.
148 $table_rows = $table->reorder( $table_rows );
149
150 // Set items.
151 $table->add_items( $table_rows );
152 $table->set_total_items( count( $table_rows ) );
153
154 // Prepare and display WP_List_Table.
155 $table->prepare_items();
156 $table->display();
157
158 // Register settings field.
159 settings_fields( $this->settings_key );
160
161 // Render closing container.
162 $this->render_container_end();
163
164 // Render submit button.
165 submit_button();
166
167 }
168
169 /**
170 * Gets membership levels from WishList Member API
171 *
172 * @return bool|array
173 */
174 public function get_wlm_levels() {
175
176 // Get WishList Member Levels from the API.
177 $wlm_get_levels = wlmapi_get_levels();
178
179 // Bail if the API call failed.
180 if ( $wlm_get_levels['success'] !== 1 ) {
181 return false;
182 }
183
184 return $wlm_get_levels['levels']['level'];
185
186 }
187
188 }
189
190 // Register Admin Settings section.
191 add_filter(
192 'convertkit_admin_settings_register_sections',
193 /**
194 * Register WishList Member as a section at Settings > Kit.
195 *
196 * @param array $sections Settings Sections.
197 * @return array
198 */
199 function ( $sections ) {
200
201 // Bail if WishList Member isn't enabled.
202 if ( ! function_exists( 'wlmapi_get_levels' ) ) {
203 return $sections;
204 }
205
206 // Register this class as a section at Settings > Kit.
207 $sections['wishlist-member'] = new ConvertKit_Wishlist_Admin_Section();
208 return $sections;
209
210 }
211 );
212