Skip to content

Commit e3212a3

Browse files
authored
Merge pull request #230 from wp-cli/228-create-wp-content-plugins-themes
2 parents 181f416 + 3384472 commit e3212a3

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

features/core-download.feature

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Feature: Download WordPress
340340
"""
341341
And the return code should be 1
342342

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

346346
When I run `wp core download --skip-content`
@@ -349,10 +349,14 @@ Feature: Download WordPress
349349
Success: WordPress downloaded.
350350
"""
351351
And the wp-includes directory should exist
352-
And the wp-content/plugins directory should not exist
352+
And the wp-content/plugins directory should exist
353+
And the wp-content/plugins directory should be:
354+
"""
355+
index.php
356+
"""
353357
And the wp-includes/js/tinymce/plugins directory should exist
354358

355-
Scenario: Core download without the wp-content/themes dir
359+
Scenario: Core download without the full wp-content/themes dir
356360
Given an empty directory
357361

358362
When I run `wp core download --skip-content`
@@ -361,10 +365,14 @@ Feature: Download WordPress
361365
Success: WordPress downloaded.
362366
"""
363367
And the wp-includes directory should exist
364-
And the wp-content/themes directory should not exist
368+
And the wp-content/themes directory should exist
369+
And the wp-content/themes directory should be:
370+
"""
371+
index.php
372+
"""
365373
And the wp-includes/js/tinymce/themes directory should exist
366374

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

370378
When I run `wp core download --skip-content --version=4.9.11 --locale=nl_NL`
@@ -373,10 +381,14 @@ Feature: Download WordPress
373381
Success: WordPress downloaded.
374382
"""
375383
And the wp-includes directory should exist
376-
And the wp-content/plugins directory should not exist
384+
And the wp-content/plugins directory should exist
385+
And the wp-content/plugins directory should be:
386+
"""
387+
index.php
388+
"""
377389
And the wp-includes/js/tinymce/plugins directory should exist
378390

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

382394
When I run `wp core download --skip-content --version=4.9.11 --locale=nl_NL`
@@ -385,10 +397,14 @@ Feature: Download WordPress
385397
Success: WordPress downloaded.
386398
"""
387399
And the wp-includes directory should exist
388-
And the wp-content/themes directory should not exist
400+
And the wp-content/themes directory should exist
401+
And the wp-content/themes directory should be:
402+
"""
403+
index.php
404+
"""
389405
And the wp-includes/js/tinymce/themes directory should exist
390406

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

394410
When I try `wp core download --skip-content --version=4.7`
@@ -397,8 +413,16 @@ Feature: Download WordPress
397413
Success: WordPress downloaded.
398414
"""
399415
And the wp-includes directory should exist
400-
And the wp-content/plugins directory should not exist
401-
And the wp-content/themes directory should not exist
416+
And the wp-content/plugins directory should exist
417+
And the wp-content/plugins directory should be:
418+
"""
419+
index.php
420+
"""
421+
And the wp-content/themes directory should exist
422+
And the wp-content/themes directory should be:
423+
"""
424+
index.php
425+
"""
402426
And the wp-includes/js/tinymce/themes directory should exist
403427
And the wp-includes/js/tinymce/plugins directory should exist
404428

src/Core_Command.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,21 @@ function () use ( $new_zip_file ) {
15241524
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
15251525
for ( $i = 0; $i < $zip->numFiles; $i++ ) {
15261526
$info = $zip->statIndex( $i );
1527+
// Strip all files in wp-content/themes and wp-content/plugins
1528+
// but leave the directories and index.php files intact.
1529+
if ( in_array(
1530+
$info['name'],
1531+
array(
1532+
'wordpress/wp-content/plugins/',
1533+
'wordpress/wp-content/plugins/index.php',
1534+
'wordpress/wp-content/themes/',
1535+
'wordpress/wp-content/themes/index.php',
1536+
),
1537+
true
1538+
) ) {
1539+
continue;
1540+
}
1541+
15271542
if ( 0 === stripos( $info['name'], 'wordpress/wp-content/themes/' ) || 0 === stripos( $info['name'], 'wordpress/wp-content/plugins/' ) ) {
15281543
$zip->deleteIndex( $i );
15291544
}

0 commit comments

Comments
 (0)