Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Look for patterns in all directories
  • Loading branch information
swissspidy committed May 2, 2022
commit ba90c4ef7a0ed08abfe477968c5ba52830de4f80
19 changes: 6 additions & 13 deletions src/MakePotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ protected function extract_strings() {

unset( $this->main_file_data['Version'], $this->main_file_data['License'], $this->main_file_data['Domain Path'], $this->main_file_data['Text Domain'] );

$is_theme = isset( $this->main_file_data['Theme Name'] );

// Set entries from main file data.
foreach ( $this->main_file_data as $header => $data ) {
if ( empty( $data ) ) {
Expand All @@ -596,7 +598,7 @@ protected function extract_strings() {

$translation = new Translation( '', $data );

if ( isset( $this->main_file_data['Theme Name'] ) ) {
if ( $is_theme ) {
$translation->addExtractedComment( sprintf( '%s of the theme', $header ) );
} else {
$translation->addExtractedComment( sprintf( '%s of the plugin', $header ) );
Expand All @@ -609,7 +611,9 @@ protected function extract_strings() {
if ( ! $this->skip_php ) {
$options = [
// Extract 'Template Name' headers in theme files.
'wpExtractTemplates' => isset( $this->main_file_data['Theme Name'] ),
'wpExtractTemplates' => $is_theme,
// Extract 'Title' and 'Description' headers from pattern files.
'wpExtractPatterns' => $is_theme,
'include' => $this->include,
'exclude' => $this->exclude,
'extensions' => [ 'php' ],
Expand All @@ -618,17 +622,6 @@ protected function extract_strings() {
PhpCodeExtractor::fromDirectory( $this->source, $translations, $options );
}

if ( ! $this->skip_php ) {
$options = [
// Extract 'Title' and 'Description' headers from pattern files.
'wpExtractPatterns' => isset( $this->main_file_data['Theme Name'] ),
'include' => array_merge( $this->include, array( 'patterns' ) ),
'exclude' => $this->exclude,
'extensions' => [ 'php' ],
];
PhpCodeExtractor::fromDirectory( $this->source, $translations, $options );
}

if ( ! $this->skip_blade ) {
$options = [
'include' => $this->include,
Expand Down