WP_Block_Type::__set()publicWP 6.1.0

Proxies setting values for deprecated properties for script and style handles for backward compatibility. Sets the value for the corresponding new property as the first item in the array. It also allows setting custom properties for backward compatibility.

Метод класса: WP_Block_Type{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Block_Type = new WP_Block_Type();
$WP_Block_Type->__set( $name, $value );
$name(строка) (обязательный)
Property name.
$value(разное) (обязательный)
Property value.

Список изменений

С версии 6.1.0 Введена.

Код WP_Block_Type::__set() WP 6.4.3

public function __set( $name, $value ) {
	if ( ! in_array( $name, $this->deprecated_properties, true ) ) {
		$this->{$name} = $value;
		return;
	}

	$new_name = $name . '_handles';

	if ( is_array( $value ) ) {
		$filtered = array_filter( $value, 'is_string' );

		if ( count( $filtered ) !== count( $value ) ) {
				_doing_it_wrong(
					__METHOD__,
					sprintf(
						/* translators: %s: The '$value' argument. */
						__( 'The %s argument must be a string or a string array.' ),
						'<code>$value</code>'
					),
					'6.1.0'
				);
		}

		$this->{$new_name} = array_values( $filtered );
		return;
	}

	if ( ! is_string( $value ) ) {
		return;
	}

	$this->{$new_name} = array( $value );
}