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

LLMS_Blocks_Migrate::remove_template_from_post( WP_Post $post )

Remove post type templates and any LifterLMS Blocks from a given post.

Parameters Parameters


(WP_Post) (Required) Post object.

Top ↑

Return Return


Top ↑

Source Source

File: libraries/lifterlms-blocks/includes/class-llms-blocks-migrate.php

	private function remove_template_from_post( $post ) {

		$template = $this->get_template( $post->post_type, true );
		if ( ! $template ) {

		// explicitly remove template pieces.
		$parts   = array_filter( array_map( 'trim', explode( "\n", $template ) ) );
		$content = str_replace( $parts, '', $post->post_content );

		// replace any remaining LLMS blocks not found in the template (also grabs any openers that have block settings JSON).
		$content = trim( preg_replace( '#<!-- \/?wp:llms\/.* \/?-->#', '', $content ) );

		if ( $this->update_post_content( $post->ID, $content ) ) {
			$this->update_migration_status( $post->ID, 'no' );
			return true;

		return false;


Top ↑

Changelog Changelog

Version Description
1.8.0 Get all post type's template with deprecated blocks versions merged.
1.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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