| @@ -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,28 +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 | - 'post', | |
| 140 | - ); | |
| 161 | + return convertkit_get_supported_post_types(); | |
| 141 | 162 | |
| 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 | 163 | } |
| 154 | 164 | |
| 155 | 165 | /** |
| 156 | 166 | * Helper method to get registered Shortcodes. |
| @@ -350,28 +360,8 @@ | ||
| 350 | 360 | |
| 351 | 361 | } |
| 352 | 362 | |
| 353 | 363 | /** |
| 354 | - * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret. | |
| 355 | - * | |
| 356 | - * @since 1.9.6.1 | |
| 357 | - * | |
| 358 | - * @return string ConvertKit App URL. | |
| 359 | - */ | |
| 360 | -function convertkit_get_api_key_url() { | |
| 361 | - | |
| 362 | - return add_query_arg( | |
| 363 | - array( | |
| 364 | - 'utm_source' => 'wordpress', | |
| 365 | - 'utm_term' => get_locale(), | |
| 366 | - 'utm_content' => 'convertkit', | |
| 367 | - ), | |
| 368 | - 'https://app.convertkit.com/account_settings/advanced_settings/' | |
| 369 | - ); | |
| 370 | - | |
| 371 | -} | |
| 372 | - | |
| 373 | -/** | |
| 374 | 364 | * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page. |
| 375 | 365 | * |
| 376 | 366 | * @since 2.2.3 |
| 377 | 367 | * |
| @@ -542,6 +532,37 @@ | ||
| 542 | 532 | } |
| 543 | 533 | |
| 544 | 534 | // Return file's contents. |
| 545 | 535 | return $contents; |
| 536 | + | |
| 537 | +} | |
| 538 | + | |
| 539 | +/** | |
| 540 | + * Returns a dropdown field commonly used for settings, comprising of: | |
| 541 | + * - Do not subscribe | |
| 542 | + * - Subscribe | |
| 543 | + * - Subscribe to Form | |
| 544 | + * | |
| 545 | + * @since 2.5.2 | |
| 546 | + * | |
| 547 | + * @param string $name Field name. | |
| 548 | + * @param string $value Field value. | |
| 549 | + * @param string $id Field ID attribute. | |
| 550 | + * @param string $css_class Field CSS class(es). | |
| 551 | + * @param string $context Resource context. | |
| 552 | + * @param bool|array $additional_options Additional <option> key/value pairs. | |
| 553 | + */ | |
| 554 | +function convertkit_get_subscription_dropdown_field( $name, $value, $id, $css_class = '', $context = '', $additional_options = false ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter | |
| 555 | + | |
| 556 | + // Load resource classes. | |
| 557 | + $forms = new ConvertKit_Resource_Forms( $context ); | |
| 558 | + $tags = new ConvertKit_Resource_Tags( $context ); | |
| 559 | + $sequences = new ConvertKit_Resource_Sequences( $context ); | |
| 560 | + | |
| 561 | + ob_start(); | |
| 562 | + include CONVERTKIT_PLUGIN_PATH . '/views/backend/subscription-dropdown-field.php'; | |
| 563 | + $output = trim( ob_get_clean() ); | |
| 564 | + | |
| 565 | + // Return output. | |
| 566 | + return $output; | |
| 546 | 567 | |
| 547 | 568 | } |