Skip to content

Commit f3d352a

Browse files
committed
Try generating the minimum versions instead.
1 parent 08aa63e commit f3d352a

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

includes/class-create-block-theme-editor-tools.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ function create_block_theme_sidebar_enqueue() {
3838
'create-block-theme-slot-fill',
3939
);
4040

41+
global $wp_version;
42+
wp_add_inline_script(
43+
'create-block-theme-slot-fill',
44+
'const WP_VERSION = "' . $wp_version . '";',
45+
'before'
46+
);
47+
4148
// Enable localization in the plugin sidebar.
4249
wp_set_script_translations( 'create-block-theme-slot-fill', 'create-block-theme' );
4350
}

src/editor-sidebar/metadata-editor-modal.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
3030
*/
3131
import { postUpdateThemeMetadata, fetchReadmeData } from '../resolvers';
3232
import { getFontsCreditsText } from '../utils/fonts';
33+
import { generateWpVersions } from '../utils/generate-versions';
3334

3435
const ALLOWED_SCREENSHOT_MEDIA_TYPES = [
3536
'image/png',
@@ -40,17 +41,7 @@ const ALLOWED_SCREENSHOT_MEDIA_TYPES = [
4041
'image/avif',
4142
];
4243

43-
const WP_MINIMUM_VERSIONS = [
44-
'5.9',
45-
'6.0',
46-
'6.1',
47-
'6.2',
48-
'6.3',
49-
'6.4',
50-
'6.5',
51-
'6.6',
52-
'6.7',
53-
];
44+
const WP_MINIMUM_VERSIONS = generateWpVersions( WP_VERSION ); // eslint-disable-line no-undef
5445

5546
export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
5647
const [ theme, setTheme ] = useState( {

src/utils/generate-versions.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export function generateWpVersions( versionString ) {
2+
const version = versionString.split( '-' )[ 0 ];
3+
let [ major, minor ] = version.split( '.' ).slice( 0, 2 ).map( Number );
4+
5+
const versions = [];
6+
7+
// Iterate through the versions from current to 5.9
8+
while ( major > 5 || ( major === 5 && minor >= 9 ) ) {
9+
versions.push( `${ major }.${ minor }` );
10+
11+
// Decrement minor version
12+
if ( minor === 0 ) {
13+
minor = 9; // Wrap around if minor is 0, decrement the major version
14+
major--;
15+
} else {
16+
minor--;
17+
}
18+
}
19+
20+
return versions;
21+
}

0 commit comments

Comments
 (0)