Ticket #2588: 2588.3.diff
File 2588.3.diff, 4.4 KB (added by , 11 years ago) |
---|
-
includes/replies/functions.php
249 249 } 250 250 } 251 251 252 /** Reply To **************************************************************/253 254 // Handle Reply To of the reply; $_REQUEST for non-JS submissions255 if ( isset( $_REQUEST['bbp_reply_to'] ) ) {256 $reply_to = (int) $_REQUEST['bbp_reply_to'];257 }258 259 $reply_to = bbp_get_reply_id( $reply_to );260 261 252 /** Unfiltered HTML *******************************************************/ 262 253 263 254 // Remove kses filters from title and content for capable users and if the nonce is verified … … 313 304 $reply_status = bbp_get_public_status_id(); 314 305 } 315 306 307 /** Reply To **************************************************************/ 308 309 // Handle Reply To of the reply; $_REQUEST for non-JS submissions 310 if ( isset( $_REQUEST['bbp_reply_to'] ) ) { 311 $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] ); 312 } 313 316 314 /** Topic Closed **********************************************************/ 317 315 318 316 // If topic is closed, moderators can still reply … … 562 560 563 561 $forum_id = bbp_get_topic_forum_id( $topic_id ); 564 562 565 /** Reply To **************************************************************/566 567 $reply_to = bbp_get_reply_to( $reply_id );568 569 563 // Forum exists 570 564 if ( !empty( $forum_id ) && ( $forum_id !== bbp_get_reply_forum_id( $reply_id ) ) ) { 571 565 … … 636 630 $reply_status = $reply->post_status; 637 631 } 638 632 633 /** Reply To **************************************************************/ 634 635 // Handle Reply To of the reply; $_REQUEST for non-JS submissions 636 if ( isset( $_REQUEST['bbp_reply_to'] ) ) { 637 $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] ); 638 } 639 639 640 /** Topic Tags ************************************************************/ 640 641 641 642 // Either replace terms … … 793 794 $reply_id = bbp_get_reply_id( $reply_id ); 794 795 $topic_id = bbp_get_topic_id( $topic_id ); 795 796 $forum_id = bbp_get_forum_id( $forum_id ); 796 $reply_to = bbp_ get_reply_id( $reply_to );797 $reply_to = bbp_validate_reply_to( $reply_to ); 797 798 798 799 // Bail if there is no reply 799 800 if ( empty( $reply_id ) ) … … 1112 1113 1113 1114 // Validation 1114 1115 $reply_id = bbp_get_reply_id( $reply_id ); 1115 $reply_to = bbp_ get_reply_id( $reply_to );1116 $reply_to = bbp_validate_reply_to( $reply_to ); 1116 1117 1117 // Return if no reply 1118 if ( empty( $reply_id ) ) 1119 return; 1118 // Update or delete the `reply_to` postmeta 1119 if ( ! empty( $reply_id ) ) { 1120 1120 1121 // Setthe reply to1122 if ( !empty( $reply_to ) ) {1123 update_post_meta( $reply_id, '_bbp_reply_to', $reply_to );1121 // Update the reply to 1122 if ( !empty( $reply_to ) ) { 1123 update_post_meta( $reply_id, '_bbp_reply_to', $reply_to ); 1124 1124 1125 // Delete the reply to 1126 } else { 1127 delete_post_meta( $reply_id, '_bbp_reply_to' ); 1125 // Delete the reply to 1126 } else { 1127 delete_post_meta( $reply_id, '_bbp_reply_to' ); 1128 } 1128 1129 } 1129 1130 1130 1131 return (int) apply_filters( 'bbp_update_reply_to', (int) $reply_to, $reply_id ); … … 2218 2220 bbpress()->max_num_pages = $walker->max_pages; 2219 2221 bbpress()->reply_query->in_the_loop = false; 2220 2222 } 2223 2224 /** 2225 * Validate a `reply_to` field for hierarchical replies 2226 * 2227 * Checks for 2 scenarios: 2228 * -- The reply to ID is actually a reply 2229 * -- The reply to ID does not match the current reply 2230 * 2231 * @since bbPress (r5377) 2232 * 2233 * @param int $reply_to 2234 * @param int $reply_id 2235 * 2236 * @return int $reply_to 2237 */ 2238 function bbp_validate_reply_to( $reply_to = 0, $reply_id = 0 ) { 2239 2240 // The parent reply must actually be a reply 2241 if ( ! bbp_is_reply( $reply_to ) ) { 2242 $reply_to = 0; 2243 } 2244 2245 // The parent reply cannot be itself 2246 if ( $reply_id === $reply_to ) { 2247 $reply_to = 0; 2248 } 2249 2250 return (int) $reply_to; 2251 } -
includes/replies/template.php
2465 2465 2466 2466 // Get $_REQUEST data 2467 2467 if ( isset( $_REQUEST['bbp_reply_to'] ) ) { 2468 $reply_to = (int) $_REQUEST['bbp_reply_to'];2468 $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] ); 2469 2469 } 2470 2470 2471 2471 // If empty, get from meta -
includes/topics/functions.php
1672 1672 } 1673 1673 1674 1674 // New topic from reply can't be a reply to 1675 if ( ( $from_reply->ID === $destination_topic->ID &&$from_reply->ID === $reply_to ) ) {1675 if ( ( $from_reply->ID === $destination_topic->ID ) && ( $from_reply->ID === $reply_to ) ) { 1676 1676 bbp_update_reply_to( $reply->ID, 0 ); 1677 1677 } 1678 1678