| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit general plugin functions. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Helper method to get supported Post Types. |
| 11 |
* |
| 12 |
* @since 1.9.6 |
| 13 |
* |
| 14 |
* @return array Post Types |
| 15 |
*/ |
| 16 |
function convertkit_get_supported_post_types() { |
| 17 |
|
| 18 |
$post_types = array( |
| 19 |
'page', |
| 20 |
'post', |
| 21 |
); |
| 22 |
|
| 23 |
/** |
| 24 |
* Defines the Post Types that support ConvertKit Forms. |
| 25 |
* |
| 26 |
* @since 1.9.6 |
| 27 |
* |
| 28 |
* @param array $post_types Post Types |
| 29 |
*/ |
| 30 |
$post_types = apply_filters( 'convertkit_get_supported_post_types', $post_types ); |
| 31 |
|
| 32 |
return $post_types; |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Helper method to get registered Shortcodes. |
| 38 |
* |
| 39 |
* @since 1.9.6.5 |
| 40 |
* |
| 41 |
* @return array Shortcodes |
| 42 |
*/ |
| 43 |
function convertkit_get_shortcodes() { |
| 44 |
|
| 45 |
$shortcodes = array(); |
| 46 |
|
| 47 |
/** |
| 48 |
* Registers shortcodes for the ConvertKit Plugin. |
| 49 |
* |
| 50 |
* @since 1.9.6.5 |
| 51 |
* |
| 52 |
* @param array $shortcodes Shortcodes |
| 53 |
*/ |
| 54 |
$shortcodes = apply_filters( 'convertkit_shortcodes', $shortcodes ); |
| 55 |
|
| 56 |
return $shortcodes; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Helper method to get registered Blocks. |
| 62 |
* |
| 63 |
* @since 1.9.6 |
| 64 |
* |
| 65 |
* @return array Blocks |
| 66 |
*/ |
| 67 |
function convertkit_get_blocks() { |
| 68 |
|
| 69 |
$blocks = array(); |
| 70 |
|
| 71 |
/** |
| 72 |
* Registers blocks for the ConvertKit Plugin. |
| 73 |
* |
| 74 |
* @since 1.9.6 |
| 75 |
* |
| 76 |
* @param array $blocks Blocks |
| 77 |
*/ |
| 78 |
$blocks = apply_filters( 'convertkit_blocks', $blocks ); |
| 79 |
|
| 80 |
return $blocks; |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Helper method to return the Plugin Settings Link |
| 86 |
* |
| 87 |
* @since 1.9.6 |
| 88 |
* |
| 89 |
* @param array $query_args Optional Query Args. |
| 90 |
* @return string Settings Link |
| 91 |
*/ |
| 92 |
function convertkit_get_settings_link( $query_args = array() ) { |
| 93 |
|
| 94 |
$query_args = array_merge( |
| 95 |
$query_args, |
| 96 |
array( |
| 97 |
'page' => '_wp_convertkit_settings', |
| 98 |
) |
| 99 |
); |
| 100 |
|
| 101 |
return add_query_arg( $query_args, admin_url( 'options-general.php' ) ); |
| 102 |
|
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Helper method to return the URL the user needs to visit to sign in to their ConvertKit account. |
| 107 |
* |
| 108 |
* @since 1.9.6.1 |
| 109 |
* |
| 110 |
* @return string ConvertKit Login URL. |
| 111 |
*/ |
| 112 |
function convertkit_get_sign_in_url() { |
| 113 |
|
| 114 |
return 'https://app.convertkit.com/?utm_source=wordpress&utm_content=convertkit'; |
| 115 |
|
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret. |
| 120 |
* |
| 121 |
* @since 1.9.6.1 |
| 122 |
* |
| 123 |
* @return string ConvertKit App URL. |
| 124 |
*/ |
| 125 |
function convertkit_get_api_key_url() { |
| 126 |
|
| 127 |
return 'https://app.convertkit.com/account_settings/advanced_settings/?utm_source=wordpress&utm_content=convertkit'; |
| 128 |
|
| 129 |
} |
| 130 |
|
| 131 |
/** |
| 132 |
* Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin. |
| 133 |
* |
| 134 |
* @since 1.9.6.4 |
| 135 |
*/ |
| 136 |
function convertkit_select2_enqueue_scripts() { |
| 137 |
|
| 138 |
wp_enqueue_script( 'convertkit-select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, false ); |
| 139 |
wp_enqueue_script( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . '/resources/backend/js/select2.js', array( 'convertkit-select2' ), CONVERTKIT_PLUGIN_VERSION, false ); |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Helper method to enqueue Select2 stylesheets for use within the ConvertKit Plugin. |
| 145 |
* |
| 146 |
* @since 1.9.6.4 |
| 147 |
*/ |
| 148 |
function convertkit_select2_enqueue_styles() { |
| 149 |
|
| 150 |
wp_enqueue_style( 'convertkit-select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 151 |
wp_enqueue_style( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . '/resources/backend/css/select2.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 152 |
|
| 153 |
} |
| 154 |
|