Skip to content
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
46 changes: 35 additions & 11 deletions features/core-download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Feature: Download WordPress
"""
And the return code should be 1

Scenario: Core download without the wp-content/plugins dir
Scenario: Core download without the full wp-content/plugins dir
Given an empty directory

When I run `wp core download --skip-content`
Expand All @@ -349,10 +349,14 @@ Feature: Download WordPress
Success: WordPress downloaded.
"""
And the wp-includes directory should exist
And the wp-content/plugins directory should not exist
And the wp-content/plugins directory should exist
And the wp-content/plugins directory should be:
"""
index.php
"""
And the wp-includes/js/tinymce/plugins directory should exist

Scenario: Core download without the wp-content/themes dir
Scenario: Core download without the full wp-content/themes dir
Given an empty directory

When I run `wp core download --skip-content`
Expand All @@ -361,10 +365,14 @@ Feature: Download WordPress
Success: WordPress downloaded.
"""
And the wp-includes directory should exist
And the wp-content/themes directory should not exist
And the wp-content/themes directory should exist
And the wp-content/themes directory should be:
"""
index.php
"""
And the wp-includes/js/tinymce/themes directory should exist

Scenario: Core download without the wp-content/plugins dir should work non US locale
Scenario: Core download without the full wp-content/plugins dir should work non US locale
Given an empty directory

When I run `wp core download --skip-content --version=4.9.11 --locale=nl_NL`
Expand All @@ -373,10 +381,14 @@ Feature: Download WordPress
Success: WordPress downloaded.
"""
And the wp-includes directory should exist
And the wp-content/plugins directory should not exist
And the wp-content/plugins directory should exist
And the wp-content/plugins directory should be:
"""
index.php
"""
And the wp-includes/js/tinymce/plugins directory should exist

Scenario: Core download without the wp-content/themes dir should work non US locale
Scenario: Core download without the full wp-content/themes dir should work non US locale
Given an empty directory

When I run `wp core download --skip-content --version=4.9.11 --locale=nl_NL`
Expand All @@ -385,10 +397,14 @@ Feature: Download WordPress
Success: WordPress downloaded.
"""
And the wp-includes directory should exist
And the wp-content/themes directory should not exist
And the wp-content/themes directory should exist
And the wp-content/themes directory should be:
"""
index.php
"""
And the wp-includes/js/tinymce/themes directory should exist

Scenario: Core download without the wp-content/plugins dir should work if a version is set
Scenario: Core download without the full wp-content/plugins dir should work if a version is set
Given an empty directory

When I try `wp core download --skip-content --version=4.7`
Expand All @@ -397,8 +413,16 @@ Feature: Download WordPress
Success: WordPress downloaded.
"""
And the wp-includes directory should exist
And the wp-content/plugins directory should not exist
And the wp-content/themes directory should not exist
And the wp-content/plugins directory should exist
And the wp-content/plugins directory should be:
"""
index.php
"""
And the wp-content/themes directory should exist
And the wp-content/themes directory should be:
"""
index.php
"""
And the wp-includes/js/tinymce/themes directory should exist
And the wp-includes/js/tinymce/plugins directory should exist

Expand Down
15 changes: 15 additions & 0 deletions src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,21 @@ function () use ( $new_zip_file ) {
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
for ( $i = 0; $i < $zip->numFiles; $i++ ) {
$info = $zip->statIndex( $i );
// Strip all files in wp-content/themes and wp-content/plugins
// but leave the directories and index.php files intact.
if ( in_array(
$info['name'],
array(
'wordpress/wp-content/plugins/',
'wordpress/wp-content/plugins/index.php',
'wordpress/wp-content/themes/',
'wordpress/wp-content/themes/index.php',
),
true
) ) {
continue;
}

if ( 0 === stripos( $info['name'], 'wordpress/wp-content/themes/' ) || 0 === stripos( $info['name'], 'wordpress/wp-content/plugins/' ) ) {
$zip->deleteIndex( $i );
}
Expand Down