bbp_admin_repair_handler()
Handle the processing and feedback of the admin tools page
Description Description
Source Source
File: includes/admin/tools/common.php
function bbp_admin_repair_handler() {
// Bail if not an actionable request
if ( ! bbp_is_get_request() ) {
return;
}
// Get the current action or bail
if ( ! empty( $_GET['action'] ) ) {
$action = sanitize_key( $_GET['action'] );
} elseif ( ! empty( $_GET['action2'] ) ) {
$action = sanitize_key( $_GET['action2'] );
} else {
return;
}
// Bail if not running an action
if ( 'run' !== $action ) {
return;
}
check_admin_referer( 'bbpress-do-counts' );
// Parse list of checked repairs
$checked = ! empty( $_GET['checked'] )
? array_map( 'sanitize_key', $_GET['checked'] )
: array();
// Flush all caches before running tools
wp_cache_flush();
// Get the list
$list = bbp_get_admin_repair_tools();
// Stores messages
$messages = array();
// Run through checked repair tools
if ( count( $checked ) ) {
foreach ( $checked as $item_id ) {
if ( isset( $list[ $item_id ] ) && is_callable( $list[ $item_id ]['callback'] ) ) {
$messages[] = call_user_func( $list[ $item_id ]['callback'] );
// Remove from pending
bbp_remove_pending_upgrade( $item_id );
}
}
}
// Feedback
if ( count( $messages ) ) {
foreach ( $messages as $message ) {
bbp_admin_tools_feedback( $message[1] );
}
}
// Flush all caches after running tools
wp_cache_flush();
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |