WooCommerce Code Reference

Utils
in package

Utils class

Table of Contents

wp_version_compare()  : bool|int
Compare the current WordPress version with a given version. It's a wrapper around `version-compare` that additionally takes into account the suffix (like `-RC1`).

Methods

wp_version_compare()

Compare the current WordPress version with a given version. It's a wrapper around `version-compare` that additionally takes into account the suffix (like `-RC1`).

public static wp_version_compare(string $version[, string|null $operator = null ]) : bool|int

For example: version 6.3 is considered lower than 6.3-RC2, so you can do wp_version_compare( '6.3', '>=' ) and that will return true for 6.3-RC2.

Parameters
$version : string

The version to compare against.

$operator : string|null = null

Optional. The comparison operator. Defaults to null.

Return values
bool|intReturns true if the current WordPress version satisfies the comparison, false otherwise.