| @@ -135,8 +135,9 @@ | ||
| 135 | 135 | function convertkit_get_supported_restrict_content_post_types() { |
| 136 | 136 | |
| 137 | 137 | $post_types = array( |
| 138 | 138 | 'page', |
| 139 | + 'post', | |
| 139 | 140 | ); |
| 140 | 141 | |
| 141 | 142 | /** |
| 142 | 143 | * Defines the Post Types that support Restricted Content / Members Content functionality. |
| @@ -223,8 +224,32 @@ | ||
| 223 | 224 | |
| 224 | 225 | } |
| 225 | 226 | |
| 226 | 227 | /** |
| 228 | + * Helper method to get registered pre-publish actions. | |
| 229 | + * | |
| 230 | + * @since 2.4.0 | |
| 231 | + * | |
| 232 | + * @return array Pre-publish actions | |
| 233 | + */ | |
| 234 | +function convertkit_get_pre_publish_actions() { | |
| 235 | + | |
| 236 | + $pre_publish_actions = array(); | |
| 237 | + | |
| 238 | + /** | |
| 239 | + * Registers pre-publish actions for the ConvertKit Plugin. | |
| 240 | + * | |
| 241 | + * @since 2.4.0 | |
| 242 | + * | |
| 243 | + * @param array $pre_publish_panels Pre-publish actions. | |
| 244 | + */ | |
| 245 | + $pre_publish_actions = apply_filters( 'convertkit_get_pre_publish_actions', $pre_publish_actions ); | |
| 246 | + | |
| 247 | + return $pre_publish_actions; | |
| 248 | + | |
| 249 | +} | |
| 250 | + | |
| 251 | +/** | |
| 227 | 252 | * Helper method to return the Plugin Settings Link |
| 228 | 253 | * |
| 229 | 254 | * @since 1.9.6 |
| 230 | 255 | * |
| @@ -244,8 +269,29 @@ | ||
| 244 | 269 | |
| 245 | 270 | } |
| 246 | 271 | |
| 247 | 272 | /** |
| 273 | + * Helper method to return the Plugin Settings Link | |
| 274 | + * | |
| 275 | + * @since 2.2.4 | |
| 276 | + * | |
| 277 | + * @param array $query_args Optional Query Args. | |
| 278 | + * @return string Settings Link | |
| 279 | + */ | |
| 280 | +function convertkit_get_setup_wizard_plugin_link( $query_args = array() ) { | |
| 281 | + | |
| 282 | + $query_args = array_merge( | |
| 283 | + $query_args, | |
| 284 | + array( | |
| 285 | + 'page' => 'convertkit-setup', | |
| 286 | + ) | |
| 287 | + ); | |
| 288 | + | |
| 289 | + return add_query_arg( $query_args, admin_url( 'options.php' ) ); | |
| 290 | + | |
| 291 | +} | |
| 292 | + | |
| 293 | +/** | |
| 248 | 294 | * Helper method to return the URL the user needs to visit to register a ConvertKit account. |
| 249 | 295 | * |
| 250 | 296 | * @since 1.9.8.4 |
| 251 | 297 | * |
| @@ -252,9 +298,16 @@ | ||
| 252 | 298 | * @return string ConvertKit Registration URL. |
| 253 | 299 | */ |
| 254 | 300 | function convertkit_get_registration_url() { |
| 255 | 301 | |
| 256 | - return 'https://app.convertkit.com/users/signup?utm_source=wordpress&utm_content=convertkit'; | |
| 302 | + return add_query_arg( | |
| 303 | + array( | |
| 304 | + 'utm_source' => 'wordpress', | |
| 305 | + 'utm_term' => get_locale(), | |
| 306 | + 'utm_content' => 'convertkit', | |
| 307 | + ), | |
| 308 | + 'https://app.convertkit.com/users/signup' | |
| 309 | + ); | |
| 257 | 310 | |
| 258 | 311 | } |
| 259 | 312 | |
| 260 | 313 | /** |
| @@ -265,13 +318,40 @@ | ||
| 265 | 318 | * @return string ConvertKit Login URL. |
| 266 | 319 | */ |
| 267 | 320 | function convertkit_get_sign_in_url() { |
| 268 | 321 | |
| 269 | - return 'https://app.convertkit.com/?utm_source=wordpress&utm_content=convertkit'; | |
| 322 | + return add_query_arg( | |
| 323 | + array( | |
| 324 | + 'utm_source' => 'wordpress', | |
| 325 | + 'utm_term' => get_locale(), | |
| 326 | + 'utm_content' => 'convertkit', | |
| 327 | + ), | |
| 328 | + 'https://app.convertkit.com/' | |
| 329 | + ); | |
| 270 | 330 | |
| 271 | 331 | } |
| 272 | 332 | |
| 273 | 333 | /** |
| 334 | + * Helper method to return the URL the user needs to visit to manage thier billing. | |
| 335 | + * | |
| 336 | + * @since 2.2.7 | |
| 337 | + * | |
| 338 | + * @return string ConvertKit Billing URL. | |
| 339 | + */ | |
| 340 | +function convertkit_get_billing_url() { | |
| 341 | + | |
| 342 | + return add_query_arg( | |
| 343 | + array( | |
| 344 | + 'utm_source' => 'wordpress', | |
| 345 | + 'utm_term' => get_locale(), | |
| 346 | + 'utm_content' => 'convertkit', | |
| 347 | + ), | |
| 348 | + 'https://app.convertkit.com/account_settings/billing/' | |
| 349 | + ); | |
| 350 | + | |
| 351 | +} | |
| 352 | + | |
| 353 | +/** | |
| 274 | 354 | * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret. |
| 275 | 355 | * |
| 276 | 356 | * @since 1.9.6.1 |
| 277 | 357 | * |
| @@ -278,13 +358,144 @@ | ||
| 278 | 358 | * @return string ConvertKit App URL. |
| 279 | 359 | */ |
| 280 | 360 | function convertkit_get_api_key_url() { |
| 281 | 361 | |
| 282 | - return 'https://app.convertkit.com/account_settings/advanced_settings/?utm_source=wordpress&utm_content=convertkit'; | |
| 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 | + ); | |
| 283 | 370 | |
| 284 | 371 | } |
| 285 | 372 | |
| 286 | 373 | /** |
| 374 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Form or Landing Page. | |
| 375 | + * | |
| 376 | + * @since 2.2.3 | |
| 377 | + * | |
| 378 | + * @return string ConvertKit App URL | |
| 379 | + */ | |
| 380 | +function convertkit_get_new_form_url() { | |
| 381 | + | |
| 382 | + return add_query_arg( | |
| 383 | + array( | |
| 384 | + 'utm_source' => 'wordpress', | |
| 385 | + 'utm_term' => get_locale(), | |
| 386 | + 'utm_content' => 'convertkit', | |
| 387 | + ), | |
| 388 | + 'https://app.convertkit.com/forms/new/' | |
| 389 | + ); | |
| 390 | + | |
| 391 | +} | |
| 392 | + | |
| 393 | +/** | |
| 394 | + * Helper method to return the URL the user needs to visit to edit ConvertKit forms. | |
| 395 | + * | |
| 396 | + * @since 2.2.3 | |
| 397 | + * | |
| 398 | + * @return string ConvertKit Form Editor URL. | |
| 399 | + */ | |
| 400 | +function convertkit_get_form_editor_url() { | |
| 401 | + | |
| 402 | + return add_query_arg( | |
| 403 | + array( | |
| 404 | + 'utm_source' => 'wordpress', | |
| 405 | + 'utm_term' => get_locale(), | |
| 406 | + 'utm_content' => 'convertkit', | |
| 407 | + ), | |
| 408 | + 'https://app.convertkit.com/forms' | |
| 409 | + ); | |
| 410 | + | |
| 411 | +} | |
| 412 | + | |
| 413 | +/** | |
| 414 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Tag. | |
| 415 | + * | |
| 416 | + * @since 2.3.3 | |
| 417 | + * | |
| 418 | + * @return string ConvertKit App URL. | |
| 419 | + */ | |
| 420 | +function convertkit_get_new_tag_url() { | |
| 421 | + | |
| 422 | + return add_query_arg( | |
| 423 | + array( | |
| 424 | + 'utm_source' => 'wordpress', | |
| 425 | + 'utm_term' => get_locale(), | |
| 426 | + 'utm_content' => 'convertkit', | |
| 427 | + ), | |
| 428 | + 'https://app.convertkit.com/subscribers/' | |
| 429 | + ); | |
| 430 | + | |
| 431 | +} | |
| 432 | + | |
| 433 | +/** | |
| 434 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Broadcast. | |
| 435 | + * | |
| 436 | + * @since 2.2.6 | |
| 437 | + * | |
| 438 | + * @return string ConvertKit App URL. | |
| 439 | + */ | |
| 440 | +function convertkit_get_new_broadcast_url() { | |
| 441 | + | |
| 442 | + return add_query_arg( | |
| 443 | + array( | |
| 444 | + 'utm_source' => 'wordpress', | |
| 445 | + 'utm_term' => get_locale(), | |
| 446 | + 'utm_content' => 'convertkit', | |
| 447 | + ), | |
| 448 | + 'https://app.convertkit.com/campaigns/' | |
| 449 | + ); | |
| 450 | + | |
| 451 | +} | |
| 452 | + | |
| 453 | +/** | |
| 454 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to edit a draft Broadcast. | |
| 455 | + * | |
| 456 | + * @since 2.4.0 | |
| 457 | + * | |
| 458 | + * @param int $broadcast_id ConvertKit Broadcast ID. | |
| 459 | + * @return string ConvertKit App URL. | |
| 460 | + */ | |
| 461 | +function convertkit_get_edit_broadcast_url( $broadcast_id ) { | |
| 462 | + | |
| 463 | + return add_query_arg( | |
| 464 | + array( | |
| 465 | + 'utm_source' => 'wordpress', | |
| 466 | + 'utm_term' => get_locale(), | |
| 467 | + 'utm_content' => 'convertkit', | |
| 468 | + ), | |
| 469 | + sprintf( | |
| 470 | + 'https://app.convertkit.com/campaigns/%s/draft', | |
| 471 | + $broadcast_id | |
| 472 | + ) | |
| 473 | + ); | |
| 474 | + | |
| 475 | +} | |
| 476 | + | |
| 477 | +/** | |
| 478 | + * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Product. | |
| 479 | + * | |
| 480 | + * @since 2.2.3 | |
| 481 | + * | |
| 482 | + * @return string ConvertKit App URL. | |
| 483 | + */ | |
| 484 | +function convertkit_get_new_product_url() { | |
| 485 | + | |
| 486 | + return add_query_arg( | |
| 487 | + array( | |
| 488 | + 'utm_source' => 'wordpress', | |
| 489 | + 'utm_term' => get_locale(), | |
| 490 | + 'utm_content' => 'convertkit', | |
| 491 | + ), | |
| 492 | + 'https://app.convertkit.com/products/new/' | |
| 493 | + ); | |
| 494 | + | |
| 495 | +} | |
| 496 | + | |
| 497 | +/** | |
| 287 | 498 | * Helper method to enqueue Select2 scripts for use within the ConvertKit Plugin. |
| 288 | 499 | * |
| 289 | 500 | * @since 1.9.6.4 |
| 290 | 501 | */ |
| @@ -303,6 +514,34 @@ | ||
| 303 | 514 | function convertkit_select2_enqueue_styles() { |
| 304 | 515 | |
| 305 | 516 | 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 ); |
| 306 | 517 | wp_enqueue_style( 'convertkit-admin-select2', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/select2.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 518 | + | |
| 519 | +} | |
| 520 | + | |
| 521 | +/** | |
| 522 | + * Return the contents of the given local file. | |
| 523 | + * | |
| 524 | + * @since 2.2.2 | |
| 525 | + * | |
| 526 | + * @param string $local_file Local file, including path. | |
| 527 | + * @return string File contents. | |
| 528 | + */ | |
| 529 | +function convertkit_get_file_contents( $local_file ) { | |
| 530 | + | |
| 531 | + // Bail if the file doesn't exist. | |
| 532 | + if ( ! file_exists( $local_file ) ) { | |
| 533 | + return ''; | |
| 534 | + } | |
| 535 | + | |
| 536 | + // Read file. | |
| 537 | + $contents = file_get_contents( $local_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents | |
| 538 | + | |
| 539 | + // Return an empty string if the contents of the file could not be read. | |
| 540 | + if ( ! $contents ) { | |
| 541 | + return ''; | |
| 542 | + } | |
| 543 | + | |
| 544 | + // Return file's contents. | |
| 545 | + return $contents; | |
| 307 | 546 | |
| 308 | 547 | } |