wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



wp_get_shadow_classes_and_styles › WordPress Function

Od7.3.0
Przestarzałyn/a
› wp_get_shadow_classes_and_styles ( $block_attributes )
Parametry:
  • (array<string,mixed>) $block_attributes Block attributes.
    Wymagane: Tak
Powrót:
  • (array<string,string>) Array with `class` and `style` keys, each present only when non-empty.
Zdefiniowane na:
Codex:

Returns shadow classes and inline styles for block attributes, like the JS `getShadowClassesAndStyles()`. Does not check block support or skipped serialization.



Źródło

function wp_get_shadow_classes_and_styles( $block_attributes ) {
	if ( ! is_array( $block_attributes ) ) {
		return array();
	}

	$shadow = $block_attributes['style']['shadow'] ?? null;

	$attributes = array();
	$styles     = wp_style_engine_get_styles( array( 'shadow' => $shadow ) );

	if ( ! empty( $styles['classnames'] ) ) {
		$attributes['class'] = $styles['classnames'];
	}

	if ( ! empty( $styles['css'] ) ) {
		$attributes['style'] = $styles['css'];
	}

	return $attributes;
}