Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Quote::get_authored_alignmentprivateWC 1.0

Get explicit quote alignment when authored.

Method of the class: Quote{}

No Hooks.

Returns

String|null.

Usage

// private - for code of main (parent) class only
$result = $this->get_authored_alignment( $block_attributes, $original_classname ): ?string;
$block_attributes(array) (required)
Block attributes.
$original_classname(string) (required)
Original quote classes.

Quote::get_authored_alignment() code WC 10.9.1

private function get_authored_alignment( array $block_attributes, string $original_classname ): ?string {
	foreach ( array( 'textAlign', 'align' ) as $attribute_name ) {
		$alignment = $block_attributes[ $attribute_name ] ?? null;
		if ( in_array( $alignment, array( 'left', 'center', 'right' ), true ) ) {
			return $alignment;
		}
	}

	foreach ( wp_parse_list( $original_classname ) as $class_name ) {
		if ( 0 !== strpos( $class_name, 'has-text-align-' ) ) {
			continue;
		}

		$alignment = substr( $class_name, strlen( 'has-text-align-' ) );
		if ( in_array( $alignment, array( 'left', 'center', 'right' ), true ) ) {
			return $alignment;
		}
	}

	return null;
}