| @@ -192,8 +192,11 @@ | ||
| 192 | 192 | $form = str_replace( '[PASSSTER_POST_ID]', absint( get_the_ID() ), $form ); |
| 193 | 193 | // term id (for category archive protection — passed to REST API so it can validate against term meta). |
| 194 | 194 | $term_id_val = ( !empty( $atts['term_id'] ) ? absint( $atts['term_id'] ) : 0 ); |
| 195 | 195 | $form = str_replace( '[PASSSTER_TERM_ID]', $term_id_val, $form ); |
| 196 | + // post type (for post type archive protection — passed to REST API so it can validate against post type config). | |
| 197 | + $post_type_val = ( !empty( $atts['post_type'] ) ? sanitize_key( $atts['post_type'] ) : '' ); | |
| 198 | + $form = str_replace( '[PASSSTER_POST_TYPE]', esc_attr( $post_type_val ), $form ); | |
| 196 | 199 | // hide or not. |
| 197 | 200 | if ( !empty( $atts['hide'] ) ) { |
| 198 | 201 | $form = str_replace( '[PASSSTER_HIDE]', ' passster-hide', $form ); |
| 199 | 202 | } else { |
| @@ -394,8 +397,12 @@ | ||
| 394 | 397 | $shortcodes[$shortcode] = do_shortcode( str_replace( '{post-id}', get_the_id(), $shortcode ) ); |
| 395 | 398 | } |
| 396 | 399 | } |
| 397 | 400 | } |
| 401 | + // Archive/taxonomy pages have no singular post, so get_permalink() can't be used | |
| 402 | + // to build the "reload after unlock" URL for links generated by area/CPT-level protection. | |
| 403 | + $current_post_id = get_the_id(); | |
| 404 | + $reload_url = ( $current_post_id ? get_permalink( $current_post_id ) : esc_url_raw( remove_query_arg( 'pass' ) ) ); | |
| 398 | 405 | $args = array( |
| 399 | 406 | 'ajax_url' => admin_url() . 'admin-ajax.php', |
| 400 | 407 | 'rest_url' => get_rest_url(), |
| 401 | 408 | 'nonce' => wp_create_nonce( 'ps-password-nonce' ), |
| @@ -400,11 +407,11 @@ | ||
| 400 | 407 | 'rest_url' => get_rest_url(), |
| 401 | 408 | 'nonce' => wp_create_nonce( 'ps-password-nonce' ), |
| 402 | 409 | 'hash_nonce' => wp_create_nonce( 'ps-hash-nonce' ), |
| 403 | 410 | 'logout_nonce' => wp_create_nonce( 'ps-logout-nonce' ), |
| 404 | - 'post_id' => get_the_id(), | |
| 411 | + 'post_id' => $current_post_id, | |
| 405 | 412 | 'shortcodes' => $shortcodes, |
| 406 | - 'permalink' => get_permalink( get_the_id() ), | |
| 413 | + 'permalink' => $reload_url, | |
| 407 | 414 | ); |
| 408 | 415 | if ( isset( $options['cookie_duration_unit'] ) ) { |
| 409 | 416 | $args['cookie_duration_unit'] = esc_html( $options['cookie_duration_unit'] ); |
| 410 | 417 | } else { |