Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Inventory_Presser_Taxonomy_Overlapper::extract_speeds( string $transmission_term_name )
extract_speeds
Contents
Description Description
Takes a transmission taxonomy term name like "6 Speed Automatic", "5 Speed Manual", "Continuously Variable", or "Unknown" and returns "6", "5", "V", and "U", respectively.
Parameters Parameters
- $transmission_term_name
-
(string) (Required)
Return Return
(string)
Source Source
File: includes/class-taxonomy-overlapper.php
private function extract_speeds( $transmission_term_name ) { // Does the term identify the number of speeds? $patterns = array( '/([0-9]+) Speed Automatic/', '/([0-9]+) Speed Automanual/', '/([0-9]+) Speed Manual/', ); foreach ( $patterns as $pattern ) { preg_match( $pattern, $transmission_term_name, $matches ); if ( ! empty( $matches ) ) { // Yes return $matches[1]; } } // Is it unknown or variable? if ( 'continuously variable' == strtolower( $transmission_term_name ) || 'CVT' == strtoupper( $transmission_term_name ) ) { // It's variable return 'V'; } // It's unknown return 'U'; }
Expand full source code Collapse full source code View on Github