bbp_admin_reset_handler ()

处理管理工具页面的处理和反馈

描述

文件:bp-forums / admin / tools.php

function bbp_admin_reset_handler(){//如果没有重置if (!bbp_is_post_request() || empty($_POST['bbpress-are-you-sure'])) return;//如果(!bbp_is_user_keymaster())返回;check_admin_referer(“bbpress-reset”);全球wpdb美元;//存储消息$messages = array();$failed = __(' failed ', 'buddyboss');$success = __('成功!”、“buddyboss”);//刷新缓存; things are about to get ugly. wp_cache_flush(); /** Posts *****************************************************************/ $statement = __( 'Deleting Posts… %s', 'buddyboss' ); $sql_posts = $wpdb->get_results( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN ('forum', 'topic', 'reply')", OBJECT_K ); $sql_delete = "DELETE FROM `{$wpdb->posts}` WHERE `post_type` IN ('forum', 'topic', 'reply')"; $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; $messages[] = sprintf( $statement, $result ); /** Post Meta *************************************************************/ if ( !empty( $sql_posts ) ) { $sql_meta = array(); foreach ( $sql_posts as $key => $value ) { $sql_meta[] = $key; } $statement = __( 'Deleting Post Meta… %s', 'buddyboss' ); $sql_meta = implode( "', '", $sql_meta ); $sql_delete = "DELETE FROM `{$wpdb->postmeta}` WHERE `post_id` IN ('{$sql_meta}');"; $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; $messages[] = sprintf( $statement, $result ); } /** Topic Tags ************************************************************/ $statement = __( 'Deleting Discussions Tags… %s', 'buddyboss' ); $sql_delete = "DELETE a,b,c FROM `{$wpdb->terms}` AS a LEFT JOIN `{$wpdb->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$wpdb->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag';"; $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; $messages[] = sprintf( $statement, $result ); /** User ******************************************************************/ // Delete users if ( !empty( $_POST['bbpress-delete-imported-users'] ) ) { $sql_users = $wpdb->get_results( "SELECT `user_id` FROM `{$wpdb->usermeta}` WHERE `meta_key` = '_bbp_user_id'", OBJECT_K ); if ( !empty( $sql_users ) ) { $sql_meta = array(); foreach ( $sql_users as $key => $value ) { $sql_meta[] = $key; } $statement = __( 'Deleting User… %s', 'buddyboss' ); $sql_meta = implode( "', '", $sql_meta ); $sql_delete = "DELETE FROM `{$wpdb->users}` WHERE `ID` IN ('{$sql_meta}');"; $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; $messages[] = sprintf( $statement, $result ); $statement = __( 'Deleting User Meta… %s', 'buddyboss' ); $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `user_id` IN ('{$sql_meta}');"; $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; $messages[] = sprintf( $statement, $result ); } // Delete imported user metadata } else { $statement = __( 'Deleting User Meta… %s', 'buddyboss' ); $sql_delete = "DELETE FROM `{$wpdb->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%';"; $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; $messages[] = sprintf( $statement, $result ); } /** Converter *************************************************************/ $statement = __( 'Deleting Conversion Table… %s', 'buddyboss' ); $table_name = $wpdb->prefix . 'bbp_converter_translator'; if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) { $wpdb->query( "DROP TABLE {$table_name}" ); $result = $success; } else { $result = $failed; } $messages[] = sprintf( $statement, $result ); /** Options ***************************************************************/ $statement = __( 'Deleting Settings… %s', 'buddyboss' ); bbp_delete_options(); $messages[] = sprintf( $statement, $success ); /** Roles *****************************************************************/ $statement = __( 'Deleting Roles and Capabilities… %s', 'buddyboss' ); remove_role( bbp_get_moderator_role() ); remove_role( bbp_get_participant_role() ); bbp_remove_caps(); $messages[] = sprintf( $statement, $success ); /** Output ****************************************************************/ if ( count( $messages ) ) { foreach ( $messages as $message ) { bbp_admin_tools_feedback( $message ); } } }

更新日志

更新日志
版本 描述
bbPress (r2613) 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队