bbp_admin_repair_topic_meta()
Recaches the topic for each post
Description
Return
(array) An array of the status code and the message
Source
File: bp-forums/admin/tools.php
1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | function bbp_admin_repair_topic_meta() { global $wpdb ; $statement = __( 'Recalculating the discussion for each post … %s' , 'buddyboss' ); $result = __( 'Failed!' , 'buddyboss' ); // First, delete everything. if ( is_wp_error( $wpdb ->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` = '_bbp_topic_id';" ) ) ) return array ( 1, sprintf( $statement , $result ) ); // Next, give all the topics with replies the ID their last reply. if ( is_wp_error( $wpdb ->query( "INSERT INTO ` $wpdb ->postmeta` (`post_id`, `meta_key`, `meta_value`) ( SELECT `topic`.`ID`, '_bbp_topic_id' , `topic`.`ID` FROM ` $wpdb ->posts` AS `topic` WHERE `topic`.`post_type` = 'topic' GROUP BY `topic`.`ID` );" ) ) ) return array ( 3, sprintf( $statement , $result ) ); // Next, give all the topics with replies the ID their last reply. if ( is_wp_error( $wpdb ->query( "INSERT INTO ` $wpdb ->postmeta` (`post_id`, `meta_key`, `meta_value`) ( SELECT `reply`.`ID`, '_bbp_topic_id' , `topic`.`ID` FROM ` $wpdb ->posts` AS `reply` INNER JOIN ` $wpdb ->posts` AS `topic` ON `reply`.`post_parent` = `topic`.`ID` WHERE `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply' GROUP BY `reply`.`ID` );" ) ) ) return array ( 4, sprintf( $statement , $result ) ); // Complete results return array ( 0, sprintf( $statement , __( 'Complete!' , 'buddyboss' ) ) ); } |
Changelog
Version | Description |
---|---|
bbPress (r3876) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.