Version 1.6 of Download Protect includes WP CLI integration as experimental. It will not be considered a “full feature” until version 2.0. Until that point, commands and options are subject to change. There may be minor changes from version to version so if a previous command you were using ceases to work, check here for the official current command documentation (also available as wp dp --help
or wp dp <command> --help
The Download Protect CLI commands can be used as their own command set (wp dp
), OR, when using WP-Members 3.3.5 or higher, it is available as a sub command of the WP-Members CLI: wp mem dp
.
List
This command “Lists” the requested item. This can be a list of files currently in Download Protect or allowed mime types.
Usage
List all files currently in Download Protect:
wp dp list files
– or –wp mem dp list files
List all mime types that can be moved by Download Protect:
wp dp list mime_types
– or –wp mem dp list mime_types
Move
The “move” command is used to move files from regular WP Media attachments to the Download Protect folder while maintaining their attachment post type data intact (i.e. the same post ID). Use this command to handle bulk moves of existing files without having to re-upload each file.
Usage
Move ALL files of allowed file mime types (see “list” command above). Note: NO image files will be moved:
wp dp move --all
orwp mem dp move --all
Move all files of a specified mime type (such as “application/pdf”). If you are not sure of the exact mime type of a specific file extension, use the “list” command to get mime types (see “list” command above):
wp dp move --type=<file mime type>
orwp mem dp move --type=<file mime type>
Dry run
The “move” command has a “dry run” option that will list what it will do for your command set without actually doing the move or updating anything. Just add the --dry-run
option to your command.
For example:
wp dp move --all --dry-run
Rename
The “rename” command can be used to rename a file. You must specify the file by its ID (you can find this either in the WP admin, the database, or use the “list” command to get files in Download Protect which also displays the attachment ID). You also must specify the new title using the --title=
option. If the title has spaces, wrap it in quotes.
Usage
wp dp rename --id=123 --title=Title
wp dp rename --id=321 --title="Title with White Space"
Delete
The delete command can be used to delete a single file in Download Protect, or all files. Note: this only affects files in Download Protect – not files in the general Media Manager.
Use the --id
option to specify a file ID to delete, or use --all
to specify all files.
The command includes a confirmation message, but it is important to note that this deletes the file attachment data in the WP database, and also deletes the physical file. It cannot be undone.
Usage
wp dp delete --id=123
wp dp delete --all