value(), FILTER_SANITIZE_NUMBER_FLOAT ); } /** * Get the array of units we're using. * * @return array */ public function get_units() { $all_units = array( 'em', 'ex', '%', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ch', 'rem', 'vh', 'vw', 'vmin', 'vmax' ); $defaults = array( 'px', '%', 'em' ); if ( isset( $this->choices ) && is_array( $this->choices ) ) { $choices = array(); foreach ( $this->choices as $choice ) { if ( in_array( $choice, $all_units ) ) { $choices[] = $choice; } } if ( ! empty( $choices ) ) { return $choices; } } return $defaults; } /** * Get the value of the units we're using. * * @return string */ public function unit_value() { foreach ( $this->get_units() as $unit ) { if ( false !== strpos( $this->value, $unit ) ) { $located_unit = $unit; break; } } return ( isset( $located_unit ) ) ? $located_unit : 'px'; } }