| 291 | | 25 => array( 'bbp-group-forums', __( 'Repair BuddyPress Group Forum relationships', 'bbpress' ), 'bbp_admin_repair_group_forum_relationship' ), |
| 292 | | 30 => array( 'bbp-forum-topics', __( 'Count topics in each forum', 'bbpress' ), 'bbp_admin_repair_forum_topic_count' ), |
| 293 | | 35 => array( 'bbp-forum-replies', __( 'Count replies in each forum', 'bbpress' ), 'bbp_admin_repair_forum_reply_count' ), |
| 294 | | 40 => array( 'bbp-topic-replies', __( 'Count replies in each topic', 'bbpress' ), 'bbp_admin_repair_topic_reply_count' ), |
| 295 | | 45 => array( 'bbp-topic-voices', __( 'Count voices in each topic', 'bbpress' ), 'bbp_admin_repair_topic_voice_count' ), |
| 296 | | 50 => array( 'bbp-topic-hidden-replies', __( 'Count spammed & trashed replies in each topic', 'bbpress' ), 'bbp_admin_repair_topic_hidden_reply_count' ), |
| 297 | | 55 => array( 'bbp-user-topics', __( 'Count topics for each user', 'bbpress' ), 'bbp_admin_repair_user_topic_count' ), |
| 298 | | 60 => array( 'bbp-user-replies', __( 'Count replies for each user', 'bbpress' ), 'bbp_admin_repair_user_reply_count' ), |
| 299 | | 65 => array( 'bbp-user-favorites', __( 'Remove trashed topics from user favorites', 'bbpress' ), 'bbp_admin_repair_user_favorites' ), |
| 300 | | 70 => array( 'bbp-user-topic-subscriptions', __( 'Remove trashed topics from user subscriptions', 'bbpress' ), 'bbp_admin_repair_user_topic_subscriptions' ), |
| 301 | | 75 => array( 'bbp-user-forum-subscriptions', __( 'Remove trashed forums from user subscriptions', 'bbpress' ), 'bbp_admin_repair_user_forum_subscriptions' ), |
| 302 | | 80 => array( 'bbp-user-role-map', __( 'Remap existing users to default forum roles', 'bbpress' ), 'bbp_admin_repair_user_roles' ) |
| | 291 | 25 => array( 'bbp-sync-all-topics-closed', __( 'Recalculate imported closed topics', 'bbpress' ), 'bbp_admin_repair_closed' ), |
| | 292 | 30 => array( 'bbp-group-forums', __( 'Repair BuddyPress Group Forum relationships', 'bbpress' ), 'bbp_admin_repair_group_forum_relationship' ), |
| | 293 | 35 => array( 'bbp-forum-topics', __( 'Count topics in each forum', 'bbpress' ), 'bbp_admin_repair_forum_topic_count' ), |
| | 294 | 40 => array( 'bbp-forum-replies', __( 'Count replies in each forum', 'bbpress' ), 'bbp_admin_repair_forum_reply_count' ), |
| | 295 | 45 => array( 'bbp-topic-replies', __( 'Count replies in each topic', 'bbpress' ), 'bbp_admin_repair_topic_reply_count' ), |
| | 296 | 50 => array( 'bbp-topic-voices', __( 'Count voices in each topic', 'bbpress' ), 'bbp_admin_repair_topic_voice_count' ), |
| | 297 | 55 => array( 'bbp-topic-hidden-replies', __( 'Count spammed & trashed replies in each topic', 'bbpress' ), 'bbp_admin_repair_topic_hidden_reply_count' ), |
| | 298 | 60 => array( 'bbp-user-topics', __( 'Count topics for each user', 'bbpress' ), 'bbp_admin_repair_user_topic_count' ), |
| | 299 | 65 => array( 'bbp-user-replies', __( 'Count replies for each user', 'bbpress' ), 'bbp_admin_repair_user_reply_count' ), |
| | 300 | 70 => array( 'bbp-user-favorites', __( 'Remove trashed topics from user favorites', 'bbpress' ), 'bbp_admin_repair_user_favorites' ), |
| | 301 | 75 => array( 'bbp-user-topic-subscriptions', __( 'Remove trashed topics from user subscriptions', 'bbpress' ), 'bbp_admin_repair_user_topic_subscriptions' ), |
| | 302 | 80 => array( 'bbp-user-forum-subscriptions', __( 'Remove trashed forums from user subscriptions', 'bbpress' ), 'bbp_admin_repair_user_forum_subscriptions' ), |
| | 303 | 85 => array( 'bbp-user-role-map', __( 'Remap existing users to default forum roles', 'bbpress' ), 'bbp_admin_repair_user_roles' ) |
| | 1156 | * Repairs closed topics postmeta publish _bbp_status |
| | 1157 | * |
| | 1158 | * @since bbPress (rXXXX) |
| | 1159 | * |
| | 1160 | * @uses wpdb::get_col() To run our recount sql queries |
| | 1161 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| | 1162 | * @uses bbp_get_topic_post_type() To get the topic post type |
| | 1163 | * @uses get_post_meta() To get the sticky topics |
| | 1164 | * @uses update_post_meta To update the topics sticky post meta |
| | 1165 | * @return array An array of the status code and the message |
| | 1166 | */ |
| | 1167 | function bbp_admin_repair_closed() { |
| | 1168 | global $wpdb; |
| | 1169 | |
| | 1170 | $statement = __( 'Repairing the closed topic status relationships… %s', 'bbpress' ); |
| | 1171 | $result = __( 'Failed!', 'bbpress' ); |
| | 1172 | $closed_topics = $wpdb->get_col( "SELECT ID FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'closed';" ); |
| | 1173 | |
| | 1174 | // Bail if no closed topics found |
| | 1175 | if ( empty( $closed_topics ) || is_wp_error( $closed_topics ) ) |
| | 1176 | return array( 1, sprintf( $statement, $result ) ); |
| | 1177 | |
| | 1178 | // Loop through each closed topic |
| | 1179 | foreach ( $closed_topics as $closed_topic ) { |
| | 1180 | |
| | 1181 | // Check if the closed topic already has a postmeta _bbp_status value |
| | 1182 | $topic_status = get_post_meta( $closed_topic, '_bbp_status', true ); |
| | 1183 | |
| | 1184 | // If we don't have a postmeta _bbp_status value |
| | 1185 | if( empty($topic_status) ) { |
| | 1186 | update_post_meta($closed_topic, '_bbp_status', 'publish'); |
| | 1187 | ++$changed; // Keep a count to display at the end |
| | 1188 | } |
| | 1189 | } |
| | 1190 | |
| | 1191 | // Cleanup |
| | 1192 | unset( $closed_topics, $closed_topic, $topic_status ); |
| | 1193 | |
| | 1194 | // Complete results |
| | 1195 | $result = sprintf( __( 'Complete! %s closed topics updated.', 'bbpress' ), bbp_number_format( $changed ) ); |
| | 1196 | return array( 0, sprintf( $statement, $result ) ); |
| | 1197 | } |
| | 1198 | |
| | 1199 | /** |