1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\CLI\Commands; |
4
|
|
|
|
5
|
|
|
use BulkWP\BulkDelete\Core\Base\BaseCommand; |
6
|
|
|
use BulkWP\BulkDelete\Core\Pages\Modules\DeletePagesByStatusModule; |
7
|
|
|
|
8
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Delete Meta CLI Command. |
12
|
|
|
* |
13
|
|
|
* @since 6.1.0 |
14
|
|
|
*/ |
15
|
|
|
class DeletePagesCommand extends BaseCommand { |
16
|
|
|
/** |
17
|
|
|
* Get the command. |
18
|
|
|
* |
19
|
|
|
* @return string Command name. |
20
|
|
|
*/ |
21
|
|
|
public static function get_command() { |
22
|
|
|
return 'pages'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Delete pages by status. |
27
|
|
|
* |
28
|
|
|
* ## OPTIONS |
29
|
|
|
* |
30
|
|
|
* --status=<status> |
31
|
|
|
* : Comma separeated list of post status from which pages need to be deleted. You can also use any custom post status. |
32
|
|
|
* |
33
|
|
|
* [--restrict=<restrict>] |
34
|
|
|
* : Restricts posts deletion with post date filter. |
35
|
|
|
* --- |
36
|
|
|
* default: false |
37
|
|
|
* options: |
38
|
|
|
* - true |
39
|
|
|
* - false |
40
|
|
|
* --- |
41
|
|
|
* |
42
|
|
|
* [--op=<op>] |
43
|
|
|
* : Can be used only when --restrict=true. Restricts pages deletion with older than(before) or in the last(after) filter. |
44
|
|
|
* --- |
45
|
|
|
* options: |
46
|
|
|
* - before |
47
|
|
|
* - after |
48
|
|
|
* --- |
49
|
|
|
* |
50
|
|
|
* [--days=<days>] |
51
|
|
|
* : Can be used only when --restrict=true. Restricts pages deletion with creation date. |
52
|
|
|
* |
53
|
|
|
* [--limit_to=<limit_to>] |
54
|
|
|
* : Limits the number of pages to be deleted. |
55
|
|
|
* --- |
56
|
|
|
* default: 0 |
57
|
|
|
* --- |
58
|
|
|
* |
59
|
|
|
* |
60
|
|
|
* [--force_delete=<force_delete>] |
61
|
|
|
* : Should pages be permanently deleted. Set to false to move them to trash. |
62
|
|
|
* --- |
63
|
|
|
* default: false |
64
|
|
|
* options: |
65
|
|
|
* - true |
66
|
|
|
* - false |
67
|
|
|
* --- |
68
|
|
|
* |
69
|
|
|
* ## EXAMPLES |
70
|
|
|
* |
71
|
|
|
* # Delete all draft and publish pages. |
72
|
|
|
* $ wp bulk-delete pages by-status --status=publish,draft |
73
|
|
|
* Success: Deleted 10 pages from the selected post status |
74
|
|
|
* |
75
|
|
|
* # Delete published pages that are older than 10 days. |
76
|
|
|
* $ wp bulk-delete pages by-status --status=publish --restrict=true --op=before --days=10 |
77
|
|
|
* Success: Deleted 10 pages from the selected post status |
78
|
|
|
* |
79
|
|
|
* # Delete published and draft pages that are created in the last 5 days. |
80
|
|
|
* $ wp bulk-delete pages by-status --status=publish,draft --restrict=true --op=after --days=5 |
81
|
|
|
* Success: Deleted 10 pages from the selected post status |
82
|
|
|
* |
83
|
|
|
* # Move 500 published pages to trash. |
84
|
|
|
* $ wp bulk-delete pages by-status --status=publish --limit_to=500 |
85
|
|
|
* Success: Deleted 500 pages from the selected post status |
86
|
|
|
* |
87
|
|
|
* # Permanently delete 500 published pages. |
88
|
|
|
* $ wp bulk-delete pages by-status --status=publish --limit_to=500 --force_delete=true |
89
|
|
|
* Success: Deleted 500 pages from the selected post status |
90
|
|
|
* |
91
|
|
|
* @subcommand by-status |
92
|
|
|
* |
93
|
|
|
* @param array $args Arguments to be supplied. |
94
|
|
|
* @param array $assoc_args Associative arguments to be supplied. |
95
|
|
|
* |
96
|
|
|
* @return void |
97
|
|
|
*/ |
98
|
|
|
public function by_status( $args, $assoc_args ) { |
99
|
|
|
$module = new DeletePagesByStatusModule(); |
100
|
|
|
|
101
|
|
|
$message = $module->process_cli_request( $assoc_args ); |
102
|
|
|
|
103
|
|
|
\WP_CLI::success( $message ); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths