Automattic\WooCommerce\Blocks\BlockTypes

Dropdown::get_option_textprivateWC 1.0

Plain-text label for a select option (no HTML in <option>).

Method of the class: Dropdown{}

No Hooks.

Returns

String.

Usage

// private - for code of main (parent) class only
$result = $this->get_option_text( $item ): string;
$item(array) (required)
Selectable item from context.

Dropdown::get_option_text() code WC 10.9.1

private function get_option_text( array $item ): string {
	if ( isset( $item['label'] ) && is_string( $item['label'] ) ) {
		return wp_strip_all_tags( $item['label'] );
	}
	if ( ! empty( $item['ariaLabel'] ) && is_string( $item['ariaLabel'] ) ) {
		return $item['ariaLabel'];
	}
	return '';
}