Changeset 5432
- Timestamp:
- 07/09/2014 10:33:59 PM (12 years ago)
- Location:
- trunk/src/includes/topics
- Files:
-
- 2 edited
-
functions.php (modified) (39 diffs)
-
template.php (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/functions.php
r5412 r5432 46 46 47 47 // Bail if no topic was added 48 if ( empty( $topic_id ) ) 48 if ( empty( $topic_id ) ) { 49 49 return false; 50 } 50 51 51 52 // Parse arguments against default values … … 115 116 116 117 // Bail if action is not bbp-new-topic 117 if ( 'bbp-new-topic' !== $action ) 118 if ( 'bbp-new-topic' !== $action ) { 118 119 return; 120 } 119 121 120 122 // Nonce check … … 165 167 /** Topic Title ***********************************************************/ 166 168 167 if ( !empty( $_POST['bbp_topic_title'] ) ) 169 if ( !empty( $_POST['bbp_topic_title'] ) ) { 168 170 $topic_title = esc_attr( strip_tags( $_POST['bbp_topic_title'] ) ); 171 } 169 172 170 173 // Filter and sanitize … … 172 175 173 176 // No topic title 174 if ( empty( $topic_title ) ) 177 if ( empty( $topic_title ) ) { 175 178 bbp_add_error( 'bbp_topic_title', __( '<strong>ERROR</strong>: Your topic needs a title.', 'bbpress' ) ); 179 } 176 180 177 181 /** Topic Content *********************************************************/ 178 182 179 if ( !empty( $_POST['bbp_topic_content'] ) ) 183 if ( !empty( $_POST['bbp_topic_content'] ) ) { 180 184 $topic_content = $_POST['bbp_topic_content']; 185 } 181 186 182 187 // Filter and sanitize … … 184 189 185 190 // No topic content 186 if ( empty( $topic_content ) ) 191 if ( empty( $topic_content ) ) { 187 192 bbp_add_error( 'bbp_topic_content', __( '<strong>ERROR</strong>: Your topic cannot be empty.', 'bbpress' ) ); 193 } 188 194 189 195 /** Topic Forum ***********************************************************/ … … 257 263 /** Topic Flooding ********************************************************/ 258 264 259 if ( !bbp_check_for_flood( $anonymous_data, $topic_author ) ) 265 if ( !bbp_check_for_flood( $anonymous_data, $topic_author ) ) { 260 266 bbp_add_error( 'bbp_topic_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) ); 267 } 261 268 262 269 /** Topic Duplicate *******************************************************/ 263 270 264 if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_topic_post_type(), 'post_author' => $topic_author, 'post_content' => $topic_content, 'anonymous_data' => $anonymous_data ) ) ) 271 if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_topic_post_type(), 'post_author' => $topic_author, 'post_content' => $topic_content, 'anonymous_data' => $anonymous_data ) ) ) { 265 272 bbp_add_error( 'bbp_topic_duplicate', __( '<strong>ERROR</strong>: Duplicate topic detected; it looks as though you’ve already said that!', 'bbpress' ) ); 273 } 266 274 267 275 /** Topic Blacklist *******************************************************/ 268 276 269 if ( !bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) 277 if ( !bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { 270 278 bbp_add_error( 'bbp_topic_blacklist', __( '<strong>ERROR</strong>: Your topic cannot be created at this time.', 'bbpress' ) ); 279 } 271 280 272 281 /** Topic Status **********************************************************/ … … 306 315 307 316 // Bail if errors 308 if ( bbp_has_errors() ) 317 if ( bbp_has_errors() ) { 309 318 return; 319 } 310 320 311 321 /** No Errors *************************************************************/ … … 468 478 469 479 // Bail if action is not bbp-edit-topic 470 if ( 'bbp-edit-topic' !== $action ) 480 if ( 'bbp-edit-topic' !== $action ) { 471 481 return; 482 } 472 483 473 484 // Define local variable(s) … … 575 586 /** Topic Title ***********************************************************/ 576 587 577 if ( !empty( $_POST['bbp_topic_title'] ) ) 588 if ( !empty( $_POST['bbp_topic_title'] ) ) { 578 589 $topic_title = esc_attr( strip_tags( $_POST['bbp_topic_title'] ) ); 590 } 579 591 580 592 // Filter and sanitize … … 582 594 583 595 // No topic title 584 if ( empty( $topic_title ) ) 596 if ( empty( $topic_title ) ) { 585 597 bbp_add_error( 'bbp_edit_topic_title', __( '<strong>ERROR</strong>: Your topic needs a title.', 'bbpress' ) ); 598 } 586 599 587 600 /** Topic Content *********************************************************/ 588 601 589 if ( !empty( $_POST['bbp_topic_content'] ) ) 602 if ( !empty( $_POST['bbp_topic_content'] ) ) { 590 603 $topic_content = $_POST['bbp_topic_content']; 604 } 591 605 592 606 // Filter and sanitize … … 594 608 595 609 // No topic content 596 if ( empty( $topic_content ) ) 610 if ( empty( $topic_content ) ) { 597 611 bbp_add_error( 'bbp_edit_topic_content', __( '<strong>ERROR</strong>: Your topic cannot be empty.', 'bbpress' ) ); 612 } 598 613 599 614 /** Topic Blacklist *******************************************************/ 600 615 601 if ( !bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) 616 if ( !bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { 602 617 bbp_add_error( 'bbp_topic_blacklist', __( '<strong>ERROR</strong>: Your topic cannot be edited at this time.', 'bbpress' ) ); 618 } 603 619 604 620 /** Topic Status **********************************************************/ … … 630 646 631 647 // Explode by comma 632 if ( strstr( $terms, ',' ) ) 648 if ( strstr( $terms, ',' ) ) { 633 649 $terms = explode( ',', $terms ); 650 } 634 651 635 652 // Add topic tag ID as main key … … 650 667 651 668 // Bail if errors 652 if ( bbp_has_errors() ) 669 if ( bbp_has_errors() ) { 653 670 return; 671 } 654 672 655 673 /** No Errors *************************************************************/ … … 764 782 765 783 // Add view all? 766 if ( !empty( $view_all ) ) 784 if ( !empty( $view_all ) ) { 767 785 $topic_url = bbp_add_view_all( $topic_url ); 786 } 768 787 769 788 // Allow to be filtered … … 823 842 824 843 // Bail if there is no topic 825 if ( empty( $topic_id ) ) 844 if ( empty( $topic_id ) ) { 826 845 return; 846 } 827 847 828 848 // Check author_id 829 if ( empty( $author_id ) ) 849 if ( empty( $author_id ) ) { 830 850 $author_id = bbp_get_current_user_id(); 851 } 831 852 832 853 // Check forum_id 833 if ( empty( $forum_id ) ) 854 if ( empty( $forum_id ) ) { 834 855 $forum_id = bbp_get_topic_forum_id( $topic_id ); 856 } 835 857 836 858 // If anonymous post, store name, email, website and ip in post_meta. … … 1132 1154 1133 1155 // Bail if action is not bbp-merge-topic 1134 if ( 'bbp-merge-topic' !== $action ) 1156 if ( 'bbp-merge-topic' !== $action ) { 1135 1157 return; 1158 } 1136 1159 1137 1160 // Define local variable(s) … … 1169 1192 1170 1193 // Topic id 1171 if ( empty( $_POST['bbp_destination_topic'] ) ) 1194 if ( empty( $_POST['bbp_destination_topic'] ) ) { 1172 1195 bbp_add_error( 'bbp_merge_topic_destination_id', __( '<strong>ERROR</strong>: Destination topic ID not found.', 'bbpress' ) ); 1173 else1196 } else { 1174 1197 $destination_topic_id = (int) $_POST['bbp_destination_topic']; 1198 } 1175 1199 1176 1200 // Destination topic not found 1177 if ( !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1201 if ( !$destination_topic = bbp_get_topic( $destination_topic_id ) ) { 1178 1202 bbp_add_error( 'bbp_merge_topic_destination_not_found', __( '<strong>ERROR</strong>: The topic you want to merge to was not found.', 'bbpress' ) ); 1203 } 1179 1204 1180 1205 // Cannot edit destination topic 1181 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) 1206 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) { 1182 1207 bbp_add_error( 'bbp_merge_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the destination topic.', 'bbpress' ) ); 1208 } 1183 1209 1184 1210 // Bail if errors 1185 if ( bbp_has_errors() ) 1211 if ( bbp_has_errors() ) { 1186 1212 return; 1213 } 1187 1214 1188 1215 /** No Errors *************************************************************/ … … 1219 1246 1220 1247 // Shift the subscriber if told to 1221 if ( !empty( $_POST['bbp_topic_subscribers'] ) && ( "1" === $_POST['bbp_topic_subscribers'] ) && bbp_is_subscriptions_active() ) 1248 if ( !empty( $_POST['bbp_topic_subscribers'] ) && ( "1" === $_POST['bbp_topic_subscribers'] ) && bbp_is_subscriptions_active() ) { 1222 1249 bbp_add_user_subscription( $subscriber, $destination_topic->ID ); 1250 } 1223 1251 1224 1252 // Remove old subscription … … 1239 1267 1240 1268 // Shift the favoriter if told to 1241 if ( !empty( $_POST['bbp_topic_favoriters'] ) && "1" === $_POST['bbp_topic_favoriters'] ) 1269 if ( !empty( $_POST['bbp_topic_favoriters'] ) && "1" === $_POST['bbp_topic_favoriters'] ) { 1242 1270 bbp_add_user_favorite( $favoriter, $destination_topic->ID ); 1271 } 1243 1272 1244 1273 // Remove old favorite … … 1256 1285 1257 1286 // Shift the tags if told to 1258 if ( !empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) 1287 if ( !empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) { 1259 1288 wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true ); 1289 } 1260 1290 1261 1291 // Delete the tags from the source topic … … 1420 1450 1421 1451 // Bail if action is not 'bbp-split-topic' 1422 if ( 'bbp-split-topic' !== $action ) 1452 if ( 'bbp-split-topic' !== $action ) { 1423 1453 return; 1454 } 1424 1455 1425 1456 global $wpdb; … … 1433 1464 /** Split Reply ***********************************************************/ 1434 1465 1435 if ( empty( $_POST['bbp_reply_id'] ) ) 1466 if ( empty( $_POST['bbp_reply_id'] ) ) { 1436 1467 bbp_add_error( 'bbp_split_topic_reply_id', __( '<strong>ERROR</strong>: Reply ID to split the topic from not found!', 'bbpress' ) ); 1437 else1468 } else { 1438 1469 $from_reply_id = (int) $_POST['bbp_reply_id']; 1470 } 1439 1471 1440 1472 $from_reply = bbp_get_reply( $from_reply_id ); 1441 1473 1442 1474 // Reply exists 1443 if ( empty( $from_reply ) ) 1475 if ( empty( $from_reply ) ) { 1444 1476 bbp_add_error( 'bbp_split_topic_r_not_found', __( '<strong>ERROR</strong>: The reply you want to split from was not found.', 'bbpress' ) ); 1477 } 1445 1478 1446 1479 /** Topic to Split ********************************************************/ … … 1450 1483 1451 1484 // No topic 1452 if ( empty( $source_topic ) ) 1485 if ( empty( $source_topic ) ) { 1453 1486 bbp_add_error( 'bbp_split_topic_source_not_found', __( '<strong>ERROR</strong>: The topic you want to split was not found.', 'bbpress' ) ); 1487 } 1454 1488 1455 1489 // Nonce check failed … … 1460 1494 1461 1495 // Use cannot edit topic 1462 if ( !current_user_can( 'edit_topic', $source_topic->ID ) ) 1496 if ( !current_user_can( 'edit_topic', $source_topic->ID ) ) { 1463 1497 bbp_add_error( 'bbp_split_topic_source_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress' ) ); 1498 } 1464 1499 1465 1500 // How to Split 1466 if ( !empty( $_POST['bbp_topic_split_option'] ) ) 1501 if ( !empty( $_POST['bbp_topic_split_option'] ) ) { 1467 1502 $split_option = (string) trim( $_POST['bbp_topic_split_option'] ); 1503 } 1468 1504 1469 1505 // Invalid split option … … 1481 1517 1482 1518 // Get destination topic id 1483 if ( empty( $_POST['bbp_destination_topic'] ) ) 1519 if ( empty( $_POST['bbp_destination_topic'] ) ) { 1484 1520 bbp_add_error( 'bbp_split_topic_destination_id', __( '<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress' ) ); 1485 else1521 } else { 1486 1522 $destination_topic_id = (int) $_POST['bbp_destination_topic']; 1523 } 1487 1524 1488 1525 // Get the destination topic … … 1490 1527 1491 1528 // No destination topic 1492 if ( empty( $destination_topic ) ) 1529 if ( empty( $destination_topic ) ) { 1493 1530 bbp_add_error( 'bbp_split_topic_destination_not_found', __( '<strong>ERROR</strong>: The topic you want to split to was not found!', 'bbpress' ) ); 1531 } 1494 1532 1495 1533 // User cannot edit the destination topic 1496 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) 1534 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) { 1497 1535 bbp_add_error( 'bbp_split_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress' ) ); 1536 } 1498 1537 1499 1538 break; … … 1545 1584 1546 1585 // Bail if there are errors 1547 if ( bbp_has_errors() ) 1586 if ( bbp_has_errors() ) { 1548 1587 return; 1588 } 1549 1589 1550 1590 /** No Errors - Do the Spit ***********************************************/ … … 1787 1827 1788 1828 // Bail if required POST actions aren't passed 1789 if ( empty( $_POST['tag-id'] ) ) 1829 if ( empty( $_POST['tag-id'] ) ) { 1790 1830 return; 1831 } 1791 1832 1792 1833 // Setup possible get actions … … 1798 1839 1799 1840 // Bail if actions aren't meant for this function 1800 if ( !in_array( $action, $possible_actions ) ) 1841 if ( !in_array( $action, $possible_actions ) ) { 1801 1842 return; 1843 } 1802 1844 1803 1845 // Setup vars … … 1876 1918 1877 1919 // If term does not exist, create it 1878 if ( !$tag = term_exists( $name, bbp_get_topic_tag_tax_id() ) ) 1920 if ( !$tag = term_exists( $name, bbp_get_topic_tag_tax_id() ) ) { 1879 1921 $tag = wp_insert_term( $name, bbp_get_topic_tag_tax_id() ); 1922 } 1880 1923 1881 1924 // Problem inserting the new term … … 2061 2104 2062 2105 // Bail if required GET actions aren't passed 2063 if ( empty( $_GET['topic_id'] ) ) 2106 if ( empty( $_GET['topic_id'] ) ) { 2064 2107 return; 2108 } 2065 2109 2066 2110 // Setup possible get actions … … 2073 2117 2074 2118 // Bail if actions aren't meant for this function 2075 if ( !in_array( $action, $possible_actions ) ) 2119 if ( !in_array( $action, $possible_actions ) ) { 2076 2120 return; 2121 } 2077 2122 2078 2123 $failure = ''; // Empty failure string … … 2085 2130 // Make sure topic exists 2086 2131 $topic = bbp_get_topic( $topic_id ); 2087 if ( empty( $topic ) ) 2132 if ( empty( $topic ) ) { 2088 2133 return; 2134 } 2089 2135 2090 2136 // What is the user doing here? … … 2134 2180 $sub_action = !empty( $_GET['sub_action'] ) && in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false; 2135 2181 2136 if ( empty( $sub_action ) ) 2182 if ( empty( $sub_action ) ) { 2137 2183 break; 2184 } 2138 2185 2139 2186 switch ( $sub_action ) { … … 2212 2259 2213 2260 // Bail if no topic 2214 if ( empty( $topic_id ) ) 2261 if ( empty( $topic_id ) ) { 2215 2262 return; 2263 } 2216 2264 2217 2265 // Get users … … 2244 2292 2245 2293 // Subscriptions are not active 2246 if ( !bbp_is_subscriptions_active() ) 2294 if ( !bbp_is_subscriptions_active() ) { 2247 2295 return; 2296 } 2248 2297 2249 2298 $topic_id = bbp_get_topic_id( $topic_id ); 2250 2299 2251 2300 // Bail if no topic 2252 if ( empty( $topic_id ) ) 2301 if ( empty( $topic_id ) ) { 2253 2302 return; 2303 } 2254 2304 2255 2305 // Get users … … 3435 3485 3436 3486 // If return val is empty, set it to default 3437 if ( empty( $retval ) ) 3487 if ( empty( $retval ) ) { 3438 3488 $retval = $default; 3489 } 3439 3490 3440 3491 // Filter and return … … 3458 3509 3459 3510 // If return val is empty, set it to default 3460 if ( empty( $retval ) ) 3511 if ( empty( $retval ) ) { 3461 3512 $retval = $default; 3513 } 3462 3514 3463 3515 // Filter and return … … 3538 3590 3539 3591 // User cannot access this forum 3540 if ( bbp_is_single_forum() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_forum_id() ) ) ) 3592 if ( bbp_is_single_forum() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_forum_id() ) ) ) { 3541 3593 return; 3594 } 3542 3595 3543 3596 // Display the feed -
trunk/src/includes/topics/template.php
r5329 r5432 104 104 105 105 // Never separate the lead topic in feeds 106 if ( is_feed() ) 106 if ( is_feed() ) { 107 107 return false; 108 } 108 109 109 110 return (bool) apply_filters( 'bbp_show_lead_topic', (bool) $show_lead ); … … 205 206 206 207 // Set post_parent back to 0 if originally set to 'any' 207 if ( 'any' === $r['post_parent'] ) 208 if ( 'any' === $r['post_parent'] ) { 208 209 $r['post_parent'] = 0; 210 } 209 211 210 212 // Limited the number of pages shown 211 if ( !empty( $r['max_num_pages'] ) ) 213 if ( !empty( $r['max_num_pages'] ) ) { 212 214 $bbp->topic_query->max_num_pages = $r['max_num_pages']; 215 } 213 216 214 217 /** Stickies **************************************************************/ … … 328 331 329 332 // If no limit to posts per page, set it to the current post_count 330 if ( -1 === $r['posts_per_page'] ) 333 if ( -1 === $r['posts_per_page'] ) { 331 334 $r['posts_per_page'] = $bbp->topic_query->post_count; 335 } 332 336 333 337 // Add pagination values to query object … … 339 343 340 344 // Limit the number of topics shown based on maximum allowed pages 341 if ( ( !empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) 345 if ( ( !empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) { 342 346 $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count; 347 } 343 348 344 349 // If pretty permalinks are enabled, make our pagination pretty … … 430 435 431 436 // Reset the post data when finished 432 if ( empty( $have_posts ) ) 437 if ( empty( $have_posts ) ) { 433 438 wp_reset_postdata(); 439 } 434 440 435 441 return $have_posts; … … 531 537 532 538 // Use topic ID 533 if ( empty( $topic ) || is_numeric( $topic ) ) 539 if ( empty( $topic ) || is_numeric( $topic ) ) { 534 540 $topic = bbp_get_topic_id( $topic ); 541 } 535 542 536 543 // Attempt to load the topic 537 544 $topic = get_post( $topic, OBJECT, $filter ); 538 if ( empty( $topic ) ) 545 if ( empty( $topic ) ) { 539 546 return $topic; 547 } 540 548 541 549 // Bail if post_type is not a topic 542 if ( $topic->post_type !== bbp_get_topic_post_type() ) 550 if ( $topic->post_type !== bbp_get_topic_post_type() ) { 543 551 return null; 552 } 544 553 545 554 // Tweak the data type to return … … 554 563 $_topic = array_values( get_object_vars( $topic ) ); 555 564 return $_topic; 556 557 565 } 558 566 … … 566 574 * 567 575 * @param int $topic_id Optional. Topic id 568 * @param $string $redirect_to Optional. Pass a redirect value for use with576 * @param string $redirect_to Optional. Pass a redirect value for use with 569 577 * shortcodes and other fun things. 570 578 * @uses bbp_get_topic_permalink() To get the topic permalink … … 579 587 * 580 588 * @param int $topic_id Optional. Topic id 581 * @param $string $redirect_to Optional. Pass a redirect value for use with589 * @param string $redirect_to Optional. Pass a redirect value for use with 582 590 * shortcodes and other fun things. 583 591 * @uses bbp_get_topic_id() To get the topic id … … 708 716 709 717 // Check if password is required 710 if ( post_password_required( $topic_id ) ) 718 if ( post_password_required( $topic_id ) ) { 711 719 return get_the_password_form(); 720 } 712 721 713 722 $content = get_post_field( 'post_content', $topic_id ); … … 876 885 877 886 // Bump if topic is in loop 878 if ( !bbp_show_lead_topic() ) 887 if ( !bbp_show_lead_topic() ) { 879 888 $total++; 889 } 880 890 881 891 // Pagination settings … … 924 934 925 935 // Bail if in admin or feed 926 if ( is_admin() || is_feed() ) 936 if ( is_admin() || is_feed() ) { 927 937 return; 938 } 928 939 929 940 // Validate the ID … … 966 977 $revision_log = bbp_get_topic_raw_revision_log( $topic_id ); 967 978 968 if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) ) 979 if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) ) { 969 980 return false; 981 } 970 982 971 983 $revisions = bbp_get_topic_revisions( $topic_id ); 972 if ( empty( $revisions ) ) 984 if ( empty( $revisions ) ) { 973 985 return false; 986 } 974 987 975 988 $r = "\n\n" . '<ul id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '" class="bbp-topic-revision-log">' . "\n\n"; … … 1141 1154 $stickies = bbp_get_stickies( $forum_id ); 1142 1155 1143 if ( in_array( $topic_id, $stickies ) || ( !empty( $check_super ) && bbp_is_topic_super_sticky( $topic_id ) ) ) 1156 if ( in_array( $topic_id, $stickies ) || ( !empty( $check_super ) && bbp_is_topic_super_sticky( $topic_id ) ) ) { 1144 1157 return true; 1158 } 1145 1159 1146 1160 return false; … … 1228 1242 $retval = false; 1229 1243 1230 if ( !bbp_get_topic_author_id( $topic_id ) ) 1244 if ( !bbp_get_topic_author_id( $topic_id ) ) { 1231 1245 $retval = true; 1232 1246 1233 elseif ( get_post_meta( $topic_id, '_bbp_anonymous_name', true ) )1247 } elseif ( get_post_meta( $topic_id, '_bbp_anonymous_name', true ) ) { 1234 1248 $retval = true; 1235 1249 1236 elseif ( get_post_meta( $topic_id, '_bbp_anonymous_email', true ) )1250 } elseif ( get_post_meta( $topic_id, '_bbp_anonymous_email', true ) ) { 1237 1251 $retval = true; 1252 } 1238 1253 1239 1254 // The topic is by an anonymous user … … 1367 1382 1368 1383 // If nothing could be found anywhere, use Anonymous 1369 if ( empty( $author_name ) ) 1384 if ( empty( $author_name ) ) { 1370 1385 $author_name = __( 'Anonymous', 'bbpress' ); 1386 } 1371 1387 1372 1388 // Encode possible UTF8 display names 1373 if ( seems_utf8( $author_name ) === false ) 1389 if ( seems_utf8( $author_name ) === false ) { 1374 1390 $author_name = utf8_encode( $author_name ); 1391 } 1375 1392 1376 1393 return apply_filters( 'bbp_get_topic_author_display_name', $author_name, $topic_id ); … … 1930 1947 $reply_id = get_post_meta( $topic_id, '_bbp_last_reply_id', true ); 1931 1948 1932 if ( empty( $reply_id ) ) 1949 if ( empty( $reply_id ) ) { 1933 1950 $reply_id = $topic_id; 1951 } 1934 1952 1935 1953 return (int) apply_filters( 'bbp_get_topic_last_reply_id', (int) $reply_id, $topic_id ); … … 2061 2079 $time_since = bbp_get_topic_last_active_time( $topic_id ); 2062 2080 2063 if ( !empty( $time_since ) ) 2081 if ( !empty( $time_since ) ) { 2064 2082 $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; 2065 else2083 } else { 2066 2084 $anchor = __( 'No Replies', 'bbpress' ); 2085 } 2067 2086 2068 2087 return apply_filters( 'bbp_get_topic_freshness_link', $anchor, $topic_id, $time_since, $link_url, $title ); … … 2108 2127 2109 2128 // First link never has view=all 2110 if ( bbp_get_view_all( 'edit_others_replies' ) ) 2129 if ( bbp_get_view_all( 'edit_others_replies' ) ) { 2111 2130 $retval .= "<a href='" . esc_url( bbp_remove_view_all( bbp_get_topic_permalink( $topic_id ) ) ) . "'>$replies</a>"; 2112 else2131 } else { 2113 2132 $retval .= $replies; 2133 } 2114 2134 2115 2135 // Any deleted replies? … … 2292 2312 2293 2313 // Bail if topic-tags are off 2294 if ( ! bbp_allow_topic_tags() ) 2314 if ( ! bbp_allow_topic_tags() ) { 2295 2315 return; 2316 } 2296 2317 2297 2318 // Parse arguments against default values … … 2511 2532 2512 2533 // Bail if no uri 2513 if ( empty( $uri ) ) 2534 if ( empty( $uri ) ) { 2514 2535 return; 2536 } 2515 2537 2516 2538 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after']; … … 2549 2571 2550 2572 $topic = bbp_get_topic( bbp_get_topic_id( $topic_id ) ); 2551 if ( empty( $topic ) ) 2573 if ( empty( $topic ) ) { 2552 2574 return; 2575 } 2553 2576 2554 2577 // Remove view=all link from edit … … 2693 2716 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2694 2717 2695 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2718 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) { 2696 2719 return; 2720 } 2697 2721 2698 2722 $display = bbp_is_topic_open( $topic->ID ) ? $r['close_text'] : $r['open_text']; … … 2754 2778 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2755 2779 2756 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2780 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) { 2757 2781 return; 2782 } 2758 2783 2759 2784 $is_sticky = bbp_is_topic_sticky( $topic->ID ); … … 2823 2848 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2824 2849 2825 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2850 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) { 2826 2851 return; 2852 } 2827 2853 2828 2854 $uri = add_query_arg( array( 'action' => 'merge' ), bbp_get_topic_edit_url( $topic->ID ) ); … … 2880 2906 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2881 2907 2882 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) 2908 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) { 2883 2909 return; 2910 } 2884 2911 2885 2912 $display = bbp_is_topic_spam( $topic->ID ) ? $r['unspam_text'] : $r['spam_text']; … … 2930 2957 2931 2958 // Bail if no reply or user cannot reply 2932 if ( empty( $topic ) || ! bbp_current_user_can_access_create_reply_form() ) 2959 if ( empty( $topic ) || ! bbp_current_user_can_access_create_reply_form() ) { 2933 2960 return; 2961 } 2934 2962 2935 2963 $uri = '#new-post'; … … 2967 2995 $bbp = bbpress(); 2968 2996 2969 if ( empty( $bbp->topic_query ) ) 2997 if ( empty( $bbp->topic_query ) ) { 2970 2998 return false; 2999 } 2971 3000 2972 3001 // Set pagination values … … 3011 3040 $bbp = bbpress(); 3012 3041 3013 if ( empty( $bbp->topic_query ) ) 3042 if ( empty( $bbp->topic_query ) ) { 3014 3043 return false; 3044 } 3015 3045 3016 3046 return apply_filters( 'bbp_get_forum_pagination_links', $bbp->topic_query->pagination_links ); … … 3032 3062 3033 3063 // Bail if not viewing a topic 3034 if ( !bbp_is_single_topic() ) 3064 if ( !bbp_is_single_topic() ) { 3035 3065 return; 3066 } 3036 3067 3037 3068 // Get the topic_status … … 3059 3090 // Filter notice text and bail if empty 3060 3091 $notice_text = apply_filters( 'bbp_topic_notices', $notice_text, $topic_status, bbp_get_topic_id() ); 3061 if ( empty( $notice_text ) ) 3092 if ( empty( $notice_text ) ) { 3062 3093 return; 3094 } 3063 3095 3064 3096 bbp_add_error( 'topic_notice', $notice_text, 'message' ); … … 3176 3208 * @since bbPress (r5059) 3177 3209 * 3178 * @param int $topic_id The topic id to use 3210 * @param $args This function supports these arguments: 3211 * - select_id: Select id. Defaults to bbp_open_close_topic 3212 * - tab: Tabindex 3213 * - topic_id: Topic id 3214 * - selected: Override the selected option 3179 3215 */ 3180 3216 function bbp_form_topic_status_dropdown( $args = '' ) {
Note: See TracChangeset
for help on using the changeset viewer.