PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.5.9
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.5.9
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 2.3.3 All 194 releases
← All changes | includes/functions.php +178 -38 2.2.72.5.9 View file →
@@ -106,13 +106,35 @@
106 106 * @return array Post Types
107 107 */
108 108 function convertkit_get_supported_post_types() {
109 109
110 + // Define supported Post Types.
110 111 $post_types = array(
111 112 'page',
112 113 'post',
113 114 );
114 115
116 + // If public Custom Post Types can be fetched, include them now.
117 + if ( function_exists( 'get_post_types' ) ) {
118 + // Get public Custom Post Types.
119 + $custom_post_types = get_post_types(
120 + array(
121 + 'public' => true,
122 +
123 + // Don't include WordPress' built in Post Types, such as attachment, revisino and nav_menu_item.
124 + '_builtin' => false,
125 + )
126 + );
127 +
128 + // Sanity check an array was returned.
129 + if ( is_array( $custom_post_types ) ) {
130 + $post_types = array_merge(
131 + $post_types,
132 + array_keys( $custom_post_types )
133 + );
134 + }
135 + }
136 +
115 137 /**
116 138 * Defines the Post Types that support ConvertKit Forms.
117 139 *
118 140 * @since 1.9.6
@@ -129,27 +151,16 @@
129 151 * Helper method to get supported Post Types for Restricted Content (Member's Content)
130 152 *
131 153 * @since 2.1.0
132 154 *
155 + * @deprecated 2.4.3 No longer used by internal code and not recommended. Use `convertkit_get_supported_post_types` instead.
156 + *
133 157 * @return array Post Types
134 158 */
135 159 function convertkit_get_supported_restrict_content_post_types() {
136 160
137 - $post_types = array(
138 - 'page',
139 - );
161 + return convertkit_get_supported_post_types();
140 162
141 - /**
142 - * Defines the Post Types that support Restricted Content / Members Content functionality.
143 - *
144 - * @since 2.0.0
145 - *
146 - * @param array $post_types Post Types
147 - */
148 - $post_types = apply_filters( 'convertkit_get_supported_restrict_content_post_types', $post_types );
149 -
150 - return $post_types;
151 -
152 163 }
153 164
154 165 /**
155 166 * Helper method to get registered Shortcodes.
@@ -223,8 +234,32 @@
223 234
224 235 }
225 236
226 237 /**
238 + * Helper method to get registered pre-publish actions.
239 + *
240 + * @since 2.4.0
241 + *
242 + * @return array Pre-publish actions
243 + */
244 +function convertkit_get_pre_publish_actions() {
245 +
246 + $pre_publish_actions = array();
247 +
248 + /**
249 + * Registers pre-publish actions for the ConvertKit Plugin.
250 + *
251 + * @since 2.4.0
252 + *
253 + * @param array $pre_publish_panels Pre-publish actions.
254 + */
255 + $pre_publish_actions = apply_filters( 'convertkit_get_pre_publish_actions', $pre_publish_actions );
256 +
257 + return $pre_publish_actions;
258 +
259 +}
260 +
261 +/**
227 262 * Helper method to return the Plugin Settings Link
228 263 *
229 264 * @since 1.9.6
230 265 *
@@ -260,9 +295,9 @@
260 295 'page' => 'convertkit-setup',
261 296 )
262 297 );
263 298
264 - return add_query_arg( $query_args, admin_url( 'index.php' ) );
299 + return add_query_arg( $query_args, admin_url( 'options.php' ) );
265 300
266 301 }
267 302
268 303 /**
@@ -325,15 +360,15 @@
325 360
326 361 }
327 362
328 363 /**
329 - * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret.
364 + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page.
330 365 *
331 - * @since 1.9.6.1
366 + * @since 2.2.3
332 367 *
333 - * @return string ConvertKit App URL.
368 + * @return string ConvertKit App URL
334 369 */
335 -function convertkit_get_api_key_url() {
370 +function convertkit_get_new_form_url() {
336 371
337 372 return add_query_arg(
338 373 array(
339 374 'utm_source' => 'wordpress',
@@ -339,21 +374,41 @@
339 374 'utm_source' => 'wordpress',
340 375 'utm_term' => get_locale(),
341 376 'utm_content' => 'convertkit',
342 377 ),
343 - 'https://app.convertkit.com/account_settings/advanced_settings/'
378 + 'https://app.convertkit.com/forms/new/'
344 379 );
345 380
346 381 }
347 382
348 383 /**
349 - * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page.
384 + * Helper method to return the URL the user needs to visit to edit ConvertKit forms.
350 385 *
351 386 * @since 2.2.3
352 387 *
388 + * @return string ConvertKit Form Editor URL.
389 + */
390 +function convertkit_get_form_editor_url() {
391 +
392 + return add_query_arg(
393 + array(
394 + 'utm_source' => 'wordpress',
395 + 'utm_term' => get_locale(),
396 + 'utm_content' => 'convertkit',
397 + ),
398 + 'https://app.convertkit.com/forms'
399 + );
400 +
401 +}
402 +
403 +/**
404 + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Landing Page.
405 + *
406 + * @since 2.5.5
407 + *
353 408 * @return string ConvertKit App URL
354 409 */
355 -function convertkit_get_new_form_url() {
410 +function convertkit_get_new_landing_page_url() {
356 411
357 412 return add_query_arg(
358 413 array(
359 414 'utm_source' => 'wordpress',
@@ -359,21 +414,21 @@
359 414 'utm_source' => 'wordpress',
360 415 'utm_term' => get_locale(),
361 416 'utm_content' => 'convertkit',
362 417 ),
363 - 'https://app.convertkit.com/forms/new/'
418 + 'https://app.convertkit.com/pages/new/'
364 419 );
365 420
366 421 }
367 422
368 423 /**
369 - * Helper method to return the URL the user needs to visit to edit ConvertKit forms.
424 + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Tag.
370 425 *
371 - * @since 2.2.3
426 + * @since 2.3.3
372 427 *
373 - * @return string ConvertKit Form Editor URL.
428 + * @return string ConvertKit App URL.
374 429 */
375 -function convertkit_get_form_editor_url() {
430 +function convertkit_get_new_tag_url() {
376 431
377 432 return add_query_arg(
378 433 array(
379 434 'utm_source' => 'wordpress',
@@ -379,9 +434,9 @@
379 434 'utm_source' => 'wordpress',
380 435 'utm_term' => get_locale(),
381 436 'utm_content' => 'convertkit',
382 437 ),
383 - 'https://app.convertkit.com/forms'
438 + 'https://app.convertkit.com/subscribers/'
384 439 );
385 440
386 441 }
387 442
@@ -405,8 +460,32 @@
405 460
406 461 }
407 462
408 463 /**
464 + * Helper method to return the URL the user needs to visit on the ConvertKit app to edit a draft Broadcast.
465 + *
466 + * @since 2.4.0
467 + *
468 + * @param int $broadcast_id ConvertKit Broadcast ID.
469 + * @return string ConvertKit App URL.
470 + */
471 +function convertkit_get_edit_broadcast_url( $broadcast_id ) {
472 +
473 + return add_query_arg(
474 + array(
475 + 'utm_source' => 'wordpress',
476 + 'utm_term' => get_locale(),
477 + 'utm_content' => 'convertkit',
478 + ),
479 + sprintf(
480 + 'https://app.convertkit.com/campaigns/%s/draft',
481 + $broadcast_id
482 + )
483 + );
484 +
485 +}
486 +
487 +/**
409 488 * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Product.
410 489 *
411 490 * @since 2.2.3
412 491 *
@@ -458,22 +537,83 @@
458 537 * @return string File contents.
459 538 */
460 539 function convertkit_get_file_contents( $local_file ) {
461 540
462 - // Call globals.
463 - global $wp_filesystem;
541 + // Bail if the file doesn't exist.
542 + if ( ! file_exists( $local_file ) ) {
543 + return '';
544 + }
464 545
465 - // Load filesystem class.
466 - require_once ABSPATH . 'wp-admin/includes/file.php';
546 + // Read file.
547 + $contents = file_get_contents( $local_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
467 548
468 - // Initiate.
469 - WP_Filesystem();
470 -
471 - // Bail if the file doesn't exist.
472 - if ( ! $wp_filesystem->exists( $local_file ) ) {
549 + // Return an empty string if the contents of the file could not be read.
550 + if ( ! $contents ) {
473 551 return '';
474 552 }
475 553
476 554 // Return file's contents.
477 - return $wp_filesystem->get_contents( $local_file );
555 + return $contents;
556 +
557 +}
558 +
559 +/**
560 + * Returns a dropdown field commonly used for settings, comprising of:
561 + * - Do not subscribe
562 + * - Subscribe
563 + * - Subscribe to Form
564 + *
565 + * @since 2.5.2
566 + *
567 + * @param string $name Field name.
568 + * @param string $value Field value.
569 + * @param string $id Field ID attribute.
570 + * @param string $css_class Field CSS class(es).
571 + * @param string $context Resource context.
572 + * @param bool|array $additional_options Additional <option> key/value pairs.
573 + */
574 +function convertkit_get_subscription_dropdown_field( $name, $value, $id, $css_class = '', $context = '', $additional_options = false ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
575 +
576 + // Load resource classes.
577 + $forms = new ConvertKit_Resource_Forms( $context );
578 + $tags = new ConvertKit_Resource_Tags( $context );
579 + $sequences = new ConvertKit_Resource_Sequences( $context );
580 +
581 + ob_start();
582 + include CONVERTKIT_PLUGIN_PATH . '/views/backend/subscription-dropdown-field.php';
583 + $output = trim( ob_get_clean() );
584 +
585 + // Return output.
586 + return $output;
587 +
588 +}
589 +
590 +/**
591 + * Helper method to safely call get_current_screen(), returning false
592 + * if the function is not available or returns null.
593 + *
594 + * Otherwise returns the given WP_Screen property.
595 + *
596 + * @since 2.5.9
597 + *
598 + * @param string $property WP_Screen property to return.
599 + * @return bool|string
600 + */
601 +function convertkit_get_current_screen( $property ) {
602 +
603 + // Bail if we cannot determine the screen.
604 + if ( ! function_exists( 'get_current_screen' ) ) {
605 + return false;
606 + }
607 +
608 + // Get screen.
609 + $screen = get_current_screen();
610 +
611 + // Bail if the screen couldn't be determined.
612 + if ( is_null( $screen ) ) {
613 + return false;
614 + }
615 +
616 + // Return property.
617 + return $screen->$property;
478 618
479 619 }