Skip to:
Content

bbPress.org

Changeset 6750


Ignore:
Timestamp:
12/05/2017 09:18:19 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Admin: split reset handler into 2 functions (handler and logic)

This change improves compatibility with future WP CLI initiatives, specifically allowing removing all bbPress data.

Fixes #3173. Props espellcaste.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools/reset.php

    r6573 r6750  
    7777
    7878/**
    79  * Handle the processing and feedback of the admin tools page
     79 * Handle a bbPress admin area reset request.
    8080 *
    8181 * @since 2.0.0 bbPress (r2613)
     
    8383function bbp_admin_reset_handler() {
    8484
    85     // Bail if not resetting
     85    // Bail if not resetting.
    8686    if ( ! bbp_is_post_request() || empty( $_POST['bbpress-are-you-sure'] ) ) {
    8787        return;
    8888    }
    8989
    90     // Only keymasters can proceed
     90    // Only keymasters can proceed.
    9191    if ( ! bbp_is_user_keymaster() ) {
    9292        return;
    9393    }
    9494
     95    // Bail if not referred from resetter
    9596    check_admin_referer( 'bbpress-reset' );
    9697
    97     // Stores messages
     98    // Reset all of bbPress
     99    bbp_admin_reset_database();
     100}
     101
     102/**
     103 * Perform a bbPress database reset.
     104 *
     105 * @since 2.6.0 bbPress
     106 */
     107function bbp_admin_reset_database() {
     108
     109    // Stores messages.
    98110    $messages = array();
    99111    $failed   = esc_html__( 'Failed!',  'bbpress' );
     
    105117    /** Posts *****************************************************************/
    106118
    107     // Post types and status
     119    // Post types and status.
    108120    $fpt = bbp_get_forum_post_type();
    109121    $tpt = bbp_get_topic_post_type();
    110122    $rpt = bbp_get_reply_post_type();
    111123
    112     // Define variables
     124    // Define variables.
    113125    $bbp_db     = bbp_db();
    114126    $statement  = esc_html__( 'Deleting Posts… %s', 'bbpress' );
Note: See TracChangeset for help on using the changeset viewer.