Changeset 3349913
- Timestamp:
- 08/25/2025 07:15:23 PM (4 months ago)
- Location:
- db-reset-pro/trunk
- Files:
-
- 2 edited
-
db-reset-pro.php (modified) (11 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
db-reset-pro/trunk/db-reset-pro.php
r3296413 r3349913 5 5 * Description: Safely resets the WordPress database back to defaults. Deletes all customizations and content. Does not modify files, only resets the database. Tools > DB Reset Pro 6 6 * Author: Duplicator 7 * Version: 1.0. 08 * Author URI: https://duplicator.com 7 * Version: 1.0.1 8 * Author URI: https://duplicator.com?utm_source=db-reset-pro&utm_medium=plugin-header&utm_campaign=author-link 9 9 * Text Domain: db-reset-pro 10 10 * Requires at least: 5.0 … … 25 25 26 26 // Define constants. 27 define( 'DUP_DB_RESET_PRO_VERSION', '1.0. 0' );27 define( 'DUP_DB_RESET_PRO_VERSION', '1.0.1' ); 28 28 define( 'DUP_DB_RESET_PRO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 29 29 define( 'DUP_DB_RESET_PRO_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); … … 33 33 * Main DB Reset Pro Class. 34 34 * 35 * @since 2.0.035 * @since 1.0.0 36 36 */ 37 37 class DUP_DB_Reset_Pro { … … 93 93 // Add settings link. 94 94 add_filter( 'plugin_action_links_' . DUP_DB_RESET_PRO_PLUGIN_BASENAME, array( $this, 'add_settings_link' ) ); 95 96 // Review request functionality. 97 add_action( 'admin_notices', array( $this, 'maybe_show_review_notice' ) ); 98 add_action( 'wp_ajax_dup_db_reset_pro_review_action', array( $this, 'handle_review_action' ) ); 95 99 } 96 100 … … 121 125 ); 122 126 wp_enqueue_style( 'dup-db-reset-pro-admin' ); 127 128 // Enqueue thickbox for plugin install modal. 129 add_thickbox(); 123 130 } 124 131 … … 339 346 $this->enable_user_hooks(); 340 347 341 // Auto-reactivate this plugin if constant is defined.342 if ( defined( 'REACTIVATE_DUP_DB_RESET_PRO' ) && constant( 'REACTIVATE_DUP_DB_RESET_PRO' ) === true ) {348 // Auto-reactivate this plugin by default, unless constant is set to false. 349 if ( ! defined( 'REACTIVATE_DUP_DB_RESET_PRO' ) || constant( 'REACTIVATE_DUP_DB_RESET_PRO' ) !== false ) { 343 350 activate_plugin( DUP_DB_RESET_PRO_PLUGIN_BASENAME ); 344 351 } … … 369 376 wp_clear_auth_cookie(); 370 377 wp_set_auth_cookie( $user_id ); 378 379 // Increment reset count for review request. 380 $reset_count = get_option( 'dup_db_reset_pro_reset_count', 0 ); 381 update_option( 'dup_db_reset_pro_reset_count', $reset_count + 1 ); 371 382 372 383 // Redirect to admin with reset notice and nonce. … … 705 716 706 717 /** 718 * Maybe show review notice after successful resets. 719 */ 720 public function maybe_show_review_notice() { 721 // Check if user can manage options. 722 if ( ! current_user_can( 'manage_options' ) ) { 723 return; 724 } 725 726 // Check if we're on an admin page (not admin-ajax). 727 if ( wp_doing_ajax() ) { 728 return; 729 } 730 731 // Get review status. 732 $review_status = get_option( 'dup_db_reset_pro_review_status', '' ); 733 734 // If already reviewed or dismissed, don't show. 735 if ( in_array( $review_status, array( 'reviewed', 'dismissed' ), true ) ) { 736 return; 737 } 738 739 // Check if snoozed. 740 if ( 'snoozed' === $review_status ) { 741 $snooze_until = get_option( 'dup_db_reset_pro_review_snooze_until', 0 ); 742 $snooze_reset_count = get_option( 'dup_db_reset_pro_review_snooze_reset_count', 0 ); 743 $current_reset_count = get_option( 'dup_db_reset_pro_reset_count', 0 ); 744 745 // Still snoozed if time hasn't passed AND reset count hasn't been reached. 746 if ( time() < $snooze_until && $current_reset_count < $snooze_reset_count ) { 747 return; 748 } 749 750 // Clear snooze status if conditions are met. 751 update_option( 'dup_db_reset_pro_review_status', '' ); 752 } 753 754 // Check reset count. 755 $reset_count = get_option( 'dup_db_reset_pro_reset_count', 0 ); 756 if ( $reset_count < 3 ) { 757 return; 758 } 759 760 // Show the notice. 761 ?> 762 <div class="notice notice-info is-dismissible" id="dup-db-reset-pro-review-notice"> 763 <p> 764 <strong><?php esc_html_e( 'Enjoying DB Reset Pro?', 'db-reset-pro' ); ?></strong><br> 765 <?php 766 printf( 767 /* translators: %d: number of resets */ 768 esc_html__( 'Hey! You\'ve successfully reset your database %d times. Would you mind taking a moment to share your experience with a quick review? It really helps us spread the word and improve the plugin.', 'db-reset-pro' ), 769 intval( $reset_count ) 770 ); 771 ?> 772 </p> 773 <p> 774 <a href="#" class="button button-primary" data-action="review"> 775 <?php esc_html_e( 'Sure, I\'ll leave a review', 'db-reset-pro' ); ?> 776 </a> 777 <a href="#" class="button" data-action="snooze"> 778 <?php esc_html_e( 'Maybe later', 'db-reset-pro' ); ?> 779 </a> 780 <a href="#" class="button-link" data-action="dismiss"> 781 <?php esc_html_e( 'I already did', 'db-reset-pro' ); ?> 782 </a> 783 </p> 784 </div> 785 <script> 786 jQuery(document).ready(function($) { 787 $('#dup-db-reset-pro-review-notice a').on('click', function(e) { 788 e.preventDefault(); 789 var action = $(this).data('action'); 790 791 // If review, open in new tab first. 792 if (action === 'review') { 793 window.open('https://wordpress.org/support/plugin/db-reset-pro/reviews/?filter=5#new-post', '_blank'); 794 } 795 796 // Send AJAX request. 797 $.post(ajaxurl, { 798 action: 'dup_db_reset_pro_review_action', 799 review_action: action, 800 _wpnonce: '<?php echo esc_js( wp_create_nonce( 'dup_db_reset_pro_review_nonce' ) ); ?>' 801 }); 802 803 // Hide the notice. 804 $('#dup-db-reset-pro-review-notice').fadeOut(); 805 }); 806 }); 807 </script> 808 <?php 809 } 810 811 /** 812 * Handle review notice actions via AJAX. 813 */ 814 public function handle_review_action() { 815 // Verify nonce. 816 if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'dup_db_reset_pro_review_nonce' ) ) { 817 wp_die(); 818 } 819 820 // Check capability. 821 if ( ! current_user_can( 'manage_options' ) ) { 822 wp_die(); 823 } 824 825 // Get the action. 826 $review_action = isset( $_POST['review_action'] ) ? sanitize_key( $_POST['review_action'] ) : ''; 827 828 switch ( $review_action ) { 829 case 'review': 830 update_option( 'dup_db_reset_pro_review_status', 'reviewed' ); 831 break; 832 case 'snooze': 833 update_option( 'dup_db_reset_pro_review_status', 'snoozed' ); 834 // Snooze for 30 days or 5 more resets, whichever comes first. 835 update_option( 'dup_db_reset_pro_review_snooze_until', time() + ( 30 * DAY_IN_SECONDS ) ); 836 $current_count = get_option( 'dup_db_reset_pro_reset_count', 0 ); 837 update_option( 'dup_db_reset_pro_review_snooze_reset_count', $current_count + 5 ); 838 break; 839 case 'dismiss': 840 update_option( 'dup_db_reset_pro_review_status', 'dismissed' ); 841 break; 842 } 843 844 wp_die(); 845 } 846 847 /** 707 848 * Render the admin page. 708 849 */ … … 714 855 715 856 // Get active plugins that can be reactivated. 716 $auto_reactivate = defined( 'REACTIVATE_DUP_DB_RESET_PRO' ) && constant( 'REACTIVATE_DUP_DB_RESET_PRO' ) === true;857 $auto_reactivate = ! defined( 'REACTIVATE_DUP_DB_RESET_PRO' ) || constant( 'REACTIVATE_DUP_DB_RESET_PRO' ) !== false; 717 858 718 859 // Get additional plugins to reactivate. … … 783 924 <?php if ( $auto_reactivate ) : ?> 784 925 <?php esc_html_e( 'This plugin will be automatically reactivated after the reset.', 'db-reset-pro' ); ?> 785 <?php else : ?>786 <?php esc_html_e( 'This plugin will NOT be automatically reactivated after the reset.', 'db-reset-pro' ); ?>787 926 <br> 788 927 <?php 789 928 printf( 790 929 /* translators: %1$s: code to add, %2$s: filename */ 791 esc_html__( 'To enable auto-reactivation, add %1$s to your %2$s file:', 'db-reset-pro' ),792 '<code>define( \'REACTIVATE_DUP_DB_RESET_PRO\', true );</code>',930 esc_html__( 'To disable auto-reactivation, add %1$s to your %2$s file:', 'db-reset-pro' ), 931 '<code>define( \'REACTIVATE_DUP_DB_RESET_PRO\', false );</code>', 793 932 '<code>wp-config.php</code>' 794 933 ); 795 934 ?> 935 <?php else : ?> 936 <?php esc_html_e( 'This plugin will NOT be automatically reactivated after the reset.', 'db-reset-pro' ); ?> 796 937 <?php endif; ?> 797 938 </p> … … 856 997 <h2><?php esc_html_e( 'Reset Summary', 'db-reset-pro' ); ?></h2> 857 998 999 <div class="dup-db-reset-pro-summary-item" style="background: #f0f8ff; padding: 15px; border-left: 4px solid #2271b1; margin-bottom: 20px;"> 1000 <p style="margin: 0;"> 1001 <strong>💡 <?php esc_html_e( 'Pro Tip:', 'db-reset-pro' ); ?></strong> 1002 <?php 1003 $duplicator_install_url = admin_url( 'plugin-install.php?s=duplicator&tab=plugin-information&plugin=duplicator&TB_iframe=true&width=772&height=550' ); 1004 printf( 1005 /* translators: %s: Duplicator link */ 1006 esc_html__( 'Create a backup before resetting in case you need to restore later. We recommend %s for quick backups and migrations.', 'db-reset-pro' ), 1007 '<a href="' . esc_url( $duplicator_install_url ) . '" class="thickbox open-plugin-details-modal">' . esc_html__( 'Duplicator', 'db-reset-pro' ) . '</a>' 1008 ); 1009 ?> 1010 </p> 1011 </div> 1012 858 1013 <div class="dup-db-reset-pro-summary-item"> 859 1014 <h3 class="dup-db-reset-pro-danger-heading"><?php esc_html_e( 'What will be reset', 'db-reset-pro' ); ?></h3> -
db-reset-pro/trunk/readme.txt
r3327686 r3349913 1 1 === Database Reset Pro - Clean & Reset WordPress Database === 2 2 Contributors: seedprod, smub 3 Donate Link: https://duplicator.com 3 Donate Link: https://duplicator.com?utm_source=db-reset-pro&utm_medium=readme&utm_campaign=donate-link 4 4 Tags: database reset, reset database, wordpress reset, database cleaner, clean database 5 5 Requires at least: 5.0 6 6 Tested up to: 6.8 7 7 Requires PHP: 7.4 8 Stable tag: 1.0. 08 Stable tag: 1.0.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 121 121 While we keep the interface simple, developers can access advanced features through wp-config.php: 122 122 123 ** Auto-Reactivate This Plugin:**124 ``` 125 define( 'REACTIVATE_DUP_DB_RESET_PRO', true );123 **Disable Auto-Reactivation (enabled by default):** 124 ``` 125 define( 'REACTIVATE_DUP_DB_RESET_PRO', false ); 126 126 ``` 127 127 … … 287 287 Database Reset Pro requires PHP 7.4 or higher for optimal performance and security. 288 288 289 = How can I havethis plugin auto-reactivate after reset? =290 291 Add this line to your wp-config.php file:292 `define( 'REACTIVATE_DUP_DB_RESET_PRO', true );`289 = Does this plugin auto-reactivate after reset? = 290 291 Yes, by default this plugin will automatically reactivate itself after a database reset. To disable auto-reactivation, add this line to your wp-config.php file: 292 `define( 'REACTIVATE_DUP_DB_RESET_PRO', false );` 293 293 294 294 = Can I have other plugins auto-reactivate as well? = … … 325 325 326 326 == Changelog == 327 328 = 1.0.1 = 329 * Plugin reactivates without constant 327 330 328 331 = 1.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.