PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.8.6
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.8.6
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-tools.php +31 -71 3.4.2 → 2.8.6 View file →
@@ -18,8 +18,12 @@
18 18 * Constructor
19 19 */
20 20 public function __construct() {
21 21
22 + // Initialize WP_Filesystem.
23 + require_once ABSPATH . 'wp-admin/includes/file.php';
24 + WP_Filesystem();
25 +
22 26 $this->settings_key = '_wp_convertkit_tools'; // Required for ConvertKit_Settings_Base, but we don't save settings on the Tools screen.
23 27 $this->name = 'tools';
24 28 $this->title = __( 'Tools', 'convertkit' );
25 29 $this->tab_text = __( 'Tools', 'convertkit' );
@@ -27,8 +31,9 @@
27 31 // Register and maybe output notices for this settings screen, and the Intercom messenger.
28 32 if ( $this->on_settings_screen( $this->name ) ) {
29 33 add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) );
30 34 add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) );
35 + add_action( 'admin_footer', array( $this, 'output_intercom' ) );
31 36 }
32 37
33 38 parent::__construct();
34 39
@@ -48,19 +53,12 @@
48 53
49 54 return array_merge(
50 55 $notices,
51 56 array(
52 - 'import_configuration_upload_error' => __( 'An error occured uploading the configuration file.', 'convertkit' ),
53 - 'import_configuration_invalid_file_type' => __( 'The uploaded configuration file isn\'t valid.', 'convertkit' ),
54 - 'import_configuration_empty' => __( 'The uploaded configuration file contains no settings.', 'convertkit' ),
55 - 'import_configuration_success' => __( 'Configuration imported successfully.', 'convertkit' ),
56 - 'migrate_activecampaign_configuration_success' => __( 'ActiveCampaign forms migrated successfully.', 'convertkit' ),
57 - 'migrate_aweber_configuration_success' => __( 'AWeber forms migrated successfully.', 'convertkit' ),
58 - 'migrate_campaignmonitor_configuration_success' => __( 'Campaign Monitor forms migrated successfully.', 'convertkit' ),
59 - 'migrate_convertkit_legacy_forms_configuration_success' => __( 'Kit Legacy Forms migrated successfully.', 'convertkit' ),
60 - 'migrate_mc4wp_configuration_success' => __( 'MC4WP forms migrated successfully.', 'convertkit' ),
61 - 'migrate_mailpoet_configuration_success' => __( 'MailPoet forms migrated successfully.', 'convertkit' ),
62 - 'migrate_newsletter_configuration_success' => __( 'Newsletter forms migrated successfully.', 'convertkit' ),
57 + 'import_configuration_upload_error' => __( 'An error occured uploading the configuration file.', 'convertkit' ),
58 + 'import_configuration_invalid_file_type' => __( 'The uploaded configuration file isn\'t valid.', 'convertkit' ),
59 + 'import_configuration_empty' => __( 'The uploaded configuration file contains no settings.', 'convertkit' ),
60 + 'import_configuration_success' => __( 'Configuration imported successfully.', 'convertkit' ),
63 61 )
64 62 );
65 63
66 64 }
@@ -77,9 +75,8 @@
77 75 $this->maybe_download_log();
78 76 $this->maybe_download_system_info();
79 77 $this->maybe_export_configuration();
80 78 $this->maybe_import_configuration();
81 - $this->maybe_migrate_forms();
82 79
83 80 }
84 81
85 82 /**
@@ -120,8 +117,10 @@
120 117 * @since 1.9.6
121 118 */
122 119 private function maybe_download_log() {
123 120
121 + global $wp_filesystem;
122 +
124 123 // Bail if nonce verification fails.
125 124 if ( ! isset( $_REQUEST['_convertkit_settings_tools_nonce'] ) ) {
126 125 return;
127 126 }
@@ -142,10 +141,9 @@
142 141 header( 'Content-type: application/octet-stream' );
143 142 header( 'Content-Disposition: attachment; filename=convertkit-log.txt' );
144 143 header( 'Pragma: no-cache' );
145 144 header( 'Expires: 0' );
146 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
147 - echo esc_html( (string) file_get_contents( $log->get_filename() ) );
145 + echo esc_html( $wp_filesystem->get_contents( $log->get_filename() ) );
148 146 exit();
149 147
150 148 }
151 149
@@ -156,8 +154,10 @@
156 154 * @since 1.9.6
157 155 */
158 156 private function maybe_download_system_info() {
159 157
158 + global $wp_filesystem;
159 +
160 160 // Bail if nonce verification fails.
161 161 if ( ! isset( $_REQUEST['_convertkit_settings_tools_nonce'] ) ) {
162 162 return;
163 163 }
@@ -173,14 +173,23 @@
173 173
174 174 // Get System Info.
175 175 $system_info = $this->get_system_info();
176 176
177 + // Write contents to temporary file.
178 + $tmpfile = tmpfile();
179 + $filename = stream_get_meta_data( $tmpfile )['uri'];
180 + $wp_filesystem->put_contents(
181 + $filename,
182 + esc_attr( $system_info )
183 + );
184 +
177 185 // Download.
178 186 header( 'Content-type: application/octet-stream' );
179 187 header( 'Content-Disposition: attachment; filename=convertkit-system-info.txt' );
180 188 header( 'Pragma: no-cache' );
181 189 header( 'Expires: 0' );
182 - echo esc_html( $system_info );
190 + echo esc_html( $wp_filesystem->get_contents( $filename ) );
191 + $wp_filesystem->delete( $filename );
183 192 exit();
184 193
185 194 }
186 195
@@ -246,8 +255,13 @@
246 255 if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_tools_nonce'] ), 'convertkit-settings-tools' ) ) {
247 256 return;
248 257 }
249 258
259 + // Allow us to easily interact with the filesystem.
260 + require_once ABSPATH . 'wp-admin/includes/file.php';
261 + WP_Filesystem();
262 + global $wp_filesystem;
263 +
250 264 // Bail if the submit button for importing the configuration was not clicked.
251 265 if ( ! array_key_exists( 'convertkit-import', $_REQUEST ) ) {
252 266 return;
253 267 }
@@ -262,10 +276,9 @@
262 276 $this->redirect_with_error_notice( 'import_configuration_upload_error' );
263 277 }
264 278
265 279 // Read file.
266 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
267 - $json = file_get_contents( sanitize_text_field( wp_unslash( $_FILES['import']['tmp_name'] ) ) );
280 + $json = $wp_filesystem->get_contents( sanitize_text_field( wp_unslash( $_FILES['import']['tmp_name'] ) ) );
268 281
269 282 // Decode.
270 283 $import = json_decode( $json, true );
271 284
@@ -302,52 +315,8 @@
302 315
303 316 }
304 317
305 318 /**
306 - * Replaces ActiveCampaign Form Shortcodes and Blocks with Kit Form Shortcodes and Blocks, if the user submitted the
307 - * ActiveCampaign Migrate Configuration section.
308 - *
309 - * @since 3.1.7
310 - */
311 - private function maybe_migrate_forms() {
312 -
313 - // Bail if nonce verification fails.
314 - if ( ! isset( $_REQUEST['_convertkit_settings_tools_nonce'] ) ) {
315 - return;
316 - }
317 -
318 - if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_tools_nonce'] ), 'convertkit-settings-tools' ) ) {
319 - return;
320 - }
321 -
322 - // Get importers.
323 - $importers = convertkit_get_form_importers();
324 -
325 - // Find the importer that was used for the form submission.
326 - foreach ( $importers as $importer ) {
327 - // Skip if this importer was not used.
328 - if ( ! isset( $_REQUEST[ 'convertkit-import-' . $importer['name'] ] ) ) {
329 - continue;
330 - }
331 -
332 - // Skip if no mappings were submitted for the importer.
333 - if ( ! isset( $_REQUEST[ '_wp_convertkit_integration_' . $importer['name'] . '_settings' ] ) ) {
334 - continue;
335 - }
336 -
337 - // Sanitize mappings.
338 - $mappings = array_map( 'sanitize_text_field', wp_unslash( $_REQUEST[ '_wp_convertkit_integration_' . $importer['name'] . '_settings' ] ) );
339 -
340 - // Replace third party form shortcodes and blocks with Kit form shortcodes and blocks.
341 - WP_ConvertKit()->get_class( 'admin_importer_' . $importer['name'] )->import( $mappings );
342 -
343 - // Redirect to Tools screen.
344 - $this->redirect_with_success_notice( 'migrate_' . $importer['name'] . '_configuration_success' );
345 - }
346 -
347 - }
348 -
349 - /**
350 319 * Outputs the Debug Log and System Info view.
351 320 *
352 321 * @since 1.9.6
353 322 */
@@ -363,17 +332,8 @@
363 332 // Get Log and System Info.
364 333 $log = new ConvertKit_Log( CONVERTKIT_PLUGIN_PATH );
365 334 $system_info = $this->get_system_info();
366 335
367 - // Get Forms.
368 - $forms = new ConvertKit_Resource_Forms();
369 -
370 - // Get Importers, if Kit Forms exist.
371 - $importers = array();
372 - if ( $forms->exist() ) {
373 - $importers = convertkit_get_form_importers();
374 - }
375 -
376 336 // Output view.
377 337 require_once CONVERTKIT_PLUGIN_PATH . '/views/backend/settings/tools.php';
378 338
379 339 /**
@@ -404,9 +364,9 @@
404 364 * @return string Documentation URL.
405 365 */
406 366 public function documentation_url() {
407 367
408 - return 'https://help.kit.com/en/articles/2502591-how-to-set-up-the-kit-plugin-on-your-wordpress-website';
368 + return 'https://help.kit.com/en/articles/2502591-the-convertkit-wordpress-plugin';
409 369
410 370 }
411 371
412 372 /**