Plugin Directory

Changeset 3349913


Ignore:
Timestamp:
08/25/2025 07:15:23 PM (4 months ago)
Author:
seedprod
Message:

Staging 1.0.1

Location:
db-reset-pro/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • db-reset-pro/trunk/db-reset-pro.php

    r3296413 r3349913  
    55 * 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
    66 * Author: Duplicator
    7  * Version: 1.0.0
    8  * 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
    99 * Text Domain: db-reset-pro
    1010 * Requires at least: 5.0
     
    2525
    2626// Define constants.
    27 define( 'DUP_DB_RESET_PRO_VERSION', '1.0.0' );
     27define( 'DUP_DB_RESET_PRO_VERSION', '1.0.1' );
    2828define( 'DUP_DB_RESET_PRO_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2929define( 'DUP_DB_RESET_PRO_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     
    3333 * Main DB Reset Pro Class.
    3434 *
    35  * @since 2.0.0
     35 * @since 1.0.0
    3636 */
    3737class DUP_DB_Reset_Pro {
     
    9393        // Add settings link.
    9494        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' ) );
    9599    }
    96100
     
    121125        );
    122126        wp_enqueue_style( 'dup-db-reset-pro-admin' );
     127       
     128        // Enqueue thickbox for plugin install modal.
     129        add_thickbox();
    123130    }
    124131
     
    339346            $this->enable_user_hooks();
    340347
    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 ) {
    343350                activate_plugin( DUP_DB_RESET_PRO_PLUGIN_BASENAME );
    344351            }
     
    369376            wp_clear_auth_cookie();
    370377            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 );
    371382
    372383            // Redirect to admin with reset notice and nonce.
     
    705716
    706717    /**
     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    /**
    707848     * Render the admin page.
    708849     */
     
    714855
    715856        // 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;
    717858       
    718859        // Get additional plugins to reactivate.
     
    783924                                    <?php if ( $auto_reactivate ) : ?>
    784925                                        <?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' ); ?>
    787926                                        <br>
    788927                                        <?php
    789928                                        printf(
    790929                                            /* 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>',
    793932                                            '<code>wp-config.php</code>'
    794933                                        );
    795934                                        ?>
     935                                    <?php else : ?>
     936                                        <?php esc_html_e( 'This plugin will NOT be automatically reactivated after the reset.', 'db-reset-pro' ); ?>
    796937                                    <?php endif; ?>
    797938                                </p>
     
    856997                        <h2><?php esc_html_e( 'Reset Summary', 'db-reset-pro' ); ?></h2>
    857998                       
     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                       
    8581013                        <div class="dup-db-reset-pro-summary-item">
    8591014                            <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  
    11=== Database Reset Pro - Clean & Reset WordPress Database ===
    22Contributors: seedprod, smub 
    3 Donate Link: https://duplicator.com
     3Donate Link: https://duplicator.com?utm_source=db-reset-pro&utm_medium=readme&utm_campaign=donate-link
    44Tags: database reset, reset database, wordpress reset, database cleaner, clean database
    55Requires at least: 5.0
    66Tested up to: 6.8
    77Requires PHP: 7.4
    8 Stable tag: 1.0.0
     8Stable tag: 1.0.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    121121While we keep the interface simple, developers can access advanced features through wp-config.php:
    122122
    123 **Auto-Reactivate This Plugin:**
    124 ```
    125 define( 'REACTIVATE_DUP_DB_RESET_PRO', true );
     123**Disable Auto-Reactivation (enabled by default):**
     124```
     125define( 'REACTIVATE_DUP_DB_RESET_PRO', false );
    126126```
    127127
     
    287287Database Reset Pro requires PHP 7.4 or higher for optimal performance and security.
    288288
    289 = How can I have this 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
     291Yes, 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 );`
    293293
    294294= Can I have other plugins auto-reactivate as well? =
     
    325325
    326326== Changelog ==
     327
     328= 1.0.1 =
     329* Plugin reactivates without constant
    327330
    328331= 1.0.0 =
Note: See TracChangeset for help on using the changeset viewer.