WP Reset – Fastest WordPress Reset Plugin - Version 1.60

Version Description

Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 WP Reset – Fastest WordPress Reset Plugin
Version 1.60
Comparing to
See all releases

Code changes from version 1.55 to 1.60

Files changed (6) hide show
  1. css/wp-reset.css +60 -1
  2. img/product-hunt.png +0 -0
  3. js/wp-reset.js +9 -0
  4. readme.txt +12 -2
  5. wp-reset-cli.php +9 -4
  6. wp-reset.php +109 -12
css/wp-reset.css CHANGED
@@ -86,6 +86,7 @@
86
 
87
  .tools_page_wp-reset p {
88
  line-height: 1.7;
 
89
  }
90
 
91
  .tools_page_wp-reset .button-delete:hover {
@@ -168,6 +169,10 @@
168
  margin: 0;
169
  }
170
 
 
 
 
 
171
  .tools_page_wp-reset .no-padding-bottom {
172
  padding-bottom: 0;
173
  }
@@ -379,6 +384,12 @@
379
  border-bottom: 1px solid #e5e5e5;
380
  }
381
 
 
 
 
 
 
 
382
  .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li .label {
383
  display: block;
384
  margin-top: -10px;
@@ -647,4 +658,52 @@
647
 
648
  .webhooks-dialog .plain-list li {
649
  text-indent: -21px;
650
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  .tools_page_wp-reset p {
88
  line-height: 1.7;
89
+ font-size: 14px;
90
  }
91
 
92
  .tools_page_wp-reset .button-delete:hover {
169
  margin: 0;
170
  }
171
 
172
+ .tools_page_wp-reset table .delete-snapshot:hover {
173
+ color: rgb(221, 48, 54);
174
+ }
175
+
176
  .tools_page_wp-reset .no-padding-bottom {
177
  padding-bottom: 0;
178
  }
384
  border-bottom: 1px solid #e5e5e5;
385
  }
386
 
387
+ @media screen and (max-width: 782px) {
388
+ .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li {
389
+ min-width: inherit;
390
+ }
391
+ }
392
+
393
  .tools_page_wp-reset .ui-tabs ul.ui-tabs-nav li .label {
394
  display: block;
395
  margin-top: -10px;
658
 
659
  .webhooks-dialog .plain-list li {
660
  text-indent: -21px;
661
+ }
662
+
663
+ .product-hunt {
664
+ background-color: #df6949;
665
+ border: 2px solid transparent;
666
+ margin-bottom: 20px;
667
+ }
668
+
669
+ .product-hunt .wpr-dismiss-notice {
670
+ position: absolute;
671
+ right: 0.9em;
672
+ top: 0.5em;
673
+ text-decoration: none;
674
+ color: white;
675
+ }
676
+
677
+ .product-hunt .wpr-dismiss-notice:hover {
678
+ color: #666;
679
+ }
680
+
681
+ .product-hunt b {
682
+ font-weight: bolder;
683
+ }
684
+
685
+ .product-hunt h2 {
686
+ display: inline-block;
687
+ color: white;
688
+ padding-left: 20px;
689
+ width: calc(100% - 100px);
690
+ vertical-align: top;
691
+ }
692
+
693
+ .product-hunt a {
694
+ text-decoration: none;
695
+ cursor: pointer;
696
+ }
697
+
698
+ .product-hunt a:focus {
699
+ box-shadow: none;
700
+ }
701
+
702
+ .product-hunt:hover {
703
+ border: 2px solid #666;
704
+ }
705
+
706
+ .product-hunt img {
707
+ height: auto;
708
+ width: 70px;
709
+ }
img/product-hunt.png ADDED
Binary file
js/wp-reset.js CHANGED
@@ -33,6 +33,15 @@ jQuery(document).ready(function($) {
33
  return false;
34
  }); // delete uploads
35
 
 
 
 
 
 
 
 
 
 
36
  // delete themes
37
  $('.tools_page_wp-reset').on('click', '#delete-themes', 'click', function(e) {
38
  e.preventDefault();
33
  return false;
34
  }); // delete uploads
35
 
36
+ // reset theme options (mods)
37
+ $('.tools_page_wp-reset').on('click', '#reset-theme-options', 'click', function(e) {
38
+ e.preventDefault();
39
+
40
+ run_tool(this, 'reset_theme_options');
41
+
42
+ return false;
43
+ }); // reset theme options
44
+
45
  // delete themes
46
  $('.tools_page_wp-reset').on('click', '#delete-themes', 'click', function(e) {
47
  e.preventDefault();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Tags: wordpress reset, reset wordpress, reset database, reset wordpress database
3
  Contributors: WebFactory, wpreset, googlemapswidget, securityninja, underconstructionpage
4
  Requires at least: 4.0
5
  Requires PHP: 5.2
6
- Tested up to: 5.1
7
- Stable tag: 1.55
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -67,6 +67,7 @@ WP Reset has yet to be completely tested with multisite! Please be careful when
67
  * Delete transients - deletes all transient related database entries. Including expired and non-expired transients, and orphaned timeout entries.
68
  * Delete uploads - delete all files and folder in the /uploads/ folder.
69
  * Delete plugins - deletes all plugins except WP Reset which remains active.
 
70
  * Delete themes - deletes all themes.
71
  * Empty or delete custom tables - empties (truncates) or deletes (drops) all custom database tables.
72
  * Delete .htaccess file - deletes the .htaccess file. If you need to edit .htaccess without FTP use our free <a href="https://wordpress.org/plugins/wp-htaccess-editor/">WP Htaccess Editor</a> plugin.
@@ -102,6 +103,15 @@ Or if needed, upload manually;
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
 
 
 
 
105
  = v1.55 =
106
  * 2019/03/25
107
  * 100k users hit on 2019/01/15 with 560,300 downloads; 34 days for +10k & 71k downloads
3
  Contributors: WebFactory, wpreset, googlemapswidget, securityninja, underconstructionpage
4
  Requires at least: 4.0
5
  Requires PHP: 5.2
6
+ Tested up to: 5.2
7
+ Stable tag: 1.60
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
67
  * Delete transients - deletes all transient related database entries. Including expired and non-expired transients, and orphaned timeout entries.
68
  * Delete uploads - delete all files and folder in the /uploads/ folder.
69
  * Delete plugins - deletes all plugins except WP Reset which remains active.
70
+ * Reset theme options - resets all options for all themes that use the WP theme mods API.
71
  * Delete themes - deletes all themes.
72
  * Empty or delete custom tables - empties (truncates) or deletes (drops) all custom database tables.
73
  * Delete .htaccess file - deletes the .htaccess file. If you need to edit .htaccess without FTP use our free <a href="https://wordpress.org/plugins/wp-htaccess-editor/">WP Htaccess Editor</a> plugin.
103
 
104
  == Changelog ==
105
 
106
+ = v1.60 =
107
+ * 2019/04/15
108
+ * bug fixes
109
+ * new tool: Reset theme options
110
+ * added Product Hunt banner
111
+ * added actions (hooks) to all tools and snapshot actions; all action names start with "wp-reset-"
112
+ * removed features survey
113
+ * announced plugin & theme collections
114
+
115
  = v1.55 =
116
  * 2019/03/25
117
  * 100k users hit on 2019/01/15 with 560,300 downloads; 34 days for +10k & 71k downloads
wp-reset-cli.php CHANGED
@@ -94,7 +94,7 @@ class WP_Reset_CLI extends WP_CLI_Command
94
  *
95
  * ## OPTIONS
96
  *
97
- * <plugins|themes|transients|uploads|custom-tables|htaccess>
98
  * : WP objects to delete.
99
  *
100
  * [--yes]
@@ -123,8 +123,8 @@ class WP_Reset_CLI extends WP_CLI_Command
123
  if (empty($args[0])) {
124
  WP_CLI::error('Please choose a subcommand: plugins, themes, transients, uploads, htaccess or custom-tables.');
125
  return;
126
- } elseif (false == in_array($args[0], array('themes', 'plugins', 'transients', 'uploads', 'htaccess', 'custom-tables'))) {
127
- WP_CLI::error('Unknown subcommand. Please choose from: plugins, themes, transients, uploads, htaccess or custom tables.');
128
  } else {
129
  $subcommand = $args[0];
130
  }
@@ -170,9 +170,14 @@ class WP_Reset_CLI extends WP_CLI_Command
170
  WP_CLI::error('Htaccess file has not been deleted. ' . $tmp->get_error_message());
171
  }
172
  break;
 
 
 
 
 
173
  default:
174
  // should never come to this but can't hurt
175
- WP_CLI::error('Unknown subcommand. Please choose from: plugins, themes, transients, uploads, htaccess or custom-tables.');
176
  return;
177
  }
178
  } // delete
94
  *
95
  * ## OPTIONS
96
  *
97
+ * <plugins|themes|transients|uploads|custom-tables|htaccess|theme-options>
98
  * : WP objects to delete.
99
  *
100
  * [--yes]
123
  if (empty($args[0])) {
124
  WP_CLI::error('Please choose a subcommand: plugins, themes, transients, uploads, htaccess or custom-tables.');
125
  return;
126
+ } elseif (false == in_array($args[0], array('themes', 'plugins', 'transients', 'uploads', 'htaccess', 'custom-tables', 'theme-options'))) {
127
+ WP_CLI::error('Unknown subcommand. Please choose from: plugins, themes, transients, uploads, htaccess, custom tables or theme-options.');
128
  } else {
129
  $subcommand = $args[0];
130
  }
170
  WP_CLI::error('Htaccess file has not been deleted. ' . $tmp->get_error_message());
171
  }
172
  break;
173
+ case 'theme-options':
174
+ WP_CLI::confirm('Are you sure you want to reset all options (mods) for all themes?', $assoc_args);
175
+ $cnt = $wp_reset->do_reset_theme_options();
176
+ WP_CLI::success('Options for ' . $cnt . ' themes have been reset.');
177
+ break;
178
  default:
179
  // should never come to this but can't hurt
180
+ WP_CLI::error('Unknown subcommand. Please choose from: plugins, themes, transients, uploads, htaccess, custom-tables or theme-options.');
181
  return;
182
  }
183
  } // delete
wp-reset.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
- /*
3
  Plugin Name: WP Reset
4
  Plugin URI: https://wpreset.com/
5
  Description: Reset the site to default installation values without modifying any files. Deletes all customizations and content.
6
- Version: 1.55
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: wp-reset
@@ -432,6 +432,9 @@ class WP_Reset
432
  return false;
433
  }
434
 
 
 
 
435
  if ($this->get_dismissed_notices('survey-' . $survey_name)) {
436
  return false;
437
  }
@@ -603,10 +606,31 @@ class WP_Reset
603
 
604
  $count = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'");
605
 
 
 
606
  return $count;
607
  } // do_delete_transients
608
 
609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  /**
611
  * Deletes all files in uploads folder.
612
  *
@@ -615,9 +639,12 @@ class WP_Reset
615
  function do_delete_uploads()
616
  {
617
  $upload_dir = wp_get_upload_dir();
 
618
 
619
  $this->delete_folder($upload_dir['basedir'], $upload_dir['basedir']);
620
 
 
 
621
  return $this->delete_count;
622
  } // do_delete_uploads
623
 
@@ -689,6 +716,8 @@ class WP_Reset
689
  delete_plugins(array_keys($all_plugins));
690
  }
691
 
 
 
692
  return sizeof($all_plugins);
693
  } // do_delete_plugins
694
 
@@ -731,8 +760,11 @@ class WP_Reset
731
  if (false == $keep_default_theme) {
732
  update_option('template', '');
733
  update_option('stylesheet', '');
 
734
  }
735
 
 
 
736
  return sizeof($all_themes);
737
  } // do_delete_themes
738
 
@@ -751,6 +783,8 @@ class WP_Reset
751
  $wpdb->query('TRUNCATE TABLE ' . $tbl['name']);
752
  } // foreach
753
 
 
 
754
  return sizeof($custom_tables);
755
  } // do_truncate_custom_tables
756
 
@@ -769,6 +803,8 @@ class WP_Reset
769
  $wpdb->query('DROP TABLE IF EXISTS ' . $tbl['name']);
770
  } // foreach
771
 
 
 
772
  return sizeof($custom_tables);
773
  } // do_drop_custom_tables
774
 
@@ -790,6 +826,8 @@ class WP_Reset
790
  $htaccess_path = $this->get_htaccess_path();
791
  clearstatcache();
792
 
 
 
793
  if (!$wp_filesystem->is_readable($htaccess_path)) {
794
  return new WP_Error(1, 'Htaccess file does not exist; there\'s nothing to delete.');
795
  }
@@ -846,6 +884,9 @@ class WP_Reset
846
  if ($tool == 'delete_transients') {
847
  $cnt = $this->do_delete_transients();
848
  wp_send_json_success($cnt);
 
 
 
849
  } elseif ($tool == 'delete_themes') {
850
  $cnt = $this->do_delete_themes(false);
851
  wp_send_json_success($cnt);
@@ -1231,6 +1272,22 @@ class WP_Reset
1231
  $notice_shown = true;
1232
  }
1233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1234
  // tabs
1235
  echo '<div id="wp-reset-tabs" class' . __('="', 'wp-reset') . 'ui-tabs">';
1236
 
@@ -1238,6 +1295,7 @@ class WP_Reset
1238
  echo '<li><a href="#tab-reset">' . __('Reset', 'wp-reset') . '</a></li>';
1239
  echo '<li><a href="#tab-tools">' . __('Tools', 'wp-reset') . '</a></li>';
1240
  echo '<li><a href="#tab-snapshots">' . __('DB Snapshots', 'wp-reset') . '</a></li>';
 
1241
  echo '<li><a href="#tab-support">' . __('Support', 'wp-reset') . '</a></li>';
1242
  echo '</ul>';
1243
 
@@ -1253,6 +1311,10 @@ class WP_Reset
1253
  $this->tab_snapshots();
1254
  echo '</div>';
1255
 
 
 
 
 
1256
  echo '<div style="display: none;" id="tab-support">';
1257
  $this->tab_support();
1258
  echo '</div>';
@@ -1379,7 +1441,7 @@ class WP_Reset
1379
 
1380
  echo '<b>' . __('WP-CLI Support', 'wp-reset') . '</b>';
1381
  echo '<p>' . sprintf(__('All tools available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored. ', 'wp-reset'), '<code>wp help reset</code>');
1382
- echo sprintf(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be carefull - there is NO UNDO.', 'wp-reset'), '<code>--yes</code>') . '</p>';
1383
 
1384
  echo '<b>' . __('WP Webhooks Support', 'wp-reset') . '</b>';
1385
  echo '<p>All WP Reset tools are integrated with <a href="https://wordpress.org/plugins/wp-webhooks/" target="_blank">WP Webhooks</a> and available as (receive data) actions. Webhooks are a standard, platform-independent way of connecting WordPress to any 3rd party system. This <a href="https://underconstructionpage.com/wp-webhooks-connect-integrate-wordpress/" target="_blank">article</a> has more info, videos and use-cases so you can see just how powerful and easy to use webhooks are.<br>';
@@ -1426,8 +1488,6 @@ class WP_Reset
1426
  */
1427
  private function tab_tools()
1428
  {
1429
- global $wpdb;
1430
-
1431
  echo '<div class="card">';
1432
  echo '<h2>' . __('Delete Transients', 'wp-reset') . '</h2>';
1433
  echo '<p>' . __('All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
@@ -1447,6 +1507,12 @@ class WP_Reset
1447
  }
1448
  echo '</div>';
1449
 
 
 
 
 
 
 
1450
  $theme = wp_get_theme();
1451
 
1452
  echo '<div class="card">';
@@ -1461,6 +1527,7 @@ class WP_Reset
1461
  echo '<p><a data-btn-confirm="Delete plugins" data-text-wait="Deleting plugins. Please wait." data-text-confirm="All plugins except WP Reset will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n plugins have been deleted." data-text-done-singular="One plugin has been deleted." class="button button-delete" href="#" id="delete-plugins">Delete plugins</a></p>';
1462
  echo '</div>';
1463
 
 
1464
  $custom_tables = $this->get_custom_tables();
1465
 
1466
  echo '<div class="card">';
@@ -1497,6 +1564,25 @@ class WP_Reset
1497
  } // tab_tools
1498
 
1499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1500
  /**
1501
  * Echoes content for support tab
1502
  *
@@ -1504,6 +1590,11 @@ class WP_Reset
1504
  */
1505
  private function tab_support()
1506
  {
 
 
 
 
 
1507
  echo '<div class="card">';
1508
  echo '<h2>' . __('Public support forum', 'wp-reset') . '</h2>';
1509
  echo '<p>' . __('We are very active on the <a href="https://wordpress.org/support/plugin/wp-reset" target="_blank">official WP Reset support forum</a>. If you found a bug, have a feature idea or just want to say hi - please drop by. We love to hear back from our users.', 'wp-reset') . '</p>';
@@ -1516,7 +1607,7 @@ class WP_Reset
1516
 
1517
  echo '<div class="card">';
1518
  echo '<h2>' . __('Care to help out?', 'wp-reset') . '</h2>';
1519
- echo '<p>' . __('No need for donations or anything like that :) If you can give us a <a href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post" target="_blank">five star rating</a> you\'ll help out more than you can imagine. Thank you!', 'wp-reset') . '</p>';
1520
  echo '</div>';
1521
  } // tab_support
1522
 
@@ -1536,7 +1627,6 @@ class WP_Reset
1536
  echo '<h2>' . __('Database Snapshots', 'wp-reset') . '</h2>';
1537
  echo '<p>A snapshot is a copy of all WP database tables, standard and custom ones, saved in your database. Files are not saved or included in snapshots in any way.<br>
1538
  Snapshots are primarily a development tool. Although they can be used for backups (and downloaded), we suggest finding a more suitable tool for live sites, such as <a href="https://wordpress.org/plugins/updraftplus/" target="_blank">UpdraftPlus</a>. Use snapshots to find out what changes a plugin made to your database or to quickly restore the dev environment after testing database related changes.<br>Restoring a snapshot does not affect other snapshots, or WP Reset settings.</p>';
1539
- echo '<p>Snapshots are still in development. If you see a bug or just have an idea how to make the tool better, please let us know <a href="https://twitter.com/WebFactoryLtd" target="_blank">@webfactoryltd</a> or <a href="mailto:wpreset@webfactoryltd.com?subject=WPR%20DB%20Snapshots%20Feedback">email us</a>. Thank you!</p>';
1540
 
1541
  $table_status = $wpdb->get_results('SHOW TABLE STATUS');
1542
  if (is_array($table_status)) {
@@ -1759,15 +1849,17 @@ class WP_Reset
1759
  return new WP_Error(1, 'Can\'t get table status data.');
1760
  }
1761
 
1762
- $snapshot['tbl_core'] = $tbl_core;
1763
  $snapshot['tbl_custom'] = $tbl_custom;
1764
- $snapshot['tbl_rows'] = $tbl_rows;
1765
- $snapshot['tbl_size'] = $tbl_size;
1766
 
1767
 
1768
  $snapshots[$uid] = $snapshot;
1769
  update_option('wp-reset-snapshots', $snapshots);
1770
 
 
 
1771
  return $snapshot;
1772
  } // create_snapshot
1773
 
@@ -1797,9 +1889,12 @@ class WP_Reset
1797
  $wpdb->query('DROP TABLE IF EXISTS ' . $table);
1798
  }
1799
 
 
1800
  unset($snapshots[$uid]);
1801
  update_option('wp-reset-snapshots', $snapshots);
1802
 
 
 
1803
  return true;
1804
  } // delete_snapshot
1805
 
@@ -1813,7 +1908,6 @@ class WP_Reset
1813
  */
1814
  function do_export_snapshot($uid = '')
1815
  {
1816
- global $wpdb;
1817
  $snapshots = $this->get_snapshots();
1818
 
1819
  if (strlen($uid) != 6) {
@@ -1844,6 +1938,8 @@ class WP_Reset
1844
  return new WP_Error(1, "Couldn't dump snapshot: " . $e->getMessage());
1845
  }
1846
 
 
 
1847
  return 'wp-reset-snapshot-' . $uid . '.sql.gz';
1848
  } // export_snapshot
1849
 
@@ -1904,6 +2000,8 @@ class WP_Reset
1904
  update_option('wp-reset', $this->options);
1905
  update_option('wp-reset-snapshots', $snapshots);
1906
 
 
 
1907
  return true;
1908
  } // restore_snapshot
1909
 
@@ -1969,7 +2067,6 @@ class WP_Reset
1969
  function do_compare_snapshots($uid)
1970
  {
1971
  global $wpdb;
1972
- $tbl_core = $tbl_custom = 0;
1973
  $current = $snapshot = array();
1974
  $out = $out2 = $out3 = '';
1975
 
1
  <?php
2
+ /*
3
  Plugin Name: WP Reset
4
  Plugin URI: https://wpreset.com/
5
  Description: Reset the site to default installation values without modifying any files. Deletes all customizations and content.
6
+ Version: 1.60
7
  Author: WebFactory Ltd
8
  Author URI: https://www.webfactoryltd.com/
9
  Text Domain: wp-reset
432
  return false;
433
  }
434
 
435
+ // all surveys are curently disabled
436
+ return false;
437
+
438
  if ($this->get_dismissed_notices('survey-' . $survey_name)) {
439
  return false;
440
  }
606
 
607
  $count = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'");
608
 
609
+ do_action('wp_reset_delete_transients', $count);
610
+
611
  return $count;
612
  } // do_delete_transients
613
 
614
 
615
+ /**
616
+ * Resets all theme options (mods).
617
+ *
618
+ * @param bool $all_themes Delete mods for all themes or just the current one
619
+ *
620
+ * @return int Number of deleted mod DB entries
621
+ */
622
+ function do_reset_theme_options($all_themes = true)
623
+ {
624
+ global $wpdb;
625
+
626
+ $count = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'theme_mods\_%' OR option_name LIKE 'mods\_%'");
627
+
628
+ do_action('wp_reset_reset_theme_options', $count);
629
+
630
+ return $count;
631
+ } // do_reset_theme_options
632
+
633
+
634
  /**
635
  * Deletes all files in uploads folder.
636
  *
639
  function do_delete_uploads()
640
  {
641
  $upload_dir = wp_get_upload_dir();
642
+ $this->delete_count = 0;
643
 
644
  $this->delete_folder($upload_dir['basedir'], $upload_dir['basedir']);
645
 
646
+ do_action('wp_reset_delete_uploads', $this->delete_count);
647
+
648
  return $this->delete_count;
649
  } // do_delete_uploads
650
 
716
  delete_plugins(array_keys($all_plugins));
717
  }
718
 
719
+ do_action('wp_reset_delete_plugins', $all_plugins, $all_plugins);
720
+
721
  return sizeof($all_plugins);
722
  } // do_delete_plugins
723
 
760
  if (false == $keep_default_theme) {
761
  update_option('template', '');
762
  update_option('stylesheet', '');
763
+ update_option('current_theme', '');
764
  }
765
 
766
+ do_action('wp_reset_delete_themes', $all_themes);
767
+
768
  return sizeof($all_themes);
769
  } // do_delete_themes
770
 
783
  $wpdb->query('TRUNCATE TABLE ' . $tbl['name']);
784
  } // foreach
785
 
786
+ do_action('wp_reset_truncate_custom_tables', $custom_tables);
787
+
788
  return sizeof($custom_tables);
789
  } // do_truncate_custom_tables
790
 
803
  $wpdb->query('DROP TABLE IF EXISTS ' . $tbl['name']);
804
  } // foreach
805
 
806
+ do_action('wp_reset_drop_custom_tables', $custom_tables);
807
+
808
  return sizeof($custom_tables);
809
  } // do_drop_custom_tables
810
 
826
  $htaccess_path = $this->get_htaccess_path();
827
  clearstatcache();
828
 
829
+ do_action('wp_reset_delete_htaccess', $htaccess_path);
830
+
831
  if (!$wp_filesystem->is_readable($htaccess_path)) {
832
  return new WP_Error(1, 'Htaccess file does not exist; there\'s nothing to delete.');
833
  }
884
  if ($tool == 'delete_transients') {
885
  $cnt = $this->do_delete_transients();
886
  wp_send_json_success($cnt);
887
+ } elseif ($tool == 'reset_theme_options') {
888
+ $cnt = $this->do_reset_theme_options(true);
889
+ wp_send_json_success($cnt);
890
  } elseif ($tool == 'delete_themes') {
891
  $cnt = $this->do_delete_themes(false);
892
  wp_send_json_success($cnt);
1272
  $notice_shown = true;
1273
  }
1274
 
1275
+ // Product Hunt banner
1276
+ if (
1277
+ false
1278
+ && false == $this->get_dismissed_notices('product-hunt')
1279
+ && current_time('mysql', false) >= '2019-04-26'
1280
+ && current_time('mysql', false) <= '2019-05-03'
1281
+ ) {
1282
+ echo '<div class="card notice-wrapper product-hunt"><a title="Check out WP Reset on Product Hunt" href="' . $this->generate_web_link('ph-banner', '/product-hunt-redirect/') . '" target="_blank">';
1283
+ echo '<img src="' . $this->plugin_url . '/img/product-hunt.png" title="Check out WP Reset on Product Hunt" alt="Check out WP Reset on Product Hunt"> ';
1284
+ echo '<h2>' . __('We\'re on <b>Product Hunt</b> this week! Come check out your favorite dev tool &amp; show support ;) <i>Thanks!</i>', 'wp-reset') . '</h2>';
1285
+ echo '</a>';
1286
+ echo '<a href="#" title="Dismiss notice" class="wpr-dismiss-notice dismiss-notice" data-notice="product-hunt"><span class="dashicons dashicons-no"></span></a>';
1287
+ echo '</div>';
1288
+ $notice_shown = true;
1289
+ }
1290
+
1291
  // tabs
1292
  echo '<div id="wp-reset-tabs" class' . __('="', 'wp-reset') . 'ui-tabs">';
1293
 
1295
  echo '<li><a href="#tab-reset">' . __('Reset', 'wp-reset') . '</a></li>';
1296
  echo '<li><a href="#tab-tools">' . __('Tools', 'wp-reset') . '</a></li>';
1297
  echo '<li><a href="#tab-snapshots">' . __('DB Snapshots', 'wp-reset') . '</a></li>';
1298
+ echo '<li><a href="#tab-collections">' . __('Collections', 'wp-reset') . '</a></li>';
1299
  echo '<li><a href="#tab-support">' . __('Support', 'wp-reset') . '</a></li>';
1300
  echo '</ul>';
1301
 
1311
  $this->tab_snapshots();
1312
  echo '</div>';
1313
 
1314
+ echo '<div style="display: none;" id="tab-collections">';
1315
+ $this->tab_collections();
1316
+ echo '</div>';
1317
+
1318
  echo '<div style="display: none;" id="tab-support">';
1319
  $this->tab_support();
1320
  echo '</div>';
1441
 
1442
  echo '<b>' . __('WP-CLI Support', 'wp-reset') . '</b>';
1443
  echo '<p>' . sprintf(__('All tools available via GUI are available in WP-CLI as well. To get the list of commands run %s. Instead of the active user, the first user with admin privileges found in the database will be restored. ', 'wp-reset'), '<code>wp help reset</code>');
1444
+ echo sprintf(__('All actions have to be confirmed. If you want to skip confirmation use the standard %s option. Please be careful - there is NO UNDO.', 'wp-reset'), '<code>--yes</code>') . '</p>';
1445
 
1446
  echo '<b>' . __('WP Webhooks Support', 'wp-reset') . '</b>';
1447
  echo '<p>All WP Reset tools are integrated with <a href="https://wordpress.org/plugins/wp-webhooks/" target="_blank">WP Webhooks</a> and available as (receive data) actions. Webhooks are a standard, platform-independent way of connecting WordPress to any 3rd party system. This <a href="https://underconstructionpage.com/wp-webhooks-connect-integrate-wordpress/" target="_blank">article</a> has more info, videos and use-cases so you can see just how powerful and easy to use webhooks are.<br>';
1488
  */
1489
  private function tab_tools()
1490
  {
 
 
1491
  echo '<div class="card">';
1492
  echo '<h2>' . __('Delete Transients', 'wp-reset') . '</h2>';
1493
  echo '<p>' . __('All transient related database entries will be deleted. Including expired and non-expired transients, and orphaned transient timeout entries.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1507
  }
1508
  echo '</div>';
1509
 
1510
+ echo '<div class="card">';
1511
+ echo '<h2>' . __('Reset Theme Options', 'wp-reset') . '</h2>';
1512
+ echo '<p>' . __('All options (mods) for all themes will be reset; not just for the active theme. The tool works only for themes that use the <a href="https://codex.wordpress.org/Theme_Modification_API" target="_blank">WordPress theme modification API</a>. If options are saved in some other, custom way they won\'t be reset.<br><b>There is NO UNDO. WP Reset does not make any backups.</b>', 'wp-reset') . '</p>';
1513
+ echo '<p><a data-btn-confirm="Reset theme options" data-text-wait="Resetting theme options. Please wait." data-text-confirm="All options (mods) for all themes will be reset. There is NO UNDO. WP Reset will not make any backups." data-text-done="Options for %n themes have been reset." data-text-done-singular="Options for one theme have been reset." class="button button-delete" href="#" id="reset-theme-options">Reset theme options</a></p>';
1514
+ echo '</div>';
1515
+
1516
  $theme = wp_get_theme();
1517
 
1518
  echo '<div class="card">';
1527
  echo '<p><a data-btn-confirm="Delete plugins" data-text-wait="Deleting plugins. Please wait." data-text-confirm="All plugins except WP Reset will be deleted. There is NO UNDO. WP Reset will not make any backups." data-text-done="%n plugins have been deleted." data-text-done-singular="One plugin has been deleted." class="button button-delete" href="#" id="delete-plugins">Delete plugins</a></p>';
1528
  echo '</div>';
1529
 
1530
+ global $wpdb;
1531
  $custom_tables = $this->get_custom_tables();
1532
 
1533
  echo '<div class="card">';
1564
  } // tab_tools
1565
 
1566
 
1567
+ /**
1568
+ * Echoes content for collections tab
1569
+ *
1570
+ * @return null
1571
+ */
1572
+ private function tab_collections()
1573
+ {
1574
+ echo '<div class="card">';
1575
+ echo '<h2>' . __('What are Plugin &amp; Theme Collections', 'wp-reset') . '</h2>';
1576
+ echo '<p>' . __('Another tools that will save your precious time! Have a set of plugins and themes that you install and activate after every reset? Or on every fresh WP installation? Well, no more clicking install/active for five minutes! Build the collection once and install it with one click the next time you need it. Collections are stored in the cloud so they\'re accessible on every site.', 'wp-reset') . '</p>';
1577
+ echo '</div>';
1578
+
1579
+ echo '<div class="card">';
1580
+ echo '<h2>' . __('So where do I click?!', 'wp-reset') . '</h2>';
1581
+ echo '<p>' . __('We are working hard on building collections as we speak and plan to have a beta version done by late May. Want to be the first to try the beta? Or tell us to code faster? :) Give us a shout <a href="https://twitter.com/webfactoryltd" target="_blank">@webfactoryltd</a>.', 'wp-reset') . '</p>';
1582
+ echo '</div>';
1583
+ } // tab_collections
1584
+
1585
+
1586
  /**
1587
  * Echoes content for support tab
1588
  *
1590
  */
1591
  private function tab_support()
1592
  {
1593
+ echo '<div class="card">';
1594
+ echo '<h2>' . __('Documentation', 'wp-reset') . '</h2>';
1595
+ echo '<p>' . __('All tools and functions are explained in detail in <a href="' . $this->generate_web_link('support-tab', '/documentation/') . '" target="_blank">the documentation</a>. We did our best to describe how things work on both the code level and a "average user" level.', 'wp-reset') . '</p>';
1596
+ echo '</div>';
1597
+
1598
  echo '<div class="card">';
1599
  echo '<h2>' . __('Public support forum', 'wp-reset') . '</h2>';
1600
  echo '<p>' . __('We are very active on the <a href="https://wordpress.org/support/plugin/wp-reset" target="_blank">official WP Reset support forum</a>. If you found a bug, have a feature idea or just want to say hi - please drop by. We love to hear back from our users.', 'wp-reset') . '</p>';
1607
 
1608
  echo '<div class="card">';
1609
  echo '<h2>' . __('Care to help out?', 'wp-reset') . '</h2>';
1610
+ echo '<p>' . __('No need for donations or anything like that :) If you can give us a <a href="https://wordpress.org/support/plugin/wp-reset/reviews/#new-post" target="_blank">five star rating</a> you\'ll help out more than you can imagine. A public mention <a href="https://twitter.com/webfactoryltd" target="_blank">@webfactoryltd</a> also does wonders. Thank you!', 'wp-reset') . '</p>';
1611
  echo '</div>';
1612
  } // tab_support
1613
 
1627
  echo '<h2>' . __('Database Snapshots', 'wp-reset') . '</h2>';
1628
  echo '<p>A snapshot is a copy of all WP database tables, standard and custom ones, saved in your database. Files are not saved or included in snapshots in any way.<br>
1629
  Snapshots are primarily a development tool. Although they can be used for backups (and downloaded), we suggest finding a more suitable tool for live sites, such as <a href="https://wordpress.org/plugins/updraftplus/" target="_blank">UpdraftPlus</a>. Use snapshots to find out what changes a plugin made to your database or to quickly restore the dev environment after testing database related changes.<br>Restoring a snapshot does not affect other snapshots, or WP Reset settings.</p>';
 
1630
 
1631
  $table_status = $wpdb->get_results('SHOW TABLE STATUS');
1632
  if (is_array($table_status)) {
1849
  return new WP_Error(1, 'Can\'t get table status data.');
1850
  }
1851
 
1852
+ $snapshot['tbl_core'] = $tbl_core;
1853
  $snapshot['tbl_custom'] = $tbl_custom;
1854
+ $snapshot['tbl_rows'] = $tbl_rows;
1855
+ $snapshot['tbl_size'] = $tbl_size;
1856
 
1857
 
1858
  $snapshots[$uid] = $snapshot;
1859
  update_option('wp-reset-snapshots', $snapshots);
1860
 
1861
+ do_action('wp_reset_create_snapshot', $uid, $snapshot);
1862
+
1863
  return $snapshot;
1864
  } // create_snapshot
1865
 
1889
  $wpdb->query('DROP TABLE IF EXISTS ' . $table);
1890
  }
1891
 
1892
+ $snapshot_copy = $snapshots[$uid];
1893
  unset($snapshots[$uid]);
1894
  update_option('wp-reset-snapshots', $snapshots);
1895
 
1896
+ do_action('wp_reset_delete_snapshot', $uid, $snapshot_copy);
1897
+
1898
  return true;
1899
  } // delete_snapshot
1900
 
1908
  */
1909
  function do_export_snapshot($uid = '')
1910
  {
 
1911
  $snapshots = $this->get_snapshots();
1912
 
1913
  if (strlen($uid) != 6) {
1938
  return new WP_Error(1, "Couldn't dump snapshot: " . $e->getMessage());
1939
  }
1940
 
1941
+ do_action('wp_reset_export_snapshot', 'wp-reset-snapshot-' . $uid . '.sql.gz');
1942
+
1943
  return 'wp-reset-snapshot-' . $uid . '.sql.gz';
1944
  } // export_snapshot
1945
 
2000
  update_option('wp-reset', $this->options);
2001
  update_option('wp-reset-snapshots', $snapshots);
2002
 
2003
+ do_action('wp_reset_restore_snapshot', $uid);
2004
+
2005
  return true;
2006
  } // restore_snapshot
2007
 
2067
  function do_compare_snapshots($uid)
2068
  {
2069
  global $wpdb;
 
2070
  $current = $snapshot = array();
2071
  $out = $out2 = $out3 = '';
2072