← All changes
|
admin/setup-wizard/class-convertkit-admin-setup-wizard-restrict-content.php
+11
-29
3.3.5
→
3.4.3
View file →
| @@ -14,17 +14,8 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | class ConvertKit_Admin_Setup_Wizard_Restrict_Content extends ConvertKit_Admin_Setup_Wizard { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Holds the Post Type to generate Members Content for. | |
| 19 | - * | |
| 20 | - * @since 2.1.0 | |
| 21 | - * | |
| 22 | - * @var string | |
| 23 | - */ | |
| 24 | - public $post_type = 'page'; | |
| 25 | - | |
| 26 | - /** | |
| 27 | 18 | * Holds the type of Member's Content to generate (course|download). |
| 28 | 19 | * |
| 29 | 20 | * @since 2.1.0 |
| 30 | 21 | * |
| @@ -184,8 +175,15 @@ | ||
| 184 | 175 | * @param string $step Current step. |
| 185 | 176 | */ |
| 186 | 177 | public function process_form( $step ) { |
| 187 | 178 | |
| 179 | + // Set and authorize the Post Type before processing data. | |
| 180 | + $this->set_post_type(); | |
| 181 | + if ( ! convertkit_user_can_create_published_post_type( $this->post_type ) ) { | |
| 182 | + $this->error = __( 'You are not allowed to create and publish this type of content.', 'convertkit' ); | |
| 183 | + return; | |
| 184 | + } | |
| 185 | + | |
| 188 | 186 | // Run security checks. |
| 189 | 187 | if ( ! isset( $_REQUEST['_wpnonce'] ) ) { |
| 190 | 188 | return; |
| 191 | 189 | } |
| @@ -255,28 +253,12 @@ | ||
| 255 | 253 | if ( ! $settings->has_access_and_refresh_token() ) { |
| 256 | 254 | wp_die( esc_html__( 'Connect your ConvertKit account in the ConvertKit Plugin\'s settings to get started', 'convertkit' ) ); |
| 257 | 255 | } |
| 258 | 256 | |
| 259 | - // Get the Post Type. | |
| 260 | - if ( filter_has_var( INPUT_GET, 'ck_post_type' ) ) { | |
| 261 | - $this->post_type = filter_input( INPUT_GET, 'ck_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); | |
| 262 | - } else { | |
| 263 | - $this->post_type = 'page'; | |
| 264 | - } | |
| 265 | - | |
| 266 | - // Bail if the Post Type isn't supported. | |
| 267 | - if ( ! in_array( $this->post_type, convertkit_get_supported_post_types(), true ) ) { | |
| 268 | - wp_die( | |
| 269 | - sprintf( | |
| 270 | - /* translators: Post Type */ | |
| 271 | - esc_html__( 'The post type `%s` is not supported for Member Content.', 'convertkit' ), | |
| 272 | - esc_html( $this->post_type ) | |
| 273 | - ), | |
| 274 | - esc_html__( 'WordPress Error', 'convertkit' ), | |
| 275 | - array( | |
| 276 | - 'back_link' => true, | |
| 277 | - ) | |
| 278 | - ); | |
| 257 | + // Set and authorize the Post Type. | |
| 258 | + $this->set_post_type(); | |
| 259 | + if ( ! convertkit_user_can_create_published_post_type( $this->post_type ) ) { | |
| 260 | + wp_die( esc_html__( 'Sorry, you are not allowed to create and publish this type of content.', 'convertkit' ) ); | |
| 279 | 261 | } |
| 280 | 262 | |
| 281 | 263 | // Define Exit URL to take the user back to the WP_List_Table for the Post Type they were viewing. |
| 282 | 264 | $this->exit_url = add_query_arg( |