Changeset 6523 for trunk/src/includes/admin/tools/repair.php
- Timestamp:
- 06/10/2017 11:19:08 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/tools/repair.php (modified) (48 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/repair.php
r6497 r6523 2 2 3 3 /** 4 * bbPress Admin Repair sPage4 * bbPress Admin Repair Page 5 5 * 6 6 * @package bbPress … … 32 32 <div class="wrap"> 33 33 <h1><?php esc_html_e( 'Forum Tools', 'bbpress' ); ?></h1> 34 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( __( 'Repair Forums', 'bbpress' ) ); ?></h2>34 <h2 class="nav-tab-wrapper"><?php bbp_tools_admin_tabs( esc_html__( 'Repair Forums', 'bbpress' ) ); ?></h2> 35 35 36 36 <p><?php esc_html_e( 'bbPress keeps track of relationships between forums, topics, replies, topic-tags, favorites, subscriptions, and users. Occasionally these relationships become out of sync, most often after an import or migration. Use the tools below to manually recalculate these relationships.', 'bbpress' ); ?></p> … … 175 175 // Define variables 176 176 $bbp_db = bbp_db(); 177 $statement = __( 'Counting the number of replies in each topic… %s', 'bbpress' );178 $result = __( 'Failed!', 'bbpress' );177 $statement = esc_html__( 'Counting the number of replies in each topic… %s', 'bbpress' ); 178 $result = esc_html__( 'Failed!', 'bbpress' ); 179 179 180 180 // Post types and status … … 210 210 } 211 211 212 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );212 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 213 213 } 214 214 … … 230 230 // Define variables 231 231 $bbp_db = bbp_db(); 232 $statement = __( 'Counting the number of voices in each topic… %s', 'bbpress' );233 $result = __( 'Failed!', 'bbpress' );232 $statement = esc_html__( 'Counting the number of voices in each topic… %s', 'bbpress' ); 233 $result = esc_html__( 'Failed!', 'bbpress' ); 234 234 235 235 $sql_delete = "DELETE FROM {$bbp_db->postmeta} WHERE meta_key IN ('_bbp_voice_count', '_bbp_engagement')"; … … 268 268 } 269 269 270 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );270 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 271 271 } 272 272 … … 288 288 // Define variables 289 289 $bbp_db = bbp_db(); 290 $statement = __( 'Counting the number of pending, spammed, and trashed replies in each topic… %s', 'bbpress' );291 $result = __( 'Failed!', 'bbpress' );290 $statement = esc_html__( 'Counting the number of pending, spammed, and trashed replies in each topic… %s', 'bbpress' ); 291 $result = esc_html__( 'Failed!', 'bbpress' ); 292 292 293 293 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_reply_count_hidden'"; … … 307 307 } 308 308 309 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );309 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 310 310 } 311 311 … … 326 326 // Define variables 327 327 $bbp_db = bbp_db(); 328 $statement = __( 'Counting the number of topics in each forum… %s', 'bbpress' );329 $result = __( 'Failed!', 'bbpress' );328 $statement = esc_html__( 'Counting the number of topics in each forum… %s', 'bbpress' ); 329 $result = esc_html__( 'Failed!', 'bbpress' ); 330 330 331 331 $sql_delete = "DELETE FROM {$bbp_db->postmeta} WHERE meta_key IN ( '_bbp_topic_count', '_bbp_total_topic_count', '_bbp_topic_count_hidden' )"; … … 344 344 } 345 345 346 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );346 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 347 347 } 348 348 … … 364 364 365 365 // Define variables 366 $statement = __( 'Counting the number of topics in each topic-tag… %s', 'bbpress' );367 $result = __( 'Failed!', 'bbpress' );366 $statement = esc_html__( 'Counting the number of topics in each topic-tag… %s', 'bbpress' ); 367 $result = esc_html__( 'Failed!', 'bbpress' ); 368 368 $tax_id = bbp_get_topic_tag_tax_id(); 369 369 $terms = get_terms( $tax_id, array( 'hide_empty' => false ) ); … … 395 395 clean_term_cache( $ints, '', false ); 396 396 397 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );397 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 398 398 } 399 399 … … 414 414 // Define variables 415 415 $bbp_db = bbp_db(); 416 $statement = __( 'Counting the number of replies in each forum… %s', 'bbpress' );417 $result = __( 'Failed!', 'bbpress' );416 $statement = esc_html__( 'Counting the number of replies in each forum… %s', 'bbpress' ); 417 $result = esc_html__( 'Failed!', 'bbpress' ); 418 418 419 419 // Post type … … 441 441 } 442 442 443 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );443 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 444 444 } 445 445 … … 459 459 // Define variables 460 460 $bbp_db = bbp_db(); 461 $statement = __( 'Counting the number of topics each user has created… %s', 'bbpress' );462 $result = __( 'Failed!', 'bbpress' );461 $statement = esc_html__( 'Counting the number of topics each user has created… %s', 'bbpress' ); 462 $result = esc_html__( 'Failed!', 'bbpress' ); 463 463 464 464 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`"; … … 493 493 } 494 494 495 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );495 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 496 496 } 497 497 … … 511 511 // Define variables 512 512 $bbp_db = bbp_db(); 513 $statement = __( 'Counting the number of topics to which each user has replied… %s', 'bbpress' );514 $result = __( 'Failed!', 'bbpress' );513 $statement = esc_html__( 'Counting the number of topics to which each user has replied… %s', 'bbpress' ); 514 $result = esc_html__( 'Failed!', 'bbpress' ); 515 515 516 516 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`"; … … 545 545 } 546 546 547 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );547 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 548 548 } 549 549 … … 563 563 // Define variables 564 564 $bbp_db = bbp_db(); 565 $statement = __( 'Removing unpublished topics from user favorites… %s', 'bbpress' );566 $result = __( 'Failed!', 'bbpress' );565 $statement = esc_html__( 'Removing unpublished topics from user favorites… %s', 'bbpress' ); 566 $result = esc_html__( 'Failed!', 'bbpress' ); 567 567 568 568 // Query for users with favorites … … 599 599 600 600 if ( !count( $values ) ) { 601 $result = __( 'Nothing to remove!', 'bbpress' );601 $result = esc_html__( 'Nothing to remove!', 'bbpress' ); 602 602 return array( 0, sprintf( $statement, $result ) ); 603 603 } … … 616 616 } 617 617 618 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );618 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 619 619 } 620 620 … … 634 634 // Define variables 635 635 $bbp_db = bbp_db(); 636 $statement = __( 'Removing trashed topics from user subscriptions… %s', 'bbpress' );637 $result = __( 'Failed!', 'bbpress' );636 $statement = esc_html__( 'Removing trashed topics from user subscriptions… %s', 'bbpress' ); 637 $result = esc_html__( 'Failed!', 'bbpress' ); 638 638 639 639 $key = $bbp_db->prefix . '_bbp_subscriptions'; … … 668 668 669 669 if ( !count( $values ) ) { 670 $result = __( 'Nothing to remove!', 'bbpress' );670 $result = esc_html__( 'Nothing to remove!', 'bbpress' ); 671 671 return array( 0, sprintf( $statement, $result ) ); 672 672 } … … 685 685 } 686 686 687 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );687 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 688 688 } 689 689 … … 703 703 // Define variables 704 704 $bbp_db = bbp_db(); 705 $statement = __( 'Removing trashed forums from user subscriptions… %s', 'bbpress' );706 $result = __( 'Failed!', 'bbpress' );705 $statement = esc_html__( 'Removing trashed forums from user subscriptions… %s', 'bbpress' ); 706 $result = esc_html__( 'Failed!', 'bbpress' ); 707 707 708 708 $key = $bbp_db->prefix . '_bbp_forum_subscriptions'; … … 737 737 738 738 if ( !count( $values ) ) { 739 $result = __( 'Nothing to remove!', 'bbpress' );739 $result = esc_html__( 'Nothing to remove!', 'bbpress' ); 740 740 return array( 0, sprintf( $statement, $result ) ); 741 741 } … … 754 754 } 755 755 756 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );756 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 757 757 } 758 758 … … 772 772 function bbp_admin_repair_user_roles() { 773 773 774 $statement = __( 'Remapping forum role for each user on this site… %s', 'bbpress' );774 $statement = esc_html__( 'Remapping forum role for each user on this site… %s', 'bbpress' ); 775 775 $changed = 0; 776 776 $role_map = bbp_get_user_role_map(); … … 779 779 // Bail if no role map exists 780 780 if ( empty( $role_map ) ) { 781 return array( 1, sprintf( $statement, __( 'Failed!', 'bbpress' ) ) );781 return array( 1, sprintf( $statement, esc_html__( 'Failed!', 'bbpress' ) ) ); 782 782 } 783 783 … … 811 811 } 812 812 813 $result = sprintf( __( 'Complete! %s users updated.', 'bbpress' ), bbp_number_format( $changed ) );813 $result = sprintf( esc_html__( 'Complete! %s users updated.', 'bbpress' ), bbp_number_format( $changed ) ); 814 814 815 815 return array( 0, sprintf( $statement, $result ) ); … … 817 817 818 818 /** 819 * Re cachesthe last post in every topic and forum819 * Repair the last post in every topic and forum 820 820 * 821 821 * @since 2.0.0 bbPress (r3040) … … 827 827 * @uses bbp_get_reply_post_type() To get the reply post type 828 828 * @uses bbp_get_public_status_id() To get the public status id 829 * @uses bbp_is_forum_category() To check if the forum is a ategory829 * @uses bbp_is_forum_category() To check if the forum is a category 830 830 * @uses bbp_update_forum() To update the forums forum id 831 831 * @return array An array of the status code and the message … … 835 835 // Define variables 836 836 $bbp_db = bbp_db(); 837 $statement = __( 'Recomputing latest post in every topic and forum… %s', 'bbpress' );838 $result = __( 'Failed!', 'bbpress' );837 $statement = esc_html__( 'Recomputing latest post in every topic and forum… %s', 'bbpress' ); 838 $result = esc_html__( 'Failed!', 'bbpress' ); 839 839 840 840 // First, delete everything. … … 942 942 943 943 // Complete results 944 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );945 } 946 947 /** 948 * Repair sthe relationship of sticky topics to the actual parent forum944 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 945 } 946 947 /** 948 * Repair the relationship of sticky topics to the actual parent forum 949 949 * 950 950 * @since 2.3.0 bbPress (r4695) … … 963 963 // Define variables 964 964 $bbp_db = bbp_db(); 965 $statement = __( 'Repairing the sticky topic to the parent forum relationships… %s', 'bbpress' );966 $result = __( 'Failed!', 'bbpress' );965 $statement = esc_html__( 'Repairing the sticky topic to the parent forum relationships… %s', 'bbpress' ); 966 $result = esc_html__( 'Failed!', 'bbpress' ); 967 967 968 968 $forums = $bbp_db->get_col( "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "'" ); … … 994 994 // If the topic is not a super sticky, and the forum ID does not 995 995 // match the topic's forum ID, unset the forum's sticky meta. 996 if ( ! bbp_is_topic_super_sticky( $topic_id ) && $forum_id !== bbp_get_topic_forum_id( $topic_id) ) {996 if ( ! bbp_is_topic_super_sticky( $topic_id ) && ( $forum_id !== bbp_get_topic_forum_id( $topic_id ) ) ) { 997 997 unset( $forum_stickies[ $forum_id ][ $id ] ); 998 998 } … … 1000 1000 1001 1001 // Get sticky topic ID's, or use empty string 1002 $stickers = empty( $forum_stickies[ $forum_id ] ) ? '' : array_values( $forum_stickies[ $forum_id ] ); 1002 $stickers = ! empty( $forum_stickies[ $forum_id ] ) 1003 ? array_values( $forum_stickies[ $forum_id ] ) 1004 : ''; 1003 1005 1004 1006 // Update the forum's sticky topics meta … … 1007 1009 1008 1010 // Complete results 1009 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );1011 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 1010 1012 } 1011 1013 … … 1013 1015 * Repair closed topics 1014 1016 * 1015 * Closed topics that are missing the post meta "_bbp_status" key value "publish"1016 * result in unexpected behavio ur, primarily this would have only occured if you1017 * Closed topics that are missing the post-meta "_bbp_status" key value "publish" 1018 * result in unexpected behavior, primarily this would have only occurred if you 1017 1019 * had imported forums from another forum package previous to bbPress v2.6, 1018 1020 * https://bbpress.trac.wordpress.org/ticket/2577 … … 1031 1033 // Define variables 1032 1034 $bbp_db = bbp_db(); 1033 $statement = __( 'Repairing closed topics… %s', 'bbpress' );1034 $result = __( 'No closed topics to repair.', 'bbpress' );1035 $statement = esc_html__( 'Repairing closed topics… %s', 'bbpress' ); 1036 $result = esc_html__( 'No closed topics to repair.', 'bbpress' ); 1035 1037 $changed = 0; 1036 1038 1037 $closed_topics = $bbp_db->get_col( "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'closed'" ); 1039 // Results 1040 $query = "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '%s' AND `post_status` = 'closed'"; 1041 $prepare = $bbp_db->prepare( $query, bbp_get_topic_post_type() ); 1042 $closed_topics = $bbp_db->get_col( $prepare ); 1038 1043 1039 1044 // Bail if no closed topics found … … 1065 1070 1066 1071 /** 1067 * Re cachesthe private and hidden forums1072 * Repair the private and hidden forums 1068 1073 * 1069 1074 * @since 2.2.0 bbPress (r4104) … … 1073 1078 */ 1074 1079 function bbp_admin_repair_forum_visibility() { 1075 $statement = __( 'Recalculating forum visibility… %s', 'bbpress' );1080 $statement = esc_html__( 'Recalculating forum visibility… %s', 'bbpress' ); 1076 1081 1077 1082 // Bail if queries returned errors 1078 1083 if ( ! bbp_repair_forum_visibility() ) { 1079 return array( 2, sprintf( $statement, __( 'Failed!', 'bbpress' ) ) );1084 return array( 2, sprintf( $statement, esc_html__( 'Failed!', 'bbpress' ) ) ); 1080 1085 1081 1086 // Complete results 1082 1087 } else { 1083 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );1084 } 1085 } 1086 1087 /** 1088 * Re cachesthe parent forum meta for each topic and reply1088 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 1089 } 1090 } 1091 1092 /** 1093 * Repair the parent forum meta for each topic and reply 1089 1094 * 1090 1095 * @since 2.1.0 bbPress (r3876) … … 1100 1105 // Define variables 1101 1106 $bbp_db = bbp_db(); 1102 $statement = __( 'Recalculating the forum for each post… %s', 'bbpress' );1103 $result = __( 'Failed!', 'bbpress' );1107 $statement = esc_html__( 'Recalculating the forum for each post… %s', 'bbpress' ); 1108 $result = esc_html__( 'Failed!', 'bbpress' ); 1104 1109 1105 1110 // First, delete everything. … … 1137 1142 1138 1143 // Complete results 1139 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );1140 } 1141 1142 /** 1143 * Re cachesthe topic for each post1144 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 1145 } 1146 1147 /** 1148 * Repair the topic for each post 1144 1149 * 1145 1150 * @since 2.1.0 bbPress (r3876) … … 1155 1160 // Define variables 1156 1161 $bbp_db = bbp_db(); 1157 $statement = __( 'Recalculating the topic for each post… %s', 'bbpress' );1158 $result = __( 'Failed!', 'bbpress' );1162 $statement = esc_html__( 'Recalculating the topic for each post… %s', 'bbpress' ); 1163 $result = esc_html__( 'Failed!', 'bbpress' ); 1159 1164 1160 1165 // First, delete everything. … … 1192 1197 1193 1198 // Complete results 1194 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );1199 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 1195 1200 } 1196 1201 … … 1210 1215 // Define variables 1211 1216 $bbp_db = bbp_db(); 1212 $statement = __( 'Recalculating reply menu order… %s', 'bbpress' );1213 $result = __( 'No reply positions to recalculate.', 'bbpress' );1217 $statement = esc_html__( 'Recalculating reply menu order… %s', 'bbpress' ); 1218 $result = esc_html__( 'No reply positions to recalculate.', 'bbpress' ); 1214 1219 1215 1220 // Delete cases where `_bbp_reply_to` was accidentally set to itself … … 1249 1254 wp_cache_flush(); 1250 1255 1251 return array( 0, sprintf( $statement, __( 'Complete!', 'bbpress' ) ) );1252 } 1256 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 1257 }
Note: See TracChangeset
for help on using the changeset viewer.