Yoast\WP\Lib

Model::get_static_property()protected staticYoast 1.0

Retrieve the value of a static property on a class. If the class or the property does not exist, returns the default value supplied as the third argument (which defaults to null).

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

Хуков нет.

Возвращает

Разное|null. The value of the property.

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

$result = Model::get_static_property( $class_name, $property, $default_value );
$class_name(строка) (обязательный)
The target class name.
$property(строка) (обязательный)
The property to get the value for.
$default_value(разное|null)
Default value when property does not exist.
По умолчанию: null

Код Model::get_static_property() Yoast 24.0

protected static function get_static_property( $class_name, $property, $default_value = null ) {
	if ( ! \class_exists( $class_name ) || ! \property_exists( $class_name, $property ) ) {
		return $default_value;
	}

	if ( ! isset( $class_name::${$property} ) ) {
		return $default_value;
	}

	return $class_name::${$property};
}