From df923b4d361c08c9f4fe99cf7f5d076fd7b34f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Borbo=C3=ABn?= Date: Wed, 11 Dec 2019 16:14:18 +0100 Subject: [PATCH 1/2] Fix specific license in a plugin The doc says: ``` If a plugin or theme specifies a license in their main plugin file or stylesheet, the comment looks like this: Copyright (C) 2018 Example Plugin Author This file is distributed under the GPLv2. ``` but it dosen't seems to work for plugins. It looks like the "License" param in get_file_headers was missing. --- src/MakePotCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MakePotCommand.php b/src/MakePotCommand.php index 65c83123..ca387e98 100644 --- a/src/MakePotCommand.php +++ b/src/MakePotCommand.php @@ -488,6 +488,7 @@ protected function get_file_headers( $type ) { 'Author', 'Author URI', 'Version', + 'License', 'Domain Path', 'Text Domain', ]; From 312d3c25b8474d6b14277077a9f3e42bd1298a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Borbo=C3=ABn?= Date: Thu, 12 Dec 2019 11:41:57 +0100 Subject: [PATCH 2/2] Ensure that the pot file use the same license as the plugin * Only if the license file header is defined * Tests updated --- features/makepot.feature | 28 ++++++++++++++++++++++++++++ src/MakePotCommand.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/features/makepot.feature b/features/makepot.feature index 8ea9db64..6de1f3ec 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -80,6 +80,34 @@ Feature: Generate a POT file of a WordPress project # This file is distributed under the same license as the Hello World plugin. """ + Scenario: Use the same license as the plugin + Given an empty foo-plugin directory + And a foo-plugin/foo-plugin.php file: + """ + main_file_data['Plugin Name'] ) ) { - if ( isset( $this->main_file_data['License'] ) ) { + if ( isset( $this->main_file_data['License'] ) && ! 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