PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.0.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.0.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 2.3.2 All 195 releases
← All changes | admin/class-convertkit-admin-settings.php +77 -116 2.2.42.0.3 View file →
@@ -55,19 +55,20 @@
55 55 if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
56 56 return;
57 57 }
58 58
59 - // Get active settings section / tab that has been requested.
60 - $section = $this->get_active_section();
59 + // Enqueue Select2 JS.
60 + convertkit_select2_enqueue_scripts();
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 +
62 65 /**
63 66 * Enqueue JavaScript for the Settings Screen at Settings > ConvertKit
64 67 *
65 68 * @since 1.9.6
66 - *
67 - * @param string $section Settings section / tab (general|tools|restrict-content).
68 69 */
69 - do_action( 'convertkit_admin_settings_enqueue_scripts', $section );
70 + do_action( 'convertkit_admin_settings_enqueue_scripts' );
70 71
71 72 }
72 73
73 74 /**
@@ -83,12 +84,12 @@
83 84 if ( $hook !== 'settings_page_' . self::SETTINGS_PAGE_SLUG ) {
84 85 return;
85 86 }
86 87
87 - // Get active settings section / tab that has been requested.
88 - $section = $this->get_active_section();
88 + // Enqueue Select2 CSS.
89 + convertkit_select2_enqueue_styles();
89 90
90 - // Always enqueue Settings CSS, as this is used for the UI across all settings sections.
91 + // Enqueue Settings CSS.
91 92 wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION );
92 93
93 94 /**
94 95 * Enqueue CSS for the Settings Screen at Settings > ConvertKit
@@ -93,12 +94,10 @@
93 94 /**
94 95 * Enqueue CSS for the Settings Screen at Settings > ConvertKit
95 96 *
96 97 * @since 1.9.6
97 - *
98 - * @param string $section Settings section / tab (general|tools|restrict-content).
99 98 */
100 - do_action( 'convertkit_admin_settings_enqueue_styles', $section );
99 + do_action( 'convertkit_admin_settings_enqueue_styles' );
101 100
102 101 }
103 102
104 103 /**
@@ -131,8 +130,12 @@
131 130 <header>
132 131 <h1><?php esc_html_e( 'ConvertKit', 'convertkit' ); ?></h1>
133 132 </header>
134 133
134 + <?php
135 + $this->maybe_display_notices();
136 + ?>
137 +
135 138 <div class="wrap">
136 139 <?php
137 140 if ( count( $this->sections ) > 1 ) {
138 141 $this->display_section_nav( $active_section );
@@ -149,18 +152,12 @@
149 152 </form>
150 153
151 154 <p class="description">
152 155 <?php
153 - // Output Documentation link, if it exists.
154 - $documentation_url = $this->get_active_section_documentation_url( $active_section );
155 - if ( $documentation_url !== false ) {
156 - echo sprintf(
157 - '%s <a href="%s" target="_blank">%s</a>',
158 - esc_html__( 'If you need help setting up the plugin please refer to the', 'convertkit' ),
159 - esc_attr( $documentation_url ),
160 - esc_html__( 'plugin documentation', 'convertkit' )
161 - );
162 - }
156 + printf(
157 + 'If you need help setting up the plugin please refer to the %s plugin documentation.</a>',
158 + '<a href="https://help.convertkit.com/en/articles/2502591-the-convertkit-wordpress-plugin" target="_blank">'
159 + );
163 160 ?>
164 161 </p>
165 162 </div>
166 163 <?php
@@ -185,36 +182,71 @@
185 182
186 183 }
187 184
188 185 /**
186 + * Display notice(s) immediately after the settings screen header.
187 + *
188 + * @since 1.9.6
189 + */
190 + private function maybe_display_notices() {
191 +
192 + $notices = array();
193 +
194 + // Check the mbstring extension is loaded.
195 + if ( ! extension_loaded( 'mbstring' ) ) {
196 + $notices[] = array(
197 + 'type' => 'warning',
198 + 'message' => sprintf(
199 + /* translators: link to php.net manual */
200 + __( 'Notice: Your server does not support the %s function - this is required for better character encoding. Please contact your webhost to have it installed.', 'convertkit' ),
201 + '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>'
202 + ),
203 + );
204 + }
205 +
206 + // Bail if no notices exist.
207 + if ( ! count( $notices ) ) {
208 + return;
209 + }
210 + ?>
211 + <div class="notices">
212 + <?php
213 + // Output inline notices.
214 + foreach ( $notices as $notice ) {
215 + ?>
216 + <div class="inline notice notice-<?php echo esc_attr( $notice['type'] ); ?>">
217 + <p>
218 + <?php echo esc_attr( $notice['message'] ); ?>
219 + </p>
220 + </div>
221 + <?php
222 + }
223 + ?>
224 + </div>
225 + <?php
226 +
227 + }
228 +
229 + /**
189 230 * Define links to display below the Plugin Name on the WP_List_Table at in the Plugins screen.
190 231 *
191 232 * @param array $links Links.
192 233 * @return array Links
193 234 */
194 - public function add_settings_page_link( $links ) {
235 + public static function add_settings_page_link( $links ) {
195 236
196 - // Add link to Plugin settings screen.
197 - $links['settings'] = sprintf(
198 - '<a href="%s">%s</a>',
199 - convertkit_get_settings_link(),
200 - __( 'Settings', 'convertkit' )
237 + return array_merge(
238 + array(
239 + 'settings' => sprintf(
240 + '<a href="%s">%s</a>',
241 + convertkit_get_settings_link(),
242 + __( 'Settings', 'convertkit' )
243 + ),
244 + ),
245 + $links
201 246 );
202 247
203 - /**
204 - * Define links to display below the Plugin Name on the WP_List_Table at Plugins > Installed Plugins.
205 - *
206 - * @since 2.1.2
207 - *
208 - * @param array $links HTML Links.
209 - */
210 - $links = apply_filters( 'convertkit_plugin_screen_action_links', $links );
211 -
212 - // Return.
213 - return $links;
214 -
215 248 }
216 -
217 249 /**
218 250 * Output tabs, one for each registered settings section.
219 251 *
220 252 * @param string $active_section Currently displayed/selected section.
@@ -225,33 +257,15 @@
225 257 <ul class="convertkit-tabs">
226 258 <?php
227 259 foreach ( $this->sections as $section ) {
228 260 printf(
229 - '<li><a href="%s" class="convertkit-tab %s">%s%s</a></li>',
230 - esc_url(
231 - add_query_arg(
232 - array(
233 - 'page' => self::SETTINGS_PAGE_SLUG,
234 - 'tab' => $section->name,
235 - ),
236 - admin_url( 'options-general.php' )
237 - )
238 - ),
239 - ( $active_section === $section->name ? 'convertkit-tab-active' : '' ),
240 - esc_html( $section->tab_text ),
241 - $section->is_beta ? $this->get_beta_tab() : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
261 + '<li><a href="?page=%s&tab=%s" class="convertkit-tab %s">%s</a></li>',
262 + sanitize_text_field( $_REQUEST['page'] ), // phpcs:ignore WordPress.Security.NonceVerification
263 + esc_html( $section->name ),
264 + $active_section === $section->name ? 'convertkit-tab-active' : '',
265 + esc_html( $section->tab_text )
242 266 );
243 267 }
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 268 ?>
255 269 </ul>
256 270 <?php
257 271 // WordPress' JS will automatically move any .notice elements to be immediately below .wp-header-end
@@ -264,29 +278,8 @@
264 278
265 279 }
266 280
267 281 /**
268 - * Returns a 'beta' tab wrapped in a span, using wp_kses to ensure only permitted
269 - * HTML elements are included in the output.
270 - *
271 - * @since 2.1.0
272 - *
273 - * @return string
274 - */
275 - private function get_beta_tab() {
276 -
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 - );
285 -
286 - }
287 -
288 - /**
289 282 * Registers settings sections at Settings > ConvertKit.
290 283 *
291 284 * Each section has its own tab.
292 285 *
@@ -310,40 +303,8 @@
310 303 $sections = apply_filters( 'convertkit_admin_settings_register_sections', $sections );
311 304
312 305 // With our sections now registered, assign them to this class.
313 306 $this->sections = $sections;
314 -
315 - }
316 -
317 - /**
318 - * Returns the documentation URL for the active settings section viewed by the user.
319 - *
320 - * @since 2.0.8
321 - *
322 - * @param string $active_section Currently displayed/selected section.
323 - * @return bool|string
324 - */
325 - private function get_active_section_documentation_url( $active_section ) {
326 -
327 - // Bail if no sections registered.
328 - if ( ! $this->sections ) {
329 - return false;
330 - }
331 -
332 - // Bail if the active section isn't registered.
333 - if ( ! array_key_exists( $active_section, $this->sections ) ) {
334 - return false;
335 - }
336 -
337 - // Pass request to section's documentation_url() function, including UTM parameters.
338 - return add_query_arg(
339 - array(
340 - 'utm_source' => 'wordpress',
341 - 'utm_term' => get_locale(),
342 - 'utm_content' => 'convertkit',
343 - ),
344 - $this->sections[ $active_section ]->documentation_url()
345 - );
346 307
347 308 }
348 309
349 310 }