Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions features/makepot.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3820,6 +3820,37 @@ Feature: Generate a POT file of a WordPress project
msgid "Other pattern description."
"""

Scenario: Use the license from the theme header
Given an empty foo-theme directory
And a foo-theme/style.css file:
"""
/*
Theme Name: Foo Theme
License: GNU General Public License v2 or later
*/
"""

When I run `wp i18n make-pot foo-theme foo-theme.pot`
Then the foo-theme.pot file should contain:
"""
# This file is distributed under the GNU General Public License v2 or later.
"""

Scenario: Use the same license as the theme
Given an empty foo-theme directory
And a foo-theme/style.css file:
"""
/*
Theme Name: Foo Theme
*/
"""

When I run `wp i18n make-pot foo-theme foo-theme.pot`
Then the foo-theme.pot file should contain:
"""
# This file is distributed under the same license as the Foo Theme theme.
"""

Scenario: Ignores a standard set of directories as expected
Given an empty foo-plugin directory
And a foo-plugin/foo-plugin.php file:
Expand Down
4 changes: 2 additions & 2 deletions src/MakePotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ protected function get_file_comment() {
}

if ( isset( $this->main_file_data['Theme Name'] ) ) {
if ( isset( $this->main_file_data['License'] ) ) {
if ( ! empty( $this->main_file_data['License'] ) ) {
return sprintf(
"Copyright (C) %1\$s %2\$s\nThis file is distributed under the %3\$s.",
date( 'Y' ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
Expand All @@ -920,7 +920,7 @@ protected function get_file_comment() {
}

if ( isset( $this->main_file_data['Plugin Name'] ) ) {
if ( isset( $this->main_file_data['License'] ) && ! empty( $this->main_file_data['License'] ) ) {
if ( ! empty( $this->main_file_data['License'] ) ) {
return sprintf(
"Copyright (C) %1\$s %2\$s\nThis file is distributed under the %3\$s.",
date( 'Y' ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
Expand Down