| @@ -106,13 +106,32 @@ | ||
| 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 = (array) 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 | + $post_types = array_merge( | |
| 129 | + $post_types, | |
| 130 | + array_keys( $custom_post_types ) | |
| 131 | + ); | |
| 132 | + } | |
| 133 | + | |
| 115 | 134 | /** |
| 116 | 135 | * Defines the Post Types that support ConvertKit Forms. |
| 117 | 136 | * |
| 118 | 137 | * @since 1.9.6 |
| @@ -129,28 +148,16 @@ | ||
| 129 | 148 | * Helper method to get supported Post Types for Restricted Content (Member's Content) |
| 130 | 149 | * |
| 131 | 150 | * @since 2.1.0 |
| 132 | 151 | * |
| 152 | + * @deprecated 2.4.3 No longer used by internal code and not recommended. Use `convertkit_get_supported_post_types` instead. | |
| 153 | + * | |
| 133 | 154 | * @return array Post Types |
| 134 | 155 | */ |
| 135 | 156 | function convertkit_get_supported_restrict_content_post_types() { |
| 136 | 157 | |
| 137 | - $post_types = array( | |
| 138 | - 'page', | |
| 139 | - 'post', | |
| 140 | - ); | |
| 158 | + return convertkit_get_supported_post_types(); | |
| 141 | 159 | |
| 142 | - /** | |
| 143 | - * Defines the Post Types that support Restricted Content / Members Content functionality. | |
| 144 | - * | |
| 145 | - * @since 2.0.0 | |
| 146 | - * | |
| 147 | - * @param array $post_types Post Types | |
| 148 | - */ | |
| 149 | - $post_types = apply_filters( 'convertkit_get_supported_restrict_content_post_types', $post_types ); | |
| 150 | - | |
| 151 | - return $post_types; | |
| 152 | - | |
| 153 | 160 | } |
| 154 | 161 | |
| 155 | 162 | /** |
| 156 | 163 | * Helper method to get registered Shortcodes. |
| @@ -304,9 +311,9 @@ | ||
| 304 | 311 | 'utm_source' => 'wordpress', |
| 305 | 312 | 'utm_term' => get_locale(), |
| 306 | 313 | 'utm_content' => 'convertkit', |
| 307 | 314 | ), |
| 308 | - 'https://app.convertkit.com/users/signup' | |
| 315 | + 'https://app.kit.com/users/signup' | |
| 309 | 316 | ); |
| 310 | 317 | |
| 311 | 318 | } |
| 312 | 319 | |
| @@ -324,9 +331,9 @@ | ||
| 324 | 331 | 'utm_source' => 'wordpress', |
| 325 | 332 | 'utm_term' => get_locale(), |
| 326 | 333 | 'utm_content' => 'convertkit', |
| 327 | 334 | ), |
| 328 | - 'https://app.convertkit.com/' | |
| 335 | + 'https://app.kit.com/' | |
| 329 | 336 | ); |
| 330 | 337 | |
| 331 | 338 | } |
| 332 | 339 | |
| @@ -344,21 +351,21 @@ | ||
| 344 | 351 | 'utm_source' => 'wordpress', |
| 345 | 352 | 'utm_term' => get_locale(), |
| 346 | 353 | 'utm_content' => 'convertkit', |
| 347 | 354 | ), |
| 348 | - 'https://app.convertkit.com/account_settings/billing/' | |
| 355 | + 'https://app.kit.com/account_settings/billing/' | |
| 349 | 356 | ); |
| 350 | 357 | |
| 351 | 358 | } |
| 352 | 359 | |
| 353 | 360 | /** |
| 354 | - * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret. | |
| 361 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page. | |
| 355 | 362 | * |
| 356 | - * @since 1.9.6.1 | |
| 363 | + * @since 2.2.3 | |
| 357 | 364 | * |
| 358 | - * @return string ConvertKit App URL. | |
| 365 | + * @return string ConvertKit App URL | |
| 359 | 366 | */ |
| 360 | -function convertkit_get_api_key_url() { | |
| 367 | +function convertkit_get_new_form_url() { | |
| 361 | 368 | |
| 362 | 369 | return add_query_arg( |
| 363 | 370 | array( |
| 364 | 371 | 'utm_source' => 'wordpress', |
| @@ -364,21 +371,21 @@ | ||
| 364 | 371 | 'utm_source' => 'wordpress', |
| 365 | 372 | 'utm_term' => get_locale(), |
| 366 | 373 | 'utm_content' => 'convertkit', |
| 367 | 374 | ), |
| 368 | - 'https://app.convertkit.com/account_settings/advanced_settings/' | |
| 375 | + 'https://app.kit.com/forms/new/' | |
| 369 | 376 | ); |
| 370 | 377 | |
| 371 | 378 | } |
| 372 | 379 | |
| 373 | 380 | /** |
| 374 | - * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page. | |
| 381 | + * Helper method to return the URL the user needs to visit to edit ConvertKit forms. | |
| 375 | 382 | * |
| 376 | 383 | * @since 2.2.3 |
| 377 | 384 | * |
| 378 | - * @return string ConvertKit App URL | |
| 385 | + * @return string ConvertKit Form Editor URL. | |
| 379 | 386 | */ |
| 380 | -function convertkit_get_new_form_url() { | |
| 387 | +function convertkit_get_form_editor_url() { | |
| 381 | 388 | |
| 382 | 389 | return add_query_arg( |
| 383 | 390 | array( |
| 384 | 391 | 'utm_source' => 'wordpress', |
| @@ -384,21 +391,21 @@ | ||
| 384 | 391 | 'utm_source' => 'wordpress', |
| 385 | 392 | 'utm_term' => get_locale(), |
| 386 | 393 | 'utm_content' => 'convertkit', |
| 387 | 394 | ), |
| 388 | - 'https://app.convertkit.com/forms/new/' | |
| 395 | + 'https://app.kit.com/forms' | |
| 389 | 396 | ); |
| 390 | 397 | |
| 391 | 398 | } |
| 392 | 399 | |
| 393 | 400 | /** |
| 394 | - * Helper method to return the URL the user needs to visit to edit ConvertKit forms. | |
| 401 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Landing Page. | |
| 395 | 402 | * |
| 396 | - * @since 2.2.3 | |
| 403 | + * @since 2.5.5 | |
| 397 | 404 | * |
| 398 | - * @return string ConvertKit Form Editor URL. | |
| 405 | + * @return string ConvertKit App URL | |
| 399 | 406 | */ |
| 400 | -function convertkit_get_form_editor_url() { | |
| 407 | +function convertkit_get_new_landing_page_url() { | |
| 401 | 408 | |
| 402 | 409 | return add_query_arg( |
| 403 | 410 | array( |
| 404 | 411 | 'utm_source' => 'wordpress', |
| @@ -404,9 +411,9 @@ | ||
| 404 | 411 | 'utm_source' => 'wordpress', |
| 405 | 412 | 'utm_term' => get_locale(), |
| 406 | 413 | 'utm_content' => 'convertkit', |
| 407 | 414 | ), |
| 408 | - 'https://app.convertkit.com/forms' | |
| 415 | + 'https://app.kit.com/pages/new/' | |
| 409 | 416 | ); |
| 410 | 417 | |
| 411 | 418 | } |
| 412 | 419 | |
| @@ -424,9 +431,9 @@ | ||
| 424 | 431 | 'utm_source' => 'wordpress', |
| 425 | 432 | 'utm_term' => get_locale(), |
| 426 | 433 | 'utm_content' => 'convertkit', |
| 427 | 434 | ), |
| 428 | - 'https://app.convertkit.com/subscribers/' | |
| 435 | + 'https://app.kit.com/subscribers/' | |
| 429 | 436 | ); |
| 430 | 437 | |
| 431 | 438 | } |
| 432 | 439 | |
| @@ -444,9 +451,9 @@ | ||
| 444 | 451 | 'utm_source' => 'wordpress', |
| 445 | 452 | 'utm_term' => get_locale(), |
| 446 | 453 | 'utm_content' => 'convertkit', |
| 447 | 454 | ), |
| 448 | - 'https://app.convertkit.com/campaigns/' | |
| 455 | + 'https://app.kit.com/campaigns/' | |
| 449 | 456 | ); |
| 450 | 457 | |
| 451 | 458 | } |
| 452 | 459 | |
| @@ -466,9 +473,9 @@ | ||
| 466 | 473 | 'utm_term' => get_locale(), |
| 467 | 474 | 'utm_content' => 'convertkit', |
| 468 | 475 | ), |
| 469 | 476 | sprintf( |
| 470 | - 'https://app.convertkit.com/campaigns/%s/draft', | |
| 477 | + 'https://app.kit.com/campaigns/%s/draft', | |
| 471 | 478 | $broadcast_id |
| 472 | 479 | ) |
| 473 | 480 | ); |
| 474 | 481 | |
| @@ -488,9 +495,9 @@ | ||
| 488 | 495 | 'utm_source' => 'wordpress', |
| 489 | 496 | 'utm_term' => get_locale(), |
| 490 | 497 | 'utm_content' => 'convertkit', |
| 491 | 498 | ), |
| 492 | - 'https://app.convertkit.com/products/new/' | |
| 499 | + 'https://app.kit.com/products/new/' | |
| 493 | 500 | ); |
| 494 | 501 | |
| 495 | 502 | } |
| 496 | 503 | |
| @@ -542,6 +549,91 @@ | ||
| 542 | 549 | } |
| 543 | 550 | |
| 544 | 551 | // Return file's contents. |
| 545 | 552 | return $contents; |
| 553 | + | |
| 554 | +} | |
| 555 | + | |
| 556 | +/** | |
| 557 | + * Returns a dropdown field commonly used for settings, comprising of: | |
| 558 | + * - Do not subscribe | |
| 559 | + * - Subscribe | |
| 560 | + * - Subscribe to Form | |
| 561 | + * | |
| 562 | + * @since 2.5.2 | |
| 563 | + * | |
| 564 | + * @param string $name Field name. | |
| 565 | + * @param string $value Field value. | |
| 566 | + * @param string $id Field ID attribute. | |
| 567 | + * @param string $css_class Field CSS class(es). | |
| 568 | + * @param string $context Resource context. | |
| 569 | + * @param bool|array $additional_options Additional <option> key/value pairs. | |
| 570 | + */ | |
| 571 | +function convertkit_get_subscription_dropdown_field( $name, $value, $id, $css_class = '', $context = '', $additional_options = false ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter | |
| 572 | + | |
| 573 | + // Load resource classes. | |
| 574 | + $forms = new ConvertKit_Resource_Forms( $context ); | |
| 575 | + $tags = new ConvertKit_Resource_Tags( $context ); | |
| 576 | + $sequences = new ConvertKit_Resource_Sequences( $context ); | |
| 577 | + | |
| 578 | + ob_start(); | |
| 579 | + include CONVERTKIT_PLUGIN_PATH . '/views/backend/subscription-dropdown-field.php'; | |
| 580 | + $output = trim( ob_get_clean() ); | |
| 581 | + | |
| 582 | + // Return output. | |
| 583 | + return $output; | |
| 584 | + | |
| 585 | +} | |
| 586 | + | |
| 587 | +/** | |
| 588 | + * Helper method to safely call get_current_screen(), returning false | |
| 589 | + * if the function is not available or returns null. | |
| 590 | + * | |
| 591 | + * Otherwise returns the given WP_Screen property. | |
| 592 | + * | |
| 593 | + * @since 2.5.9 | |
| 594 | + * | |
| 595 | + * @param string $property WP_Screen property to return. | |
| 596 | + * @return bool|string | |
| 597 | + */ | |
| 598 | +function convertkit_get_current_screen( $property ) { | |
| 599 | + | |
| 600 | + // Bail if we cannot determine the screen. | |
| 601 | + if ( ! function_exists( 'get_current_screen' ) ) { | |
| 602 | + return false; | |
| 603 | + } | |
| 604 | + | |
| 605 | + // Get screen. | |
| 606 | + $screen = get_current_screen(); | |
| 607 | + | |
| 608 | + // Bail if the screen couldn't be determined. | |
| 609 | + if ( is_null( $screen ) ) { | |
| 610 | + return false; | |
| 611 | + } | |
| 612 | + | |
| 613 | + // Return property. | |
| 614 | + return $screen->$property; | |
| 615 | + | |
| 616 | +} | |
| 617 | + | |
| 618 | +/** | |
| 619 | + * Outputs the Intercom help widget script. | |
| 620 | + * | |
| 621 | + * @since 2.7.2 | |
| 622 | + */ | |
| 623 | +function convertkit_output_intercom_messenger() { | |
| 624 | + | |
| 625 | + ?> | |
| 626 | + <script> | |
| 627 | + const KIT_INTERCOM_APP_ID = 'e4n3xtxz'; | |
| 628 | + window.intercomSettings = { | |
| 629 | + api_base: 'https://api-iam.intercom.io', | |
| 630 | + app_id: KIT_INTERCOM_APP_ID | |
| 631 | + }; | |
| 632 | + </script> | |
| 633 | + | |
| 634 | + <script> | |
| 635 | + (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/' + KIT_INTERCOM_APP_ID;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})(); | |
| 636 | + </script> | |
| 637 | + <?php | |
| 546 | 638 | |
| 547 | 639 | } |