diff --git a/composer.json b/composer.json
index d23833f..9be7448 100644
--- a/composer.json
+++ b/composer.json
@@ -23,7 +23,8 @@
},
"files": [
"includes/enqueues.php",
- "includes/query-loop.php"
+ "includes/query-loop.php",
+ "includes/utilities.php"
]
},
"require-dev": {
diff --git a/includes/enqueues.php b/includes/enqueues.php
index 443e14f..c5ebbcf 100644
--- a/includes/enqueues.php
+++ b/includes/enqueues.php
@@ -7,6 +7,9 @@
namespace AdvancedQueryLoop;
+use function AdvancedQueryLoop\Utils\{ is_gutenberg_plugin_version_or_higher,is_core_version_or_higher };
+
+
// Bail on unit tests.
if ( ! function_exists( 'add_action' ) ) {
return;
@@ -33,5 +36,23 @@ function () {
// Allow for translation.
wp_set_script_translations( 'advanced-query-loop', 'advanced-query-loop' );
}
+
+ // Per Page, Offset, and Max count controls where merged into GB 19.
+ if ( ! is_gutenberg_plugin_version_or_higher( '19' ) && ! is_core_version_or_higher( '6.7' ) ) {
+ // Enqueue the legacy controls.
+ $pre_gb_19_assets_file = BUILD_DIR_PATH . 'legacy-pre-gb-19.asset.php';
+
+ if ( file_exists( $pre_gb_19_assets_file ) ) {
+ $pre_gb_19_assets = include $pre_gb_19_assets_file;
+
+ \wp_enqueue_script(
+ 'advanced-query-loop-legacy-pre-gb-19',
+ BUILD_DIR_URL . 'legacy-pre-gb-19.js',
+ array_merge( array( 'advanced-query-loop' ), $pre_gb_19_assets['dependencies'] ),
+ $pre_gb_19_assets['version'],
+ true
+ );
+ }
+ }
}
);
diff --git a/includes/utilities.php b/includes/utilities.php
new file mode 100644
index 0000000..a046d72
--- /dev/null
+++ b/includes/utilities.php
@@ -0,0 +1,36 @@
+=' );
+ }
+ return false;
+}
+
+/**
+ * Helper to determine is the current WP install is at or higher than a given version.
+ *
+ * @param string $version The version to check for.
+
+ * @return boolean.
+ */
+function is_core_version_or_higher( string $version ) {
+ $core = get_bloginfo( 'version' );
+ return version_compare( $core, $version, '>=' );
+}
+
diff --git a/src/legacy-controls/pre-gb-19.js b/src/legacy-controls/pre-gb-19.js
new file mode 100644
index 0000000..51d2280
--- /dev/null
+++ b/src/legacy-controls/pre-gb-19.js
@@ -0,0 +1,28 @@
+/**
+ * WordPress dependencies
+ */
+import { registerPlugin } from '@wordpress/plugins';
+
+/**
+ * Internal dependencies
+ */
+import AQLLegacyControls from '../slots/aql-legacy-controls';
+import { PostCountControls } from '../components/post-count-controls';
+import { PostOffsetControls } from '../components/post-offset-controls';
+
+registerPlugin( 'aql-pre-gb-19-controls', {
+ render: () => {
+ return (
+ <>
+
+ { ( props ) => (
+ <>
+
+
+ >
+ ) }
+
+ >
+ );
+ },
+} );
diff --git a/src/slots/aql-legacy-controls.js b/src/slots/aql-legacy-controls.js
new file mode 100644
index 0000000..2ca7d13
--- /dev/null
+++ b/src/slots/aql-legacy-controls.js
@@ -0,0 +1,25 @@
+/**
+ * WordPress dependencies
+ */
+import { createSlotFill } from '@wordpress/components';
+
+/**
+ * Create our Slot and Fill components
+ */
+const { Fill, Slot } = createSlotFill( 'AQLLegacyControls' );
+
+/**
+ * This slot is not exposed and is used to try to maintain the same UI
+ */
+
+const AQLLegacyControls = ( { children } ) => { children };
+
+AQLLegacyControls.Slot = ( { fillProps } ) => (
+
+ { ( fills ) => {
+ return fills.length ? fills : null;
+ } }
+
+);
+
+export default AQLLegacyControls;
diff --git a/src/variations/controls.js b/src/variations/controls.js
index a58e8f2..32ac2de 100644
--- a/src/variations/controls.js
+++ b/src/variations/controls.js
@@ -12,8 +12,7 @@ import { createBlock } from '@wordpress/blocks';
import { AQL } from '.';
import AQLControls from '../slots/aql-controls';
import AQLControlsInheritedQuery from '../slots/aql-controls-inherited-query';
-import { PostCountControls } from '../components/post-count-controls';
-import { PostOffsetControls } from '../components/post-offset-controls';
+import AQLLegacyControls from '../slots/aql-legacy-controls';
import { PostMetaQueryControls } from '../components/post-meta-query-controls';
import { PostDateQueryControls } from '../components/post-date-query-controls';
import { MultiplePostSelect } from '../components/multiple-post-select';
@@ -58,10 +57,11 @@ const withAdvancedQueryControls = ( BlockEdit ) => ( props ) => {
'advanced-query-loop'
) }
>
+
-
-
diff --git a/webpack.config.js b/webpack.config.js
index f805079..c3dcf7b 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -10,6 +10,7 @@ module.exports = {
entry: {
...getWebpackEntryPoints(),
variations: './src/variations/index.js',
+ 'legacy-pre-gb-19': './src/legacy-controls/pre-gb-19.js',
},
output: {
...defaultConfig.output,