| @@ -2,15 +2,15 @@ | ||
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * WP Reset |
| 5 | 5 | * https://wpreset.com/ |
| 6 | - * (c) WebFactory Ltd, 2017-2019 | |
| 6 | + * (c) WebFactory Ltd, 2017-2023 | |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | // include only file |
| 11 | 11 | if (!defined('ABSPATH')) { |
| 12 | - wp_die(__('Do not open this file directly.', 'wp-error')); | |
| 12 | + die('Do not open this file directly.'); | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /** |
| @@ -29,11 +29,8 @@ | ||
| 29 | 29 | * |
| 30 | 30 | * [--reactivate-plugins] |
| 31 | 31 | * : Reactivate all currently active plugins after reset. |
| 32 | 32 | * |
| 33 | - * [--reactivate-webhooks] | |
| 34 | - * : Reactivate WP Webhooks plugin after reset. | |
| 35 | - * | |
| 36 | 33 | * [--deactivate-wp-reset] |
| 37 | 34 | * : Deactivate WP Reset plugin after reset. By default it will stay active after reset. |
| 38 | 35 | * |
| 39 | 36 | * [--yes] |
| @@ -63,11 +60,8 @@ | ||
| 63 | 60 | } |
| 64 | 61 | if (!empty($assoc_args['reactivate-plugins'])) { |
| 65 | 62 | $params['reactivate_plugins'] = true; |
| 66 | 63 | } |
| 67 | - if (!empty($assoc_args['reactivate-webhooks'])) { | |
| 68 | - $params['reactivate_webhooks'] = true; | |
| 69 | - } | |
| 70 | 64 | |
| 71 | 65 | $result = $wp_reset->do_reinstall($params); |
| 72 | 66 | if (is_wp_error($result)) { |
| 73 | 67 | WP_CLI::error($result->get_error_message); |
| @@ -238,9 +232,9 @@ | ||
| 238 | 232 | $tmp['name'] = $ss['name']; |
| 239 | 233 | } else { |
| 240 | 234 | $tmp['name'] = 'n/a'; |
| 241 | 235 | } |
| 242 | - $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'])); | |
| 243 | 237 | $tmp['info'] = $ss['tbl_core'] . ' standard & '; |
| 244 | 238 | if ($ss['tbl_custom']) { |
| 245 | 239 | $tmp['info'] .= $ss['tbl_custom'] . ' custom table' . ($ss['tbl_custom'] == 1 ? '' : 's'); |
| 246 | 240 | } else { |
| @@ -245,9 +239,9 @@ | ||
| 245 | 239 | $tmp['info'] .= $ss['tbl_custom'] . ' custom table' . ($ss['tbl_custom'] == 1 ? '' : 's'); |
| 246 | 240 | } else { |
| 247 | 241 | $tmp['info'] .= 'no custom tables'; |
| 248 | 242 | } |
| 249 | - $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'; | |
| 250 | 244 | |
| 251 | 245 | $table[] = $tmp; |
| 252 | 246 | } // foreach |
| 253 | 247 | WP_CLI\Utils\format_items('table', $table, array('id', 'name', 'created', 'info')); |
| @@ -320,76 +314,13 @@ | ||
| 320 | 314 | } // snapshots |
| 321 | 315 | |
| 322 | 316 | |
| 323 | 317 | /** |
| 324 | - * Manipulate backups. | |
| 325 | - * | |
| 326 | - * ## OPTIONS | |
| 327 | - * | |
| 328 | - * <create|list> | |
| 329 | - * : Actions to take with backup(s). | |
| 330 | - * | |
| 331 | - * ## EXAMPLES | |
| 332 | - * | |
| 333 | - * $ wp reset backup create | |
| 334 | - * Success: New backup created; /wp-content/wp-reset-backups/wp-reset-backup-site-com-2019-09-25-16-44-37-654a.sql.gz | |
| 335 | - * | |
| 336 | - * $ wp reset backup list | |
| 337 | - * Success: 2 backups found. | |
| 338 | - * --- | |
| 339 | - * - | |
| 340 | - * file: /wp-content/wp-reset-backups/wp-reset-backup-site-com-2019-09-24-15-35-55-6514.sql.gz | |
| 341 | - * - | |
| 342 | - * file: /wp-content/wp-reset-backups/wp-reset-backup-site-com-2019-09-24-15-38-09-45ab.sql.gz | |
| 343 | - * | |
| 344 | - * @when after_wp_load | |
| 318 | + * This command is no longer available. Please use "wp reset snapshots create" instead. | |
| 345 | 319 | */ |
| 346 | - function backup($args, $assoc_args) | |
| 320 | + function backups($args, $assoc_args) | |
| 347 | 321 | { |
| 348 | - global $wp_reset; | |
| 349 | - | |
| 350 | - if (empty($args[0])) { | |
| 351 | - WP_CLI::error('Please choose a subcommand: create or list.'); | |
| 352 | - return; | |
| 353 | - } elseif (false == in_array($args[0], array('create', 'list'))) { | |
| 354 | - WP_CLI::error('Unknown subcommand. Please choose from: create or list.'); | |
| 355 | - } else { | |
| 356 | - $subcommand = $args[0]; | |
| 357 | - } | |
| 358 | - | |
| 359 | - switch ($subcommand) { | |
| 360 | - case 'create': | |
| 361 | - $filename = $wp_reset->do_create_backup(true); | |
| 362 | - if (is_wp_error($filename)) { | |
| 363 | - WP_CLI::error('Unable to create new backup. ' . $filename->get_error_message()); | |
| 364 | - } else { | |
| 365 | - WP_CLI::success('New backup created: /wp-content/' . $wp_reset->backups_folder . '/' . $filename); | |
| 366 | - } | |
| 367 | - break; | |
| 368 | - case 'list': | |
| 369 | - $out = array(); | |
| 370 | - $files = @scandir(trailingslashit(WP_CONTENT_DIR) . $wp_reset->backups_folder . '/'); | |
| 371 | - if (false === $files || !is_array($files)) { | |
| 372 | - WP_CLI::error('Unable to open backups folder.'); | |
| 373 | - } else { | |
| 374 | - foreach ($files as $file) { | |
| 375 | - if (substr($file, -3) == '.gz') { | |
| 376 | - $out[] = array('file' => '/wp-content/' . $wp_reset->backups_folder . '/' . $file); | |
| 377 | - } | |
| 378 | - } // foreach | |
| 379 | - if ($out) { | |
| 380 | - WP_CLI::success(sizeof($out) . ' backup' . (sizeof($out) == 1 ? '' : 's') . ' found.'); | |
| 381 | - WP_CLI\Utils\format_items('yaml', $out, array('file')); | |
| 382 | - } else { | |
| 383 | - WP_CLI::error('No backups found.'); | |
| 384 | - } | |
| 385 | - } | |
| 386 | - break; | |
| 387 | - default: | |
| 388 | - // should never come to this but can't hurt | |
| 389 | - WP_CLI::error('Unknown subcommand. Please choose from: create or list.'); | |
| 390 | - return; | |
| 391 | - } | |
| 392 | - } // backup | |
| 322 | + WP_CLI::error('This command is no longer available. Please use: wp reset snapshots create'); | |
| 323 | + } // backups | |
| 393 | 324 | } // WP_Reset_CLI |
| 394 | 325 | |
| 395 | 326 | WP_CLI::add_command('reset', 'WP_Reset_CLI'); |