post_password ) ) { return true; } if ( get_post_meta( $post->ID, self::META_CONTAINS_PAID_CONTENT, true ) || get_post_meta( $post->ID, self::META_CONTAINS_PAYWALLED_CONTENT, true ) || has_block( self::BLOCK_PREMIUM_CONTENT, $post ) || has_block( self::BLOCK_PAYWALL, $post ) ) { return true; } return self::ACCESS_LEVEL_EVERYBODY !== self::access_level( $post->ID ); } /** * The part of a gated post's body that is published to everyone anyway. * * A `jetpack/paywall` post serves everything above the block to anonymous * readers, but only because `do_blocks()` then renders that prefix: a * `premium-content` block inside it hides itself, which raw markup does not. * * @since 0.9.2 * * @param \WP_Post|int|null $post Post, post ID, or null for the global post. * @return string Public teaser, or '' when no part of the body is public. */ public static function public_teaser( $post = null ) { $post = $post instanceof \WP_Post ? $post : get_post( $post ); if ( ! $post instanceof \WP_Post || ! empty( $post->post_password ) ) { return ''; } // Split on the same delimiter the subscriptions paywall splits on, so the // teaser we summarize is the one the front end actually serves. $delimiter = ''; if ( ! str_contains( $post->post_content, $delimiter ) ) { return ''; } $teaser = strstr( $post->post_content, $delimiter, true ); // Callers summarize this without rendering it, so a block that withholds // its own content at render time would publish here as plain text. if ( str_contains( $teaser, '