PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.6
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.6
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/section/class-convertkit-admin-section-general.php +189 -38 3.3.4 → 3.4.6 View file →
@@ -14,17 +14,8 @@
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 - /**
27 18 * Holds the ConvertKit Account Name.
28 19 *
29 20 * @since 1.9.6
30 21 *
@@ -52,30 +43,30 @@
52 43 // Define the settings key.
53 44 $this->settings_key = $this->settings::SETTINGS_NAME;
54 45
55 46 // Define the programmatic name, Title and Tab Text.
56 - $this->name = 'general';
57 - $this->title = __( 'General Settings', 'convertkit' );
47 + $this->name = $this->settings->get_name();
48 + $this->title = $this->settings->get_title();
58 49 $this->tab_text = __( 'General', 'convertkit' );
59 50
60 51 // Define settings sections.
61 52 $this->settings_sections = array(
62 - 'general' => array(
53 + 'general' => array(
63 54 'title' => $this->title,
64 55 'callback' => array( $this, 'print_section_info' ),
65 56 'wrap' => true,
66 57 ),
67 - 'site-wide' => array(
58 + 'site-wide' => array(
68 59 'title' => __( 'Non-inline Forms', 'convertkit' ),
69 60 'callback' => array( $this, 'print_section_info_site_wide' ),
70 61 'wrap' => true,
71 62 ),
72 - 'recaptcha' => array(
73 - 'title' => __( 'reCAPTCHA', 'convertkit' ),
74 - 'callback' => array( $this, 'print_section_info_recaptcha' ),
63 + 'spam-protection' => array(
64 + 'title' => __( 'Spam Protection', 'convertkit' ),
65 + 'callback' => array( $this, 'print_section_info_spam_protection' ),
75 66 'wrap' => true,
76 67 ),
77 - 'advanced' => array(
68 + 'advanced' => array(
78 69 'title' => __( 'Advanced', 'convertkit' ),
79 70 'callback' => array( $this, 'print_section_info_advanced' ),
80 71 'wrap' => true,
81 72 ),
@@ -86,8 +77,9 @@
86 77 // Register and maybe output notices for this settings screen, and the Intercom messenger.
87 78 if ( $this->on_settings_screen( $this->name ) ) {
88 79 add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) );
89 80 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' ) );
90 82 }
91 83
92 84 // Enqueue scripts and CSS.
93 85 add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -119,8 +111,43 @@
119 111
120 112 }
121 113
122 114 /**
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 + /**
123 150 * Test the access token, if it exists.
124 151 * If the access token has been revoked or is invalid, remove it from the settings now.
125 152 *
126 153 * @since 2.5.0
@@ -146,21 +173,12 @@
146 173 );
147 174 exit();
148 175 }
149 176
150 - // Initialize the API.
151 - $this->api = new ConvertKit_API_V4(
152 - CONVERTKIT_OAUTH_CLIENT_ID,
153 - CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI,
154 - $this->settings->get_access_token(),
155 - $this->settings->get_refresh_token(),
156 - $this->settings->debug_enabled(),
157 - 'settings'
158 - );
159 -
160 177 // Get Account Details, which we'll use in account_name_callback(), but also lets us test
161 178 // whether the API credentials are valid.
162 - $this->account = $this->api->get_account();
179 + $account = new ConvertKit_Resource_Account();
180 + $this->account = $account->refresh();
163 181
164 182 // If the request succeeded, no need to perform further actions.
165 183 if ( ! is_wp_error( $this->account ) ) {
166 184 return;
@@ -184,13 +202,18 @@
184 202 if ( ! $this->on_settings_screen( $this->name ) ) {
185 203 return;
186 204 }
187 205
206 + // Bail if the user is not permitted to disconnect the Plugin from a Kit account.
207 + if ( ! current_user_can( 'manage_options' ) ) {
208 + return;
209 + }
210 +
188 211 // Bail if nonce verification fails.
189 212 if ( ! isset( $_REQUEST['_convertkit_settings_oauth_disconnect'] ) ) {
190 213 return;
191 214 }
192 - if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_oauth_disconnect'] ), 'convertkit-oauth-disconnect' ) ) {
215 + if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_oauth_disconnect'] ), CONVERTKIT_NONCE_ACTION_OAUTH_DISCONNECT ) ) {
193 216 return;
194 217 }
195 218
196 219 // Get Settings class.
@@ -223,8 +246,9 @@
223 246 return;
224 247 }
225 248
226 249 // Delete cached resources.
250 + $account = new ConvertKit_Resource_Account();
227 251 $creator_network = new ConvertKit_Resource_Creator_Network_Recommendations();
228 252 $custom_fields = new ConvertKit_Resource_Custom_Fields();
229 253 $forms = new ConvertKit_Resource_Forms();
230 254 $landing_pages = new ConvertKit_Resource_Landing_Pages();
@@ -231,8 +255,9 @@
231 255 $posts = new ConvertKit_Resource_Posts();
232 256 $products = new ConvertKit_Resource_Products();
233 257 $sequences = new ConvertKit_Resource_Sequences();
234 258 $tags = new ConvertKit_Resource_Tags();
259 + $account->delete();
235 260 $creator_network->delete();
236 261 $custom_fields->delete();
237 262 $forms->delete();
238 263 $landing_pages->delete();
@@ -408,8 +433,23 @@
408 433 'label_for' => 'non_inline_form_limit_per_session',
409 434 )
410 435 );
411 436
437 + // Spam Protection.
438 + add_settings_field(
439 + 'spam_protection_provider',
440 + __( 'Provider', 'convertkit' ),
441 + array( $this, 'spam_protection_provider_callback' ),
442 + $this->settings_key,
443 + $this->name . '-spam-protection',
444 + array(
445 + 'label_for' => 'spam_protection_provider',
446 + 'description' => array(
447 + __( 'Select which spam protection service to use for the Member Content signup form and Form Builder block.', 'convertkit' ),
448 + ),
449 + )
450 + );
451 +
412 452 // reCAPTCHA.
413 453 add_settings_field(
414 454 'recaptcha_site_key',
415 455 __( 'reCAPTCHA: Site Key', 'convertkit' ),
@@ -414,11 +454,12 @@
414 454 'recaptcha_site_key',
415 455 __( 'reCAPTCHA: Site Key', 'convertkit' ),
416 456 array( $this, 'recaptcha_site_key_callback' ),
417 457 $this->settings_key,
418 - $this->name . '-recaptcha',
458 + $this->name . '-spam-protection',
419 459 array(
420 460 'label_for' => 'recaptcha_site_key',
461 + 'class' => 'convertkit-spam-protection-recaptcha',
421 462 'description' => array(
422 463 __( 'Enter your Google reCAPTCHA v3 Site Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
423 464 ),
424 465 )
@@ -427,11 +468,12 @@
427 468 'recaptcha_secret_key',
428 469 __( 'reCAPTCHA: Secret Key', 'convertkit' ),
429 470 array( $this, 'recaptcha_secret_key_callback' ),
430 471 $this->settings_key,
431 - $this->name . '-recaptcha',
472 + $this->name . '-spam-protection',
432 473 array(
433 474 'label_for' => 'recaptcha_secret_key',
475 + 'class' => 'convertkit-spam-protection-recaptcha',
434 476 'description' => array(
435 477 __( 'Enter your Google reCAPTCHA v3 Secret Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
436 478 ),
437 479 )
@@ -440,11 +482,12 @@
440 482 'recaptcha_minimum_score',
441 483 __( 'reCAPTCHA: Minimum Score', 'convertkit' ),
442 484 array( $this, 'recaptcha_minimum_score_callback' ),
443 485 $this->settings_key,
444 - $this->name . '-recaptcha',
486 + $this->name . '-spam-protection',
445 487 array(
446 488 'label_for' => 'recaptcha_minimum_score',
489 + 'class' => 'convertkit-spam-protection-recaptcha',
447 490 'min' => 0,
448 491 'max' => 1,
449 492 'step' => 0.01,
450 493 'description' => array(
@@ -452,8 +495,38 @@
452 495 ),
453 496 )
454 497 );
455 498
499 + // Cloudflare Turnstile.
500 + add_settings_field(
501 + 'cloudflare_turnstile_site_key',
502 + __( 'Cloudflare Turnstile: Site Key', 'convertkit' ),
503 + array( $this, 'cloudflare_turnstile_site_key_callback' ),
504 + $this->settings_key,
505 + $this->name . '-spam-protection',
506 + array(
507 + 'label_for' => 'cloudflare_turnstile_site_key',
508 + 'class' => 'convertkit-spam-protection-cloudflare_turnstile',
509 + 'description' => array(
510 + __( 'Enter your Cloudflare Turnstile Site Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
511 + ),
512 + )
513 + );
514 + add_settings_field(
515 + 'cloudflare_turnstile_secret_key',
516 + __( 'Cloudflare Turnstile: Secret Key', 'convertkit' ),
517 + array( $this, 'cloudflare_turnstile_secret_key_callback' ),
518 + $this->settings_key,
519 + $this->name . '-spam-protection',
520 + array(
521 + 'label_for' => 'cloudflare_turnstile_secret_key',
522 + 'class' => 'convertkit-spam-protection-cloudflare_turnstile',
523 + 'description' => array(
524 + __( 'Enter your Cloudflare Turnstile Secret Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
525 + ),
526 + )
527 + );
528 +
456 529 // Advanced.
457 530 add_settings_field(
458 531 'debug',
459 532 __( 'Debug', 'convertkit' ),
@@ -546,15 +619,15 @@
546 619
547 620 }
548 621
549 622 /**
550 - * Prints help info for the recaptcha section of the settings screen.
623 + * Prints help info for the spam protection section of the settings screen.
551 624 *
552 - * @since 3.0.0
625 + * @since 3.3.7
553 626 */
554 - public function print_section_info_recaptcha() {
627 + public function print_section_info_spam_protection() {
555 628 ?>
556 - <p class="description"><?php esc_html_e( 'Configure reCAPTCHA to protect the Member Content signup form and Form Builder block from spam and abuse.', 'convertkit' ); ?></p>
629 + <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>
557 630 <?php
558 631 }
559 632
560 633 /**
@@ -603,9 +676,9 @@
603 676 esc_url(
604 677 add_query_arg(
605 678 array(
606 679 'page' => '_wp_convertkit_settings',
607 - '_convertkit_settings_oauth_disconnect' => wp_create_nonce( 'convertkit-oauth-disconnect' ),
680 + '_convertkit_settings_oauth_disconnect' => wp_create_nonce( CONVERTKIT_NONCE_ACTION_OAUTH_DISCONNECT ),
608 681 ),
609 682 'options-general.php'
610 683 )
611 684 ),
@@ -646,10 +719,21 @@
646 719 if ( is_wp_error( $result ) ) {
647 720 return;
648 721 }
649 722
650 - // Also refresh Landing Pages, Tags and Posts. Whilst not displayed in the Plugin Settings, this ensures up to date
723 + // Also refresh other resources. Whilst not displayed in the Plugin Settings, this ensures up to date
651 724 // lists are stored for when editing e.g. Pages.
725 +
726 + // Refresh Custom Fields.
727 + $custom_fields = new ConvertKit_Resource_Custom_Fields( 'settings' );
728 + $result = $custom_fields->refresh();
729 +
730 + // Bail if an error occured.
731 + if ( is_wp_error( $result ) ) {
732 + return;
733 + }
734 +
735 + // Refresh Landing Pages.
652 736 $landing_pages = new ConvertKit_Resource_Landing_Pages( 'settings' );
653 737 $result = $landing_pages->refresh();
654 738
655 739 // Bail if an error occured.
@@ -656,8 +740,9 @@
656 740 if ( is_wp_error( $result ) ) {
657 741 return;
658 742 }
659 743
744 + // Refresh Posts.
660 745 remove_all_actions( 'convertkit_resource_refreshed_posts' );
661 746 $posts = new ConvertKit_Resource_Posts( 'settings' );
662 747 $result = $posts->refresh();
663 748
@@ -665,8 +750,9 @@
665 750 if ( is_wp_error( $result ) ) {
666 751 return;
667 752 }
668 753
754 + // Refresh Products.
669 755 $products = new ConvertKit_Resource_Products( 'settings' );
670 756 $result = $products->refresh();
671 757
672 758 // Bail if an error occured.
@@ -673,8 +759,9 @@
673 759 if ( is_wp_error( $result ) ) {
674 760 return;
675 761 }
676 762
763 + // Refresh Sequences.
677 764 $sequences = new ConvertKit_Resource_Sequences( 'settings' );
678 765 $result = $sequences->refresh();
679 766
680 767 // Bail if an error occured.
@@ -681,8 +768,9 @@
681 768 if ( is_wp_error( $result ) ) {
682 769 return;
683 770 }
684 771
772 + // Refresh Tags.
685 773 $tags = new ConvertKit_Resource_Tags( 'settings' );
686 774 $result = $tags->refresh();
687 775
688 776 // Bail if an error occured.
@@ -919,8 +1007,31 @@
919 1007
920 1008 }
921 1009
922 1010 /**
1011 + * Renders the dropdown for choosing the active spam protection provider.
1012 + *
1013 + * @since 3.3.7
1014 + *
1015 + * @param array $args Setting field arguments (name,description).
1016 + */
1017 + public function spam_protection_provider_callback( $args ) {
1018 +
1019 + $this->output_select_field(
1020 + 'spam_protection_provider',
1021 + esc_attr( $this->settings->spam_protection_provider() ),
1022 + array(
1023 + 'recaptcha' => esc_html__( 'Google reCAPTCHA v3', 'convertkit' ),
1024 + 'cloudflare_turnstile' => esc_html__( 'Cloudflare Turnstile', 'convertkit' ),
1025 + ),
1026 + $args['description'],
1027 + array( 'convertkit-conditional-display' ),
1028 + array( 'data-conditional-class-prefix' => 'convertkit-spam-protection-' )
1029 + );
1030 +
1031 + }
1032 +
1033 + /**
923 1034 * Renders the input for the reCAPTCHA Site Key setting.
924 1035 *
925 1036 * @since 3.0.0
926 1037 *
@@ -976,8 +1087,48 @@
976 1087 esc_attr( (string) $this->settings->recaptcha_minimum_score() ),
977 1088 $args['min'],
978 1089 $args['max'],
979 1090 $args['step'],
1091 + $args['description'],
1092 + array(
1093 + 'widefat',
1094 + )
1095 + );
1096 +
1097 + }
1098 +
1099 + /**
1100 + * Renders the input for the Cloudflare Turnstile Site Key setting.
1101 + *
1102 + * @since 3.3.7
1103 + *
1104 + * @param array $args Setting field arguments (name,description).
1105 + */
1106 + public function cloudflare_turnstile_site_key_callback( $args ) {
1107 +
1108 + $this->output_text_field(
1109 + 'cloudflare_turnstile_site_key',
1110 + esc_attr( $this->settings->cloudflare_turnstile_site_key() ),
1111 + $args['description'],
1112 + array(
1113 + 'widefat',
1114 + )
1115 + );
1116 +
1117 + }
1118 +
1119 + /**
1120 + * Renders the input for the Cloudflare Turnstile Secret Key setting.
1121 + *
1122 + * @since 3.3.7
1123 + *
1124 + * @param array $args Setting field arguments (name,description).
1125 + */
1126 + public function cloudflare_turnstile_secret_key_callback( $args ) {
1127 +
1128 + $this->output_text_field(
1129 + 'cloudflare_turnstile_secret_key',
1130 + esc_attr( $this->settings->cloudflare_turnstile_secret_key() ),
980 1131 $args['description'],
981 1132 array(
982 1133 'widefat',
983 1134 )