Changeset 5829 for trunk/src/includes/replies/functions.php
- Timestamp:
- 07/14/2015 12:46:38 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/replies/functions.php (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r5827 r5829 129 129 130 130 // Anonymous data checks out, so set cookies, etc... 131 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) {131 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) { 132 132 bbp_set_current_anonymous_user_data( $anonymous_data ); 133 133 } … … 179 179 180 180 // Try to use the forum id of the topic 181 if ( ! isset( $_POST['bbp_forum_id'] ) && !empty( $topic_id ) ) {181 if ( ! isset( $_POST['bbp_forum_id'] ) && ! empty( $topic_id ) ) { 182 182 $forum_id = bbp_get_topic_forum_id( $topic_id ); 183 183 … … 219 219 220 220 // Forum exists 221 if ( ! empty( $forum_id ) ) {221 if ( ! empty( $forum_id ) ) { 222 222 223 223 // Forum is a category … … 251 251 252 252 // Remove kses filters from title and content for capable users and if the nonce is verified 253 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_reply'] ) && wp_create_nonce( 'bbp-unfiltered-html-reply_' . $topic_id ) === $_POST['_bbp_unfiltered_html_reply'] ) {253 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_reply'] ) && wp_create_nonce( 'bbp-unfiltered-html-reply_' . $topic_id ) === $_POST['_bbp_unfiltered_html_reply'] ) { 254 254 remove_filter( 'bbp_new_reply_pre_title', 'wp_filter_kses' ); 255 255 remove_filter( 'bbp_new_reply_pre_content', 'bbp_encode_bad', 10 ); … … 259 259 /** Reply Title ***********************************************************/ 260 260 261 if ( ! empty( $_POST['bbp_reply_title'] ) ) {261 if ( ! empty( $_POST['bbp_reply_title'] ) ) { 262 262 $reply_title = sanitize_text_field( $_POST['bbp_reply_title'] ); 263 263 } … … 268 268 /** Reply Content *********************************************************/ 269 269 270 if ( ! empty( $_POST['bbp_reply_content'] ) ) {270 if ( ! empty( $_POST['bbp_reply_content'] ) ) { 271 271 $reply_content = $_POST['bbp_reply_content']; 272 272 } … … 282 282 /** Reply Flooding ********************************************************/ 283 283 284 if ( ! bbp_check_for_flood( $anonymous_data, $reply_author ) ) {284 if ( ! bbp_check_for_flood( $anonymous_data, $reply_author ) ) { 285 285 bbp_add_error( 'bbp_reply_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) ); 286 286 } … … 288 288 /** Reply Duplicate *******************************************************/ 289 289 290 if ( ! bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) {290 if ( ! bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) { 291 291 bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: Duplicate reply detected; it looks as though you’ve already said that!', 'bbpress' ) ); 292 292 } … … 294 294 /** Reply Blacklist *******************************************************/ 295 295 296 if ( ! bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {296 if ( ! bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 297 297 bbp_add_error( 'bbp_reply_blacklist', __( '<strong>ERROR</strong>: Your reply cannot be created at this time.', 'bbpress' ) ); 298 298 } … … 301 301 302 302 // Maybe put into moderation 303 if ( ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {303 if ( ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 304 304 $reply_status = bbp_get_pending_status_id(); 305 305 … … 368 368 369 369 // Check for missing reply_id or error 370 if ( ! empty( $reply_id ) && !is_wp_error( $reply_id ) ) {370 if ( ! empty( $reply_id ) && !is_wp_error( $reply_id ) ) { 371 371 372 372 /** Topic Tags ********************************************************/ … … 547 547 548 548 // Remove kses filters from title and content for capable users and if the nonce is verified 549 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_reply'] ) && wp_create_nonce( 'bbp-unfiltered-html-reply_' . $reply_id ) === $_POST['_bbp_unfiltered_html_reply'] ) {549 if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_reply'] ) && wp_create_nonce( 'bbp-unfiltered-html-reply_' . $reply_id ) === $_POST['_bbp_unfiltered_html_reply'] ) { 550 550 remove_filter( 'bbp_edit_reply_pre_title', 'wp_filter_kses' ); 551 551 remove_filter( 'bbp_edit_reply_pre_content', 'bbp_encode_bad', 10 ); … … 562 562 563 563 // Forum exists 564 if ( ! empty( $forum_id ) && ( $forum_id !== bbp_get_reply_forum_id( $reply_id ) ) ) {564 if ( ! empty( $forum_id ) && ( $forum_id !== bbp_get_reply_forum_id( $reply_id ) ) ) { 565 565 566 566 // Forum is a category … … 593 593 /** Reply Title ***********************************************************/ 594 594 595 if ( ! empty( $_POST['bbp_reply_title'] ) ) {595 if ( ! empty( $_POST['bbp_reply_title'] ) ) { 596 596 $reply_title = sanitize_text_field( $_POST['bbp_reply_title'] ); 597 597 } … … 602 602 /** Reply Content *********************************************************/ 603 603 604 if ( ! empty( $_POST['bbp_reply_content'] ) ) {604 if ( ! empty( $_POST['bbp_reply_content'] ) ) { 605 605 $reply_content = $_POST['bbp_reply_content']; 606 606 } … … 616 616 /** Reply Blacklist *******************************************************/ 617 617 618 if ( ! bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {618 if ( ! bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 619 619 bbp_add_error( 'bbp_reply_blacklist', __( '<strong>ERROR</strong>: Your reply cannot be edited at this time.', 'bbpress' ) ); 620 620 } … … 623 623 624 624 // Maybe put into moderation 625 if ( ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {625 if ( ! bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 626 626 627 627 // Set post status to pending if public … … 711 711 712 712 // Revision Reason 713 if ( ! empty( $_POST['bbp_reply_edit_reason'] ) ) {713 if ( ! empty( $_POST['bbp_reply_edit_reason'] ) ) { 714 714 $reply_edit_reason = sanitize_text_field( $_POST['bbp_reply_edit_reason'] ); 715 715 } 716 716 717 717 // Update revision log 718 if ( ! empty( $_POST['bbp_log_reply_edit'] ) && ( "1" === $_POST['bbp_log_reply_edit'] ) ) {718 if ( ! empty( $_POST['bbp_log_reply_edit'] ) && ( "1" === $_POST['bbp_log_reply_edit'] ) ) { 719 719 $revision_id = wp_save_post_revision( $reply_id ); 720 if ( ! empty( $revision_id ) ) {720 if ( ! empty( $revision_id ) ) { 721 721 bbp_update_reply_revision_log( array( 722 722 'reply_id' => $reply_id, … … 730 730 /** No Errors *************************************************************/ 731 731 732 if ( ! empty( $reply_id ) && !is_wp_error( $reply_id ) ) {732 if ( ! empty( $reply_id ) && !is_wp_error( $reply_id ) ) { 733 733 734 734 // Update counts, etc... … … 816 816 817 817 // Check forum_id 818 if ( ! empty( $topic_id ) && empty( $forum_id ) ) {818 if ( ! empty( $topic_id ) && empty( $forum_id ) ) { 819 819 $forum_id = bbp_get_topic_forum_id( $topic_id ); 820 820 } … … 823 823 // It expects anonymous_data to be sanitized. 824 824 // Check bbp_filter_anonymous_post_data() for sanitization. 825 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) {825 if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) { 826 826 827 827 // Parse arguments against default values … … 849 849 850 850 // Handle Subscription Checkbox 851 if ( bbp_is_subscriptions_active() && ! empty( $author_id ) && !empty( $topic_id ) ) {851 if ( bbp_is_subscriptions_active() && ! empty( $author_id ) && ! empty( $topic_id ) ) { 852 852 $subscribed = bbp_is_user_subscribed( $author_id, $topic_id ); 853 $subscheck = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false;853 $subscheck = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false; 854 854 855 855 // Subscribed and unsubscribing … … 922 922 923 923 // Reply was passed 924 if ( ! empty( $reply_id ) ) {924 if ( ! empty( $reply_id ) ) { 925 925 926 926 // Get the topic ID if none was passed … … 947 947 948 948 // Walk up ancestors 949 if ( ! empty( $ancestors ) ) {949 if ( ! empty( $ancestors ) ) { 950 950 foreach ( $ancestors as $ancestor ) { 951 951 … … 1036 1036 1037 1037 // Loop through ancestors 1038 if ( ! empty( $ancestors ) ) {1038 if ( ! empty( $ancestors ) ) { 1039 1039 foreach ( $ancestors as $ancestor ) { 1040 1040 … … 1085 1085 1086 1086 // Loop through ancestors 1087 if ( ! empty( $ancestors ) ) {1087 if ( ! empty( $ancestors ) ) { 1088 1088 foreach ( $ancestors as $ancestor ) { 1089 1089 … … 1311 1311 1312 1312 // How to move 1313 if ( ! empty( $_POST['bbp_reply_move_option'] ) ) {1313 if ( ! empty( $_POST['bbp_reply_move_option'] ) ) { 1314 1314 $move_option = (string) trim( $_POST['bbp_reply_move_option'] ); 1315 1315 } 1316 1316 1317 1317 // Invalid move option 1318 if ( empty( $move_option ) || ! in_array( $move_option, array( 'existing', 'topic' ) ) ) {1318 if ( empty( $move_option ) || ! in_array( $move_option, array( 'existing', 'topic' ) ) ) { 1319 1319 bbp_add_error( 'bbp_move_reply_option', __( '<strong>ERROR</strong>: You need to choose a valid move option.', 'bbpress' ) ); 1320 1320 … … 1375 1375 1376 1376 // Use the new title that was passed 1377 if ( ! empty( $_POST['bbp_reply_move_destination_title'] ) ) {1377 if ( ! empty( $_POST['bbp_reply_move_destination_title'] ) ) { 1378 1378 $destination_topic_title = sanitize_text_field( $_POST['bbp_reply_move_destination_title'] ); 1379 1379 … … 1570 1570 1571 1571 // Bail if actions aren't meant for this function 1572 if ( ! in_array( $action, $possible_actions ) ) {1572 if ( ! in_array( $action, $possible_actions ) ) { 1573 1573 return; 1574 1574 } … … 1602 1602 $success = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id ); 1603 1603 $failure = $is_approve ? __( '<strong>ERROR</strong>: There was a problem approving the reply!', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving the reply!', 'bbpress' ); 1604 $view_all = ! $is_approve;1604 $view_all = ! $is_approve; 1605 1605 1606 1606 break; … … 1613 1613 $success = $is_spam ? bbp_unspam_reply( $reply_id ) : bbp_spam_reply( $reply_id ); 1614 1614 $failure = $is_spam ? __( '<strong>ERROR</strong>: There was a problem unmarking the reply as spam!', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem marking the reply as spam!', 'bbpress' ); 1615 $view_all = ! $is_spam;1615 $view_all = ! $is_spam; 1616 1616 1617 1617 break; … … 1671 1671 1672 1672 // Add view all if needed 1673 if ( ! empty( $view_all ) ) {1673 if ( ! empty( $view_all ) ) { 1674 1674 $reply_url = bbp_add_view_all( $reply_url, true ); 1675 1675 } … … 1911 1911 $reply_id = bbp_get_reply_id( $reply_id ); 1912 1912 1913 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {1913 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 1914 1914 return false; 1915 1915 } … … 1928 1928 $reply_id = bbp_get_reply_id( $reply_id ); 1929 1929 1930 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {1930 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 1931 1931 return false; 1932 1932 } … … 1945 1945 $reply_id = bbp_get_reply_id( $reply_id ); 1946 1946 1947 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {1947 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 1948 1948 return false; 1949 1949 } … … 1964 1964 $reply_id = bbp_get_reply_id( $reply_id ); 1965 1965 1966 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {1966 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 1967 1967 return false; 1968 1968 } … … 1981 1981 $reply_id = bbp_get_reply_id( $reply_id ); 1982 1982 1983 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {1983 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 1984 1984 return false; 1985 1985 } … … 1998 1998 $reply_id = bbp_get_reply_id( $reply_id ); 1999 1999 2000 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {2000 if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) { 2001 2001 return false; 2002 2002 } … … 2176 2176 2177 2177 // User cannot access forum this topic is in 2178 if ( bbp_is_single_topic() && ! bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) {2178 if ( bbp_is_single_topic() && ! bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) { 2179 2179 return; 2180 2180 } … … 2183 2183 if ( bbp_is_single_topic() && bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) { 2184 2184 $title = apply_filters( 'wp_title_rss', get_wp_title_rss( ' » ' ) ); 2185 } elseif ( ! bbp_show_lead_topic() ) {2185 } elseif ( ! bbp_show_lead_topic() ) { 2186 2186 $title = ' » ' . __( 'All Posts', 'bbpress' ); 2187 2187 } else { … … 2368 2368 // Get required data 2369 2369 $reply_id = bbp_get_reply_id( $reply_id ); 2370 $topic_id = ! empty( $topic_id ) ? bbp_get_topic_id( $topic_id ) : bbp_get_reply_topic_id( $reply_id );2370 $topic_id = ! empty( $topic_id ) ? bbp_get_topic_id( $topic_id ) : bbp_get_reply_topic_id( $reply_id ); 2371 2371 $reply_position = 0; 2372 2372 … … 2376 2376 // Make sure the topic has replies before running another query 2377 2377 $reply_count = bbp_get_topic_reply_count( $topic_id, false ); 2378 if ( ! empty( $reply_count ) ) {2378 if ( ! empty( $reply_count ) ) { 2379 2379 2380 2380 // Get reply id's 2381 2381 $topic_replies = bbp_get_all_child_ids( $topic_id, bbp_get_reply_post_type() ); 2382 if ( ! empty( $topic_replies ) ) {2382 if ( ! empty( $topic_replies ) ) { 2383 2383 2384 2384 // Reverse replies array and search for current reply position
Note: See TracChangeset
for help on using the changeset viewer.