WP_Block_List::__construct() WordPress Method

The WP_Block_List::__construct() method is used to construct a list of blocks. This method takes two parameters: $blocks: an array of block objects. $attributes: an array of attributes. The blocks in the $blocks array will be added to the list in the order they appear in the array. The $attributes array is used to set the list's attributes. The following attributes can be set: class: the class attribute of the list. id: the id attribute of the list. style: the style attribute of the list. The WP_Block_List::__construct() method can be used to create a list of blocks that can be displayed on a WordPress post or page.

WP_Block_List::__construct( array[]|WP_Block[] $blocks, array $available_context = array(), WP_Block_Type_Registry $registry = null ) #

Constructor.


Description

Populates object properties from the provided block instance argument.


Top ↑

Parameters

$blocks

(array[]|WP_Block[])(Required)Array of parsed block data, or block instances.

$available_context

(array)(Optional)array of ancestry context values.

Default value: array()

$registry

(WP_Block_Type_Registry)(Optional)block type registry.

Default value: null


Top ↑

Source

File: wp-includes/class-wp-block-list.php

	public function __construct( $blocks, $available_context = array(), $registry = null ) {
		if ( ! $registry instanceof WP_Block_Type_Registry ) {
			$registry = WP_Block_Type_Registry::get_instance();
		}

		$this->blocks            = $blocks;
		$this->available_context = $available_context;
		$this->registry          = $registry;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.