← All changes
|
includes/blocks/class-convertkit-block-member-content-login.php
+10
-13
3.4.3
→
3.4.5
View file →
| @@ -58,8 +58,9 @@ | ||
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * This will register as: |
| 61 | 61 | * - a shortcode, with the name [convertkit_login]. |
| 62 | + * - a shortcode, with the name [kit_login]. | |
| 62 | 63 | * - a Gutenberg block, with the name convertkit/login. |
| 63 | 64 | */ |
| 64 | 65 | return 'login'; |
| 65 | 66 | |
| @@ -355,12 +356,15 @@ | ||
| 355 | 356 | |
| 356 | 357 | // Enqueue CSS and JS. |
| 357 | 358 | $output_restrict_content->enqueue_scripts_and_styles(); |
| 358 | 359 | |
| 359 | - // If the subscriber is logged in, output the log out button. | |
| 360 | + // Get the subscriber ID, if the subscriber is logged in. | |
| 360 | 361 | $subscriber = new ConvertKit_Subscriber(); |
| 361 | 362 | $subscriber_id = $subscriber->get_subscriber_id(); |
| 363 | + | |
| 364 | + ob_start(); | |
| 362 | 365 | if ( ! is_wp_error( $subscriber_id ) && $subscriber_id ) { |
| 366 | + // If the subscriber is logged in, output the log out button. | |
| 363 | 367 | $logout_url = add_query_arg( |
| 364 | 368 | array( |
| 365 | 369 | 'convertkit_logout' => 1, |
| 366 | 370 | '_wpnonce' => wp_create_nonce( 'convertkit_member_content_logout' ), |
| @@ -367,23 +371,16 @@ | ||
| 367 | 371 | ), |
| 368 | 372 | get_permalink( $post_id ) |
| 369 | 373 | ); |
| 370 | 374 | |
| 371 | - ob_start(); | |
| 372 | 375 | include CONVERTKIT_PLUGIN_PATH . '/views/frontend/restrict-content/member-content-logged-in.php'; |
| 373 | - return trim( ob_get_clean() ); | |
| 374 | - } | |
| 375 | - | |
| 376 | - // If the subscriber submitted their email address, output the code form. | |
| 377 | - if ( $output_restrict_content->token !== false ) { | |
| 378 | - ob_start(); | |
| 376 | + } elseif ( $output_restrict_content->token !== false ) { | |
| 377 | + // If the subscriber submitted their email address, output the code form. | |
| 379 | 378 | include CONVERTKIT_PLUGIN_PATH . '/views/frontend/restrict-content/code.php'; |
| 380 | - return trim( ob_get_clean() ); | |
| 379 | + } else { | |
| 380 | + // Output the login form. | |
| 381 | + include CONVERTKIT_PLUGIN_PATH . '/views/frontend/restrict-content/member-content-login.php'; | |
| 381 | 382 | } |
| 382 | - | |
| 383 | - // Output. | |
| 384 | - ob_start(); | |
| 385 | - include CONVERTKIT_PLUGIN_PATH . '/views/frontend/restrict-content/member-content-login.php'; | |
| 386 | 383 | $html = trim( ob_get_clean() ); |
| 387 | 384 | |
| 388 | 385 | /** |
| 389 | 386 | * Filter the block's content immediately before it is output. |