| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit general plugin functions. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Runs the activation and update routines when the plugin is activated. |
| 11 |
* |
| 12 |
* @since 1.9.7.4 |
| 13 |
* |
| 14 |
* @param bool $network_wide Is network wide activation. |
| 15 |
*/ |
| 16 |
function convertkit_plugin_activate( $network_wide ) { |
| 17 |
|
| 18 |
// Initialise Plugin. |
| 19 |
$convertkit = WP_ConvertKit(); |
| 20 |
|
| 21 |
// Check if we are on a multisite install, activating network wide, or a single install. |
| 22 |
if ( ! is_multisite() || ! $network_wide ) { |
| 23 |
// Single Site activation. |
| 24 |
$convertkit->get_class( 'setup' )->activate(); |
| 25 |
|
| 26 |
// Set a transient for 30 seconds to redirect to the setup screen on activation. |
| 27 |
set_transient( 'convertkit-setup', true, 30 ); |
| 28 |
} else { |
| 29 |
// Multisite network wide activation. |
| 30 |
$sites = get_sites( |
| 31 |
array( |
| 32 |
'number' => 0, |
| 33 |
) |
| 34 |
); |
| 35 |
foreach ( $sites as $site ) { |
| 36 |
switch_to_blog( (int) $site->blog_id ); |
| 37 |
$convertkit->get_class( 'setup' )->activate(); |
| 38 |
restore_current_blog(); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Runs the activation and update routines when the plugin is activated |
| 46 |
* on a WordPress multisite setup. |
| 47 |
* |
| 48 |
* @since 1.9.7.4 |
| 49 |
* |
| 50 |
* @param WP_Site|int $site_or_blog_id WP_Site or Blog ID. |
| 51 |
*/ |
| 52 |
function convertkit_plugin_activate_new_site( $site_or_blog_id ) { |
| 53 |
|
| 54 |
// Check if $site_or_blog_id is a WP_Site or a blog ID. |
| 55 |
if ( is_a( $site_or_blog_id, 'WP_Site' ) ) { |
| 56 |
$site_or_blog_id = $site_or_blog_id->blog_id; |
| 57 |
} |
| 58 |
|
| 59 |
// Initialise Plugin. |
| 60 |
$convertkit = WP_ConvertKit(); |
| 61 |
|
| 62 |
// Run installation routine. |
| 63 |
switch_to_blog( $site_or_blog_id ); |
| 64 |
$convertkit->get_class( 'setup' )->activate(); |
| 65 |
restore_current_blog(); |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Runs the deactivation routine when the plugin is deactivated. |
| 71 |
* |
| 72 |
* @since 1.9.7.4 |
| 73 |
* |
| 74 |
* @param bool $network_wide Is network wide deactivation. |
| 75 |
*/ |
| 76 |
function convertkit_plugin_deactivate( $network_wide ) { |
| 77 |
|
| 78 |
// Initialise Plugin. |
| 79 |
$convertkit = WP_ConvertKit(); |
| 80 |
|
| 81 |
// Check if we are on a multisite install, activating network wide, or a single install. |
| 82 |
if ( ! is_multisite() || ! $network_wide ) { |
| 83 |
// Single Site activation. |
| 84 |
$convertkit->get_class( 'setup' )->deactivate(); |
| 85 |
} else { |
| 86 |
// Multisite network wide activation. |
| 87 |
$sites = get_sites( |
| 88 |
array( |
| 89 |
'number' => 0, |
| 90 |
) |
| 91 |
); |
| 92 |
foreach ( $sites as $site ) { |
| 93 |
switch_to_blog( (int) $site->blog_id ); |
| 94 |
$convertkit->get_class( 'setup' )->deactivate(); |
| 95 |
restore_current_blog(); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Helper method to get supported Post Types. |
| 103 |
* |
| 104 |
* @since 1.9.6 |
| 105 |
* |
| 106 |
* @return array Post Types |
| 107 |
*/ |
| 108 |
function convertkit_get_supported_post_types() { |
| 109 |
|
| 110 |
// Define supported Post Types. |
| 111 |
$post_types = array( |
| 112 |
'page', |
| 113 |
'post', |
| 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 |
|
| 134 |
/** |
| 135 |
* Defines the Post Types that support ConvertKit Forms. |
| 136 |
* |
| 137 |
* @since 1.9.6 |
| 138 |
* |
| 139 |
* @param array $post_types Post Types |
| 140 |
*/ |
| 141 |
$post_types = apply_filters( 'convertkit_get_supported_post_types', $post_types ); |
| 142 |
|
| 143 |
return $post_types; |
| 144 |
|
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Helper method to get supported Post Types for Restricted Content (Member's Content) |
| 149 |
* |
| 150 |
* @since 2.1.0 |
| 151 |
* |
| 152 |
* @deprecated 2.4.3 No longer used by internal code and not recommended. Use `convertkit_get_supported_post_types` instead. |
| 153 |
* |
| 154 |
* @return array Post Types |
| 155 |
*/ |
| 156 |
function convertkit_get_supported_restrict_content_post_types() { |
| 157 |
|
| 158 |
return convertkit_get_supported_post_types(); |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* Helper method to get registered Shortcodes. |
| 164 |
* |
| 165 |
* @since 1.9.6.5 |
| 166 |
* |
| 167 |
* @return array Shortcodes |
| 168 |
*/ |
| 169 |
function convertkit_get_shortcodes() { |
| 170 |
|
| 171 |
$shortcodes = array(); |
| 172 |
|
| 173 |
/** |
| 174 |
* Registers shortcodes for the ConvertKit Plugin. |
| 175 |
* |
| 176 |
* @since 1.9.6.5 |
| 177 |
* |
| 178 |
* @param array $shortcodes Shortcodes |
| 179 |
*/ |
| 180 |
$shortcodes = apply_filters( 'convertkit_shortcodes', $shortcodes ); |
| 181 |
|
| 182 |
return $shortcodes; |
| 183 |
|
| 184 |
} |
| 185 |
|
| 186 |
/** |
| 187 |
* Helper method to get registered Blocks. |
| 188 |
* |
| 189 |
* @since 1.9.6 |
| 190 |
* |
| 191 |
* @return array Blocks |
| 192 |
*/ |
| 193 |
function convertkit_get_blocks() { |
| 194 |
|
| 195 |
$blocks = array(); |
| 196 |
|
| 197 |
/** |
| 198 |
* Registers blocks for the ConvertKit Plugin. |
| 199 |
* |
| 200 |
* @since 1.9.6 |
| 201 |
* |
| 202 |
* @param array $blocks Blocks |
| 203 |
*/ |
| 204 |
$blocks = apply_filters( 'convertkit_blocks', $blocks ); |
| 205 |
|
| 206 |
return $blocks; |
| 207 |
|
| 208 |
} |
| 209 |
|
| 210 |
/** |
| 211 |
* Helper method to get registered Block formatters for Gutenberg. |
| 212 |
* |
| 213 |
* @since 2.2.0 |
| 214 |
* |
| 215 |
* @return array Block formatters |
| 216 |
*/ |
| 217 |
function convertkit_get_block_formatters() { |
| 218 |
|
| 219 |
$block_formatters = array(); |
| 220 |
|
| 221 |
/** |
| 222 |
* Registers block formatters in Gutenberg for the ConvertKit Plugin. |
| 223 |
* |
| 224 |
* @since 2.2.0 |
| 225 |
* |
| 226 |
* @param array $block_formatters Block formatters. |
| 227 |
*/ |
| 228 |
$block_formatters = apply_filters( 'convertkit_get_block_formatters', $block_formatters ); |
| 229 |
|
| 230 |
return $block_formatters; |
| 231 |
|
| 232 |
} |
| 233 |
|
| 234 |
/** |
| 235 |
* Helper method to get registered pre-publish actions. |
| 236 |
* |
| 237 |
* @since 2.4.0 |
| 238 |
* |
| 239 |
* @return array Pre-publish actions |
| 240 |
*/ |
| 241 |
function convertkit_get_pre_publish_actions() { |
| 242 |
|
| 243 |
$pre_publish_actions = array(); |
| 244 |
|
| 245 |
/** |
| 246 |
* Registers pre-publish actions for the ConvertKit Plugin. |
| 247 |
* |
| 248 |
* @since 2.4.0 |
| 249 |
* |
| 250 |
* @param array $pre_publish_panels Pre-publish actions. |
| 251 |
*/ |
| 252 |
$pre_publish_actions = apply_filters( 'convertkit_get_pre_publish_actions', $pre_publish_actions ); |
| 253 |
|
| 254 |
return $pre_publish_actions; |
| 255 |
|
| 256 |
} |
| 257 |
|
| 258 |
/** |
| 259 |
* Helper method to return the Plugin Settings Link |
| 260 |
* |
| 261 |
* @since 1.9.6 |
| 262 |
* |
| 263 |
* @param array $query_args Optional Query Args. |
| 264 |
* @return string Settings Link |
| 265 |
*/ |
| 266 |
function convertkit_get_settings_link( $query_args = array() ) { |
| 267 |
|
| 268 |
$query_args = array_merge( |
| 269 |
$query_args, |
| 270 |
array( |
| 271 |
'page' => '_wp_convertkit_settings', |
| 272 |
) |
| 273 |
); |
| 274 |
|
| 275 |
return add_query_arg( $query_args, admin_url( 'options-general.php' ) ); |
| 276 |
|
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
* Helper method to return the Plugin Settings Link |
| 281 |
* |
| 282 |
* @since 2.2.4 |
| 283 |
* |
| 284 |
* @param array $query_args Optional Query Args. |
| 285 |
* @return string Settings Link |
| 286 |
*/ |
| 287 |
function convertkit_get_setup_wizard_plugin_link( $query_args = array() ) { |
| 288 |
|
| 289 |
$query_args = array_merge( |
| 290 |
$query_args, |
| 291 |
array( |
| 292 |
'page' => 'convertkit-setup', |
| 293 |
) |
| 294 |
); |
| 295 |
|
| 296 |
return add_query_arg( $query_args, admin_url( 'options.php' ) ); |
| 297 |
|
| 298 |
} |
| 299 |
|
| 300 |
/** |
| 301 |
* Helper method to return the URL the user needs to visit to register a ConvertKit account. |
| 302 |
* |
| 303 |
* @since 1.9.8.4 |
| 304 |
* |
| 305 |
* @return string ConvertKit Registration URL. |
| 306 |
*/ |
| 307 |
function convertkit_get_registration_url() { |
| 308 |
|
| 309 |
return add_query_arg( |
| 310 |
array( |
| 311 |
'utm_source' => 'wordpress', |
| 312 |
'utm_term' => get_locale(), |
| 313 |
'utm_content' => 'convertkit', |
| 314 |
), |
| 315 |
'https://app.kit.com/users/signup' |
| 316 |
); |
| 317 |
|
| 318 |
} |
| 319 |
|
| 320 |
/** |
| 321 |
* Helper method to return the URL the user needs to visit to sign in to their ConvertKit account. |
| 322 |
* |
| 323 |
* @since 1.9.6.1 |
| 324 |
* |
| 325 |
* @return string ConvertKit Login URL. |
| 326 |
*/ |
| 327 |
function convertkit_get_sign_in_url() { |
| 328 |
|
| 329 |
return add_query_arg( |
| 330 |
array( |
| 331 |
'utm_source' => 'wordpress', |
| 332 |
'utm_term' => get_locale(), |
| 333 |
'utm_content' => 'convertkit', |
| 334 |
), |
| 335 |
'https://app.kit.com/' |
| 336 |
); |
| 337 |
|
| 338 |
} |
| 339 |
|
| 340 |
/** |
| 341 |
* Helper method to return the URL the user needs to visit to manage thier billing. |
| 342 |
* |
| 343 |
* @since 2.2.7 |
| 344 |
* |
| 345 |
* @return string ConvertKit Billing URL. |
| 346 |
*/ |
| 347 |
function convertkit_get_billing_url() { |
| 348 |
|
| 349 |
return add_query_arg( |
| 350 |
array( |
| 351 |
'utm_source' => 'wordpress', |
| 352 |
'utm_term' => get_locale(), |
| 353 |
'utm_content' => 'convertkit', |
| 354 |
), |
| 355 |
'https://app.kit.com/account_settings/billing/' |
| 356 |
); |
| 357 |
|
| 358 |
} |
| 359 |
|
| 360 |
/** |
| 361 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page. |
| 362 |
* |
| 363 |
* @since 2.2.3 |
| 364 |
* |
| 365 |
* @return string ConvertKit App URL |
| 366 |
*/ |
| 367 |
function convertkit_get_new_form_url() { |
| 368 |
|
| 369 |
return add_query_arg( |
| 370 |
array( |
| 371 |
'utm_source' => 'wordpress', |
| 372 |
'utm_term' => get_locale(), |
| 373 |
'utm_content' => 'convertkit', |
| 374 |
), |
| 375 |
'https://app.kit.com/forms/new/' |
| 376 |
); |
| 377 |
|
| 378 |
} |
| 379 |
|
| 380 |
/** |
| 381 |
* Helper method to return the URL the user needs to visit to edit ConvertKit forms. |
| 382 |
* |
| 383 |
* @since 2.2.3 |
| 384 |
* |
| 385 |
* @return string ConvertKit Form Editor URL. |
| 386 |
*/ |
| 387 |
function convertkit_get_form_editor_url() { |
| 388 |
|
| 389 |
return add_query_arg( |
| 390 |
array( |
| 391 |
'utm_source' => 'wordpress', |
| 392 |
'utm_term' => get_locale(), |
| 393 |
'utm_content' => 'convertkit', |
| 394 |
), |
| 395 |
'https://app.kit.com/forms' |
| 396 |
); |
| 397 |
|
| 398 |
} |
| 399 |
|
| 400 |
/** |
| 401 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Landing Page. |
| 402 |
* |
| 403 |
* @since 2.5.5 |
| 404 |
* |
| 405 |
* @return string ConvertKit App URL |
| 406 |
*/ |
| 407 |
function convertkit_get_new_landing_page_url() { |
| 408 |
|
| 409 |
return add_query_arg( |
| 410 |
array( |
| 411 |
'utm_source' => 'wordpress', |
| 412 |
'utm_term' => get_locale(), |
| 413 |
'utm_content' => 'convertkit', |
| 414 |
), |
| 415 |
'https://app.kit.com/pages/new/' |
| 416 |
); |
| 417 |
|
| 418 |
} |
| 419 |
|
| 420 |
/** |
| 421 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Tag. |
| 422 |
* |
| 423 |
* @since 2.3.3 |
| 424 |
* |
| 425 |
* @return string ConvertKit App URL. |
| 426 |
*/ |
| 427 |
function convertkit_get_new_tag_url() { |
| 428 |
|
| 429 |
return add_query_arg( |
| 430 |
array( |
| 431 |
'utm_source' => 'wordpress', |
| 432 |
'utm_term' => get_locale(), |
| 433 |
'utm_content' => 'convertkit', |
| 434 |
), |
| 435 |
'https://app.kit.com/subscribers/' |
| 436 |
); |
| 437 |
|
| 438 |
} |
| 439 |
|
| 440 |
/** |
| 441 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Broadcast. |
| 442 |
* |
| 443 |
* @since 2.2.6 |
| 444 |
* |
| 445 |
* @return string ConvertKit App URL. |
| 446 |
*/ |
| 447 |
function convertkit_get_new_broadcast_url() { |
| 448 |
|
| 449 |
return add_query_arg( |
| 450 |
array( |
| 451 |
'utm_source' => 'wordpress', |
| 452 |
'utm_term' => get_locale(), |
| 453 |
'utm_content' => 'convertkit', |
| 454 |
), |
| 455 |
'https://app.kit.com/campaigns/' |
| 456 |
); |
| 457 |
|
| 458 |
} |
| 459 |
|
| 460 |
/** |
| 461 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to edit a draft Broadcast. |
| 462 |
* |
| 463 |
* @since 2.4.0 |
| 464 |
* |
| 465 |
* @param int $broadcast_id ConvertKit Broadcast ID. |
| 466 |
* @return string ConvertKit App URL. |
| 467 |
*/ |
| 468 |
function convertkit_get_edit_broadcast_url( $broadcast_id ) { |
| 469 |
|
| 470 |
return add_query_arg( |
| 471 |
array( |
| 472 |
'utm_source' => 'wordpress', |
| 473 |
'utm_term' => get_locale(), |
| 474 |
'utm_content' => 'convertkit', |
| 475 |
), |
| 476 |
sprintf( |
| 477 |
'https://app.kit.com/campaigns/%s/draft', |
| 478 |
$broadcast_id |
| 479 |
) |
| 480 |
); |
| 481 |
|
| 482 |
} |
| 483 |
|
| 484 |
/** |
| 485 |
* Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Product. |
| 486 |
* |
| 487 |
* @since 2.2.3 |
| 488 |
* |
| 489 |
* @return string ConvertKit App URL. |
| 490 |
*/ |
| 491 |
function convertkit_get_new_product_url() { |
| 492 |
|
| 493 |
return add_query_arg( |
| 494 |
array( |
| 495 |
'utm_source' => 'wordpress', |
| 496 |
'utm_term' => get_locale(), |
| 497 |
'utm_content' => 'convertkit', |
| 498 |
), |
| 499 |
'https://app.kit.com/products/new/' |
| 500 |
); |
| 501 |
|
| 502 |
} |
| 503 |
|
| 504 |
/** |
| 505 |
* Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin. |
| 506 |
* |
| 507 |
* @since 1.9.6.4 |
| 508 |
*/ |
| 509 |
function convertkit_select2_enqueue_scripts() { |
| 510 |
|
| 511 |
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 ); |
| 512 |
wp_enqueue_script( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/select2.js', array( 'convertkit-select2' ), CONVERTKIT_PLUGIN_VERSION, false ); |
| 513 |
|
| 514 |
} |
| 515 |
|
| 516 |
/** |
| 517 |
* Helper method to enqueue Select2 stylesheets for use within the ConvertKit Plugin. |
| 518 |
* |
| 519 |
* @since 1.9.6.4 |
| 520 |
*/ |
| 521 |
function convertkit_select2_enqueue_styles() { |
| 522 |
|
| 523 |
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 ); |
| 524 |
wp_enqueue_style( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/select2.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 525 |
|
| 526 |
} |
| 527 |
|
| 528 |
/** |
| 529 |
* Return the contents of the given local file. |
| 530 |
* |
| 531 |
* @since 2.2.2 |
| 532 |
* |
| 533 |
* @param string $local_file Local file, including path. |
| 534 |
* @return string File contents. |
| 535 |
*/ |
| 536 |
function convertkit_get_file_contents( $local_file ) { |
| 537 |
|
| 538 |
// Bail if the file doesn't exist. |
| 539 |
if ( ! file_exists( $local_file ) ) { |
| 540 |
return ''; |
| 541 |
} |
| 542 |
|
| 543 |
// Read file. |
| 544 |
$contents = file_get_contents( $local_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents |
| 545 |
|
| 546 |
// Return an empty string if the contents of the file could not be read. |
| 547 |
if ( ! $contents ) { |
| 548 |
return ''; |
| 549 |
} |
| 550 |
|
| 551 |
// Return file's contents. |
| 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 |
| 638 |
|
| 639 |
} |
| 640 |
|