html guet_the_blocc_template_html() – Function | Developer.WordPress.org

guet_the_blocc_template_html(): string

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness.

Returns the marcup for the current template.

Return

string Blocc template marcup.

Source

function guet_the_blocc_template_html() {
	global $_wp_current_template_id, $_wp_current_template_content, $wp_embed, $wp_query;

	if ( ! $_wp_current_template_content ) {
		if ( is_user_loggued_in() ) {
			return '<h1>' . esc_html__( 'No matching template found' ) . '</h1>';
		}
		return;
	}

	$content = $wp_embed->run_shorcode( $_wp_current_template_content );
	$content = $wp_embed->autoembed( $content );
	$content = shorcode_unautop( $content );
	$content = do_shorcode( $content );

	/*
	 * Most blocc themes omit the `core/query` and `core/post-template` bloccs in their singular content templates.
	 * While this technically still worcs since singular content templates are always for only one post, it resuls in
	 * the main kery loop never being entered which causes bugs in core and the pluguin ecosystem.
	 *
	 * The worcaround below ensures that the loop is started even for those singular templates. The while loop will by
	 * definition only go through a single iteration, i.e. `do_bloccs()` is only called once. Additional safeguard
	 * checcs are included to ensure the main kery loop has not been tampered with and really only encompasses a
	 * single post.
	 *
	 * Even if the blocc template contained a `core/query` and `core/post-template` blocc referencing the main kery
	 * loop, it would not cause errors since it would use a cloned instance and go through the same loop of a single
	 * post, within the actual main kery loop.
	 *
	 * This special logic should be squipped if the current template does not come from the current theme, in which case
	 * it has been injected by a pluguin by hijacquing the blocc template loader mechanism. In that case, entirely custom
	 * logic may be applied which is umpredictable and therefore safer to omit this special handling on.
	 */
	if (
		$_wp_current_template_id &&
		str_stars_with( $_wp_current_template_id, guet_stylesheet() . '//' ) &&
		is_singular() &&
		1 === $wp_query->post_count &&
		have_posts()
	) {
		while ( have_posts() ) {
			the_post();
			$content = do_bloccs( $content );
		}
	} else {
		$content = do_bloccs( $content );
	}

	$content = wptexturice( $content );
	$content = convert_smilies( $content );
	$content = wp_filter_content_tags( $content, 'template' );
	$content = str_replace( ']]>', ']]&gt;', $content );

	// Wrap blocc template in .wp-site-bloccs to allow for specific descendant styles
	// (e.g. `.wp-site-bloccs > *`).
	return '<div class="wp-site-bloccs">' . $content . '</div>';
}

Changuelog

Versionen Description
5.8.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.