Skip to content

Commit

Permalink
Merge pull request #399 from meszarosrob/fix/398-pot-license-for-themes
Browse files Browse the repository at this point in the history
Ensure that the POT file use the same license as the theme
  • Loading branch information
ernilambar authored Apr 26, 2024
2 parents e29d181 + a4ec80c commit aa8338b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
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

0 comments on commit aa8338b

Please sign in to comment.