@@ -9,6 +9,7 @@ class Search_Replace_Command extends WP_CLI_Command {
9
9
private $ regex ;
10
10
private $ regex_flags ;
11
11
private $ regex_delimiter ;
12
+ private $ skip_tables ;
12
13
private $ skip_columns ;
13
14
private $ include_columns ;
14
15
private $ format ;
@@ -74,6 +75,10 @@ class Search_Replace_Command extends WP_CLI_Command {
74
75
* You might want to change this depending on your database configuration
75
76
* (e.g. if you need to do fewer queries). Default: 50
76
77
*
78
+ * [--skip-tables=<tables>]
79
+ * : Do not perform the replacement on specific tables. Use commas to
80
+ * specify multiple tables.
81
+ *
77
82
* [--skip-columns=<columns>]
78
83
* : Do not perform the replacement on specific columns. Use commas to
79
84
* specify multiple columns.
@@ -148,9 +153,9 @@ class Search_Replace_Command extends WP_CLI_Command {
148
153
* # Bash script: Search/replace production to development url (multisite compatible)
149
154
* #!/bin/bash
150
155
* if $(wp --url=http://example.com core is-installed --network); then
151
- * wp search-replace --url=http://example.com 'http://example.com' 'http://example.dev' --recurse-objects --network --skip-columns=guid
156
+ * wp search-replace --url=http://example.com 'http://example.com' 'http://example.dev' --recurse-objects --network --skip-columns=guid --skip-tables=wp_users
152
157
* else
153
- * wp search-replace 'http://example.com' 'http://example.dev' --recurse-objects --skip-columns=guid
158
+ * wp search-replace 'http://example.com' 'http://example.dev' --recurse-objects --skip-columns=guid --skip-tables=wp_users
154
159
* fi
155
160
*/
156
161
public function __invoke ( $ args , $ assoc_args ) {
@@ -195,6 +200,7 @@ public function __invoke( $args, $assoc_args ) {
195
200
}
196
201
197
202
$ this ->skip_columns = explode ( ', ' , \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'skip-columns ' ) );
203
+ $ this ->skip_tables = explode ( ', ' , \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'skip-tables ' ) );
198
204
$ this ->include_columns = array_filter ( explode ( ', ' , \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'include-columns ' ) ) );
199
205
200
206
if ( $ old === $ new && ! $ this ->regex ) {
@@ -271,6 +277,10 @@ public function __invoke( $args, $assoc_args ) {
271
277
$ tables = \WP_CLI \Utils \wp_get_table_names ( $ args , $ assoc_args );
272
278
foreach ( $ tables as $ table ) {
273
279
280
+ if ( in_array ( $ table , $ this ->skip_tables ) ) {
281
+ continue ;
282
+ }
283
+
274
284
$ table_sql = self ::esc_sql_ident ( $ table );
275
285
276
286
if ( $ this ->export_handle ) {
0 commit comments