Changeset 5378
- Timestamp:
- 06/06/2014 07:38:59 PM (11 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r5338 r5378 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 … … 312 303 } else { 313 304 $reply_status = bbp_get_public_status_id(); 305 } 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'] ); 314 312 } 315 313 … … 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 ) ) ) { … … 635 629 } else { 636 630 $reply_status = $reply->post_status; 631 } 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'] ); 637 638 } 638 639 … … 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 … … 1113 1114 // Validation 1114 1115 $reply_id = bbp_get_reply_id( $reply_id ); 1115 $reply_to = bbp_ get_reply_id( $reply_to );1116 1117 // Return if no reply1118 if ( empty( $reply_id ) )1119 return; 1120 1121 // Set the reply to1122 if ( !empty( $reply_to ) ) {1123 update_post_meta( $reply_id, '_bbp_reply_to', $reply_to ); 1124 1125 // Delete the reply to1126 } else {1127 delete_post_meta( $reply_id, '_bbp_reply_to' );1116 $reply_to = bbp_validate_reply_to( $reply_to ); 1117 1118 // Update or delete the `reply_to` postmeta 1119 if ( ! empty( $reply_id ) ) { 1120 1121 // Update the reply to 1122 if ( !empty( $reply_to ) ) { 1123 update_post_meta( $reply_id, '_bbp_reply_to', $reply_to ); 1124 1125 // Delete the reply to 1126 } else { 1127 delete_post_meta( $reply_id, '_bbp_reply_to' ); 1128 } 1128 1129 } 1129 1130 … … 2220 2221 bbpress()->reply_query->in_the_loop = false; 2221 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 * @see https://bbpress.trac.wordpress.org/ticket/2588 2232 * @see https://bbpress.trac.wordpress.org/ticket/2586 2233 * 2234 * @since bbPress (r5377) 2235 * 2236 * @param int $reply_to 2237 * @param int $reply_id 2238 * 2239 * @return int $reply_to 2240 */ 2241 function bbp_validate_reply_to( $reply_to = 0, $reply_id = 0 ) { 2242 2243 // The parent reply must actually be a reply 2244 if ( ! bbp_is_reply( $reply_to ) ) { 2245 $reply_to = 0; 2246 } 2247 2248 // The parent reply cannot be itself 2249 if ( $reply_id === $reply_to ) { 2250 $reply_to = 0; 2251 } 2252 2253 return (int) $reply_to; 2254 } -
trunk/src/includes/replies/template.php
r5372 r5378 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 -
trunk/src/includes/topics/functions.php
r5338 r5378 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 }
Note: See TracChangeset
for help on using the changeset viewer.