PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.7.5
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.7.5
3.4.6 3.4.5 3.4.4 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 All 199 releases
← All changes | admin/class-convertkit-admin-settings.php +51 -33 2.2.1 → 2.7.5 View file →
@@ -6,9 +6,9 @@
6 6 * @author ConvertKit
7 7 */
8 8
9 9 /**
10 - * Registers a screen at Settings > ConvertKit in the WordPress Administration
10 + * Registers a screen at Settings > Kit in the WordPress Administration
11 11 * interface, and handles saving its data.
12 12 *
13 13 * @package ConvertKit
14 14 * @author ConvertKit
@@ -55,25 +55,24 @@
55 55 if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
56 56 return;
57 57 }
58 58
59 - // Enqueue Select2 JS.
60 - convertkit_select2_enqueue_scripts();
59 + // Get active settings section / tab that has been requested.
60 + $section = $this->get_active_section();
61 61
62 - // Enqueue Preview Output JS.
63 - wp_enqueue_script( 'convertkit-admin-preview-output', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/preview-output.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true );
64 -
65 62 /**
66 - * Enqueue JavaScript for the Settings Screen at Settings > ConvertKit
63 + * Enqueue JavaScript for the Settings Screen at Settings > Kit
67 64 *
68 65 * @since 1.9.6
66 + *
67 + * @param string $section Settings section / tab (general|tools|restrict-content).
69 68 */
70 - do_action( 'convertkit_admin_settings_enqueue_scripts' );
69 + do_action( 'convertkit_admin_settings_enqueue_scripts', $section );
71 70
72 71 }
73 72
74 73 /**
75 - * Enqueue CSS for the Settings Screens at Settings > ConvertKit
74 + * Enqueue CSS for the Settings Screens at Settings > Kit
76 75 *
77 76 * @since 1.9.6
78 77 *
79 78 * @param string $hook Hook.
@@ -84,20 +83,22 @@
84 83 if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
85 84 return;
86 85 }
87 86
88 - // Enqueue Select2 CSS.
89 - convertkit_select2_enqueue_styles();
87 + // Get active settings section / tab that has been requested.
88 + $section = $this->get_active_section();
90 89
91 - // Enqueue Settings CSS.
90 + // Always enqueue Settings CSS, as this is used for the UI across all settings sections.
92 91 wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION );
93 92
94 93 /**
95 - * Enqueue CSS for the Settings Screen at Settings > ConvertKit
94 + * Enqueue CSS for the Settings Screen at Settings > Kit
96 95 *
97 96 * @since 1.9.6
97 + *
98 + * @param string $section Settings section / tab (general|tools|restrict-content).
98 99 */
99 - do_action( 'convertkit_admin_settings_enqueue_styles' );
100 + do_action( 'convertkit_admin_settings_enqueue_styles', $section );
100 101
101 102 }
102 103
103 104 /**
@@ -107,10 +108,10 @@
107 108 */
108 109 public function add_settings_page() {
109 110
110 111 add_options_page(
111 - __( 'ConvertKit', 'convertkit' ),
112 - __( 'ConvertKit', 'convertkit' ),
112 + __( 'Kit', 'convertkit' ),
113 + __( 'Kit', 'convertkit' ),
113 114 'manage_options',
114 115 self::SETTINGS_PAGE_SLUG,
115 116 array( $this, 'display_settings_page' )
116 117 );
@@ -127,9 +128,21 @@
127 128 $active_section = $this->get_active_section();
128 129 ?>
129 130
130 131 <header>
131 - <h1><?php esc_html_e( 'ConvertKit', 'convertkit' ); ?></h1>
132 + <h1><?php esc_html_e( 'Kit', 'convertkit' ); ?></h1>
133 +
134 + <?php
135 + // Output Help link tab, if it exists.
136 + $documentation_url = $this->get_active_section_documentation_url( $active_section );
137 + if ( $documentation_url !== false ) {
138 + printf(
139 + '<a href="%s" class="convertkit-docs" target="_blank">%s</a>',
140 + esc_attr( $documentation_url ),
141 + esc_html__( 'Help', 'convertkit' )
142 + );
143 + }
144 + ?>
132 145 </header>
133 146
134 147 <div class="wrap">
135 148 <?php
@@ -148,12 +161,12 @@
148 161 </form>
149 162
150 163 <p class="description">
151 164 <?php
152 - // Output Documentation link, if it exists.
165 + // Output Help link, if it exists.
153 166 $documentation_url = $this->get_active_section_documentation_url( $active_section );
154 167 if ( $documentation_url !== false ) {
155 - echo sprintf(
168 + printf(
156 169 '%s <a href="%s" target="_blank">%s</a>',
157 170 esc_html__( 'If you need help setting up the plugin please refer to the', 'convertkit' ),
158 171 esc_attr( $documentation_url ),
159 172 esc_html__( 'plugin documentation', 'convertkit' )
@@ -239,18 +252,8 @@
239 252 esc_html( $section->tab_text ),
240 253 $section->is_beta ? $this->get_beta_tab() : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
241 254 );
242 255 }
243 -
244 - // Output Documentation link tab, if it exists.
245 - $documentation_url = $this->get_active_section_documentation_url( $active_section );
246 - if ( $documentation_url !== false ) {
247 - printf(
248 - '<li class="convertkit-docs"><a href="%s" class="convertkit-tab" target="_blank">%s <span class="dashicons dashicons-external"></span></a></li>',
249 - esc_attr( $documentation_url ),
250 - esc_html__( 'Documentation', 'convertkit' )
251 - );
252 - }
253 256 ?>
254 257 </ul>
255 258 <?php
256 259 // WordPress' JS will automatically move any .notice elements to be immediately below .wp-header-end
@@ -284,9 +287,9 @@
284 287
285 288 }
286 289
287 290 /**
288 - * Registers settings sections at Settings > ConvertKit.
291 + * Registers settings sections at Settings > Kit.
289 292 *
290 293 * Each section has its own tab.
291 294 *
292 295 * @since 1.9.6
@@ -292,16 +295,31 @@
292 295 * @since 1.9.6
293 296 */
294 297 public function register_sections() {
295 298
299 + // If no Access Token exists, register a settings section that shows a button
300 + // to start the OAuth authentication flow.
301 + $settings = new ConvertKit_Settings();
302 + if ( ! $settings->has_access_and_refresh_token() ) {
303 + // Just register the OAuth screen.
304 + $sections = array(
305 + 'oauth' => new ConvertKit_Admin_Section_OAuth(),
306 + );
307 +
308 + // Assign them to this class.
309 + $this->sections = $sections;
310 +
311 + return;
312 + }
313 +
296 314 // Register the General and Tools settings sections.
297 315 $sections = array(
298 - 'general' => new ConvertKit_Settings_General(),
299 - 'tools' => new ConvertKit_Settings_Tools(),
316 + 'general' => new ConvertKit_Admin_Section_General(),
317 + 'tools' => new ConvertKit_Admin_Section_Tools(),
300 318 );
301 319
302 320 /**
303 - * Registers settings sections at Settings > ConvertKit.
321 + * Registers settings sections at Settings > Kit.
304 322 *
305 323 * @since 1.9.6
306 324 *
307 325 * @param array $sections Array of settings classes that handle individual tabs e.g. General, Tools etc.