Checks whether a viewport breakpoint value is a safe CSS length.
Description
Viewport breakpoints are limited to numeric px, em, and rem lengths.
CSS functions, percentages, and other units are rejected because breakpoint values are interpolated into generated media queries.
Parameters
$valuemixedrequired- Value to check.
Source
private static function is_valid_viewport_breakpoint_size( $value ) {
if ( ! is_string( $value ) ) {
return false;
}
$value = trim( $value );
if ( '' === $value ) {
return false;
}
return 1 === preg_match( '/^(?:\d+|\d*\.\d+)(?:px|em|rem)$/', $value );
}
Changelog
| Version | Description |
|---|---|
| 7.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.