0

Using wp-cli on Windows all works fine.

When I am in project root folder I like to download the WordPress core files skipping all the WordPress default themes twenty*.

For that I use the command wp core download --skip-themes --debug however it always downloads all the default themes.

How can I get wp-cli to only really give me the core files without the included default WordPress themes?

Is there a wp-cli command for deleting folders perhaps?

If this cannot be done with wp-cli what other ways could I use to always automatically remove the default themes from the WordPress core download without actually going into the project folder?

yivi
  • 42,438
  • 18
  • 116
  • 138
lowtechsun
  • 1,915
  • 5
  • 27
  • 55
  • For me, and I would assume many other devs coming from Windows, the wp-cli setup procedure for Windows is relevant. Was very happy to [have found that it being more detailed than the official docs](http://www.deluxeblogtips.com/install-wp-cli-windows/). I am now including [the official setup procedure from wordpress.org](https://make.wordpress.org/cli/handbook/installing/#installing-on-windows) and would prefer for that to be left intact to help devs new to wp-cli get this working on Windows, thanks. – lowtechsun Mar 01 '17 at 09:44

3 Answers3

1

No, you can't. Default themes are part of the Wordpress distribution.

The --skip-themes flag is not meant for this, but to disable loading installed themes during wp-cli execution (in case there is some theme triggered logic you may want avoid executing).

There is no wp-cli command to delete files, that doesn't make a lot of sense. You can always delete them with the appropriate commands for your platform.

Tim Penner
  • 3,551
  • 21
  • 36
yivi
  • 42,438
  • 18
  • 116
  • 138
0

Why not add a rm -rf wp-content/themes/*? This should do it:

wp core download && rm -rf wp-content/themes/*

Eventually, if you have to do this a alot, you could create your own script, let's say wp-clean.sh:

#!/bin/bash
wp core download && rm -rf wp-content/themes/*

Then chmod +x wp-clean.sh and you're set.

Edit, because I missed the Windows part (honestly I didn't even knew that wp cli works on Win :D).

wp core download && rmdir wp-content/themes/* /s

If you want to automate, just create a .bat file instead of .sh with only the above line.

Ionuț Staicu
  • 21,360
  • 11
  • 51
  • 58
  • 1
    Considering he's using windows, rm -rf would work nicely. ;) – yivi Mar 01 '17 at 09:42
  • 1
    And "how to delete files" is a horrible q&a for StackOverflow. – yivi Mar 01 '17 at 09:43
  • Sorry @yivi, Ionuț Staicu supplied what I am looking for helping with automation and hence gets the answer. Thank you Ionuț. – lowtechsun Mar 01 '17 at 09:51
  • Glad to know you needed help *deleting files*. :( But this answer is potentially **very dangerous** and wrong. This will delete **ALL YOUR THEMES**, not only the default ones – yivi Mar 01 '17 at 09:53
  • @yivi Read the question again and don't assume incorrectly. It is about wp-cli not about generally deleting files. No need to downvote, but if that floats your boat I don't mind. Having the core WordPress files without the default themes is what I am looking for and Ionut supplied the answer to that question. I am not going into further discussion. Thank you both for your help. – lowtechsun Mar 01 '17 at 09:59
  • @Iowtechsun, this answer doesn't address how skip theme downloads when using wp-cli (which you can't). It helps you _delete files_, which apparently you needed help with. Glad to know you found what you needed. Peace out. :) – yivi Mar 01 '17 at 10:02
-1

Make a batch (.bat) file with below code in the project folder and run.

This will download the latest WordPress core files to that project folder.

Then it will go to the project folder/wp-content/themes and delete ALL FILES AND FOLDERS from that themes folder.

If that themes folder does not exist the batch file will exit without deleting any files in that themes folder after an user confirmation.

call wp core download
set mypath=%~dp0wp-content\themes%
echo %mypath%
if exist "%mypath%" (
    cd %mypath%
    for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
)
pause

This will work, however the command prompt output will show The directory name is invalid. when going in the %mypath% after the WordPress core download has finished. I have no clue why this happens and might ask this in another question if nobody comments about this.

Reference:
How to get the path of the batch script in Windows?

Windows shell command to get the full path to current directory?

Batch file. Delete all files and folders in a directory

https://indigotree.co.uk/automated-wordpress-installation-cmd/

lowtechsun
  • 1,915
  • 5
  • 27
  • 55