PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.7.4
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.7.4
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 2.2.9 2.3.0 All 197 releases
← All changes | admin/section/class-convertkit-admin-section-general.php +96 -510 3.4.22.7.4 View file →
@@ -14,8 +14,17 @@
14 14 */
15 15 class ConvertKit_Admin_Section_General extends ConvertKit_Admin_Section_Base {
16 16
17 17 /**
18 + * Holds the API instance.
19 + *
20 + * @since 1.9.6
21 + *
22 + * @var ConvertKit_API_V4
23 + */
24 + private $api;
25 +
26 + /**
18 27 * Holds the ConvertKit Account Name.
19 28 *
20 29 * @since 1.9.6
21 30 *
@@ -43,30 +52,25 @@
43 52 // Define the settings key.
44 53 $this->settings_key = $this->settings::SETTINGS_NAME;
45 54
46 55 // Define the programmatic name, Title and Tab Text.
47 - $this->name = $this->settings->get_name();
48 - $this->title = $this->settings->get_title();
56 + $this->name = 'general';
57 + $this->title = __( 'General Settings', 'convertkit' );
49 58 $this->tab_text = __( 'General', 'convertkit' );
50 59
51 60 // Define settings sections.
52 61 $this->settings_sections = array(
53 - 'general' => array(
62 + 'general' => array(
54 63 'title' => $this->title,
55 64 'callback' => array( $this, 'print_section_info' ),
56 65 'wrap' => true,
57 66 ),
58 - 'site-wide' => array(
59 - 'title' => __( 'Non-inline Forms', 'convertkit' ),
67 + 'site-wide' => array(
68 + 'title' => __( 'Site Wide', 'convertkit' ),
60 69 'callback' => array( $this, 'print_section_info_site_wide' ),
61 70 'wrap' => true,
62 71 ),
63 - 'spam-protection' => array(
64 - 'title' => __( 'Spam Protection', 'convertkit' ),
65 - 'callback' => array( $this, 'print_section_info_spam_protection' ),
66 - 'wrap' => true,
67 - ),
68 - 'advanced' => array(
72 + 'advanced' => array(
69 73 'title' => __( 'Advanced', 'convertkit' ),
70 74 'callback' => array( $this, 'print_section_info_advanced' ),
71 75 'wrap' => true,
72 76 ),
@@ -71,15 +75,13 @@
71 75 'wrap' => true,
72 76 ),
73 77 );
74 78
75 - $this->maybe_disconnect();
76 -
77 79 // Register and maybe output notices for this settings screen, and the Intercom messenger.
78 80 if ( $this->on_settings_screen( $this->name ) ) {
79 81 add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) );
80 82 add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) );
81 - add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_legacy_form_notice' ) );
83 + add_action( 'admin_footer', array( $this, 'output_intercom' ) );
82 84 }
83 85
84 86 // Enqueue scripts and CSS.
85 87 add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -87,8 +89,9 @@
87 89
88 90 parent::__construct();
89 91
90 92 $this->check_credentials();
93 + $this->maybe_disconnect();
91 94
92 95 }
93 96
94 97 /**
@@ -111,43 +114,8 @@
111 114
112 115 }
113 116
114 117 /**
115 - * Outputs a non-dismissible warning when one or more Default Form settings
116 - * reference Legacy Forms.
117 - *
118 - * @since 3.3.9
119 - */
120 - public function maybe_output_legacy_form_notice() {
121 -
122 - // Get warnings.
123 - $warnings = WP_ConvertKit()->get_class( 'admin_legacy_resource_notice' )->get_legacy_warnings_for_plugin_settings( $this->settings->get() );
124 -
125 - // Bail if no warnings are found.
126 - if ( empty( $warnings ) ) {
127 - return;
128 - }
129 -
130 - // Output warnings.
131 - ?>
132 - <div id="convertkit-legacy-settings-warning" class="notice notice-warning">
133 - <p>
134 - <strong><?php esc_html_e( 'Kit', 'convertkit' ); ?>:</strong>
135 - <?php esc_html_e( 'Your Default Form settings reference Legacy Forms. They still work, but should be migrated:', 'convertkit' ); ?>
136 - </p>
137 - <ul>
138 - <?php
139 - foreach ( $warnings as $warning ) {
140 - echo '<li>' . esc_html( $warning ) . '</li>';
141 - }
142 - ?>
143 - </ul>
144 - </div>
145 - <?php
146 -
147 - }
148 -
149 - /**
150 118 * Test the access token, if it exists.
151 119 * If the access token has been revoked or is invalid, remove it from the settings now.
152 120 *
153 121 * @since 2.5.0
@@ -160,33 +128,58 @@
160 128 }
161 129
162 130 // Bail if no access and refresh token exist.
163 131 if ( ! $this->settings->has_access_and_refresh_token() ) {
164 - // Redirect to General screen, which will now show the ConvertKit_Admin_Section_OAuth screen, because
165 - // the Plugin has no access token.
166 - wp_safe_redirect(
167 - add_query_arg(
168 - array(
169 - 'page' => $this->settings_key,
170 - ),
171 - 'options-general.php'
172 - )
173 - );
174 - exit();
132 + return;
175 133 }
176 134
135 + // Initialize the API.
136 + $this->api = new ConvertKit_API_V4(
137 + CONVERTKIT_OAUTH_CLIENT_ID,
138 + CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI,
139 + $this->settings->get_access_token(),
140 + $this->settings->get_refresh_token(),
141 + $this->settings->debug_enabled(),
142 + 'settings'
143 + );
144 +
177 145 // Get Account Details, which we'll use in account_name_callback(), but also lets us test
178 146 // whether the API credentials are valid.
179 - $account = new ConvertKit_Resource_Account();
180 - $this->account = $account->refresh();
147 + $this->account = $this->api->get_account();
181 148
182 149 // If the request succeeded, no need to perform further actions.
183 150 if ( ! is_wp_error( $this->account ) ) {
151 + // Remove any existing persistent notice.
152 + WP_ConvertKit()->get_class( 'admin_notices' )->delete( 'authorization_failed' );
153 +
184 154 return;
185 155 }
186 156
187 - // Depending on the error code, display an error notice in the settings screen until the user
157 + // Depending on the error code, maybe persist a notice in the WordPress Administration until the user
188 158 // fixes the problem.
159 + switch ( $this->account->get_error_data( $this->account->get_error_code() ) ) {
160 + case 401:
161 + // Access token either expired or was revoked in ConvertKit.
162 + // Remove from settings.
163 + $this->settings->delete_credentials();
164 +
165 + // Display a site wide notice.
166 + WP_ConvertKit()->get_class( 'admin_notices' )->add( 'authorization_failed' );
167 +
168 + // Redirect to General screen, which will now show the ConvertKit_Admin_Section_OAuth screen, because
169 + // the Plugin has no access token.
170 + wp_safe_redirect(
171 + add_query_arg(
172 + array(
173 + 'page' => $this->settings_key,
174 + ),
175 + 'options-general.php'
176 + )
177 + );
178 + exit();
179 + }
180 +
181 + // Output a non-401 error now.
189 182 $this->output_error( $this->account->get_error_message() );
190 183
191 184 }
192 185
@@ -210,56 +203,24 @@
210 203 if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_oauth_disconnect'] ), 'convertkit-oauth-disconnect' ) ) {
211 204 return;
212 205 }
213 206
214 - // Get Settings class.
207 + // Delete Access Token.
215 208 $settings = new ConvertKit_Settings();
209 + $settings->delete_credentials();
216 210
217 - // Setup API.
218 - $api = new ConvertKit_API_V4(
219 - CONVERTKIT_OAUTH_CLIENT_ID,
220 - CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI,
221 - $settings->get_access_token(),
222 - $settings->get_refresh_token(),
223 - $settings->debug_enabled(),
224 - 'settings'
225 - );
226 -
227 - // Check that we're using the Kit WordPress Libraries 2.1.4 or higher.
228 - // If another Kit Plugin is active and out of date, its libraries might
229 - // be loaded that don't have this method.
230 - if ( ! method_exists( $api, 'revoke_tokens' ) ) { // @phpstan-ignore-line Older WordPress Libraries won't have this function.
231 - $this->output_error( __( 'The Kit WordPress Libraries is missing the `revoke_tokens` method. Please update all Kit WordPress Plugins to their latest versions, and click Disconnect again.', 'convertkit' ) );
232 - return;
233 - }
234 -
235 - // Revoke Access and Refresh Tokens.
236 - // See convertkit_delete_credentials() method in functions.php, which is called
237 - // by the `convertkit_api_revoke_tokens` action and deletes credentials from the Plugin's settings.
238 - $result = $api->revoke_tokens();
239 - if ( is_wp_error( $result ) ) {
240 - $this->output_error( $result->get_error_message() );
241 - return;
242 - }
243 -
244 211 // Delete cached resources.
245 - $account = new ConvertKit_Resource_Account();
246 212 $creator_network = new ConvertKit_Resource_Creator_Network_Recommendations();
247 - $custom_fields = new ConvertKit_Resource_Custom_Fields();
248 213 $forms = new ConvertKit_Resource_Forms();
249 214 $landing_pages = new ConvertKit_Resource_Landing_Pages();
250 215 $posts = new ConvertKit_Resource_Posts();
251 216 $products = new ConvertKit_Resource_Products();
252 - $sequences = new ConvertKit_Resource_Sequences();
253 217 $tags = new ConvertKit_Resource_Tags();
254 - $account->delete();
255 218 $creator_network->delete();
256 - $custom_fields->delete();
257 219 $forms->delete();
258 220 $landing_pages->delete();
259 221 $posts->delete();
260 222 $products->delete();
261 - $sequences->delete();
262 223 $tags->delete();
263 224
264 225 // Redirect to General screen, which will now show the ConvertKit_Settings_OAuth screen, because
265 226 // the Plugin has no access token.
@@ -416,112 +377,8 @@
416 377 'label_for' => 'non_inline_form_honor_none_setting',
417 378 )
418 379 );
419 380
420 - // Non-inline Form Limit per Session.
421 - add_settings_field(
422 - 'non_inline_form_limit_per_session',
423 - __( 'Limit Display', 'convertkit' ),
424 - array( $this, 'non_inline_form_limit_per_session_callback' ),
425 - $this->settings_key,
426 - $this->name . '-site-wide',
427 - array(
428 - 'label_for' => 'non_inline_form_limit_per_session',
429 - )
430 - );
431 -
432 - // Spam Protection.
433 - add_settings_field(
434 - 'spam_protection_provider',
435 - __( 'Provider', 'convertkit' ),
436 - array( $this, 'spam_protection_provider_callback' ),
437 - $this->settings_key,
438 - $this->name . '-spam-protection',
439 - array(
440 - 'label_for' => 'spam_protection_provider',
441 - 'description' => array(
442 - __( 'Select which spam protection service to use for the Member Content signup form and Form Builder block.', 'convertkit' ),
443 - ),
444 - )
445 - );
446 -
447 - // reCAPTCHA.
448 - add_settings_field(
449 - 'recaptcha_site_key',
450 - __( 'reCAPTCHA: Site Key', 'convertkit' ),
451 - array( $this, 'recaptcha_site_key_callback' ),
452 - $this->settings_key,
453 - $this->name . '-spam-protection',
454 - array(
455 - 'label_for' => 'recaptcha_site_key',
456 - 'class' => 'convertkit-spam-protection-recaptcha',
457 - 'description' => array(
458 - __( 'Enter your Google reCAPTCHA v3 Site Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
459 - ),
460 - )
461 - );
462 - add_settings_field(
463 - 'recaptcha_secret_key',
464 - __( 'reCAPTCHA: Secret Key', 'convertkit' ),
465 - array( $this, 'recaptcha_secret_key_callback' ),
466 - $this->settings_key,
467 - $this->name . '-spam-protection',
468 - array(
469 - 'label_for' => 'recaptcha_secret_key',
470 - 'class' => 'convertkit-spam-protection-recaptcha',
471 - 'description' => array(
472 - __( 'Enter your Google reCAPTCHA v3 Secret Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
473 - ),
474 - )
475 - );
476 - add_settings_field(
477 - 'recaptcha_minimum_score',
478 - __( 'reCAPTCHA: Minimum Score', 'convertkit' ),
479 - array( $this, 'recaptcha_minimum_score_callback' ),
480 - $this->settings_key,
481 - $this->name . '-spam-protection',
482 - array(
483 - 'label_for' => 'recaptcha_minimum_score',
484 - 'class' => 'convertkit-spam-protection-recaptcha',
485 - 'min' => 0,
486 - 'max' => 1,
487 - 'step' => 0.01,
488 - 'description' => array(
489 - __( 'Enter the minimum threshold for a subscriber to pass Google reCAPTCHA. A higher number will reduce spam signups (1.0 is very likely a good interaction, 0.0 is very likely a bot).', 'convertkit' ),
490 - ),
491 - )
492 - );
493 -
494 - // Cloudflare Turnstile.
495 - add_settings_field(
496 - 'cloudflare_turnstile_site_key',
497 - __( 'Cloudflare Turnstile: Site Key', 'convertkit' ),
498 - array( $this, 'cloudflare_turnstile_site_key_callback' ),
499 - $this->settings_key,
500 - $this->name . '-spam-protection',
501 - array(
502 - 'label_for' => 'cloudflare_turnstile_site_key',
503 - 'class' => 'convertkit-spam-protection-cloudflare_turnstile',
504 - 'description' => array(
505 - __( 'Enter your Cloudflare Turnstile Site Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
506 - ),
507 - )
508 - );
509 - add_settings_field(
510 - 'cloudflare_turnstile_secret_key',
511 - __( 'Cloudflare Turnstile: Secret Key', 'convertkit' ),
512 - array( $this, 'cloudflare_turnstile_secret_key_callback' ),
513 - $this->settings_key,
514 - $this->name . '-spam-protection',
515 - array(
516 - 'label_for' => 'cloudflare_turnstile_secret_key',
517 - 'class' => 'convertkit-spam-protection-cloudflare_turnstile',
518 - 'description' => array(
519 - __( 'Enter your Cloudflare Turnstile Secret Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
520 - ),
521 - )
522 - );
523 -
524 381 // Advanced.
525 382 add_settings_field(
526 383 'debug',
527 384 __( 'Debug', 'convertkit' ),
@@ -554,30 +411,8 @@
554 411 'label_for' => 'no_css',
555 412 )
556 413 );
557 414
558 - add_settings_field(
559 - 'no_add_new_button',
560 - __( 'Disable Add New Landing Page / Member Content Button', 'convertkit' ),
561 - array( $this, 'no_add_new_button_callback' ),
562 - $this->settings_key,
563 - $this->name . '-advanced',
564 - array(
565 - 'label_for' => 'no_add_new_button',
566 - )
567 - );
568 -
569 - add_settings_field(
570 - 'usage_tracking',
571 - __( 'Usage Tracking', 'convertkit' ),
572 - array( $this, 'usage_tracking_callback' ),
573 - $this->settings_key,
574 - $this->name . '-advanced',
575 - array(
576 - 'label_for' => 'usage_tracking',
577 - )
578 - );
579 -
580 415 }
581 416
582 417 /**
583 418 * Prints help info for this section
@@ -584,11 +419,10 @@
584 419 */
585 420 public function print_section_info() {
586 421
587 422 ?>
588 - <p><?php esc_html_e( 'Forms can be embedded before and/or after (or following number of elements) on every post or page (in single view only) across your site by using the settings below.', 'convertkit' ); ?>
589 - <p><?php esc_html_e( 'You can also configure non-inline forms to display site wide under the "Non-inline Forms" section below.', 'convertkit' ); ?></p>
590 - <p><?php esc_html_e( 'These default form settings can be overridden using the Kit meta box on a page or post\'s edit screen. For site wide non-inline forms to respect when a post/page has forms disabled, enable the "Behavior" option in the "Non-inline Forms" section below.', 'convertkit' ); ?></p>
423 + <p><?php esc_html_e( 'Choosing a default form will embed it at the top, bottom or top and bottom of every post or page (in single view only) across your site.', 'convertkit' ); ?></p>
424 + <p><?php esc_html_e( 'If you wish to turn off form embedding or select a different form for an individual post or page, you can do so using the Kit meta box on the edit page.', 'convertkit' ); ?></p>
591 425 <p>
592 426 <?php
593 427 printf(
594 428 /* translators: [convertkit] shortcode, wrapped in <code> tags */
@@ -614,19 +448,8 @@
614 448
615 449 }
616 450
617 451 /**
618 - * Prints help info for the spam protection section of the settings screen.
619 - *
620 - * @since 3.3.7
621 - */
622 - public function print_section_info_spam_protection() {
623 - ?>
624 - <p class="description"><?php esc_html_e( 'Configure a spam protection service to protect the Member Content signup form and Form Builder block from spam and abuse. Choose a provider below, then enter the corresponding site and secret keys.', 'convertkit' ); ?></p>
625 - <?php
626 - }
627 -
628 - /**
629 452 * Prints help info for the advanced section of the settings screen.
630 453 *
631 454 * @since 2.7.1
632 455 */
@@ -646,9 +469,9 @@
646 469 * @return string Documentation URL.
647 470 */
648 471 public function documentation_url() {
649 472
650 - return 'https://help.kit.com/en/articles/2502591-how-to-set-up-the-kit-plugin-on-your-wordpress-website';
473 + return 'https://help.kit.com/en/articles/2502591-the-convertkit-wordpress-plugin';
651 474
652 475 }
653 476
654 477 /**
@@ -658,12 +481,11 @@
658 481 */
659 482 public function account_name_callback() {
660 483
661 484 // Output Account Name.
662 - // If account is an error, check_credentials() will output an error above the settings section.
663 485 $html = sprintf(
664 486 '<p>%s</p>',
665 - ! is_wp_error( $this->account ) && isset( $this->account['account']['name'] ) ? esc_attr( $this->account['account']['name'] ) : esc_html__( '(Not specified)', 'convertkit' )
487 + isset( $this->account['account']['name'] ) ? esc_attr( $this->account['account']['name'] ) : esc_html__( '(Not specified)', 'convertkit' )
666 488 );
667 489
668 490 // Display an option to disconnect.
669 491 $html .= sprintf(
@@ -679,10 +501,10 @@
679 501 ),
680 502 esc_html__( 'Disconnect', 'convertkit' )
681 503 );
682 504
683 - echo wp_kses( $html, convertkit_kses_allowed_html() );
684 -
505 + // Output has already been run through escaping functions above.
506 + echo $html; // phpcs:ignore WordPress.Security.EscapeOutput
685 507 }
686 508
687 509 /**
688 510 * Initialize resource classes and perform a and refresh of resources,
@@ -707,73 +529,27 @@
707 529 return;
708 530 }
709 531
710 532 // Refresh Forms.
711 - $result = $this->forms->refresh();
533 + $this->forms->refresh();
712 534
713 - // Bail if an error occured.
714 - if ( is_wp_error( $result ) ) {
715 - return;
716 - }
717 -
718 - // Also refresh other resources. Whilst not displayed in the Plugin Settings, this ensures up to date
535 + // Also refresh Landing Pages, Tags and Posts. Whilst not displayed in the Plugin Settings, this ensures up to date
719 536 // lists are stored for when editing e.g. Pages.
720 -
721 - // Refresh Custom Fields.
722 - $custom_fields = new ConvertKit_Resource_Custom_Fields( 'settings' );
723 - $result = $custom_fields->refresh();
724 -
725 - // Bail if an error occured.
726 - if ( is_wp_error( $result ) ) {
727 - return;
728 - }
729 -
730 - // Refresh Landing Pages.
731 537 $landing_pages = new ConvertKit_Resource_Landing_Pages( 'settings' );
732 - $result = $landing_pages->refresh();
538 + $landing_pages->refresh();
733 539
734 - // Bail if an error occured.
735 - if ( is_wp_error( $result ) ) {
736 - return;
737 - }
738 -
739 - // Refresh Posts.
740 540 remove_all_actions( 'convertkit_resource_refreshed_posts' );
741 - $posts = new ConvertKit_Resource_Posts( 'settings' );
742 - $result = $posts->refresh();
541 + $posts = new ConvertKit_Resource_Posts( 'settings' );
542 + $posts->refresh();
743 543
744 - // Bail if an error occured.
745 - if ( is_wp_error( $result ) ) {
746 - return;
747 - }
748 -
749 - // Refresh Products.
750 544 $products = new ConvertKit_Resource_Products( 'settings' );
751 - $result = $products->refresh();
545 + $products->refresh();
752 546
753 - // Bail if an error occured.
754 - if ( is_wp_error( $result ) ) {
755 - return;
756 - }
757 -
758 - // Refresh Sequences.
759 547 $sequences = new ConvertKit_Resource_Sequences( 'settings' );
760 - $result = $sequences->refresh();
548 + $sequences->refresh();
761 549
762 - // Bail if an error occured.
763 - if ( is_wp_error( $result ) ) {
764 - return;
765 - }
766 -
767 - // Refresh Tags.
768 - $tags = new ConvertKit_Resource_Tags( 'settings' );
769 - $result = $tags->refresh();
770 -
771 - // Bail if an error occured.
772 - if ( is_wp_error( $result ) ) {
773 - return;
774 - }
775 -
550 + $tags = new ConvertKit_Resource_Tags( 'settings' );
551 + $tags->refresh();
776 552 }
777 553
778 554 /**
779 555 * Renders the input for the Default Form setting for the given Post Type.
@@ -814,11 +590,10 @@
814 590 $args['post_type_object']->label
815 591 );
816 592 }
817 593
818 - // Output field.
819 - echo '<div class="convertkit-select2-container">';
820 - $this->forms->output_select_field_all(
594 + // Build field.
595 + $select_field = $this->forms->get_select_field_all(
821 596 $this->settings_key . '[' . $args['post_type'] . '_form]',
822 597 $this->settings_key . '_' . $args['post_type'] . '_form',
823 598 array(
824 599 'convertkit-select2',
@@ -833,10 +608,12 @@
833 608 'data-link' => esc_attr( $preview_url ) . '&convertkit_form_id=',
834 609 ),
835 610 $description
836 611 );
837 - echo '</div>';
838 612
613 + // Output field.
614 + echo '<div class="convertkit-select2-container">' . $select_field . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput
615 +
839 616 }
840 617
841 618 /**
842 619 * Renders the input for the Default Form Position setting for the given Post Type.
@@ -846,9 +623,9 @@
846 623 * @param array $args Field arguments.
847 624 */
848 625 public function default_form_position_callback( $args ) {
849 626
850 - $this->output_select_field(
627 + echo $this->get_select_field( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
851 628 $args['post_type'] . '_form_position',
852 629 esc_attr( $this->settings->get_default_form_position( $args['post_type'] ) ),
853 630 array(
854 631 'before_content' => sprintf(
@@ -890,9 +667,9 @@
890 667 * @param array $args Field arguments.
891 668 */
892 669 public function default_form_position_element_callback( $args ) {
893 670
894 - $this->output_number_field(
671 + echo $this->get_number_field( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
895 672 $args['post_type'] . '_form_position_element_index',
896 673 esc_attr( (string) $this->settings->get_default_form_position_element_index( $args['post_type'] ) ),
897 674 1,
898 675 999,
@@ -900,9 +677,9 @@
900 677 false,
901 678 array( 'after_element' )
902 679 );
903 680
904 - $this->output_select_field(
681 + echo $this->get_select_field( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
905 682 $args['post_type'] . '_form_position_element',
906 683 esc_attr( $this->settings->get_default_form_position_element( $args['post_type'] ) ),
907 684 array(
908 685 'p' => esc_html__( 'Paragraphs', 'convertkit' ),
@@ -943,11 +720,10 @@
943 720 '<a href="' . esc_url( $preview_url ) . '" id="convertkit-preview-non-inline-form" target="_blank">' . esc_html__( 'Click here', 'convertkit' ) . '</a>',
944 721 esc_html__( 'to preview how this will display.', 'convertkit' )
945 722 );
946 723
947 - // Output field.
948 - echo '<div class="convertkit-select2-container">';
949 - $this->forms->output_select_field_non_inline(
724 + // Build field.
725 + $select_field = $this->forms->get_select_field_non_inline(
950 726 $this->settings_key . '[non_inline_form]',
951 727 $this->settings_key . '_non_inline_form',
952 728 array(
953 729 'convertkit-select2',
@@ -960,10 +736,12 @@
960 736 'data-link' => esc_attr( $preview_url ) . '&convertkit_form_id=',
961 737 ),
962 738 $description
963 739 );
964 - echo '</div>';
965 740
741 + // Output field.
742 + echo '<div class="convertkit-select2-container">' . $select_field . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput
743 +
966 744 }
967 745
968 746 /**
969 747 * Renders the input for the Non-inline Form override setting.
@@ -972,167 +750,18 @@
972 750 */
973 751 public function non_inline_form_honor_none_setting_callback() {
974 752
975 753 // Output field.
976 - $this->output_checkbox_field(
754 + echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
977 755 'non_inline_form_honor_none_setting',
978 756 'on',
979 - $this->settings->non_inline_form_honor_none_setting(),
757 + $this->settings->non_inline_form_honor_none_setting(), // phpcs:ignore WordPress.Security.EscapeOutput
980 758 esc_html__( 'If checked, do not display the site wide form(s) above on Pages / Posts that have their Kit Form setting = None.', 'convertkit' )
981 759 );
982 760
983 761 }
984 762
985 -
986 763 /**
987 - * Renders the input for the Modal Form Limit per Session setting.
988 - *
989 - * @since 3.0.0
990 - *
991 - * @param array $args Setting field arguments (name,description).
992 - */
993 - public function non_inline_form_limit_per_session_callback( $args ) {
994 -
995 - // Output field.
996 - $this->output_checkbox_field(
997 - 'non_inline_form_limit_per_session',
998 - 'on',
999 - $this->settings->non_inline_form_limit_per_session(),
1000 - esc_html__( 'If checked, one non-inline form will be displayed per session. This applies to all non-inline forms defined on this screen, Page / Post / Category settings, and any Form blocks or shortcodes specifying a non-inline form.', 'convertkit' )
1001 - );
1002 -
1003 - }
1004 -
1005 - /**
1006 - * Renders the dropdown for choosing the active spam protection provider.
1007 - *
1008 - * @since 3.3.7
1009 - *
1010 - * @param array $args Setting field arguments (name,description).
1011 - */
1012 - public function spam_protection_provider_callback( $args ) {
1013 -
1014 - $this->output_select_field(
1015 - 'spam_protection_provider',
1016 - esc_attr( $this->settings->spam_protection_provider() ),
1017 - array(
1018 - 'recaptcha' => esc_html__( 'Google reCAPTCHA v3', 'convertkit' ),
1019 - 'cloudflare_turnstile' => esc_html__( 'Cloudflare Turnstile', 'convertkit' ),
1020 - ),
1021 - $args['description'],
1022 - array( 'convertkit-conditional-display' ),
1023 - array( 'data-conditional-class-prefix' => 'convertkit-spam-protection-' )
1024 - );
1025 -
1026 - }
1027 -
1028 - /**
1029 - * Renders the input for the reCAPTCHA Site Key setting.
1030 - *
1031 - * @since 3.0.0
1032 - *
1033 - * @param array $args Setting field arguments (name,description).
1034 - */
1035 - public function recaptcha_site_key_callback( $args ) {
1036 -
1037 - // Output field.
1038 - $this->output_text_field(
1039 - 'recaptcha_site_key',
1040 - esc_attr( $this->settings->recaptcha_site_key() ),
1041 - $args['description'],
1042 - array(
1043 - 'widefat',
1044 - )
1045 - );
1046 -
1047 - }
1048 -
1049 - /**
1050 - * Renders the input for the reCAPTCHA Secret Key setting.
1051 - *
1052 - * @since 3.0.0
1053 - *
1054 - * @param array $args Setting field arguments (name,description).
1055 - */
1056 - public function recaptcha_secret_key_callback( $args ) {
1057 -
1058 - // Output field.
1059 - $this->output_text_field(
1060 - 'recaptcha_secret_key',
1061 - esc_attr( $this->settings->recaptcha_secret_key() ),
1062 - $args['description'],
1063 - array(
1064 - 'widefat',
1065 - )
1066 - );
1067 -
1068 - }
1069 -
1070 - /**
1071 - * Renders the input for the reCAPTCHA Minimum Score setting.
1072 - *
1073 - * @since 3.0.0
1074 - *
1075 - * @param array $args Setting field arguments (name,description).
1076 - */
1077 - public function recaptcha_minimum_score_callback( $args ) {
1078 -
1079 - // Output field.
1080 - $this->output_number_field(
1081 - 'recaptcha_minimum_score',
1082 - esc_attr( (string) $this->settings->recaptcha_minimum_score() ),
1083 - $args['min'],
1084 - $args['max'],
1085 - $args['step'],
1086 - $args['description'],
1087 - array(
1088 - 'widefat',
1089 - )
1090 - );
1091 -
1092 - }
1093 -
1094 - /**
1095 - * Renders the input for the Cloudflare Turnstile Site Key setting.
1096 - *
1097 - * @since 3.3.7
1098 - *
1099 - * @param array $args Setting field arguments (name,description).
1100 - */
1101 - public function cloudflare_turnstile_site_key_callback( $args ) {
1102 -
1103 - $this->output_text_field(
1104 - 'cloudflare_turnstile_site_key',
1105 - esc_attr( $this->settings->cloudflare_turnstile_site_key() ),
1106 - $args['description'],
1107 - array(
1108 - 'widefat',
1109 - )
1110 - );
1111 -
1112 - }
1113 -
1114 - /**
1115 - * Renders the input for the Cloudflare Turnstile Secret Key setting.
1116 - *
1117 - * @since 3.3.7
1118 - *
1119 - * @param array $args Setting field arguments (name,description).
1120 - */
1121 - public function cloudflare_turnstile_secret_key_callback( $args ) {
1122 -
1123 - $this->output_text_field(
1124 - 'cloudflare_turnstile_secret_key',
1125 - esc_attr( $this->settings->cloudflare_turnstile_secret_key() ),
1126 - $args['description'],
1127 - array(
1128 - 'widefat',
1129 - )
1130 - );
1131 -
1132 - }
1133 -
1134 - /**
1135 764 * Renders the input for the Debug setting.
1136 765 *
1137 766 * @since 1.9.6
1138 767 */
@@ -1138,12 +767,12 @@
1138 767 */
1139 768 public function debug_callback() {
1140 769
1141 770 // Output field.
1142 - $this->output_checkbox_field(
771 + echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
1143 772 'debug',
1144 773 'on',
1145 - $this->settings->debug_enabled(),
774 + $this->settings->debug_enabled(), // phpcs:ignore WordPress.Security.EscapeOutput
1146 775 esc_html__( 'Log requests to file and output browser console messages.', 'convertkit' ),
1147 776 esc_html__( 'You can ignore this unless you\'re working with our support team to resolve an issue. Decheck this option to improve performance.', 'convertkit' )
1148 777 );
1149 778
@@ -1156,13 +785,13 @@
1156 785 */
1157 786 public function no_scripts_callback() {
1158 787
1159 788 // Output field.
1160 - $this->output_checkbox_field(
789 + echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
1161 790 'no_scripts',
1162 791 'on',
1163 - $this->settings->scripts_disabled(),
1164 - esc_html__( 'Prevent plugin JavaScript files loading on the frontend site. This will disable the custom content and tagging features of the plugin. Does not apply to embedding forms or landing pages. Use with caution!', 'convertkit' )
792 + $this->settings->scripts_disabled(), // phpcs:ignore WordPress.Security.EscapeOutput
793 + esc_html__( 'Prevent plugin from loading JavaScript files. This will disable the custom content and tagging features of the plugin. Does not apply to landing pages. Use with caution!', 'convertkit' )
1165 794 );
1166 795
1167 796 }
1168 797
@@ -1173,12 +802,12 @@
1173 802 */
1174 803 public function no_css_callback() {
1175 804
1176 805 // Output field.
1177 - $this->output_checkbox_field(
806 + echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
1178 807 'no_css',
1179 808 'on',
1180 - $this->settings->css_disabled(),
809 + $this->settings->css_disabled(), // phpcs:ignore WordPress.Security.EscapeOutput
1181 810 esc_html__( 'Prevents loading plugin CSS files. This will disable styling on broadcasts, form trigger buttons, product buttons and member\'s content. Use with caution!', 'convertkit' ),
1182 811 array(
1183 812 sprintf(
1184 813 '%s <a href="%s" target="_blank">%s</a>',
@@ -1185,9 +814,8 @@
1185 814 esc_html__( 'To customize forms and their styling, use the', 'convertkit' ),
1186 815 esc_url( convertkit_get_form_editor_url() ),
1187 816 esc_html__( 'Kit form editor', 'convertkit' )
1188 817 ),
1189 - esc_html__( 'For creators who require form designs to follow their WordPress theme, use the Kit Form Builder block in the block editor.', 'convertkit' ),
1190 818 sprintf(
1191 819 '%s <a href="https://wordpress.org/plugins/contact-form-7/" target="_blank">Contact Form 7</a>, <a href="https://wordpress.org/plugins/convertkit-gravity-forms/" target="_blank">Gravity Forms</a> %s <a href="https://wordpress.org/plugins/integrate-convertkit-wpforms/" target="_blank">WPForms</a> %s',
1192 820 esc_html__( 'For developers who require custom form designs through use of CSS, consider using the', 'convertkit' ),
1193 821 esc_html__( 'or', 'convertkit' ),
@@ -1198,50 +826,8 @@
1198 826
1199 827 }
1200 828
1201 829 /**
1202 - * Renders the input for the Disable Add New Landing Page / Member Content setting.
1203 - *
1204 - * @since 3.2.0
1205 - */
1206 - public function no_add_new_button_callback() {
1207 -
1208 - // Output field.
1209 - $this->output_checkbox_field(
1210 - 'no_add_new_button',
1211 - 'on',
1212 - $this->settings->add_new_button_disabled(),
1213 - esc_html__( 'Hide the "Add New" button on Pages for creating Landing Pages and Member Content.', 'convertkit' )
1214 - );
1215 -
1216 - }
1217 -
1218 - /**
1219 - * Renders the input for the Usage Tracking setting.
1220 - *
1221 - * @since 3.0.4
1222 - */
1223 - public function usage_tracking_callback() {
1224 -
1225 - // Output field.
1226 - $this->output_checkbox_field(
1227 - 'usage_tracking',
1228 - 'on',
1229 - $this->settings->usage_tracking(),
1230 - esc_html__( 'By allowing us to collect usage data, we can better understand which WordPress configurations, themes and plugins we should test.', 'convertkit' ),
1231 - array(
1232 - sprintf(
1233 - '%s <a href="%s" target="_blank">%s</a>',
1234 - esc_html__( 'Complete documentation on usage tracking can be found', 'convertkit' ),
1235 - $this->documentation_url(),
1236 - esc_html__( 'here', 'convertkit' )
1237 - ),
1238 - )
1239 - );
1240 -
1241 - }
1242 -
1243 - /**
1244 830 * Sanitizes the settings prior to being saved.
1245 831 *
1246 832 * @since 2.4.3
1247 833 *
@@ -1253,9 +839,9 @@
1253 839 // If no Access Token, Refresh Token or Token Expiry keys were specified in the settings
1254 840 // prior to save, don't overwrite them with the blank setting from get_defaults().
1255 841 // This ensures we only blank these values if we explicitly do so via $settings,
1256 842 // as they won't be included in the Settings screen for security.
1257 - if ( ! filter_has_var( INPUT_GET, 'disconnect' ) ) {
843 + if ( ! array_key_exists( 'disconnect', $_REQUEST ) ) { // phpcs:ignore WordPress.Security.NonceVerification
1258 844 // If settings are null, no checkboxes were ticked and no other form elements
1259 845 // were submitted i.e. the Kit account has no forms.
1260 846 if ( is_null( $settings ) ) {
1261 847 $settings = array();