Skip to content

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

@kraftner

Description

@kraftner

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions