| @@ -37,8 +37,17 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | public $error = false; |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | + * Holds the Post Type to generate. | |
| 42 | + * | |
| 43 | + * @since 3.3.9 | |
| 44 | + * | |
| 45 | + * @var string | |
| 46 | + */ | |
| 47 | + public $post_type = 'page'; | |
| 48 | + | |
| 49 | + /** | |
| 41 | 50 | * The required user capability to access the setup wizard. |
| 42 | 51 | * |
| 43 | 52 | * @since 1.9.8.4 |
| 44 | 53 | * |
| @@ -503,8 +512,33 @@ | ||
| 503 | 512 | return false; |
| 504 | 513 | } |
| 505 | 514 | |
| 506 | 515 | return true; |
| 516 | + | |
| 517 | + } | |
| 518 | + | |
| 519 | + /** | |
| 520 | + * Sets the Post Type from the request, ensuring it is supported by the Plugin. | |
| 521 | + * | |
| 522 | + * @since 3.3.9 | |
| 523 | + */ | |
| 524 | + protected function set_post_type() { | |
| 525 | + | |
| 526 | + $this->post_type = ( filter_has_var( INPUT_GET, 'ck_post_type' ) ? filter_input( INPUT_GET, 'ck_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : 'page' ); | |
| 527 | + | |
| 528 | + if ( ! in_array( $this->post_type, convertkit_get_supported_post_types(), true ) ) { | |
| 529 | + wp_die( | |
| 530 | + sprintf( | |
| 531 | + /* translators: Post Type */ | |
| 532 | + esc_html__( 'The post type `%s` is not supported for Member Content.', 'convertkit' ), | |
| 533 | + esc_html( $this->post_type ) | |
| 534 | + ), | |
| 535 | + esc_html__( 'WordPress Error', 'convertkit' ), | |
| 536 | + array( | |
| 537 | + 'back_link' => true, | |
| 538 | + ) | |
| 539 | + ); | |
| 540 | + } | |
| 507 | 541 | |
| 508 | 542 | } |
| 509 | 543 | |
| 510 | 544 | } |