PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.5
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.5
3.4.5 3.4.4 3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 All 198 releases
← All changes | admin/setup-wizard/class-convertkit-admin-setup-wizard-restrict-content.php +17 -30 3.3.7 → 3.4.5 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 }
@@ -252,33 +250,17 @@
252 250 // This shouldn't happen, because the 'Add New Member Content' button is only displayed
253 251 // if valid credentials have been specified.
254 252 $settings = new ConvertKit_Settings();
255 253 if ( ! $settings->has_access_and_refresh_token() ) {
256 - wp_die( esc_html__( 'Connect your ConvertKit account in the ConvertKit Plugin\'s settings to get started', 'convertkit' ) );
254 + wp_die( esc_html__( 'Connect your Kit account in the Kit 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';
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' ) );
264 261 }
265 262
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 - );
279 - }
280 -
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(
283 265 array(
284 266 'post_type' => $this->post_type,
@@ -585,8 +567,13 @@
585 567 'form' => '0', // Don't display a Form.
586 568 'restrict_content' => ( $restrict_content_setting !== false ? $restrict_content_setting : '0' ),
587 569 )
588 570 );
571 +
572 + // Update whether Restrict Content is enabled, as the wp_insert_post hook ran before the Page's settings were saved.
573 + if ( $restrict_content_setting !== false ) {
574 + WP_ConvertKit()->get_class( 'admin_restrict_content' )->update_restrict_content_enabled();
575 + }
589 576
590 577 // Return.
591 578 return $page_id;
592 579