WP_Theme_JSON::is_valid_viewport_breakpoint_size( mixed $value ): bool

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

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.

Return

bool Whether the value is valid.

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

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.