WP_Block::__get() WordPress Method

The WP_Block::__get() method is used to get a property of a WP_Block object.

WP_Block::__get( string $name ) #

Returns a value from an inaccessible property.


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.


Top ↑

Parameters

$name

(string)(Required)Property name.


Top ↑

Return

(array|null) Prepared attributes, or null.


Top ↑

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;
	}

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.