1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\CLI\Commands; |
4
|
|
|
|
5
|
|
|
use BulkWP\BulkDelete\Core\Base\BaseCommand; |
6
|
|
|
use BulkWP\BulkDelete\Core\Terms\Modules\DeleteTermsByNameModule; |
7
|
|
|
use BulkWP\BulkDelete\Core\Terms\Modules\DeleteTermsByPostCountModule; |
8
|
|
|
|
9
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Delete Terms CLI Command. |
13
|
|
|
* |
14
|
|
|
* @since 6.1.0 |
15
|
|
|
*/ |
16
|
|
|
class DeleteTermsCommand extends BaseCommand { |
17
|
|
|
/** |
18
|
|
|
* Get the command. |
19
|
|
|
* |
20
|
|
|
* @return string Command name. |
21
|
|
|
*/ |
22
|
|
|
public static function get_command() { |
23
|
|
|
return 'terms'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Delete terms by name. |
28
|
|
|
* |
29
|
|
|
* ## OPTIONS |
30
|
|
|
* |
31
|
|
|
* [--taxonomy=<taxonomy>] |
32
|
|
|
* : Taxonomy the term going to be deleted belongs to. You can use any custom taxonomy. |
33
|
|
|
* --- |
34
|
|
|
* default: category |
35
|
|
|
* --- |
36
|
|
|
* |
37
|
|
|
* [--operator=<operator>] |
38
|
|
|
* : Comparison operator for name to compare with. |
39
|
|
|
* --- |
40
|
|
|
* default: = |
41
|
|
|
* options: |
42
|
|
|
* - = |
43
|
|
|
* - != |
44
|
|
|
* - LIKE |
45
|
|
|
* - NOT LIKE |
46
|
|
|
* - STARTS_WITH |
47
|
|
|
* - ENDS_WITH |
48
|
|
|
* --- |
49
|
|
|
* |
50
|
|
|
* --value=<value> |
51
|
|
|
* : Term name |
52
|
|
|
* |
53
|
|
|
* ## EXAMPLES |
54
|
|
|
* |
55
|
|
|
* # Delete terms with name fruit under category taxonomy. |
56
|
|
|
* $ wp bulk-delete terms by-name --value=fruit |
57
|
|
|
* Success: Deleted 10 terms with the selected options |
58
|
|
|
* |
59
|
|
|
* # Delete terms with name containing apple under product_cat(custom taxonomy) taxonomy. |
60
|
|
|
* $ wp bulk-delete terms by-name --taxonomy=product_cat --operator=LIKE --value=apple |
61
|
|
|
* Success: Deleted 5 terms with the selected options |
62
|
|
|
* |
63
|
|
|
* # Delete terms with name ends with apple under post tag taxonomy. |
64
|
|
|
* $ wp bulk-delete terms by-name --taxonomy=post_tag --operator=ENDS_WITH --value=apple |
65
|
|
|
* Success: Deleted 3 terms with the selected options |
66
|
|
|
* |
67
|
|
|
* @subcommand by-name |
68
|
|
|
* |
69
|
|
|
* @param array $args Arguments to be supplied. |
70
|
|
|
* @param array $assoc_args Associative arguments to be supplied. |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
public function by_name( $args, $assoc_args ) { |
75
|
|
|
$module = new DeleteTermsByNameModule(); |
76
|
|
|
|
77
|
|
|
$message = $module->process_cli_request( $assoc_args ); |
78
|
|
|
|
79
|
|
|
\WP_CLI::success( $message ); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Delete terms by post count. |
84
|
|
|
* |
85
|
|
|
* ## OPTIONS |
86
|
|
|
* |
87
|
|
|
* [--taxonomy=<taxonomy>] |
88
|
|
|
* : Taxonomy, the term going to be deleted belongs to. You can use any custom taxonomy. |
89
|
|
|
* --- |
90
|
|
|
* default: category |
91
|
|
|
* --- |
92
|
|
|
* |
93
|
|
|
* [--operator=<operator>] |
94
|
|
|
* : Comparison operator for post count to compare with. |
95
|
|
|
* --- |
96
|
|
|
* default: = |
97
|
|
|
* options: |
98
|
|
|
* - = |
99
|
|
|
* - != |
100
|
|
|
* - > |
101
|
|
|
* - < |
102
|
|
|
* --- |
103
|
|
|
* |
104
|
|
|
* --count=<count> |
105
|
|
|
* : Post count(Any positive integer). |
106
|
|
|
* |
107
|
|
|
* ## EXAMPLES |
108
|
|
|
* |
109
|
|
|
* # Delete terms with post count equal to 0 under category taxonomy. |
110
|
|
|
* $ wp bulk-delete terms by-post-count --count=0 |
111
|
|
|
* Success: Deleted 10 terms with the selected options |
112
|
|
|
* |
113
|
|
|
* # Delete terms with post count less than 10 under product_cat(custom taxonomy) taxonomy. |
114
|
|
|
* $ wp bulk-delete terms by-post-count --taxonomy=product_cat --operator=< --count=10 |
115
|
|
|
* Success: Deleted 5 terms with the selected options |
116
|
|
|
* |
117
|
|
|
* # Delete terms with post count not equal to 20 under post tag taxonomy. |
118
|
|
|
* $ wp bulk-delete terms by-post-count --taxonomy=post_tag --operator=!= --count=20 |
119
|
|
|
* Success: Deleted 3 terms with the selected options |
120
|
|
|
* |
121
|
|
|
* @subcommand by-post-count |
122
|
|
|
* |
123
|
|
|
* @param array $args Arguments to be supplied. |
124
|
|
|
* @param array $assoc_args Associative arguments to be supplied. |
125
|
|
|
* |
126
|
|
|
* @return void |
127
|
|
|
*/ |
128
|
|
|
public function by_post_count( $args, $assoc_args ) { |
129
|
|
|
$module = new DeleteTermsByPostCountModule(); |
130
|
|
|
|
131
|
|
|
$message = $module->process_cli_request( $assoc_args ); |
132
|
|
|
|
133
|
|
|
\WP_CLI::success( $message ); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
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