WP_Block::__get

Advertisement

Summery Summery

Returns a value from an inaccessible property.

Syntax Syntax

WP_Block::__get( string $name )

Description Description

This is used to lazily initialize the attributes property of a block, such that it is only prepared with default attributes at the time that the property is accessed. For all other inaccessible properties, a null value is returned.

Parameters Parameters

$name

(string) (Required) Property name.

Return Return

(array|null) Prepared attributes, or null.

Source Source

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

	public function __get( $name ) {
		if ( 'attributes' === $name ) {
			$this->attributes = isset( $this->parsed_block['attrs'] ) ?
				$this->parsed_block['attrs'] :
				array();

			if ( ! is_null( $this->block_type ) ) {
				$this->attributes = $this->block_type->prepare_attributes_for_render( $this->attributes );
			}

			return $this->attributes;
		}

		return null;
	}

Advertisement

Changelog Changelog

Changelog
Version Description
5.5.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.