Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the pot file use the same license as the plugin #199

Merged
merged 3 commits into from
Dec 13, 2019
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
28 changes: 28 additions & 0 deletions features/makepot.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
<?php
/**
* Plugin Name: Foo Plugin
* Plugin URI: https://example.com
* Description:
* Version: 0.1.0
* Author:
* Author URI:
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: foo-plugin
* Domain Path: /languages
*/

__( 'Hello World', 'foo-plugin' );

"""

When I run `wp i18n make-pot foo-plugin foo-plugin.pot`
Then the foo-plugin.pot file should contain:
"""
# This file is distributed under the GPL-2.0+.
"""

Scenario: Sets Project-Id-Version
When I run `wp scaffold plugin hello-world`

Expand Down
3 changes: 2 additions & 1 deletion src/MakePotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ protected function get_file_headers( $type ) {
'Author',
'Author URI',
'Version',
'License',
'Domain Path',
'Text Domain',
];
Expand Down Expand Up @@ -758,7 +759,7 @@ protected function get_file_comment() {
}

if ( isset( $this->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
Expand Down