Changeset 5829 for trunk/src/includes/forums/functions.php
- Timestamp:
- 07/14/2015 12:46:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r5827 r5829 142 142 143 143 // Remove kses filters from title and content for capable users and if the nonce is verified 144 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_forum'] ) && wp_create_nonce( 'bbp-unfiltered-html-forum_new' ) === $_POST['_bbp_unfiltered_html_forum'] ) {144 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_forum'] ) && wp_create_nonce( 'bbp-unfiltered-html-forum_new' ) === $_POST['_bbp_unfiltered_html_forum'] ) { 145 145 remove_filter( 'bbp_new_forum_pre_title', 'wp_filter_kses' ); 146 146 remove_filter( 'bbp_new_forum_pre_content', 'bbp_encode_bad', 10 ); … … 150 150 /** Forum Title ***********************************************************/ 151 151 152 if ( ! empty( $_POST['bbp_forum_title'] ) ) {152 if ( ! empty( $_POST['bbp_forum_title'] ) ) { 153 153 $forum_title = sanitize_text_field( $_POST['bbp_forum_title'] ); 154 154 } … … 164 164 /** Forum Content *********************************************************/ 165 165 166 if ( ! empty( $_POST['bbp_forum_content'] ) ) {166 if ( ! empty( $_POST['bbp_forum_content'] ) ) { 167 167 $forum_content = $_POST['bbp_forum_content']; 168 168 } … … 179 179 180 180 // Forum parent was passed (the norm) 181 if ( ! empty( $_POST['bbp_forum_parent_id'] ) ) {181 if ( ! empty( $_POST['bbp_forum_parent_id'] ) ) { 182 182 $forum_parent_id = bbp_get_forum_id( $_POST['bbp_forum_parent_id'] ); 183 183 } … … 191 191 192 192 // Forum exists 193 } elseif ( ! empty( $forum_parent_id ) ) {193 } elseif ( ! empty( $forum_parent_id ) ) { 194 194 195 195 // Forum is a category … … 216 216 /** Forum Flooding ********************************************************/ 217 217 218 if ( ! bbp_check_for_flood( $anonymous_data, $forum_author ) ) {218 if ( ! bbp_check_for_flood( $anonymous_data, $forum_author ) ) { 219 219 bbp_add_error( 'bbp_forum_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) ); 220 220 } … … 222 222 /** Forum Duplicate *******************************************************/ 223 223 224 if ( ! bbp_check_for_duplicate( array( 'post_type' => bbp_get_forum_post_type(), 'post_author' => $forum_author, 'post_content' => $forum_content, 'anonymous_data' => $anonymous_data ) ) ) {224 if ( ! bbp_check_for_duplicate( array( 'post_type' => bbp_get_forum_post_type(), 'post_author' => $forum_author, 'post_content' => $forum_content, 'anonymous_data' => $anonymous_data ) ) ) { 225 225 bbp_add_error( 'bbp_forum_duplicate', __( '<strong>ERROR</strong>: This forum already exists.', 'bbpress' ) ); 226 226 } … … 228 228 /** Forum Blacklist *******************************************************/ 229 229 230 if ( ! bbp_check_for_blacklist( $anonymous_data, $forum_author, $forum_title, $forum_content ) ) {230 if ( ! bbp_check_for_blacklist( $anonymous_data, $forum_author, $forum_title, $forum_content ) ) { 231 231 bbp_add_error( 'bbp_forum_blacklist', __( '<strong>ERROR</strong>: Your forum cannot be created at this time.', 'bbpress' ) ); 232 232 } … … 235 235 236 236 $post_status = bbp_get_public_status_id(); 237 if ( ! bbp_check_for_moderation( $anonymous_data, $forum_author, $forum_title, $forum_content ) ) {237 if ( ! bbp_check_for_moderation( $anonymous_data, $forum_author, $forum_title, $forum_content ) ) { 238 238 $post_status = bbp_get_pending_status_id(); 239 239 } … … 267 267 /** No Errors *************************************************************/ 268 268 269 if ( ! empty( $forum_id ) && !is_wp_error( $forum_id ) ) {269 if ( ! empty( $forum_id ) && !is_wp_error( $forum_id ) ) { 270 270 271 271 /** Trash Check *******************************************************/ … … 318 318 319 319 // Add view all? 320 if ( bbp_get_view_all() || ! empty( $view_all ) ) {320 if ( bbp_get_view_all() || ! empty( $view_all ) ) { 321 321 322 322 // User can moderate, so redirect to forum with view all set … … 419 419 420 420 // Remove kses filters from title and content for capable users and if the nonce is verified 421 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_forum'] ) && ( wp_create_nonce( 'bbp-unfiltered-html-forum_' . $forum_id ) === $_POST['_bbp_unfiltered_html_forum'] ) ) {421 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_forum'] ) && ( wp_create_nonce( 'bbp-unfiltered-html-forum_' . $forum_id ) === $_POST['_bbp_unfiltered_html_forum'] ) ) { 422 422 remove_filter( 'bbp_edit_forum_pre_title', 'wp_filter_kses' ); 423 423 remove_filter( 'bbp_edit_forum_pre_content', 'bbp_encode_bad', 10 ); … … 428 428 429 429 // Forum parent id was passed 430 if ( ! empty( $_POST['bbp_forum_parent_id'] ) ) {430 if ( ! empty( $_POST['bbp_forum_parent_id'] ) ) { 431 431 $forum_parent_id = bbp_get_forum_id( $_POST['bbp_forum_parent_id'] ); 432 432 } … … 436 436 437 437 // Forum exists 438 if ( ! empty( $forum_parent_id ) && ( $forum_parent_id !== $current_parent_forum_id ) ) {438 if ( ! empty( $forum_parent_id ) && ( $forum_parent_id !== $current_parent_forum_id ) ) { 439 439 440 440 // Forum is closed and user cannot access … … 456 456 /** Forum Title ***********************************************************/ 457 457 458 if ( ! empty( $_POST['bbp_forum_title'] ) ) {458 if ( ! empty( $_POST['bbp_forum_title'] ) ) { 459 459 $forum_title = sanitize_text_field( $_POST['bbp_forum_title'] ); 460 460 } … … 470 470 /** Forum Content *********************************************************/ 471 471 472 if ( ! empty( $_POST['bbp_forum_content'] ) ) {472 if ( ! empty( $_POST['bbp_forum_content'] ) ) { 473 473 $forum_content = $_POST['bbp_forum_content']; 474 474 } … … 484 484 /** Forum Blacklist *******************************************************/ 485 485 486 if ( ! bbp_check_for_blacklist( $anonymous_data, bbp_get_forum_author_id( $forum_id ), $forum_title, $forum_content ) ) {486 if ( ! bbp_check_for_blacklist( $anonymous_data, bbp_get_forum_author_id( $forum_id ), $forum_title, $forum_content ) ) { 487 487 bbp_add_error( 'bbp_forum_blacklist', __( '<strong>ERROR</strong>: Your forum cannot be edited at this time.', 'bbpress' ) ); 488 488 } … … 491 491 492 492 $post_status = bbp_get_public_status_id(); 493 if ( ! bbp_check_for_moderation( $anonymous_data, bbp_get_forum_author_id( $forum_id ), $forum_title, $forum_content ) ) {493 if ( ! bbp_check_for_moderation( $anonymous_data, bbp_get_forum_author_id( $forum_id ), $forum_title, $forum_content ) ) { 494 494 $post_status = bbp_get_pending_status_id(); 495 495 } … … 524 524 * @todo omitted for 2.1 525 525 // Revision Reason 526 if ( ! empty( $_POST['bbp_forum_edit_reason'] ) )526 if ( ! empty( $_POST['bbp_forum_edit_reason'] ) ) 527 527 $forum_edit_reason = sanitize_text_field( $_POST['bbp_forum_edit_reason'] ); 528 528 529 529 // Update revision log 530 if ( ! empty( $_POST['bbp_log_forum_edit'] ) && ( "1" === $_POST['bbp_log_forum_edit'] ) && ( $revision_id = wp_save_post_revision( $forum_id ) ) ) {530 if ( ! empty( $_POST['bbp_log_forum_edit'] ) && ( "1" === $_POST['bbp_log_forum_edit'] ) && ( $revision_id = wp_save_post_revision( $forum_id ) ) ) { 531 531 bbp_update_forum_revision_log( array( 532 532 'forum_id' => $forum_id, … … 540 540 /** No Errors *************************************************************/ 541 541 542 if ( ! empty( $forum_id ) && !is_wp_error( $forum_id ) ) {542 if ( ! empty( $forum_id ) && !is_wp_error( $forum_id ) ) { 543 543 544 544 // Update counts, etc... … … 577 577 578 578 // Add view all? 579 if ( ! empty( $view_all ) ) {579 if ( ! empty( $view_all ) ) { 580 580 $forum_url = bbp_add_view_all( $forum_url ); 581 581 } … … 653 653 /** Forum Visibility **************************************************/ 654 654 655 if ( ! empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() ) ) ) {655 if ( ! empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() ) ) ) { 656 656 657 657 // Get forums current visibility … … 1025 1025 1026 1026 // Users exist 1027 if ( ! empty( $users ) ) {1027 if ( ! empty( $users ) ) { 1028 1028 1029 1029 // Loop through users … … 1077 1077 1078 1078 // If has ancestors, loop through them... 1079 if ( ! empty( $ancestors ) ) {1079 if ( ! empty( $ancestors ) ) { 1080 1080 foreach ( (array) $ancestors as $parent_forum_id ) { 1081 1081 … … 1168 1168 1169 1169 // If has ancestors, loop through them... 1170 if ( ! empty( $ancestors ) ) {1170 if ( ! empty( $ancestors ) ) { 1171 1171 foreach ( (array) $ancestors as $parent_forum_id ) { 1172 1172 … … 1217 1217 // Loop through children and add together forum reply counts 1218 1218 $children = bbp_forum_query_subforum_ids( $forum_id ); 1219 if ( ! empty( $children ) ) {1219 if ( ! empty( $children ) ) { 1220 1220 foreach ( $children as $child ) { 1221 1221 $children_last_topic = bbp_update_forum_last_topic_id( $child ); // Recursive … … 1235 1235 // Get the most recent topic in this forum_id 1236 1236 $recent_topic = get_posts( $post_vars ); 1237 if ( ! empty( $recent_topic ) ) {1237 if ( ! empty( $recent_topic ) ) { 1238 1238 $topic_id = $recent_topic[0]->ID; 1239 1239 } … … 1245 1245 1246 1246 // If child forums have higher id, use that instead 1247 if ( ! empty( $children ) && ( $children_last_topic > $topic_id ) ) {1247 if ( ! empty( $children ) && ( $children_last_topic > $topic_id ) ) { 1248 1248 $topic_id = $children_last_topic; 1249 1249 } … … 1287 1287 // Loop through children and get the most recent reply id 1288 1288 $children = bbp_forum_query_subforum_ids( $forum_id ); 1289 if ( ! empty( $children ) ) {1289 if ( ! empty( $children ) ) { 1290 1290 foreach ( $children as $child ) { 1291 1291 $children_last_reply = bbp_update_forum_last_reply_id( $child ); // Recursive … … 1295 1295 // If this forum has topics... 1296 1296 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1297 if ( ! empty( $topic_ids ) ) {1297 if ( ! empty( $topic_ids ) ) { 1298 1298 1299 1299 // ...get the most recent reply from those topics... … … 1310 1310 1311 1311 // If child forums have higher ID, check for newer reply id 1312 if ( ! empty( $children ) && ( $children_last_reply > $reply_id ) ) {1312 if ( ! empty( $children ) && ( $children_last_reply > $reply_id ) ) { 1313 1313 $reply_id = $children_last_reply; 1314 1314 } … … 1353 1353 // Loop through children and add together forum reply counts 1354 1354 $children = bbp_forum_query_subforum_ids( $forum_id ); 1355 if ( ! empty( $children ) ) {1355 if ( ! empty( $children ) ) { 1356 1356 foreach ( $children as $child ) { 1357 1357 $children_last_active = bbp_update_forum_last_active_id( $child, $active_id ); … … 1361 1361 // Don't count replies if the forum is a category 1362 1362 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1363 if ( ! empty( $topic_ids ) ) {1363 if ( ! empty( $topic_ids ) ) { 1364 1364 $active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids ); 1365 1365 $active_id = $active_id > max( $topic_ids ) ? $active_id : max( $topic_ids ); … … 1376 1376 1377 1377 // If child forums have higher id, use that instead 1378 if ( ! empty( $children ) && ( $children_last_active > $active_id ) ) {1378 if ( ! empty( $children ) && ( $children_last_active > $active_id ) ) { 1379 1379 $active_id = $children_last_active; 1380 1380 } … … 1412 1412 1413 1413 // Update only if there is a time 1414 if ( ! empty( $new_time ) ) {1414 if ( ! empty( $new_time ) ) { 1415 1415 update_post_meta( $forum_id, '_bbp_last_active_time', $new_time ); 1416 1416 } … … 1467 1467 // Loop through subforums and add together forum topic counts 1468 1468 $children = bbp_forum_query_subforum_ids( $forum_id ); 1469 if ( ! empty( $children ) ) {1469 if ( ! empty( $children ) ) { 1470 1470 foreach ( $children as $child ) { 1471 1471 $children_topic_count += bbp_update_forum_topic_count( $child ); // Recursive … … 1567 1567 // Loop through children and add together forum reply counts 1568 1568 $children = bbp_forum_query_subforum_ids( $forum_id ); 1569 if ( ! empty( $children ) ) {1569 if ( ! empty( $children ) ) { 1570 1570 foreach ( (array) $children as $child ) { 1571 1571 $children_reply_count += bbp_update_forum_reply_count( $child ); … … 1653 1653 1654 1654 // Update the parent forum if one was passed 1655 if ( ! empty( $r['post_parent'] ) && is_numeric( $r['post_parent'] ) ) {1655 if ( ! empty( $r['post_parent'] ) && is_numeric( $r['post_parent'] ) ) { 1656 1656 bbp_update_forum( array( 1657 1657 'forum_id' => $r['post_parent'], … … 1792 1792 1793 1793 // There are forums that need to be excluded 1794 if ( ! empty( $forum_ids ) ) {1794 if ( ! empty( $forum_ids ) ) { 1795 1795 1796 1796 switch ( $type ) { … … 1884 1884 if ( ! current_user_can( 'read_private_forums' ) ) { 1885 1885 $key = array_search( bbp_get_private_status_id(), $post_stati ); 1886 if ( ! empty( $key ) ) {1886 if ( ! empty( $key ) ) { 1887 1887 unset( $post_stati[$key] ); 1888 1888 } … … 1898 1898 if ( ! current_user_can( 'read_hidden_forums' ) ) { 1899 1899 $key = array_search( bbp_get_hidden_status_id(), $post_stati ); 1900 if ( ! empty( $key ) ) {1900 if ( ! empty( $key ) ) { 1901 1901 unset( $post_stati[$key] ); 1902 1902 } … … 2012 2012 } 2013 2013 2014 if ( ! empty( $topic_ids ) ) {2014 if ( ! empty( $topic_ids ) ) { 2015 2015 $bbp_db = bbp_db(); 2016 2016 $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) ); … … 2080 2080 2081 2081 // If forum is explicitly hidden and user not capable, set 404 2082 if ( ! empty( $forum_id ) && bbp_is_forum_hidden( $forum_id ) && !current_user_can( 'read_hidden_forums' ) ) {2082 if ( ! empty( $forum_id ) && bbp_is_forum_hidden( $forum_id ) && !current_user_can( 'read_hidden_forums' ) ) { 2083 2083 bbp_set_404(); 2084 2084 } … … 2135 2135 2136 2136 // If forum is explicitly hidden and user not capable, set 404 2137 if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && !current_user_can( 'read_private_forums' ) ) {2137 if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && !current_user_can( 'read_private_forums' ) ) { 2138 2138 bbp_set_404(); 2139 2139 } … … 2202 2202 // Loop through and delete child topics. Topic replies will get deleted by 2203 2203 // the bbp_delete_topic() action. 2204 if ( ! empty( $topics->posts ) ) {2204 if ( ! empty( $topics->posts ) ) { 2205 2205 foreach ( $topics->posts as $topic ) { 2206 2206 wp_delete_post( $topic->ID, true ); … … 2259 2259 // Loop through and trash child topics. Topic replies will get trashed by 2260 2260 // the bbp_trash_topic() action. 2261 if ( ! empty( $topics->posts ) ) {2261 if ( ! empty( $topics->posts ) ) { 2262 2262 2263 2263 // Prevent debug notices … … 2308 2308 2309 2309 // There are topics to untrash 2310 if ( ! empty( $pre_trashed_topics ) ) {2310 if ( ! empty( $pre_trashed_topics ) ) { 2311 2311 2312 2312 // Maybe reverse the trashed topics array … … 2339 2339 $forum_id = bbp_get_forum_id( $forum_id ); 2340 2340 2341 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) {2341 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) { 2342 2342 return false; 2343 2343 } … … 2361 2361 $forum_id = bbp_get_forum_id( $forum_id ); 2362 2362 2363 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) {2363 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) { 2364 2364 return false; 2365 2365 } … … 2379 2379 $forum_id = bbp_get_forum_id( $forum_id ); 2380 2380 2381 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) {2381 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) { 2382 2382 return false; 2383 2383 } … … 2399 2399 $forum_id = bbp_get_forum_id( $forum_id ); 2400 2400 2401 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) {2401 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) { 2402 2402 return false; 2403 2403 } … … 2417 2417 $forum_id = bbp_get_forum_id( $forum_id ); 2418 2418 2419 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) {2419 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) { 2420 2420 return false; 2421 2421 } … … 2435 2435 $forum_id = bbp_get_forum_id( $forum_id ); 2436 2436 2437 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) {2437 if ( empty( $forum_id ) || ! bbp_is_forum( $forum_id ) ) { 2438 2438 return false; 2439 2439 }
Note: See TracChangeset
for help on using the changeset viewer.