From 3848cbf3c3af0516c9f9b3254dd42f2380b371f4 Mon Sep 17 00:00:00 2001 From: meszarosrob Date: Fri, 26 Apr 2024 14:07:39 +0300 Subject: [PATCH 1/2] Add tests for the expected behaviour --- features/makepot.feature | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/features/makepot.feature b/features/makepot.feature index 902d4de..4df6200 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -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: From a4ec80c48997bb8ec57484879e513ad5df977f16 Mon Sep 17 00:00:00 2001 From: meszarosrob Date: Fri, 26 Apr 2024 14:09:56 +0300 Subject: [PATCH 2/2] Fix condition for themes without license in the header --- src/MakePotCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MakePotCommand.php b/src/MakePotCommand.php index fea7bcd..affce87 100644 --- a/src/MakePotCommand.php +++ b/src/MakePotCommand.php @@ -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 @@ -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