Skip to content

Commit

Permalink
Merge pull request #230 from wp-cli/228-create-wp-content-plugins-themes
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Apr 27, 2023
2 parents 181f416 + 3384472 commit e3212a3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
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

0 comments on commit e3212a3

Please sign in to comment.