Changeset 5443 for trunk/src/includes/topics/functions.php
- Timestamp:
- 07/11/2014 09:57:54 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/topics/functions.php (modified) (92 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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();
Note: See TracChangeset
for help on using the changeset viewer.