| @@ -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 | * |
| @@ -260,9 +285,9 @@ | ||
| 260 | 285 | 'page' => 'convertkit-setup', |
| 261 | 286 | ) |
| 262 | 287 | ); |
| 263 | 288 | |
| 264 | - return add_query_arg( $query_args, admin_url( 'index.php' ) ); | |
| 289 | + return add_query_arg( $query_args, admin_url( 'options.php' ) ); | |
| 265 | 290 | |
| 266 | 291 | } |
| 267 | 292 | |
| 268 | 293 | /** |
| @@ -305,8 +330,28 @@ | ||
| 305 | 330 | |
| 306 | 331 | } |
| 307 | 332 | |
| 308 | 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 | +/** | |
| 309 | 354 | * Helper method to return the URL the user needs to visit on the ConvertKit app to obtain their API Key and Secret. |
| 310 | 355 | * |
| 311 | 356 | * @since 1.9.6.1 |
| 312 | 357 | * |
| @@ -365,8 +410,28 @@ | ||
| 365 | 410 | |
| 366 | 411 | } |
| 367 | 412 | |
| 368 | 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 | +/** | |
| 369 | 434 | * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Broadcast. |
| 370 | 435 | * |
| 371 | 436 | * @since 2.2.6 |
| 372 | 437 | * |
| @@ -385,8 +450,32 @@ | ||
| 385 | 450 | |
| 386 | 451 | } |
| 387 | 452 | |
| 388 | 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 | +/** | |
| 389 | 478 | * Helper method to return the URL the user needs to visit on the ConvertKit app to create a new Product. |
| 390 | 479 | * |
| 391 | 480 | * @since 2.2.3 |
| 392 | 481 | * |
| @@ -438,22 +527,21 @@ | ||
| 438 | 527 | * @return string File contents. |
| 439 | 528 | */ |
| 440 | 529 | function convertkit_get_file_contents( $local_file ) { |
| 441 | 530 | |
| 442 | - // Call globals. | |
| 443 | - global $wp_filesystem; | |
| 531 | + // Bail if the file doesn't exist. | |
| 532 | + if ( ! file_exists( $local_file ) ) { | |
| 533 | + return ''; | |
| 534 | + } | |
| 444 | 535 | |
| 445 | - // Load filesystem class. | |
| 446 | - require_once ABSPATH . 'wp-admin/includes/file.php'; | |
| 536 | + // Read file. | |
| 537 | + $contents = file_get_contents( $local_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents | |
| 447 | 538 | |
| 448 | - // Initiate. | |
| 449 | - WP_Filesystem(); | |
| 450 | - | |
| 451 | - // Bail if the file doesn't exist. | |
| 452 | - if ( ! $wp_filesystem->exists( $local_file ) ) { | |
| 539 | + // Return an empty string if the contents of the file could not be read. | |
| 540 | + if ( ! $contents ) { | |
| 453 | 541 | return ''; |
| 454 | 542 | } |
| 455 | 543 | |
| 456 | 544 | // Return file's contents. |
| 457 | - return $wp_filesystem->get_contents( $local_file ); | |
| 545 | + return $contents; | |
| 458 | 546 | |
| 459 | 547 | } |