Skip to content

Commit

Permalink
Ensure that the pot file use the same license as the plugin (#199)
Browse files Browse the repository at this point in the history
Ensure that the pot file use the same license as the plugin
  • Loading branch information
schlessera authored Dec 13, 2019
2 parents 085e93a + da1ec4f commit 8c24d56
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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

0 comments on commit 8c24d56

Please sign in to comment.