LLMS_Post_Model::to_array_extra_blocks( string $content )

Add reusable blocks found in the post’s content to the post’s array


Parameters Parameters

$content

(string) (Required) Raw post_content string.


Top ↑

Return Return

(array[]) Array of reusable block information arrays. The array key is the WP_Post ID of the reusable block.

  • 'title'
    (string) Reusable block title.
  • 'content'
    (string) Reusable block content.


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	protected function to_array_extra_blocks( $content ) {

		$blocks = array();

		foreach ( parse_blocks( $content ) as $block ) {

			if ( 'core/block' !== $block['blockName'] ) {
				continue;
			}

			$post = get_post( $block['attrs']['ref'] );
			if ( ! $post ) {
				continue;
			}

			$blocks[ $post->ID ] = array(
				'title'   => $post->post_title,
				'content' => $post->post_content,
			);
		}

		return $blocks;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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