-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds minimum WordPress version to theme metadata (#715)
* Add a field for required wordpress version. * Add a minimum required version if none exists. * Sanitize the requires_wp attribute. * Use SelectControl instead of TextControl and rename attribute to requires_wp. * Update includes/create-theme/theme-styles.php Co-authored-by: Grant Kinney <[email protected]> * Try generating the minimum versions instead. * Ensure Required WP version is updated when readme is updated. * Use current wordpress version if none is provided. * Use a dynamic value for Requires at least when theme readme and style.css are created. * Make variable names consistent. * Check for empty string and use current wordpress version as fallback. * Add minimum version to additional metadata panel. --------- Co-authored-by: Grant Kinney <[email protected]>
- Loading branch information
1 parent
fbf9933
commit cdede9a
Showing
9 changed files
with
89 additions
and
4 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
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
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
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,21 @@ | ||
export function generateWpVersions( versionString ) { | ||
const version = versionString.split( '-' )[ 0 ]; | ||
let [ major, minor ] = version.split( '.' ).slice( 0, 2 ).map( Number ); | ||
|
||
const versions = []; | ||
|
||
// Iterate through the versions from current to 5.9 | ||
while ( major > 5 || ( major === 5 && minor >= 9 ) ) { | ||
versions.push( `${ major }.${ minor }` ); | ||
|
||
// Decrement minor version | ||
if ( minor === 0 ) { | ||
minor = 9; // Wrap around if minor is 0, decrement the major version | ||
major--; | ||
} else { | ||
minor--; | ||
} | ||
} | ||
|
||
return versions; | ||
} |
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