PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.3.0
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.3.0
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
← All changes | admin/class-convertkit-admin-settings.php +69 -38 2.2.83.3.0 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
@@ -59,9 +59,9 @@
59 59 // Get active settings section / tab that has been requested.
60 60 $section = $this->get_active_section();
61 61
62 62 /**
63 - * Enqueue JavaScript for the Settings Screen at Settings > ConvertKit
63 + * Enqueue JavaScript for the Settings Screen at Settings > Kit
64 64 *
65 65 * @since 1.9.6
66 66 *
67 67 * @param string $section Settings section / tab (general|tools|restrict-content).
@@ -70,9 +70,9 @@
70 70
71 71 }
72 72
73 73 /**
74 - * Enqueue CSS for the Settings Screens at Settings > ConvertKit
74 + * Enqueue CSS for the Settings Screens at Settings > Kit
75 75 *
76 76 * @since 1.9.6
77 77 *
78 78 * @param string $hook Hook.
@@ -90,9 +90,9 @@
90 90 // Always enqueue Settings CSS, as this is used for the UI across all settings sections.
91 91 wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION );
92 92
93 93 /**
94 - * Enqueue CSS for the Settings Screen at Settings > ConvertKit
94 + * Enqueue CSS for the Settings Screen at Settings > Kit
95 95 *
96 96 * @since 1.9.6
97 97 *
98 98 * @param string $section Settings section / tab (general|tools|restrict-content).
@@ -108,10 +108,10 @@
108 108 */
109 109 public function add_settings_page() {
110 110
111 111 add_options_page(
112 - __( 'ConvertKit', 'convertkit' ),
113 - __( 'ConvertKit', 'convertkit' ),
112 + __( 'Kit', 'convertkit' ),
113 + __( 'Kit', 'convertkit' ),
114 114 'manage_options',
115 115 self::SETTINGS_PAGE_SLUG,
116 116 array( $this, 'display_settings_page' )
117 117 );
@@ -128,9 +128,21 @@
128 128 $active_section = $this->get_active_section();
129 129 ?>
130 130
131 131 <header>
132 - <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 + ?>
133 145 </header>
134 146
135 147 <div class="wrap">
136 148 <?php
@@ -136,11 +148,30 @@
136 148 <?php
137 149 if ( count( $this->sections ) > 1 ) {
138 150 $this->display_section_nav( $active_section );
139 151 }
152 +
153 + /**
154 + * Defines the settings form's method.
155 + *
156 + * @since 3.0.0
157 + *
158 + * @param string $form_method The method of the form.
159 + * @param string $active_section The active section.
160 + */
161 + $form_method = apply_filters( 'convertkit_admin_settings_form_method', 'post', $active_section );
162 +
163 + /**
164 + * Defines the settings form's action URL.
165 + *
166 + * @since 3.0.0
167 + *
168 + * @param string $form_action_url The URL to submit the form to.
169 + * @param string $active_section The active section.
170 + */
171 + $form_action_url = apply_filters( 'convertkit_admin_settings_form_action_url', admin_url( 'options.php' ), $active_section );
140 172 ?>
141 -
142 - <form method="post" action="options.php" enctype="multipart/form-data">
173 + <form method="<?php echo esc_attr( $form_method ); ?>" action="<?php echo esc_url( $form_action_url ); ?>" enctype="multipart/form-data">
143 174 <?php
144 175 // Iterate through sections to find the active section to render.
145 176 if ( isset( $this->sections[ $active_section ] ) ) {
146 177 $this->sections[ $active_section ]->render();
@@ -149,12 +180,12 @@
149 180 </form>
150 181
151 182 <p class="description">
152 183 <?php
153 - // Output Documentation link, if it exists.
184 + // Output Help link, if it exists.
154 185 $documentation_url = $this->get_active_section_documentation_url( $active_section );
155 186 if ( $documentation_url !== false ) {
156 - echo sprintf(
187 + printf(
157 188 '%s <a href="%s" target="_blank">%s</a>',
158 189 esc_html__( 'If you need help setting up the plugin please refer to the', 'convertkit' ),
159 190 esc_attr( $documentation_url ),
160 191 esc_html__( 'plugin documentation', 'convertkit' )
@@ -175,10 +206,10 @@
175 206 * @return string Tab Name
176 207 */
177 208 private function get_active_section() {
178 209
179 - if ( isset( $_GET['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
180 - return sanitize_text_field( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
210 + if ( filter_has_var( INPUT_GET, 'tab' ) ) {
211 + return filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
181 212 }
182 213
183 214 // First registered section will be the active section.
184 215 return current( $this->sections )->name;
@@ -237,21 +268,14 @@
237 268 )
238 269 ),
239 270 ( $active_section === $section->name ? 'convertkit-tab-active' : '' ),
240 271 esc_html( $section->tab_text ),
241 - $section->is_beta ? $this->get_beta_tab() : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
272 + wp_kses(
273 + $section->is_beta ? $this->get_beta_tab() : '',
274 + convertkit_kses_allowed_html()
275 + )
242 276 );
243 277 }
244 -
245 - // Output Documentation link tab, if it exists.
246 - $documentation_url = $this->get_active_section_documentation_url( $active_section );
247 - if ( $documentation_url !== false ) {
248 - printf(
249 - '<li class="convertkit-docs"><a href="%s" class="convertkit-tab" target="_blank">%s <span class="dashicons dashicons-external"></span></a></li>',
250 - esc_attr( $documentation_url ),
251 - esc_html__( 'Documentation', 'convertkit' )
252 - );
253 - }
254 278 ?>
255 279 </ul>
256 280 <?php
257 281 // WordPress' JS will automatically move any .notice elements to be immediately below .wp-header-end
@@ -264,10 +288,9 @@
264 288
265 289 }
266 290
267 291 /**
268 - * Returns a 'beta' tab wrapped in a span, using wp_kses to ensure only permitted
269 - * HTML elements are included in the output.
292 + * Returns a 'beta' tab wrapped in a span.
270 293 *
271 294 * @since 2.1.0
272 295 *
273 296 * @return string
@@ -273,21 +296,14 @@
273 296 * @return string
274 297 */
275 298 private function get_beta_tab() {
276 299
277 - return wp_kses(
278 - '<span class="convertkit-beta-label">' . esc_html__( 'Beta', 'convertkit' ) . '</span>',
279 - array(
280 - 'span' => array(
281 - 'class' => array(),
282 - ),
283 - )
284 - );
300 + return '<span class="convertkit-beta-label">' . esc_html__( 'Beta', 'convertkit' ) . '</span>';
285 301
286 302 }
287 303
288 304 /**
289 - * Registers settings sections at Settings > ConvertKit.
305 + * Registers settings sections at Settings > Kit.
290 306 *
291 307 * Each section has its own tab.
292 308 *
293 309 * @since 1.9.6
@@ -293,16 +309,31 @@
293 309 * @since 1.9.6
294 310 */
295 311 public function register_sections() {
296 312
313 + // If no Access Token exists, register a settings section that shows a button
314 + // to start the OAuth authentication flow.
315 + $settings = new ConvertKit_Settings();
316 + if ( ! $settings->has_access_and_refresh_token() ) {
317 + // Just register the OAuth screen.
318 + $sections = array(
319 + 'oauth' => new ConvertKit_Admin_Section_OAuth(),
320 + );
321 +
322 + // Assign them to this class.
323 + $this->sections = $sections;
324 +
325 + return;
326 + }
327 +
297 328 // Register the General and Tools settings sections.
298 329 $sections = array(
299 - 'general' => new ConvertKit_Settings_General(),
300 - 'tools' => new ConvertKit_Settings_Tools(),
330 + 'general' => new ConvertKit_Admin_Section_General(),
331 + 'tools' => new ConvertKit_Admin_Section_Tools(),
301 332 );
302 333
303 334 /**
304 - * Registers settings sections at Settings > ConvertKit.
335 + * Registers settings sections at Settings > Kit.
305 336 *
306 337 * @since 1.9.6
307 338 *
308 339 * @param array $sections Array of settings classes that handle individual tabs e.g. General, Tools etc.