LLMS_Forms::load_reusable_blocks( array[] $blocks )

Loads reusable blocks into a block list.


Description Description

A reusable block contains a reference to the block post, e.g. <!-- wp:block {"ref":2198} /-->, which will be loaded during rendering.

Dereferencing the reusable blocks allows the entire block list to be reviewed and to validate all form fields. This function will replace each reusable block with the parsed blocks from its reference post.


Top ↑

Parameters Parameters

$blocks

(array[]) (Required) An array of blocks from parse_blocks(), where each block is usually an array cast from WP_Block_Parser_Block.


Top ↑

Return Return

(array[])


Top ↑

Source Source

File: includes/forms/class-llms-forms.php

		}

		return $loaded;
	}

	/**
	 * Load form autosaves when previewing a form
	 *
	 * @since 5.0.0
	 *
	 * @param WP_Post|boolean $post WP_Post object for the llms_form post or `false` if no form found.
	 * @return WP_Post|boolean
	 */
	public function maybe_load_preview( $post ) {

		// No form post found.
		if ( ! is_object( $post ) ) {
			return $post;
		}

		// The `_set_preview()` method is marked as private but has existed since 2.7 and my guess is that we can use this safely.
		if ( ! function_exists( '_set_preview' ) ) {
			return $post;
		}

		$is_preview = ( is_preview() && current_user_can( $this->get_capability(), $post->ID ) );

		return $is_preview ? _set_preview( $post ) : $post;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.1.0 Access turned to public.
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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