Skip to content

Commit ef78481

Browse files
committed
Add some utilities to allow checking for GB and core versions.
1 parent 17bf11c commit ef78481

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

Diff for: composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
},
2424
"files": [
2525
"includes/enqueues.php",
26-
"includes/query-loop.php"
26+
"includes/query-loop.php",
27+
"includes/utilities.php"
2728
]
2829
},
2930
"require-dev": {

Diff for: includes/utilities.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Handles enqueueing of assets for the plugin.
4+
*
5+
* @package AdvancedQueryLoop/Utils
6+
*/
7+
8+
namespace AdvancedQueryLoop\Utils;
9+
10+
/**
11+
* Helper to determine if the Gutenberg plugin is installed and if so, if it is at or higher a given version.
12+
*
13+
* @param string $version The version to check for.
14+
*
15+
* @return boolean.
16+
*/
17+
function is_gutenberg_plugin_version_or_higher( string $version ) {
18+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && defined( 'GUTENBERG_VERSION' ) ) {
19+
// This means the plugin is installed
20+
return version_compare( GUTENBERG_VERSION, $version, '>=' );
21+
}
22+
return false;
23+
}
24+
25+
/**
26+
* Helper to determine is the current WP install is at or higher than a given version.
27+
*
28+
* @param string $version The version to check for.
29+
30+
* @return boolean.
31+
*/
32+
function is_core_version_or_higher( string $version ) {
33+
$core = get_bloginfo( 'version' );
34+
return version_compare( $core, $version, '>=' );
35+
}
36+

0 commit comments

Comments
 (0)