diff --git includes/admin/tools.php b/includes/admin/tools.php
index c0c1d6b..23f4d58 100644
|
|
function bbp_admin_repair_list() { |
186 | 186 | * |
187 | 187 | * @since bbPress (r2613) |
188 | 188 | * |
189 | | * @uses bbp_get_reply_post_type() To get the reply post type |
190 | 189 | * @uses wpdb::query() To run our recount sql queries |
191 | 190 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 191 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 192 | * @uses bbp_get_reply_post_type() To get the reply post type |
| 193 | * @uses bbp_get_public_status_id() To get the public status id |
| 194 | * @uses bbp_get_closed_status_id() To get the closed status id |
192 | 195 | * @return array An array of the status code and the message |
193 | 196 | */ |
194 | 197 | function bbp_admin_repair_topic_reply_count() { |
… |
… |
function bbp_admin_repair_topic_reply_count() { |
229 | 232 | * |
230 | 233 | * @since bbPress (r2613) |
231 | 234 | * |
232 | | * @uses bbp_get_reply_post_type() To get the reply post type |
233 | 235 | * @uses wpdb::query() To run our recount sql queries |
234 | 236 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 237 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 238 | * @uses bbp_get_reply_post_type() To get the reply post type |
| 239 | * @uses bbp_get_public_status_id() To get the public status id |
| 240 | * @uses bbp_get_closed_status_id() To get the closed status id |
235 | 241 | * @return array An array of the status code and the message |
236 | 242 | */ |
237 | 243 | function bbp_admin_repair_topic_voice_count() { |
… |
… |
function bbp_admin_repair_topic_voice_count() { |
274 | 280 | * |
275 | 281 | * @uses wpdb::query() To run our recount sql queries |
276 | 282 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 283 | * @uses bbp_get_reply_post_type() To get the reply post type |
| 284 | * @uses bbp_get_trash_status_id() To get the trash status id |
| 285 | * @uses bbp_get_spam_status_id() To get the spam status id |
277 | 286 | * @return array An array of the status code and the message |
278 | 287 | */ |
279 | 288 | function bbp_admin_repair_topic_hidden_reply_count() { |
… |
… |
function bbp_admin_repair_topic_hidden_reply_count() { |
286 | 295 | if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) |
287 | 296 | return array( 1, sprintf( $statement, $result ) ); |
288 | 297 | |
289 | | $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . implode( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') GROUP BY `post_parent`);"; |
| 298 | // Post types and status |
| 299 | $rpt = bbp_get_reply_post_type(); |
| 300 | $tps = bbp_get_trash_status_id(); |
| 301 | $sps = bbp_get_spam_status_id(); |
| 302 | |
| 303 | $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '{$rpt}' AND `post_status` IN ( '{$tps}', '{$sps}' ) GROUP BY `post_parent`);"; |
290 | 304 | if ( is_wp_error( $wpdb->query( $sql ) ) ) |
291 | 305 | return array( 2, sprintf( $statement, $result ) ); |
292 | 306 | |
… |
… |
function bbp_admin_repair_topic_hidden_reply_count() { |
299 | 313 | * @since bbPress (r4395) |
300 | 314 | * |
301 | 315 | * @global WPDB $wpdb |
| 316 | * @uses bbp_get_forum_post_type() To get the forum post type |
302 | 317 | * @return If a wp_error() occurs and no converted forums are found |
303 | 318 | */ |
304 | 319 | function bbp_admin_repair_group_forum_relationship() { |
… |
… |
function bbp_admin_repair_group_forum_relationship() { |
320 | 335 | LEFT JOIN `{$wpdb->postmeta}` AS `forummeta` |
321 | 336 | ON `forum`.`ID` = `forummeta`.`post_id` |
322 | 337 | AND `forummeta`.`meta_key` = '_bbp_old_forum_id' |
323 | | WHERE `forum`.`post_type` = 'forum' |
| 338 | WHERE `forum`.`post_type` = '" . bbp_get_forum_post_type() . "' |
324 | 339 | GROUP BY `forum`.`ID`;" ); |
325 | 340 | |
326 | 341 | // Bail if forum IDs returned an error |
… |
… |
function bbp_admin_repair_forum_reply_count() { |
499 | 514 | * |
500 | 515 | * @since bbPress (r3889) |
501 | 516 | * |
502 | | * @uses bbp_get_reply_post_type() To get the reply post type |
| 517 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 518 | * @uses bbp_get_public_status_id() To get the public status id |
503 | 519 | * @uses wpdb::query() To run our recount sql queries |
504 | 520 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
505 | 521 | * @return array An array of the status code and the message |
… |
… |
function bbp_admin_repair_user_topic_count() { |
545 | 561 | * @since bbPress (r2613) |
546 | 562 | * |
547 | 563 | * @uses bbp_get_reply_post_type() To get the reply post type |
| 564 | * @uses bbp_get_public_status_id() To get the public status id |
548 | 565 | * @uses wpdb::query() To run our recount sql queries |
549 | 566 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
550 | 567 | * @return array An array of the status code and the message |
… |
… |
function bbp_admin_repair_user_reply_count() { |
589 | 606 | * |
590 | 607 | * @since bbPress (r2613) |
591 | 608 | * |
592 | | * @uses bbp_get_topic_post_type() To get the topic post type |
593 | 609 | * @uses wpdb::query() To run our recount sql queries |
594 | 610 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 611 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 612 | * @uses bbp_get_public_status_id() To get the public status id |
595 | 613 | * @return array An array of the status code and the message |
596 | 614 | */ |
597 | 615 | function bbp_admin_repair_user_favorites() { |
… |
… |
function bbp_admin_repair_user_favorites() { |
651 | 669 | * |
652 | 670 | * @since bbPress (r2668) |
653 | 671 | * |
654 | | * @uses bbp_get_topic_post_type() To get the topic post type |
655 | 672 | * @uses wpdb::query() To run our recount sql queries |
656 | 673 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 674 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 675 | * @uses bbp_get_public_status_id() To get the public status id |
657 | 676 | * @return array An array of the status code and the message |
658 | 677 | */ |
659 | 678 | function bbp_admin_repair_user_topic_subscriptions() { |
… |
… |
function bbp_admin_repair_user_topic_subscriptions() { |
712 | 731 | * |
713 | 732 | * @since bbPress (r5155) |
714 | 733 | * |
715 | | * @uses bbp_get_forum_post_type() To get the topic post type |
716 | 734 | * @uses wpdb::query() To run our recount sql queries |
717 | 735 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 736 | * @uses bbp_get_forum_post_type() To get the forum post type |
| 737 | * @uses bbp_get_public_status_id() To get the public status id |
718 | 738 | * @return array An array of the status code and the message |
719 | 739 | */ |
720 | 740 | function bbp_admin_repair_user_forum_subscriptions() { |
… |
… |
function bbp_admin_repair_user_roles() { |
831 | 851 | * |
832 | 852 | * @uses wpdb::query() To run our recount sql queries |
833 | 853 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 854 | * @uses bbp_get_forum_post_type() To get the forum post type |
| 855 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 856 | * @uses bbp_get_reply_post_type() To get the reply post type |
| 857 | * @uses bbp_get_public_status_id() To get the public status id |
834 | 858 | * @return array An array of the status code and the message |
835 | 859 | */ |
836 | 860 | function bbp_admin_repair_freshness() { |
… |
… |
function bbp_admin_repair_freshness() { |
842 | 866 | // First, delete everything. |
843 | 867 | if ( is_wp_error( $wpdb->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` IN ( '_bbp_last_reply_id', '_bbp_last_topic_id', '_bbp_last_active_id', '_bbp_last_active_time' );" ) ) ) |
844 | 868 | return array( 1, sprintf( $statement, $result ) ); |
| 869 | |
| 870 | // Post types and status |
| 871 | $fpt = bbp_get_forum_post_type(); |
| 872 | $tpt = bbp_get_topic_post_type(); |
| 873 | $rpt = bbp_get_reply_post_type(); |
| 874 | $pps = bbp_get_public_status_id(); |
845 | 875 | |
846 | 876 | // Next, give all the topics with replies the ID their last reply. |
847 | 877 | if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`) |
848 | 878 | ( SELECT `topic`.`ID`, '_bbp_last_reply_id', MAX( `reply`.`ID` ) |
849 | 879 | FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent` |
850 | | WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply' |
| 880 | WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}' |
851 | 881 | GROUP BY `topic`.`ID` );" ) ) ) |
852 | 882 | return array( 2, sprintf( $statement, $result ) ); |
853 | 883 | |
… |
… |
function bbp_admin_repair_freshness() { |
856 | 886 | ( SELECT `ID`, '_bbp_last_reply_id', 0 |
857 | 887 | FROM `$wpdb->posts` AS `topic` LEFT JOIN `$wpdb->postmeta` AS `reply` |
858 | 888 | ON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_reply_id' |
859 | | WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = 'topic' );" ) ) ) |
| 889 | WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );" ) ) ) |
860 | 890 | return array( 3, sprintf( $statement, $result ) ); |
861 | 891 | |
862 | 892 | // Now we give all the forums with topics the ID their last topic. |
863 | 893 | if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`) |
864 | 894 | ( SELECT `forum`.`ID`, '_bbp_last_topic_id', `topic`.`ID` |
865 | 895 | FROM `$wpdb->posts` AS `forum` INNER JOIN `$wpdb->posts` AS `topic` ON `forum`.`ID` = `topic`.`post_parent` |
866 | | WHERE `topic`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `forum`.`post_type` = 'forum' AND `topic`.`post_type` = 'topic' |
| 896 | WHERE `topic`.`post_status` = '{$pps}' AND `forum`.`post_type` = '{$fpt}' AND `topic`.`post_type` = '{$tpt}' |
867 | 897 | GROUP BY `forum`.`ID` );" ) ) ) |
868 | 898 | return array( 4, sprintf( $statement, $result ) ); |
869 | 899 | |
… |
… |
function bbp_admin_repair_freshness() { |
872 | 902 | ( SELECT `ID`, '_bbp_last_topic_id', 0 |
873 | 903 | FROM `$wpdb->posts` AS `forum` LEFT JOIN `$wpdb->postmeta` AS `topic` |
874 | 904 | ON `forum`.`ID` = `topic`.`post_id` AND `topic`.`meta_key` = '_bbp_last_topic_id' |
875 | | WHERE `topic`.`meta_id` IS NULL AND `forum`.`post_type` = 'forum' );" ) ) ) |
| 905 | WHERE `topic`.`meta_id` IS NULL AND `forum`.`post_type` = '{$fpt}' );" ) ) ) |
876 | 906 | return array( 5, sprintf( $statement, $result ) ); |
877 | 907 | |
878 | 908 | // After that, we give all the topics with replies the ID their last reply (again, this time for a different reason). |
879 | 909 | if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`) |
880 | 910 | ( SELECT `topic`.`ID`, '_bbp_last_active_id', MAX( `reply`.`ID` ) |
881 | 911 | FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent` |
882 | | WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply' |
| 912 | WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}' |
883 | 913 | GROUP BY `topic`.`ID` );" ) ) ) |
884 | 914 | return array( 6, sprintf( $statement, $result ) ); |
885 | 915 | |
… |
… |
function bbp_admin_repair_freshness() { |
888 | 918 | ( SELECT `ID`, '_bbp_last_active_id', `ID` |
889 | 919 | FROM `$wpdb->posts` AS `topic` LEFT JOIN `$wpdb->postmeta` AS `reply` |
890 | 920 | ON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_active_id' |
891 | | WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = 'topic' );" ) ) ) |
| 921 | WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );" ) ) ) |
892 | 922 | return array( 7, sprintf( $statement, $result ) ); |
893 | 923 | |
894 | 924 | // Give topics with replies their last update time. |
895 | 925 | if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`) |
896 | 926 | ( SELECT `topic`.`ID`, '_bbp_last_active_time', MAX( `reply`.`post_date` ) |
897 | 927 | FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent` |
898 | | WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply' |
| 928 | WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}' |
899 | 929 | GROUP BY `topic`.`ID` );" ) ) ) |
900 | 930 | return array( 8, sprintf( $statement, $result ) ); |
901 | 931 | |
… |
… |
function bbp_admin_repair_freshness() { |
904 | 934 | ( SELECT `ID`, '_bbp_last_active_time', `post_date` |
905 | 935 | FROM `$wpdb->posts` AS `topic` LEFT JOIN `$wpdb->postmeta` AS `reply` |
906 | 936 | ON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_active_time' |
907 | | WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = 'topic' );" ) ) ) |
| 937 | WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );" ) ) ) |
908 | 938 | return array( 9, sprintf( $statement, $result ) ); |
909 | 939 | |
910 | 940 | // Forums need to know what their last active item is as well. Now it gets a bit more complex to do in the database. |
911 | | $forums = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = 'forum' and `post_status` != 'auto-draft';" ); |
| 941 | $forums = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '{$fpt}' and `post_status` != 'auto-draft';" ); |
912 | 942 | if ( is_wp_error( $forums ) ) |
913 | 943 | return array( 10, sprintf( $statement, $result ) ); |
914 | 944 | |
… |
… |
function bbp_admin_repair_freshness() { |
937 | 967 | * |
938 | 968 | * @uses wpdb::get_col() To run our recount sql queries |
939 | 969 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 970 | * @uses bbp_get_forum_post_type() To get the forum post type |
940 | 971 | * @return array An array of the status code and the message |
941 | 972 | */ |
942 | 973 | function bbp_admin_repair_sticky() { |
… |
… |
function bbp_admin_repair_sticky() { |
944 | 975 | |
945 | 976 | $statement = __( 'Repairing the sticky topic to the parent forum relationships… %s', 'bbpress' ); |
946 | 977 | $result = __( 'Failed!', 'bbpress' ); |
947 | | $forums = $wpdb->get_col( "SELECT ID FROM `{$wpdb->posts}` WHERE `post_type` = 'forum';" ); |
| 978 | $forums = $wpdb->get_col( "SELECT ID FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "';" ); |
948 | 979 | |
949 | 980 | // Bail if no forums found |
950 | 981 | if ( empty( $forums ) || is_wp_error( $forums ) ) |
… |
… |
function bbp_admin_repair_forum_visibility() { |
1018 | 1049 | * |
1019 | 1050 | * @uses wpdb::query() To run our recount sql queries |
1020 | 1051 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 1052 | * @uses bbp_get_forum_post_type() To get the forum post type |
| 1053 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 1054 | * @uses bbp_get_reply_post_type() To get the reply post type |
1021 | 1055 | * @return array An array of the status code and the message |
1022 | 1056 | */ |
1023 | 1057 | function bbp_admin_repair_forum_meta() { |
… |
… |
function bbp_admin_repair_forum_meta() { |
1029 | 1063 | // First, delete everything. |
1030 | 1064 | if ( is_wp_error( $wpdb->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` = '_bbp_forum_id';" ) ) ) |
1031 | 1065 | return array( 1, sprintf( $statement, $result ) ); |
| 1066 | |
| 1067 | // Post types and status |
| 1068 | $fpt = bbp_get_forum_post_type(); |
| 1069 | $tpt = bbp_get_topic_post_type(); |
| 1070 | $rpt = bbp_get_reply_post_type(); |
1032 | 1071 | |
1033 | 1072 | // Next, give all the topics with replies the ID their last reply. |
1034 | 1073 | if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`) |
1035 | 1074 | ( SELECT `forum`.`ID`, '_bbp_forum_id', `forum`.`post_parent` |
1036 | 1075 | FROM `$wpdb->posts` |
1037 | 1076 | AS `forum` |
1038 | | WHERE `forum`.`post_type` = 'forum' |
| 1077 | WHERE `forum`.`post_type` = '{$fpt}' |
1039 | 1078 | GROUP BY `forum`.`ID` );" ) ) ) |
1040 | 1079 | return array( 2, sprintf( $statement, $result ) ); |
1041 | 1080 | |
… |
… |
function bbp_admin_repair_forum_meta() { |
1044 | 1083 | ( SELECT `topic`.`ID`, '_bbp_forum_id', `topic`.`post_parent` |
1045 | 1084 | FROM `$wpdb->posts` |
1046 | 1085 | AS `topic` |
1047 | | WHERE `topic`.`post_type` = 'topic' |
| 1086 | WHERE `topic`.`post_type` = '{$tpt}' |
1048 | 1087 | GROUP BY `topic`.`ID` );" ) ) ) |
1049 | 1088 | return array( 3, sprintf( $statement, $result ) ); |
1050 | 1089 | |
… |
… |
function bbp_admin_repair_forum_meta() { |
1056 | 1095 | INNER JOIN `$wpdb->posts` |
1057 | 1096 | AS `topic` |
1058 | 1097 | ON `reply`.`post_parent` = `topic`.`ID` |
1059 | | WHERE `topic`.`post_type` = 'topic' |
1060 | | AND `reply`.`post_type` = 'reply' |
| 1098 | WHERE `topic`.`post_type` = '{$tpt}' |
| 1099 | AND `reply`.`post_type` = '{$rpt}' |
1061 | 1100 | GROUP BY `reply`.`ID` );" ) ) ) |
1062 | 1101 | return array( 4, sprintf( $statement, $result ) ); |
1063 | 1102 | |
… |
… |
function bbp_admin_repair_forum_meta() { |
1072 | 1111 | * |
1073 | 1112 | * @uses wpdb::query() To run our recount sql queries |
1074 | 1113 | * @uses is_wp_error() To check if the executed query returned {@link WP_Error} |
| 1114 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 1115 | * @uses bbp_get_reply_post_type() To get the reply post type |
1075 | 1116 | * @return array An array of the status code and the message |
1076 | 1117 | */ |
1077 | 1118 | function bbp_admin_repair_topic_meta() { |
… |
… |
function bbp_admin_repair_topic_meta() { |
1084 | 1125 | if ( is_wp_error( $wpdb->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` = '_bbp_topic_id';" ) ) ) |
1085 | 1126 | return array( 1, sprintf( $statement, $result ) ); |
1086 | 1127 | |
| 1128 | // Post types and status |
| 1129 | $tpt = bbp_get_topic_post_type(); |
| 1130 | $rpt = bbp_get_reply_post_type(); |
| 1131 | |
1087 | 1132 | // Next, give all the topics with replies the ID their last reply. |
1088 | 1133 | if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`) |
1089 | 1134 | ( SELECT `topic`.`ID`, '_bbp_topic_id', `topic`.`ID` |
1090 | 1135 | FROM `$wpdb->posts` |
1091 | 1136 | AS `topic` |
1092 | | WHERE `topic`.`post_type` = 'topic' |
| 1137 | WHERE `topic`.`post_type` = '{$tpt}' |
1093 | 1138 | GROUP BY `topic`.`ID` );" ) ) ) |
1094 | 1139 | return array( 3, sprintf( $statement, $result ) ); |
1095 | 1140 | |
… |
… |
function bbp_admin_repair_topic_meta() { |
1101 | 1146 | INNER JOIN `$wpdb->posts` |
1102 | 1147 | AS `topic` |
1103 | 1148 | ON `reply`.`post_parent` = `topic`.`ID` |
1104 | | WHERE `topic`.`post_type` = 'topic' |
1105 | | AND `reply`.`post_type` = 'reply' |
| 1149 | WHERE `topic`.`post_type` = '{$tpt}' |
| 1150 | AND `reply`.`post_type` = '{$rpt}' |
1106 | 1151 | GROUP BY `reply`.`ID` );" ) ) ) |
1107 | 1152 | return array( 4, sprintf( $statement, $result ) ); |
1108 | 1153 | |
… |
… |
function bbp_admin_reset() { |
1190 | 1235 | * |
1191 | 1236 | * @uses check_admin_referer() To verify the nonce and the referer |
1192 | 1237 | * @uses wp_cache_flush() To flush the cache |
| 1238 | * @uses bbp_get_forum_post_type() To get the forum post type |
| 1239 | * @uses bbp_get_topic_post_type() To get the topic post type |
| 1240 | * @uses bbp_get_reply_post_type() To get the reply post type |
1193 | 1241 | */ |
1194 | 1242 | function bbp_admin_reset_handler() { |
1195 | 1243 | |
… |
… |
function bbp_admin_reset_handler() { |
1215 | 1263 | |
1216 | 1264 | /** Posts *****************************************************************/ |
1217 | 1265 | |
| 1266 | // Post types and status |
| 1267 | $fpt = bbp_get_forum_post_type(); |
| 1268 | $tpt = bbp_get_topic_post_type(); |
| 1269 | $rpt = bbp_get_reply_post_type(); |
| 1270 | |
1218 | 1271 | $statement = __( 'Deleting Posts… %s', 'bbpress' ); |
1219 | | $sql_posts = $wpdb->get_results( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN ('forum', 'topic', 'reply')", OBJECT_K ); |
1220 | | $sql_delete = "DELETE FROM `{$wpdb->posts}` WHERE `post_type` IN ('forum', 'topic', 'reply')"; |
| 1272 | $sql_posts = $wpdb->get_results( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')", OBJECT_K ); |
| 1273 | $sql_delete = "DELETE FROM `{$wpdb->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')"; |
1221 | 1274 | $result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success; |
1222 | 1275 | $messages[] = sprintf( $statement, $result ); |
1223 | 1276 | |