Automattic\WooCommerce\Blocks\BlockTypes
CouponCode::get_alignment
Get alignment from parsed block attributes.
Method of the class: CouponCode{}
No Hooks.
Returns
String.
Usage
// private - for code of main (parent) class only $result = $this->get_alignment( $parsed_block ): string;
- $parsed_block(array) (required)
- Parsed block data.
CouponCode::get_alignment() CouponCode::get alignment code WC 10.8.1
private function get_alignment( array $parsed_block ): string {
$allowed = array( 'left', 'center', 'right' );
$align = $parsed_block['attrs']['align'] ?? 'center';
if ( ! is_string( $align ) || ! in_array( $align, $allowed, true ) ) {
return 'center';
}
return $align;
}