This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mini Cart: Remove deprecated print_inline_script() (#10165)
* Mini Cart: Replace the deprecated print_inline_script() with supported get_inline_script_data(). Fixes #10004 * Mini Cart: Add version check for the new get_inline_script_data() function * Update the variable names and fix a typo * Mini Cart: Add regex to check for the WP version * Abstract the WP version comparison regex to a separate Utils class
- Loading branch information
1 parent
73cb0ce
commit b75f00e
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
namespace Automattic\WooCommerce\Blocks\Utils; | ||
|
||
/** | ||
* Utils class | ||
*/ | ||
class Utils { | ||
|
||
/** | ||
* Compare the current WordPress version with a given version. | ||
* | ||
* @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]; | ||
} | ||
|
||
return version_compare( $current_wp_version, $version, $operator ); | ||
} | ||
} |