Changeset 5443
- Timestamp:
- 07/11/2014 09:57:54 PM (11 years ago)
- Location:
- trunk/src/includes/topics
- Files:
-
- 3 edited
-
capabilities.php (modified) (4 diffs)
-
functions.php (modified) (92 diffs)
-
template.php (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/capabilities.php
r5079 r5443 79 79 // Get the post 80 80 $_post = get_post( $args[0] ); 81 if ( ! empty( $_post ) ) {81 if ( ! empty( $_post ) ) { 82 82 83 83 // Get caps for post type object … … 134 134 // Get the post 135 135 $_post = get_post( $args[0] ); 136 if ( ! empty( $_post ) ) {136 if ( ! empty( $_post ) ) { 137 137 138 138 // Get caps for post type object … … 145 145 146 146 // User is author so allow edit if not in admin 147 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) {147 } elseif ( ! is_admin() && ( (int) $user_id === (int) $_post->post_author ) ) { 148 148 $caps[] = $post_type->cap->edit_posts; 149 149 … … 162 162 // Get the post 163 163 $_post = get_post( $args[0] ); 164 if ( ! empty( $_post ) ) {164 if ( ! empty( $_post ) ) { 165 165 166 166 // Get caps for post type object -
trunk/src/includes/topics/functions.php
r5432 r5443 70 70 // Update the forum 71 71 $forum_id = bbp_get_topic_forum_id( $topic_id ); 72 if ( ! empty( $forum_id ) ) {72 if ( ! empty( $forum_id ) ) { 73 73 bbp_update_forum( array( 'forum_id' => $forum_id ) ); 74 74 } … … 141 141 142 142 // Anonymous data checks out, so set cookies, etc... 143 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) {143 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) { 144 144 bbp_set_current_anonymous_user_data( $anonymous_data ); 145 145 } … … 149 149 150 150 // User cannot create topics 151 if ( ! current_user_can( 'publish_topics' ) ) {151 if ( ! current_user_can( 'publish_topics' ) ) { 152 152 bbp_add_error( 'bbp_topic_permissions', __( '<strong>ERROR</strong>: You do not have permission to create new topics.', 'bbpress' ) ); 153 153 return; … … 159 159 160 160 // Remove kses filters from title and content for capable users and if the nonce is verified 161 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_topic'] ) && wp_create_nonce( 'bbp-unfiltered-html-topic_new' ) === $_POST['_bbp_unfiltered_html_topic'] ) {161 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_topic'] ) && wp_create_nonce( 'bbp-unfiltered-html-topic_new' ) === $_POST['_bbp_unfiltered_html_topic'] ) { 162 162 remove_filter( 'bbp_new_topic_pre_title', 'wp_filter_kses' ); 163 163 remove_filter( 'bbp_new_topic_pre_content', 'bbp_encode_bad', 10 ); … … 167 167 /** Topic Title ***********************************************************/ 168 168 169 if ( ! empty( $_POST['bbp_topic_title'] ) ) {169 if ( ! empty( $_POST['bbp_topic_title'] ) ) { 170 170 $topic_title = esc_attr( strip_tags( $_POST['bbp_topic_title'] ) ); 171 171 } … … 181 181 /** Topic Content *********************************************************/ 182 182 183 if ( ! empty( $_POST['bbp_topic_content'] ) ) {183 if ( ! empty( $_POST['bbp_topic_content'] ) ) { 184 184 $topic_content = $_POST['bbp_topic_content']; 185 185 } … … 232 232 233 233 // Forum exists 234 if ( ! empty( $forum_id ) ) {234 if ( ! empty( $forum_id ) ) { 235 235 236 236 // Forum is a category … … 242 242 243 243 // Forum is closed and user cannot access 244 if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {244 if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) { 245 245 bbp_add_error( 'bbp_new_topic_forum_closed', __( '<strong>ERROR</strong>: This forum has been closed to new topics.', 'bbpress' ) ); 246 246 } … … 248 248 // Forum is private and user cannot access 249 249 if ( bbp_is_forum_private( $forum_id ) ) { 250 if ( ! current_user_can( 'read_private_forums' ) ) {250 if ( ! current_user_can( 'read_private_forums' ) ) { 251 251 bbp_add_error( 'bbp_new_topic_forum_private', __( '<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); 252 252 } … … 254 254 // Forum is hidden and user cannot access 255 255 } elseif ( bbp_is_forum_hidden( $forum_id ) ) { 256 if ( ! current_user_can( 'read_hidden_forums' ) ) {256 if ( ! current_user_can( 'read_hidden_forums' ) ) { 257 257 bbp_add_error( 'bbp_new_topic_forum_hidden', __( '<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); 258 258 } … … 263 263 /** Topic Flooding ********************************************************/ 264 264 265 if ( ! bbp_check_for_flood( $anonymous_data, $topic_author ) ) {265 if ( ! bbp_check_for_flood( $anonymous_data, $topic_author ) ) { 266 266 bbp_add_error( 'bbp_topic_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) ); 267 267 } … … 269 269 /** Topic Duplicate *******************************************************/ 270 270 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 ) ) ) {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 ) ) ) { 272 272 bbp_add_error( 'bbp_topic_duplicate', __( '<strong>ERROR</strong>: Duplicate topic detected; it looks as though you’ve already said that!', 'bbpress' ) ); 273 273 } … … 275 275 /** Topic Blacklist *******************************************************/ 276 276 277 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 ) ) { 278 278 bbp_add_error( 'bbp_topic_blacklist', __( '<strong>ERROR</strong>: Your topic cannot be created at this time.', 'bbpress' ) ); 279 279 } … … 282 282 283 283 // Maybe put into moderation 284 if ( ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {284 if ( ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { 285 285 $topic_status = bbp_get_pending_status_id(); 286 286 287 287 // Check a whitelist of possible topic status ID's 288 } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) {288 } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) { 289 289 $topic_status = $_POST['bbp_topic_status']; 290 290 … … 296 296 /** Topic Tags ************************************************************/ 297 297 298 if ( bbp_allow_topic_tags() && ! empty( $_POST['bbp_topic_tags'] ) ) {298 if ( bbp_allow_topic_tags() && ! empty( $_POST['bbp_topic_tags'] ) ) { 299 299 300 300 // Escape tag input … … 339 339 /** No Errors *************************************************************/ 340 340 341 if ( ! empty( $topic_id ) && !is_wp_error( $topic_id ) ) {341 if ( ! empty( $topic_id ) && ! is_wp_error( $topic_id ) ) { 342 342 343 343 /** Trash Check *******************************************************/ … … 371 371 372 372 // Sticky check after 'bbp_new_topic' action so forum ID meta is set 373 if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {373 if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) { 374 374 375 375 // What's the caps? … … 410 410 411 411 // Add view all? 412 if ( bbp_get_view_all() || ! empty( $view_all ) ) {412 if ( bbp_get_view_all() || ! empty( $view_all ) ) { 413 413 414 414 // User can moderate, so redirect to topic with view all set … … 512 512 513 513 // User cannot edit this topic 514 if ( ! current_user_can( 'edit_topic', $topic_id ) ) {514 if ( ! current_user_can( 'edit_topic', $topic_id ) ) { 515 515 bbp_add_error( 'bbp_edit_topic_permissions', __( '<strong>ERROR</strong>: You do not have permission to edit that topic.', 'bbpress' ) ); 516 516 } … … 534 534 535 535 // Remove kses filters from title and content for capable users and if the nonce is verified 536 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_topic'] ) && ( wp_create_nonce( 'bbp-unfiltered-html-topic_' . $topic_id ) === $_POST['_bbp_unfiltered_html_topic'] ) ) {536 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_topic'] ) && ( wp_create_nonce( 'bbp-unfiltered-html-topic_' . $topic_id ) === $_POST['_bbp_unfiltered_html_topic'] ) ) { 537 537 remove_filter( 'bbp_edit_topic_pre_title', 'wp_filter_kses' ); 538 538 remove_filter( 'bbp_edit_topic_pre_content', 'bbp_encode_bad', 10 ); … … 555 555 556 556 // Forum exists 557 if ( ! empty( $forum_id ) && ( $forum_id !== $current_forum_id ) ) {557 if ( ! empty( $forum_id ) && ( $forum_id !== $current_forum_id ) ) { 558 558 559 559 // Forum is a category … … 565 565 566 566 // Forum is closed and user cannot access 567 if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {567 if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) { 568 568 bbp_add_error( 'bbp_edit_topic_forum_closed', __( '<strong>ERROR</strong>: This forum has been closed to new topics.', 'bbpress' ) ); 569 569 } … … 571 571 // Forum is private and user cannot access 572 572 if ( bbp_is_forum_private( $forum_id ) ) { 573 if ( ! current_user_can( 'read_private_forums' ) ) {573 if ( ! current_user_can( 'read_private_forums' ) ) { 574 574 bbp_add_error( 'bbp_edit_topic_forum_private', __( '<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); 575 575 } … … 577 577 // Forum is hidden and user cannot access 578 578 } elseif ( bbp_is_forum_hidden( $forum_id ) ) { 579 if ( ! current_user_can( 'read_hidden_forums' ) ) {579 if ( ! current_user_can( 'read_hidden_forums' ) ) { 580 580 bbp_add_error( 'bbp_edit_topic_forum_hidden', __( '<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress' ) ); 581 581 } … … 586 586 /** Topic Title ***********************************************************/ 587 587 588 if ( ! empty( $_POST['bbp_topic_title'] ) ) {588 if ( ! empty( $_POST['bbp_topic_title'] ) ) { 589 589 $topic_title = esc_attr( strip_tags( $_POST['bbp_topic_title'] ) ); 590 590 } … … 600 600 /** Topic Content *********************************************************/ 601 601 602 if ( ! empty( $_POST['bbp_topic_content'] ) ) {602 if ( ! empty( $_POST['bbp_topic_content'] ) ) { 603 603 $topic_content = $_POST['bbp_topic_content']; 604 604 } … … 614 614 /** Topic Blacklist *******************************************************/ 615 615 616 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 ) ) { 617 617 bbp_add_error( 'bbp_topic_blacklist', __( '<strong>ERROR</strong>: Your topic cannot be edited at this time.', 'bbpress' ) ); 618 618 } … … 621 621 622 622 // Maybe put into moderation 623 if ( ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {623 if ( ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) { 624 624 625 625 // Set post status to pending if public or closed … … 629 629 630 630 // Check a whitelist of possible topic status ID's 631 } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) {631 } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) { 632 632 $topic_status = $_POST['bbp_topic_status']; 633 633 … … 703 703 /** No Errors *************************************************************/ 704 704 705 if ( ! empty( $topic_id ) && !is_wp_error( $topic_id ) ) {705 if ( ! empty( $topic_id ) && ! is_wp_error( $topic_id ) ) { 706 706 707 707 // Update counts, etc... … … 711 711 712 712 // Revision Reason 713 if ( ! empty( $_POST['bbp_topic_edit_reason'] ) ) {713 if ( ! empty( $_POST['bbp_topic_edit_reason'] ) ) { 714 714 $topic_edit_reason = esc_attr( strip_tags( $_POST['bbp_topic_edit_reason'] ) ); 715 715 } 716 716 717 717 // Update revision log 718 if ( ! empty( $_POST['bbp_log_topic_edit'] ) && ( "1" === $_POST['bbp_log_topic_edit'] ) ) {718 if ( ! empty( $_POST['bbp_log_topic_edit'] ) && ( "1" === $_POST['bbp_log_topic_edit'] ) ) { 719 719 $revision_id = wp_save_post_revision( $topic_id ); 720 720 if ( ! empty( $revision_id ) ) { … … 739 739 /** Stickies **********************************************************/ 740 740 741 if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( bbp_get_topic_types() ) ) ) {741 if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( bbp_get_topic_types() ) ) ) { 742 742 743 743 // What's the caps? … … 782 782 783 783 // Add view all? 784 if ( ! empty( $view_all ) ) {784 if ( ! empty( $view_all ) ) { 785 785 $topic_url = bbp_add_view_all( $topic_url ); 786 786 } … … 859 859 // It expects anonymous_data to be sanitized. 860 860 // Check bbp_filter_anonymous_post_data() for sanitization. 861 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) {861 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) { 862 862 863 863 // Parse arguments against default values … … 879 879 880 880 } else { 881 if ( empty( $is_edit ) && ! current_user_can( 'throttle' ) ) {881 if ( empty( $is_edit ) && ! current_user_can( 'throttle' ) ) { 882 882 bbp_update_user_last_posted( $author_id ); 883 883 } … … 885 885 886 886 // Handle Subscription Checkbox 887 if ( bbp_is_subscriptions_active() && ! empty( $author_id ) ) {887 if ( bbp_is_subscriptions_active() && ! empty( $author_id ) ) { 888 888 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id ); 889 $subscheck = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false;889 $subscheck = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false; 890 890 891 891 // Subscribed and unsubscribing … … 952 952 953 953 // Topic was passed 954 if ( ! empty( $topic_id ) ) {954 if ( ! empty( $topic_id ) ) { 955 955 956 956 // Get the forum ID if none was passed … … 976 976 977 977 // Loop through ancestors 978 if ( ! empty( $ancestors ) ) {978 if ( ! empty( $ancestors ) ) { 979 979 foreach ( $ancestors as $ancestor ) { 980 980 … … 1033 1033 1034 1034 // Only proceed if stickies are found 1035 if ( ! empty( $old_stickies ) ) {1035 if ( ! empty( $old_stickies ) ) { 1036 1036 1037 1037 // Define local variables … … 1078 1078 1079 1079 // Loop through ancestors and update them 1080 if ( ! empty( $old_forum_ancestors ) ) {1080 if ( ! empty( $old_forum_ancestors ) ) { 1081 1081 foreach ( $old_forum_ancestors as $ancestor ) { 1082 1082 if ( bbp_is_forum( $ancestor ) ) { … … 1091 1091 1092 1092 // Make sure we're not walking twice 1093 if ( ! in_array( $new_forum_id, $old_forum_ancestors ) ) {1093 if ( ! in_array( $new_forum_id, $old_forum_ancestors ) ) { 1094 1094 1095 1095 // Get topic ancestors … … 1100 1100 1101 1101 // Loop through ancestors and update them 1102 if ( ! empty( $new_forum_ancestors ) ) {1102 if ( ! empty( $new_forum_ancestors ) ) { 1103 1103 foreach ( $new_forum_ancestors as $ancestor ) { 1104 1104 if ( bbp_is_forum( $ancestor ) ) { … … 1184 1184 1185 1185 // Cannot edit source topic 1186 if ( ! current_user_can( 'edit_topic', $source_topic->ID ) ) {1186 if ( ! current_user_can( 'edit_topic', $source_topic->ID ) ) { 1187 1187 bbp_add_error( 'bbp_merge_topic_source_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress' ) ); 1188 1188 return; … … 1204 1204 1205 1205 // Cannot edit destination topic 1206 if ( ! current_user_can( 'edit_topic', $destination_topic->ID ) ) {1206 if ( ! current_user_can( 'edit_topic', $destination_topic->ID ) ) { 1207 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 1208 } … … 1240 1240 1241 1241 // Remove the topic from everybody's subscriptions 1242 if ( ! empty( $subscribers ) ) {1242 if ( ! empty( $subscribers ) ) { 1243 1243 1244 1244 // Loop through each user … … 1246 1246 1247 1247 // Shift the subscriber if told to 1248 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() ) { 1249 1249 bbp_add_user_subscription( $subscriber, $destination_topic->ID ); 1250 1250 } … … 1261 1261 1262 1262 // Remove the topic from everybody's favorites 1263 if ( ! empty( $favoriters ) ) {1263 if ( ! empty( $favoriters ) ) { 1264 1264 1265 1265 // Loop through each user … … 1267 1267 1268 1268 // Shift the favoriter if told to 1269 if ( ! empty( $_POST['bbp_topic_favoriters'] ) && "1" === $_POST['bbp_topic_favoriters'] ) {1269 if ( ! empty( $_POST['bbp_topic_favoriters'] ) && "1" === $_POST['bbp_topic_favoriters'] ) { 1270 1270 bbp_add_user_favorite( $favoriter, $destination_topic->ID ); 1271 1271 } … … 1282 1282 1283 1283 // Tags to possibly merge 1284 if ( ! empty( $source_topic_tags ) && !is_wp_error( $source_topic_tags ) ) {1284 if ( ! empty( $source_topic_tags ) && ! is_wp_error( $source_topic_tags ) ) { 1285 1285 1286 1286 // Shift the tags if told to 1287 if ( ! empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) {1287 if ( ! empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) { 1288 1288 wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true ); 1289 1289 } … … 1312 1312 array_unshift( $replies, $source_topic ); 1313 1313 1314 if ( ! empty( $replies ) ) {1314 if ( ! empty( $replies ) ) { 1315 1315 1316 1316 /** Merge Replies *****************************************************/ … … 1494 1494 1495 1495 // Use cannot edit topic 1496 if ( ! current_user_can( 'edit_topic', $source_topic->ID ) ) {1496 if ( ! current_user_can( 'edit_topic', $source_topic->ID ) ) { 1497 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 1498 } 1499 1499 1500 1500 // How to Split 1501 if ( ! empty( $_POST['bbp_topic_split_option'] ) ) {1501 if ( ! empty( $_POST['bbp_topic_split_option'] ) ) { 1502 1502 $split_option = (string) trim( $_POST['bbp_topic_split_option'] ); 1503 1503 } 1504 1504 1505 1505 // Invalid split option 1506 if ( empty( $split_option ) || ! in_array( $split_option, array( 'existing', 'reply' ) ) ) {1506 if ( empty( $split_option ) || ! in_array( $split_option, array( 'existing', 'reply' ) ) ) { 1507 1507 bbp_add_error( 'bbp_split_topic_option', __( '<strong>ERROR</strong>: You need to choose a valid split option.', 'bbpress' ) ); 1508 1508 … … 1532 1532 1533 1533 // User cannot edit the destination topic 1534 if ( ! current_user_can( 'edit_topic', $destination_topic->ID ) ) {1534 if ( ! current_user_can( 'edit_topic', $destination_topic->ID ) ) { 1535 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 1536 } … … 1546 1546 1547 1547 // Use the new title that was passed 1548 if ( ! empty( $_POST['bbp_topic_split_destination_title'] ) ) {1548 if ( ! empty( $_POST['bbp_topic_split_destination_title'] ) ) { 1549 1549 $destination_topic_title = esc_attr( strip_tags( $_POST['bbp_topic_split_destination_title'] ) ); 1550 1550 … … 1612 1612 1613 1613 // Copy the subscribers 1614 if ( ! empty( $_POST['bbp_topic_subscribers'] ) && "1" === $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active() ) {1614 if ( ! empty( $_POST['bbp_topic_subscribers'] ) && "1" === $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active() ) { 1615 1615 1616 1616 // Get the subscribers 1617 1617 $subscribers = bbp_get_topic_subscribers( $source_topic->ID ); 1618 1618 1619 if ( ! empty( $subscribers ) ) {1619 if ( ! empty( $subscribers ) ) { 1620 1620 1621 1621 // Add subscribers to new topic … … 1629 1629 1630 1630 // Copy the favoriters if told to 1631 if ( ! empty( $_POST['bbp_topic_favoriters'] ) && ( "1" === $_POST['bbp_topic_favoriters'] ) ) {1631 if ( ! empty( $_POST['bbp_topic_favoriters'] ) && ( "1" === $_POST['bbp_topic_favoriters'] ) ) { 1632 1632 1633 1633 // Get the favoriters 1634 1634 $favoriters = bbp_get_topic_favoriters( $source_topic->ID ); 1635 1635 1636 if ( ! empty( $favoriters ) ) {1636 if ( ! empty( $favoriters ) ) { 1637 1637 1638 1638 // Add the favoriters to new topic … … 1646 1646 1647 1647 // Copy the tags if told to 1648 if ( ! empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) {1648 if ( ! empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) { 1649 1649 1650 1650 // Get the source topic tags 1651 1651 $source_topic_tags = wp_get_post_terms( $source_topic->ID, bbp_get_topic_tag_tax_id(), array( 'fields' => 'names' ) ); 1652 1652 1653 if ( ! empty( $source_topic_tags ) ) {1653 if ( ! empty( $source_topic_tags ) ) { 1654 1654 wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true ); 1655 1655 } … … 1663 1663 1664 1664 // Make sure there are replies to loop through 1665 if ( ! empty( $replies ) && !is_wp_error( $replies ) ) {1665 if ( ! empty( $replies ) && ! is_wp_error( $replies ) ) { 1666 1666 1667 1667 // Calculate starting point for reply positions … … 1709 1709 1710 1710 // Not a reply to a reply that moved over 1711 if ( ! in_array( $reply_to, $reply_ids ) ) {1711 if ( ! in_array( $reply_to, $reply_ids ) ) { 1712 1712 bbp_update_reply_to( $reply->ID, 0 ); 1713 1713 } … … 1839 1839 1840 1840 // Bail if actions aren't meant for this function 1841 if ( ! in_array( $action, $possible_actions ) ) {1841 if ( ! in_array( $action, $possible_actions ) ) { 1842 1842 return; 1843 1843 } … … 1866 1866 1867 1867 // Can user edit topic tags? 1868 if ( ! current_user_can( 'edit_topic_tags' ) ) {1868 if ( ! current_user_can( 'edit_topic_tags' ) ) { 1869 1869 bbp_add_error( 'bbp_manage_topic_tag_update_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags.', 'bbpress' ) ); 1870 1870 return; … … 1878 1878 1879 1879 // Attempt to update the tag 1880 $slug = ! empty( $_POST['tag-slug'] ) ? $_POST['tag-slug'] : '';1881 $description = ! empty( $_POST['tag-description'] ) ? $_POST['tag-description'] : '';1880 $slug = ! empty( $_POST['tag-slug'] ) ? $_POST['tag-slug'] : ''; 1881 $description = ! empty( $_POST['tag-description'] ) ? $_POST['tag-description'] : ''; 1882 1882 $tag = wp_update_term( $tag_id, bbp_get_topic_tag_tax_id(), array( 'name' => $name, 'slug' => $slug, 'description' => $description ) ); 1883 1883 … … 1906 1906 1907 1907 // Can user edit topic tags? 1908 if ( ! current_user_can( 'edit_topic_tags' ) ) {1908 if ( ! current_user_can( 'edit_topic_tags' ) ) { 1909 1909 bbp_add_error( 'bbp_manage_topic_tag_merge_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags.', 'bbpress' ) ); 1910 1910 return; … … 1964 1964 1965 1965 // Can user delete topic tags? 1966 if ( ! current_user_can( 'delete_topic_tags' ) ) {1966 if ( ! current_user_can( 'delete_topic_tags' ) ) { 1967 1967 bbp_add_error( 'bbp_manage_topic_tag_delete_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to delete the topic tags.', 'bbpress' ) ); 1968 1968 return; … … 1990 1990 1991 1991 // Redirect back 1992 $redirect = ( ! empty( $redirect ) && !is_wp_error( $redirect ) ) ? $redirect : home_url();1992 $redirect = ( ! empty( $redirect ) && ! is_wp_error( $redirect ) ) ? $redirect : home_url(); 1993 1993 wp_safe_redirect( $redirect ); 1994 1994 … … 2046 2046 function bbp_get_stickies( $forum_id = 0 ) { 2047 2047 $stickies = empty( $forum_id ) ? bbp_get_super_stickies() : get_post_meta( $forum_id, '_bbp_sticky_topics', true ); 2048 $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies;2048 $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies; 2049 2049 2050 2050 return apply_filters( 'bbp_get_stickies', $stickies, (int) $forum_id ); … … 2062 2062 function bbp_get_super_stickies() { 2063 2063 $stickies = get_option( '_bbp_super_sticky_topics', array() ); 2064 $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies;2064 $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies; 2065 2065 2066 2066 return apply_filters( 'bbp_get_super_stickies', $stickies ); … … 2117 2117 2118 2118 // Bail if actions aren't meant for this function 2119 if ( ! in_array( $action, $possible_actions ) ) {2119 if ( ! in_array( $action, $possible_actions ) ) { 2120 2120 return; 2121 2121 } … … 2135 2135 2136 2136 // What is the user doing here? 2137 if ( ! current_user_can( 'edit_topic', $topic->ID ) || ( 'bbp_toggle_topic_trash' === $action && !current_user_can( 'delete_topic', $topic->ID ) ) ) {2137 if ( ! current_user_can( 'edit_topic', $topic->ID ) || ( 'bbp_toggle_topic_trash' === $action && ! current_user_can( 'delete_topic', $topic->ID ) ) ) { 2138 2138 bbp_add_error( 'bbp_toggle_topic_permission', __( '<strong>ERROR:</strong> You do not have the permission to do that.', 'bbpress' ) ); 2139 2139 return; … … 2158 2158 2159 2159 $is_sticky = bbp_is_topic_sticky( $topic_id ); 2160 $is_super = false === $is_sticky && ! empty( $_GET['super'] ) && ( "1" === $_GET['super'] ) ? true : false;2160 $is_super = false === $is_sticky && ! empty( $_GET['super'] ) && ( "1" === $_GET['super'] ) ? true : false; 2161 2161 $success = true === $is_sticky ? bbp_unstick_topic( $topic_id ) : bbp_stick_topic( $topic_id, $is_super ); 2162 2162 $failure = true === $is_sticky ? __( '<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress' ); … … 2178 2178 case 'bbp_toggle_topic_trash' : 2179 2179 2180 $sub_action = ! empty( $_GET['sub_action'] ) && in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false;2180 $sub_action = ! empty( $_GET['sub_action'] ) && in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false; 2181 2181 2182 2182 if ( empty( $sub_action ) ) { … … 2218 2218 2219 2219 // No errors 2220 if ( false !== $success && ! is_wp_error( $success ) ) {2220 if ( false !== $success && ! is_wp_error( $success ) ) { 2221 2221 2222 2222 // Redirect back to the topic's forum … … 2267 2267 2268 2268 // Users exist 2269 if ( ! empty( $users ) ) {2269 if ( ! empty( $users ) ) { 2270 2270 2271 2271 // Loop through users … … 2292 2292 2293 2293 // Subscriptions are not active 2294 if ( ! bbp_is_subscriptions_active() ) {2294 if ( ! bbp_is_subscriptions_active() ) { 2295 2295 return; 2296 2296 } … … 2307 2307 2308 2308 // Users exist 2309 if ( ! empty( $users ) ) {2309 if ( ! empty( $users ) ) { 2310 2310 2311 2311 // Loop through users … … 2536 2536 2537 2537 // Adjust last_id's based on last_reply post_type 2538 if ( empty( $active_id ) || ! bbp_is_reply( $active_id ) ) {2538 if ( empty( $active_id ) || ! bbp_is_reply( $active_id ) ) { 2539 2539 $active_id = $topic_id; 2540 2540 } … … 2576 2576 2577 2577 // Update only if published 2578 if ( ! empty( $new_time ) ) {2578 if ( ! empty( $new_time ) ) { 2579 2579 update_post_meta( $topic_id, '_bbp_last_active_time', $new_time ); 2580 2580 } … … 2617 2617 2618 2618 // Adjust last_id's based on last_reply post_type 2619 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {2619 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 2620 2620 $reply_id = 0; 2621 2621 } … … 2933 2933 ) ); 2934 2934 2935 if ( ! empty( $replies->posts ) ) {2935 if ( ! empty( $replies->posts ) ) { 2936 2936 2937 2937 // Prevent debug notices … … 2976 2976 2977 2977 // Topic has tags 2978 if ( ! empty( $terms ) ) {2978 if ( ! empty( $terms ) ) { 2979 2979 2980 2980 // Loop through and collect term names … … 2984 2984 2985 2985 // Topic terms have slugs 2986 if ( ! empty( $term_names ) ) {2986 if ( ! empty( $term_names ) ) { 2987 2987 2988 2988 // Add the original post status as post meta for future restoration … … 3070 3070 3071 3071 // There are replies to untrash 3072 if ( ! empty( $pre_spammed_replies ) ) {3072 if ( ! empty( $pre_spammed_replies ) ) { 3073 3073 3074 3074 // Maybe reverse the trashed replies array … … 3105 3105 3106 3106 // Delete pre-spam topic tag meta 3107 if ( ! empty( $terms ) ) {3107 if ( ! empty( $terms ) ) { 3108 3108 delete_post_meta( $topic_id, '_bbp_spam_topic_tags' ); 3109 3109 } … … 3149 3149 do_action( 'bbp_stick_topic', $topic_id, $super ); 3150 3150 3151 if ( ! is_array( $stickies ) ) {3151 if ( ! is_array( $stickies ) ) { 3152 3152 $stickies = array( $topic_id ); 3153 3153 } else { … … 3167 3167 // Reset keys 3168 3168 $stickies = array_values( $stickies ); 3169 $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies );3169 $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); 3170 3170 3171 3171 do_action( 'bbp_stuck_topic', $topic_id, $super, $success ); … … 3203 3203 if ( empty( $stickies ) ) { 3204 3204 $success = true; 3205 } elseif ( ! in_array( $topic_id, $stickies ) ) {3205 } elseif ( ! in_array( $topic_id, $stickies ) ) { 3206 3206 $success = true; 3207 3207 } elseif ( false === $offset ) { … … 3210 3210 array_splice( $stickies, $offset, 1 ); 3211 3211 if ( empty( $stickies ) ) { 3212 $success = ! empty( $super ) ? delete_option( '_bbp_super_sticky_topics' ) : delete_post_meta( $forum_id, '_bbp_sticky_topics' );3212 $success = ! empty( $super ) ? delete_option( '_bbp_super_sticky_topics' ) : delete_post_meta( $forum_id, '_bbp_sticky_topics' ); 3213 3213 } else { 3214 $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies );3214 $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies ); 3215 3215 } 3216 3216 } … … 3338 3338 ) ); 3339 3339 3340 if ( ! empty( $replies->posts ) ) {3340 if ( ! empty( $replies->posts ) ) { 3341 3341 3342 3342 // Prevent debug notices … … 3397 3397 3398 3398 // There are replies to untrash 3399 if ( ! empty( $pre_trashed_replies ) ) {3399 if ( ! empty( $pre_trashed_replies ) ) { 3400 3400 3401 3401 // Maybe reverse the trashed replies array … … 3535 3535 $terms[] = $term->name; 3536 3536 } 3537 $terms = ! empty( $terms ) ? implode( $sep, $terms ) : '';3537 $terms = ! empty( $terms ) ? implode( $sep, $terms ) : ''; 3538 3538 3539 3539 return apply_filters( 'bbp_get_topic_tags', $terms, $topic_id ); … … 3590 3590 3591 3591 // User cannot access this forum 3592 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() ) ) ) { 3593 3593 return; 3594 3594 } … … 3681 3681 3682 3682 // User cannot edit topic, so redirect back to topic 3683 if ( ! current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {3683 if ( ! current_user_can( 'edit_topic', bbp_get_topic_id() ) ) { 3684 3684 wp_safe_redirect( bbp_get_topic_permalink() ); 3685 3685 exit(); … … 3706 3706 3707 3707 // Bail if current user cannot edit topic tags 3708 if ( ! current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {3708 if ( ! current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) { 3709 3709 wp_safe_redirect( bbp_get_topic_tag_link() ); 3710 3710 exit(); -
trunk/src/includes/topics/template.php
r5434 r5443 145 145 146 146 // Other defaults 147 $default_topic_search = ! empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;147 $default_topic_search = ! empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false; 148 148 $default_show_stickies = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) && ( false === $default_topic_search ); 149 149 $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any'; … … 211 211 212 212 // Limited the number of pages shown 213 if ( ! empty( $r['max_num_pages'] ) ) {213 if ( ! empty( $r['max_num_pages'] ) ) { 214 214 $bbp->topic_query->max_num_pages = $r['max_num_pages']; 215 215 } … … 218 218 219 219 // Put sticky posts at the top of the posts array 220 if ( ! empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) {220 if ( ! empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) { 221 221 222 222 // Get super stickies and stickies in this forum … … 224 224 225 225 // Get stickies for current forum 226 if ( ! empty( $r['post_parent'] ) ) {226 if ( ! empty( $r['post_parent'] ) ) { 227 227 $stickies = array_merge( $stickies, bbp_get_stickies( $r['post_parent'] ) ); 228 228 } … … 232 232 233 233 // We have stickies 234 if ( is_array( $stickies ) && ! empty( $stickies ) ) {234 if ( is_array( $stickies ) && ! empty( $stickies ) ) { 235 235 236 236 // Start the offset at -1 so first sticky is at correct 0 offset … … 273 273 274 274 // If any posts have been excluded specifically, Ignore those that are sticky. 275 if ( ! empty( $stickies ) && !empty( $r['post__not_in'] ) ) {275 if ( ! empty( $stickies ) && ! empty( $r['post__not_in'] ) ) { 276 276 $stickies = array_diff( $stickies, $r['post__not_in'] ); 277 277 } 278 278 279 279 // Fetch sticky posts that weren't in the query results 280 if ( ! empty( $stickies ) ) {280 if ( ! empty( $stickies ) ) { 281 281 282 282 // Query to use in get_posts to get sticky posts … … 311 311 // Get all stickies 312 312 $sticky_posts = get_posts( $sticky_query ); 313 if ( ! empty( $sticky_posts ) ) {313 if ( ! empty( $sticky_posts ) ) { 314 314 315 315 // Get a count of the visible stickies … … 343 343 344 344 // Limit the number of topics shown based on maximum allowed pages 345 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 ) { 346 346 $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count; 347 347 } … … 490 490 491 491 // Easy empty checking 492 if ( ! empty( $topic_id ) && is_numeric( $topic_id ) ) {492 if ( ! empty( $topic_id ) && is_numeric( $topic_id ) ) { 493 493 $bbp_topic_id = $topic_id; 494 494 495 495 // Currently inside a topic loop 496 } elseif ( ! empty( $bbp->topic_query->in_the_loop ) && isset( $bbp->topic_query->post->ID ) ) {496 } elseif ( ! empty( $bbp->topic_query->in_the_loop ) && isset( $bbp->topic_query->post->ID ) ) { 497 497 $bbp_topic_id = $bbp->topic_query->post->ID; 498 498 499 499 // Currently inside a search loop 500 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_topic( $bbp->search_query->post->ID ) ) {500 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_topic( $bbp->search_query->post->ID ) ) { 501 501 $bbp_topic_id = $bbp->search_query->post->ID; 502 502 503 503 // Currently viewing/editing a topic, likely alone 504 } elseif ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && ! empty( $bbp->current_topic_id ) ) {504 } elseif ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && ! empty( $bbp->current_topic_id ) ) { 505 505 $bbp_topic_id = $bbp->current_topic_id; 506 506 … … 600 600 601 601 // Use the redirect address 602 if ( ! empty( $redirect_to ) ) {602 if ( ! empty( $redirect_to ) ) { 603 603 $topic_permalink = esc_url_raw( $redirect_to ); 604 604 … … 674 674 // Set root text to page title 675 675 $page = bbp_get_page_by_path( bbp_get_topic_archive_slug() ); 676 if ( ! empty( $page ) ) {676 if ( ! empty( $page ) ) { 677 677 $title = get_the_title( $page->ID ); 678 678 … … 770 770 } 771 771 772 if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {772 if ( ! empty( $length ) && ( $excerpt_length > $length ) ) { 773 773 $excerpt = substr( $excerpt, 0, $length - 1 ); 774 774 $excerpt .= '…'; … … 808 808 809 809 // 4 days, 4 hours ago 810 if ( ! empty( $humanize ) ) {811 $gmt_s = ! empty( $gmt ) ? 'U' : 'G';810 if ( ! empty( $humanize ) ) { 811 $gmt_s = ! empty( $gmt ) ? 'U' : 'G'; 812 812 $date = get_post_time( $gmt_s, $gmt, $topic_id ); 813 813 $time = false; // For filter below … … 885 885 886 886 // Bump if topic is in loop 887 if ( ! bbp_show_lead_topic() ) {887 if ( ! bbp_show_lead_topic() ) { 888 888 $total++; 889 889 } … … 903 903 // Add pagination to query object 904 904 $pagination_links = paginate_links( $pagination ); 905 if ( ! empty( $pagination_links ) ) {905 if ( ! empty( $pagination_links ) ) { 906 906 907 907 // Remove first page from pagination … … 977 977 $revision_log = bbp_get_topic_raw_revision_log( $topic_id ); 978 978 979 if ( empty( $topic_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) {979 if ( empty( $topic_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) { 980 980 return false; 981 981 } … … 1003 1003 1004 1004 $r .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n"; 1005 if ( ! empty( $reason ) ) {1005 if ( ! empty( $reason ) ) { 1006 1006 $r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n"; 1007 1007 } else { … … 1115 1115 */ 1116 1116 function bbp_is_topic_open( $topic_id = 0 ) { 1117 return ! bbp_is_topic_closed( $topic_id );1117 return ! bbp_is_topic_closed( $topic_id ); 1118 1118 } 1119 1119 … … 1154 1154 $stickies = bbp_get_stickies( $forum_id ); 1155 1155 1156 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 ) ) ) { 1157 1157 return true; 1158 1158 } … … 1242 1242 $retval = false; 1243 1243 1244 if ( ! bbp_get_topic_author_id( $topic_id ) ) {1244 if ( ! bbp_get_topic_author_id( $topic_id ) ) { 1245 1245 $retval = true; 1246 1246 … … 1292 1292 $topic_id = bbp_get_topic_id( $topic_id ); 1293 1293 1294 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1294 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1295 1295 $author = get_the_author_meta( 'display_name', bbp_get_topic_author_id( $topic_id ) ); 1296 1296 } else { … … 1363 1363 1364 1364 // Check for anonymous user 1365 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1365 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1366 1366 1367 1367 // Get the author ID … … 1427 1427 1428 1428 $topic_id = bbp_get_topic_id( $topic_id ); 1429 if ( ! empty( $topic_id ) ) {1430 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1429 if ( ! empty( $topic_id ) ) { 1430 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1431 1431 $author_avatar = get_avatar( bbp_get_topic_author_id( $topic_id ), $size ); 1432 1432 } else { … … 1490 1490 1491 1491 // Topic ID is good 1492 if ( ! empty( $topic_id ) ) {1492 if ( ! empty( $topic_id ) ) { 1493 1493 1494 1494 // Get some useful topic information … … 1506 1506 1507 1507 // Setup title and author_links array 1508 $link_title = ! empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : '';1508 $link_title = ! empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : ''; 1509 1509 $author_links = array(); 1510 1510 … … 1582 1582 1583 1583 // Check for anonymous user or non-existant user 1584 if ( ! bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) {1584 if ( ! bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) { 1585 1585 $author_url = bbp_get_user_profile_url( bbp_get_topic_author_id( $topic_id ) ); 1586 1586 } else { … … 1627 1627 1628 1628 // Not anonymous user 1629 if ( ! bbp_is_topic_anonymous( $topic_id ) ) {1629 if ( ! bbp_is_topic_anonymous( $topic_id ) ) { 1630 1630 1631 1631 // Use topic author email address 1632 1632 $user_id = bbp_get_topic_author_id( $topic_id ); 1633 1633 $user = get_userdata( $user_id ); 1634 $author_email = ! empty( $user->user_email ) ? $user->user_email : '';1634 $author_email = ! empty( $user->user_email ) ? $user->user_email : ''; 1635 1635 1636 1636 // Anonymous … … 1815 1815 if ( empty( $last_active ) ) { 1816 1816 $reply_id = bbp_get_topic_last_reply_id( $topic_id ); 1817 if ( ! empty( $reply_id ) ) {1817 if ( ! empty( $reply_id ) ) { 1818 1818 $last_active = get_post_field( 'post_date', $reply_id ); 1819 1819 } else { … … 1822 1822 } 1823 1823 1824 $last_active = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';1824 $last_active = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; 1825 1825 1826 1826 // Return the time since … … 2037 2037 $reply_id = bbp_get_topic_last_reply_id( $topic_id ); 2038 2038 2039 if ( ! empty( $reply_id ) && ( $reply_id !== $topic_id ) ) {2039 if ( ! empty( $reply_id ) && ( $reply_id !== $topic_id ) ) { 2040 2040 $reply_url = bbp_get_reply_url( $reply_id ); 2041 2041 } else { … … 2079 2079 $time_since = bbp_get_topic_last_active_time( $topic_id ); 2080 2080 2081 if ( ! empty( $time_since ) ) {2081 if ( ! empty( $time_since ) ) { 2082 2082 $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; 2083 2083 } else { … … 2137 2137 2138 2138 // This forum has hidden topics 2139 if ( ! empty( $deleted ) && current_user_can( 'edit_others_replies' ) ) {2139 if ( ! empty( $deleted ) && current_user_can( 'edit_others_replies' ) ) { 2140 2140 2141 2141 // Extra text … … 2332 2332 2333 2333 // If terms exist, explode them and compile the return value 2334 if ( ! empty( $terms ) ) {2334 if ( ! empty( $terms ) ) { 2335 2335 $terms = implode( $r['sep'], $terms ); 2336 2336 $retval = $r['before'] . $terms . $r['after']; … … 2520 2520 2521 2521 // Bypass check if user has caps 2522 if ( ! current_user_can( 'edit_others_topics' ) ) {2522 if ( ! current_user_can( 'edit_others_topics' ) ) { 2523 2523 2524 2524 // User cannot edit or it is past the lock time 2525 if ( empty( $topic ) || ! current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) {2525 if ( empty( $topic ) || ! current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) { 2526 2526 return; 2527 2527 } … … 2648 2648 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2649 2649 2650 if ( empty( $topic ) || ! current_user_can( 'delete_topic', $topic->ID ) ) {2650 if ( empty( $topic ) || ! current_user_can( 'delete_topic', $topic->ID ) ) { 2651 2651 return; 2652 2652 } … … 2658 2658 } 2659 2659 2660 if ( bbp_is_topic_trash( $topic->ID ) || ! EMPTY_TRASH_DAYS ) {2660 if ( bbp_is_topic_trash( $topic->ID ) || ! empty_TRASH_DAYS ) { 2661 2661 $actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>'; 2662 2662 } … … 2716 2716 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2717 2717 2718 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2718 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2719 2719 return; 2720 2720 } … … 2778 2778 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2779 2779 2780 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2780 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2781 2781 return; 2782 2782 } … … 2848 2848 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2849 2849 2850 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2850 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2851 2851 return; 2852 2852 } … … 2906 2906 $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) ); 2907 2907 2908 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {2908 if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { 2909 2909 return; 2910 2910 } … … 3003 3003 $from_num = bbp_number_format( $start_num ); 3004 3004 $to_num = bbp_number_format( ( $start_num + ( $bbp->topic_query->posts_per_page - 1 ) > $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $start_num + ( $bbp->topic_query->posts_per_page - 1 ) ); 3005 $total_int = (int) ! empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count;3005 $total_int = (int) ! empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count; 3006 3006 $total = bbp_number_format( $total_int ); 3007 3007 … … 3062 3062 3063 3063 // Bail if not viewing a topic 3064 if ( ! bbp_is_single_topic() ) {3064 if ( ! bbp_is_single_topic() ) { 3065 3065 return; 3066 3066 } … … 3182 3182 3183 3183 // Used variables 3184 $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : '';3184 $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : ''; 3185 3185 3186 3186 // Start an output buffer, we'll finish it after the select loop … … 3348 3348 // Topic has replies 3349 3349 $last_reply = bbp_get_topic_last_reply_id( $topic_id ); 3350 if ( ! empty( $last_reply ) ) {3350 if ( ! empty( $last_reply ) ) { 3351 3351 $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) ); 3352 3352 $retstr = sprintf( esc_html__( 'This topic contains %1$s, has %2$s, and was last updated by %3$s %4$s.', 'bbpress' ), $reply_count, $voice_count, $last_updated_by, $time_since ); … … 3465 3465 3466 3466 // Add before and after if description exists 3467 if ( ! empty( $term->term_id ) ) {3467 if ( ! empty( $term->term_id ) ) { 3468 3468 $retval = $term->term_id; 3469 3469 … … 3509 3509 3510 3510 // Add before and after if description exists 3511 if ( ! empty( $term->name ) ) {3511 if ( ! empty( $term->name ) ) { 3512 3512 $retval = $term->name; 3513 3513 … … 3553 3553 3554 3554 // Add before and after if description exists 3555 if ( ! empty( $term->slug ) ) {3555 if ( ! empty( $term->slug ) ) { 3556 3556 $retval = $term->slug; 3557 3557 … … 3597 3597 3598 3598 // Add before and after if description exists 3599 if ( ! empty( $term->term_id ) ) {3599 if ( ! empty( $term->term_id ) ) { 3600 3600 $retval = get_term_link( $term, bbp_get_topic_tag_tax_id() ); 3601 3601 … … 3642 3642 3643 3643 // Add before and after if description exists 3644 if ( ! empty( $term->term_id ) ) {3644 if ( ! empty( $term->term_id ) ) { 3645 3645 3646 3646 $bbp = bbpress(); … … 3705 3705 3706 3706 // Add before and after if description exists 3707 if ( ! empty( $term->description ) ) {3707 if ( ! empty( $term->description ) ) { 3708 3708 $retval = $r['before'] . $term->description . $r['after']; 3709 3709 … … 3845 3845 3846 3846 // Topic exists 3847 if ( ! empty( $topic_id ) ) {3847 if ( ! empty( $topic_id ) ) { 3848 3848 3849 3849 // Topic is spammed so display pre-spam terms … … 3874 3874 3875 3875 // Set the return value 3876 $topic_tags = ( ! empty( $new_terms ) ) ? implode( ', ', $new_terms ) : '';3876 $topic_tags = ( ! empty( $new_terms ) ) ? implode( ', ', $new_terms ) : ''; 3877 3877 3878 3878 // No data
Note: See TracChangeset
for help on using the changeset viewer.