← All changes
|
admin/setup-wizard/class-convertkit-admin-setup-wizard-landing-page.php
+11
-29
3.3.7
→
3.4.4
View file →
| @@ -14,17 +14,8 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | class ConvertKit_Admin_Setup_Wizard_Landing_Page extends ConvertKit_Admin_Setup_Wizard { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Holds the Post Type to generate. | |
| 19 | - * | |
| 20 | - * @since 2.5.5 | |
| 21 | - * | |
| 22 | - * @var string | |
| 23 | - */ | |
| 24 | - public $post_type = 'page'; | |
| 25 | - | |
| 26 | - /** | |
| 27 | 18 | * Holds the ConvertKit Products resource class. |
| 28 | 19 | * |
| 29 | 20 | * @since 2.5.5 |
| 30 | 21 | * |
| @@ -127,8 +118,15 @@ | ||
| 127 | 118 | * @param string $step Current step. |
| 128 | 119 | */ |
| 129 | 120 | public function process_form( $step ) { |
| 130 | 121 | |
| 122 | + // Set and authorize the Post Type before processing data. | |
| 123 | + $this->set_post_type(); | |
| 124 | + if ( ! convertkit_user_can_create_published_post_type( $this->post_type ) ) { | |
| 125 | + $this->error = __( 'You are not allowed to create and publish this type of content.', 'convertkit' ); | |
| 126 | + return; | |
| 127 | + } | |
| 128 | + | |
| 131 | 129 | // Run security checks. |
| 132 | 130 | if ( ! isset( $_REQUEST['_wpnonce'] ) ) { |
| 133 | 131 | return; |
| 134 | 132 | } |
| @@ -180,28 +178,12 @@ | ||
| 180 | 178 | if ( ! $settings->has_access_and_refresh_token() ) { |
| 181 | 179 | wp_die( esc_html__( 'Connect your Kit account in the Kit Plugin\'s settings to get started', 'convertkit' ) ); |
| 182 | 180 | } |
| 183 | 181 | |
| 184 | - // Get Post Type. | |
| 185 | - if ( filter_has_var( INPUT_GET, 'ck_post_type' ) ) { | |
| 186 | - $this->post_type = filter_input( INPUT_GET, 'ck_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); | |
| 187 | - } else { | |
| 188 | - $this->post_type = 'page'; | |
| 189 | - } | |
| 190 | - | |
| 191 | - // Bail if the Post Type isn't supported. | |
| 192 | - if ( ! in_array( $this->post_type, convertkit_get_supported_post_types(), true ) ) { | |
| 193 | - wp_die( | |
| 194 | - sprintf( | |
| 195 | - /* translators: Post Type */ | |
| 196 | - esc_html__( 'The post type `%s` is not supported for Member Content.', 'convertkit' ), | |
| 197 | - esc_html( $this->post_type ) | |
| 198 | - ), | |
| 199 | - esc_html__( 'WordPress Error', 'convertkit' ), | |
| 200 | - array( | |
| 201 | - 'back_link' => true, | |
| 202 | - ) | |
| 203 | - ); | |
| 182 | + // Set and authorize the Post Type. | |
| 183 | + $this->set_post_type(); | |
| 184 | + if ( ! convertkit_user_can_create_published_post_type( $this->post_type ) ) { | |
| 185 | + wp_die( esc_html__( 'Sorry, you are not allowed to create and publish this type of content.', 'convertkit' ) ); | |
| 204 | 186 | } |
| 205 | 187 | |
| 206 | 188 | // Define Exit URL to take the user back to the WP_List_Table for the Post Type they were viewing. |
| 207 | 189 | $this->exit_url = add_query_arg( |