Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Fix casting on Utils::wp_version_compare
Browse files Browse the repository at this point in the history
  • Loading branch information
alefesouza committed Nov 16, 2023
1 parent 2ec01df commit bf1794a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Utils/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Utils {
* @return bool|int Returns true if the current WordPress version satisfies the comparison, false otherwise.
*/
public static function wp_version_compare( $version, $operator = null ) {
// Replace non-alphanumeric characters with a dot
$version = preg_replace( '/[^0-9a-zA-Z\.]+/i', '.', $version );

$current_wp_version = get_bloginfo( 'version' );
if ( preg_match( '/^([0-9]+\.[0-9]+)/', $current_wp_version, $matches ) ) {
$current_wp_version = (float) $matches[1];
Expand Down

0 comments on commit bf1794a

Please sign in to comment.