PluginProbe
WP Reset / 2.05
WP Reset v2.05
trunk 1.0 1.1 1.11 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.77 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.90 All 42 releases
← All changes | wp-reset-cli.php +96 -92 1.602.05 View file →
@@ -1,15 +1,16 @@
1 1 <?php
2 +
2 3 /**
3 4 * WP Reset
4 5 * https://wpreset.com/
5 - * (c) WebFactory Ltd, 2017-2019
6 + * (c) WebFactory Ltd, 2017-2023
6 7 */
7 8
8 9
9 10 // include only file
10 11 if (!defined('ABSPATH')) {
11 - wp_die(__('Do not open this file directly.', 'wp-error'));
12 + die('Do not open this file directly.');
12 13 }
13 14
14 15
15 16 /**
@@ -18,34 +19,31 @@
18 19 class WP_Reset_CLI extends WP_CLI_Command
19 20 {
20 21
21 22 /**
22 - * Reset the site database to default values. No files are modified.
23 - *
24 - * ## OPTIONS
25 - *
26 - * [--reactivate-theme]
27 - * : Reactivate currently active theme after reset.
28 - *
29 - * [--reactivate-plugins]
30 - * : Reactivate all currently active plugins after reset.
31 - *
32 - * [--reactivate-webhooks]
33 - * : Reactivate WP Webhooks plugin after reset.
34 - *
35 - * [--deactivate-wp-reset]
36 - * : Deactivate WP Reset plugin after reset. By default it will stay active after reset.
37 - *
38 - * [--yes]
39 - * : Answer yes to the confirmation message.
40 - *
41 - * ## EXAMPLES
42 - *
43 - * $ wp reset reset --yes
44 - * Success: Database has been reset.
45 - *
46 - * @when after_wp_load
47 - */
23 + * Reset the site database to default values. No files are modified.
24 + *
25 + * ## OPTIONS
26 + *
27 + * [--reactivate-theme]
28 + * : Reactivate currently active theme after reset.
29 + *
30 + * [--reactivate-plugins]
31 + * : Reactivate all currently active plugins after reset.
32 + *
33 + * [--deactivate-wp-reset]
34 + * : Deactivate WP Reset plugin after reset. By default it will stay active after reset.
35 + *
36 + * [--yes]
37 + * : Answer yes to the confirmation message.
38 + *
39 + * ## EXAMPLES
40 + *
41 + * $ wp reset reset --yes
42 + * Success: Database has been reset.
43 + *
44 + * @when after_wp_load
45 + */
48 46 function reset($args, $assoc_args)
49 47 {
50 48 WP_CLI::confirm('Are you sure you want to reset the site? There is NO UNDO!', $assoc_args);
51 49
@@ -62,11 +60,8 @@
62 60 }
63 61 if (!empty($assoc_args['reactivate-plugins'])) {
64 62 $params['reactivate_plugins'] = true;
65 63 }
66 - if (!empty($assoc_args['reactivate-webhooks'])) {
67 - $params['reactivate_webhooks'] = true;
68 - }
69 64
70 65 $result = $wp_reset->do_reinstall($params);
71 66 if (is_wp_error($result)) {
72 67 WP_CLI::error($result->get_error_message);
@@ -76,12 +71,12 @@
76 71 } // reset
77 72
78 73
79 74 /**
80 - * Display WP Reset version.
81 - *
82 - * @when after_wp_load
83 - */
75 + * Display WP Reset version.
76 + *
77 + * @when after_wp_load
78 + */
84 79 function version($args, $assoc_args)
85 80 {
86 81 global $wp_reset;
87 82
@@ -89,34 +84,34 @@
89 84 } // version
90 85
91 86
92 87 /**
93 - * Delete selected WordPress objects.
94 - *
95 - * ## OPTIONS
96 - *
97 - * <plugins|themes|transients|uploads|custom-tables|htaccess|theme-options>
98 - * : WP objects to delete.
99 - *
100 - * [--yes]
101 - * : Answer yes to the confirmation message.
102 - *
103 - * [--empty]
104 - * : Empty (truncate) custom tables instead of deleting (dropping) them.
105 - *
106 - * ## EXAMPLES
107 - *
108 - * $ wp reset delete themes --yes
109 - * Success: 3 themes have been deleted.
110 - *
111 - * $ wp reset delete custom-tables --truncate --yes
112 - * Success: 3 custom tables have been emptied.
113 - *
114 - * $ wp reset delete htaccess --yes
115 - * Success: Htaccess file has been deleted.
116 - *
117 - * @when after_wp_load
118 - */
88 + * Delete selected WordPress objects.
89 + *
90 + * ## OPTIONS
91 + *
92 + * <plugins|themes|transients|uploads|custom-tables|htaccess|theme-options>
93 + * : WP objects to delete.
94 + *
95 + * [--yes]
96 + * : Answer yes to the confirmation message.
97 + *
98 + * [--empty]
99 + * : Empty (truncate) custom tables instead of deleting (dropping) them.
100 + *
101 + * ## EXAMPLES
102 + *
103 + * $ wp reset delete themes --yes
104 + * Success: 3 themes have been deleted.
105 + *
106 + * $ wp reset delete custom-tables --truncate --yes
107 + * Success: 3 custom tables have been emptied.
108 + *
109 + * $ wp reset delete htaccess --yes
110 + * Success: Htaccess file has been deleted.
111 + *
112 + * @when after_wp_load
113 + */
119 114 function delete($args, $assoc_args)
120 115 {
121 116 global $wp_reset, $wpdb;
122 117
@@ -183,37 +178,37 @@
183 178 } // delete
184 179
185 180
186 181 /**
187 - * List and manipulate DB snapshots.
188 - *
189 - * ## OPTIONS
190 - *
191 - * <list|create|restore|export|delete>
192 - * : Action to perform with snapshot.
193 - *
194 - * [--yes]
195 - * : Answer yes to the confirmation message.
196 - *
197 - * [--id=<snapshot-id>]
198 - * : Specify snapshot ID when doing restore, export and delete.
199 - *
200 - * [--name=<snapshot-name>]
201 - * : When creating a new snapshot specify an optional name.
202 - *
203 - * ## EXAMPLES
204 - *
205 - * wp reset snapshots create --yes
206 - * Success: New snapshot with ID 089bea has been created.
207 - *
208 - * $ wp reset snapshots delete --id=123456
209 - * Success: Snapshot has been deleted.
210 - *
211 - * $ wp reset snapshots export --id=123456
212 - * Success: Snapshot has been exported and saved to: https://test.site/wp-content/wp-reset-snapshots-export/wp-reset-snapshot-123456.sql.gz
213 - *
214 - * @when after_wp_load
215 - */
182 + * List and manipulate DB snapshots.
183 + *
184 + * ## OPTIONS
185 + *
186 + * <list|create|restore|export|delete>
187 + * : Action to perform with snapshot.
188 + *
189 + * [--yes]
190 + * : Answer yes to the confirmation message.
191 + *
192 + * [--id=<snapshot-id>]
193 + * : Specify snapshot ID when doing restore, export and delete.
194 + *
195 + * [--name=<snapshot-name>]
196 + * : When creating a new snapshot specify an optional name.
197 + *
198 + * ## EXAMPLES
199 + *
200 + * wp reset snapshots create --yes
201 + * Success: New snapshot with ID 089bea has been created.
202 + *
203 + * $ wp reset snapshots delete --id=123456
204 + * Success: Snapshot has been deleted.
205 + *
206 + * $ wp reset snapshots export --id=123456
207 + * Success: Snapshot has been exported and saved to: https://test.site/wp-content/wp-reset-snapshots-export/wp-reset-snapshot-123456.sql.gz
208 + *
209 + * @when after_wp_load
210 + */
216 211 function snapshots($args, $assoc_args)
217 212 {
218 213 global $wp_reset;
219 214
@@ -237,9 +232,9 @@
237 232 $tmp['name'] = $ss['name'];
238 233 } else {
239 234 $tmp['name'] = 'n/a';
240 235 }
241 - $tmp['created'] = date(get_option('date_format'), strtotime($ss['timestamp'])) . ' @ ' . date(get_option('time_format'), strtotime($ss['timestamp']));
236 + $tmp['created'] = gmdate(get_option('date_format'), strtotime($ss['timestamp'])) . ' @ ' . gmdate(get_option('time_format'), strtotime($ss['timestamp']));
242 237 $tmp['info'] = $ss['tbl_core'] . ' standard & ';
243 238 if ($ss['tbl_custom']) {
244 239 $tmp['info'] .= $ss['tbl_custom'] . ' custom table' . ($ss['tbl_custom'] == 1 ? '' : 's');
245 240 } else {
@@ -244,9 +239,9 @@
244 239 $tmp['info'] .= $ss['tbl_custom'] . ' custom table' . ($ss['tbl_custom'] == 1 ? '' : 's');
245 240 } else {
246 241 $tmp['info'] .= 'no custom tables';
247 242 }
248 - $tmp['info'] .= ' totaling ' . $wp_reset->format_size($ss['tbl_size']) . ' in ' . number_format($ss['tbl_rows']) . ' rows';
243 + $tmp['info'] .= ' totaling ' . WP_Reset_Utility::format_size($ss['tbl_size']) . ' in ' . number_format($ss['tbl_rows']) . ' rows';
249 244
250 245 $table[] = $tmp;
251 246 } // foreach
252 247 WP_CLI\Utils\format_items('table', $table, array('id', 'name', 'created', 'info'));
@@ -316,7 +311,16 @@
316 311 WP_CLI::error('Unknown subcommand. Please choose from: list, create, restore, export or delete.');
317 312 return;
318 313 }
319 314 } // snapshots
315 +
316 +
317 + /**
318 + * This command is no longer available. Please use "wp reset snapshots create" instead.
319 + */
320 + function backups($args, $assoc_args)
321 + {
322 + WP_CLI::error('This command is no longer available. Please use: wp reset snapshots create');
323 + } // backups
320 324 } // WP_Reset_CLI
321 325
322 326 WP_CLI::add_command('reset', 'WP_Reset_CLI');