$value ) { if ( 'tag' !== $key && strlen( $value ) ) { if ( preg_match( '/description/', $key ) ) { continue; } if ( 'font_size' === $key || 'line_height' === $key ) { $value = preg_replace( '/\s+/', '', $value ); } if ( 'font_size' === $key ) { $pattern = '/^(\d*(?:\.\d+)?)\s*(px|\%|in|cm|mm|em|rem|ex|pt|pc|vw|vh|vmin|vmax)?$/'; // allowed metrics: http://www.w3schools.com/cssref/css_units.asp preg_match( $pattern, $value, $matches ); $value = isset( $matches[1] ) ? (float) $matches[1] : (float) $value; $unit = isset( $matches[2] ) ? $matches[2] : 'px'; $value = $value . $unit; } if ( strlen( $value ) > 0 ) { $styles[] = str_replace( '_', '-', $key ) . ': ' . $value; } } } } if ( ! empty( $styles ) ) { $style = 'style="' . esc_attr( implode( ';', $styles ) ) . '"'; } else { $style = ''; } return $style; }