wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_apply_padding_support › WordPress Function

Seit5.8.0
Veraltetn/v
wp_apply_padding_support ( $block_type, $block_attributes )
Zugriff:
  • private
Parameter: (2)
  • (WP_Block_Type) $block_type Block Type.
    Erforderlich: Ja
  • (array) $block_attributes Block attributes.
    Erforderlich: Ja
Gibt zurück:
  • (array) Block padding CSS classes and inline styles.
Definiert in:
Codex:

Add CSS classes for block padding to the incoming attributes array.

This will be applied to the block markup in the front-end.


Quellcode

function wp_apply_padding_support( $block_type, $block_attributes ) {
	$has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false );
	$styles              = array();
	if ( $has_padding_support ) {
		$padding_value = _wp_array_get( $block_attributes, array( 'style', 'spacing', 'padding' ), null );
		if ( null !== $padding_value ) {
			foreach ( $padding_value as $key => $value ) {
				$styles[] = sprintf( 'padding-%s: %s;', $key, $value );
			}
		}
	}

	return empty( $styles ) ? array() : array( 'style' => implode( ' ', $styles ) );
}