Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version only read from plugins, not from theme's style.css #50

Closed
2 tasks done
kraftner opened this issue Mar 1, 2022 · 5 comments · Fixed by #65
Closed
2 tasks done

Version only read from plugins, not from theme's style.css #50

kraftner opened this issue Mar 1, 2022 · 5 comments · Fixed by #65

Comments

@kraftner
Copy link

kraftner commented Mar 1, 2022

Bug Report

Describe the current, buggy behavior

The command currently only parses the version from PHP files, hence not getting the version of a theme in style.css hence not including it in the archive filename.

Describe how other contributors can replicate this bug

Run the dist-archive command on a theme

Describe what you would expect as the correct outcome

An archive that includes the theme version in the filename.

Let us know what environment you are running this on

> wp cli info
OS:     Linux 5.4.0-100-generic #113~18.04.1-Ubuntu SMP Mon Feb 7 15:02:59 UTC 2022 x86_64
Shell:  
PHP binary:     /usr/local/bin/php
PHP version:    7.4.28
php.ini used:   /usr/local/etc/php/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
SQL modes:      
WP-CLI root dir:        /var/www/html/wp-content/themes/foo/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      /var/www/html/wp-content/themes/foo/vendor
WP_CLI phar path:       
WP-CLI packages dir:    /home/wordpress/.wp-cli/packages/
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.6.0

Provide a possible solution

This probably should also parse style.css, the regex could stay the same I suppose.

$version = '';
foreach ( glob( $path . '/*.php' ) as $php_file ) {
$contents = file_get_contents( $php_file, false, null, 0, 5000 );
if ( preg_match( '#\* Version:(.+)#', $contents, $matches ) ) {
$version = '.' . trim( $matches[1] );
break;
}
}

Provide additional context/Screenshots

@kraftner
Copy link
Author

kraftner commented Mar 1, 2022

Temporary workaround for others that hit this:

wp dist-archive . ./foo-$(wp theme get foo --field=version).zip

@janw-me
Copy link
Member

janw-me commented May 29, 2022

A candidate for good-first-issue ?

@schlessera schlessera changed the title Version only read from plugins, not from themes style.css Jun 2, 2022
@danielpost
Copy link

I'm working on this 👍🏼

@kjohnson
Copy link
Contributor

Not seeing any updates since June (presumably WordCamp Europe), so I'm going to take a look.

@kjohnson
Copy link
Contributor

Getting the version from the docblock is using token_get_all, which specifically produces PHP tokens.

Another method for getting a theme's version will be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment