at path:
ROOT
/
wp-content
/
plugins
/
woocommerce
/
src
/
Blocks
/
Utils
/
Utils.php
run:
R
W
Run
BlockHooksTrait.php
6.89 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
BlockTemplateUtils.php
30.19 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
BlocksSharedState.php
6.86 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
BlocksWpQuery.php
2.08 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
CartCheckoutUtils.php
17.35 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
MiniCartUtils.php
3.51 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
ProductAvailabilityUtils.php
1.26 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
ProductDataUtils.php
455 By
2026-04-15 05:42:46
R
W
Run
Delete
Rename
ProductGalleryUtils.php
5.75 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
StyleAttributesUtils.php
23.12 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
Utils.php
1.21 KB
2026-04-15 05:42:46
R
W
Run
Delete
Rename
error_log
up
📄
Utils.php
Save
<?php namespace Automattic\WooCommerce\Blocks\Utils; /** * Utils class */ class Utils { /** * 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`). * 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. * * @param string $version The version to compare against. * @param string|null $operator Optional. The comparison operator. Defaults to null. * @return bool|int Returns true if the current WordPress version satisfies the comparison, false otherwise. */ public static function wp_version_compare( $version, $operator = null ) { $current_wp_version = get_bloginfo( 'version' ); if ( preg_match( '/^([0-9]+\.[0-9]+)/', $current_wp_version, $matches ) ) { $current_wp_version = (float) $matches[1]; } // Replace non-alphanumeric characters with a dot. $current_wp_version = preg_replace( '/[^0-9a-zA-Z\.]+/i', '.', $current_wp_version ); $version = preg_replace( '/[^0-9a-zA-Z\.]+/i', '.', $version ); return version_compare( $current_wp_version, $version, $operator ); } }