Changeset 5390
- Timestamp:
- 06/12/2014 02:16:50 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r5378 r5390 1114 1114 // Validation 1115 1115 $reply_id = bbp_get_reply_id( $reply_id ); 1116 $reply_to = bbp_validate_reply_to( $reply_to );1116 $reply_to = bbp_validate_reply_to( $reply_to, $reply_id ); 1117 1117 1118 1118 // Update or delete the `reply_to` postmeta … … 1130 1130 1131 1131 return (int) apply_filters( 'bbp_update_reply_to', (int) $reply_to, $reply_id ); 1132 } 1133 1134 /** 1135 * Get all ancestors to a reply 1136 * 1137 * Because settings can be changed, this function does not care if hierarchical 1138 * replies are active or to what depth. 1139 * 1140 * @since bbPress (r5390) 1141 * 1142 * @param int $reply_id 1143 * @return array 1144 */ 1145 function bbp_get_reply_ancestors( $reply_id = 0 ) { 1146 1147 // Validation 1148 $reply_id = bbp_get_reply_id( $reply_id ); 1149 $ancestors = array(); 1150 1151 // Reply id is valid 1152 if ( ! empty( $reply_id ) ) { 1153 1154 // Try to get reply parent 1155 $reply_to = bbp_get_reply_to( $reply_id ); 1156 1157 // Reply has a hierarchical parent 1158 if ( ! empty( $reply_to ) ) { 1159 1160 // Setup the current ID and current post as an ancestor 1161 $id = $ancestors[] = $reply_to; 1162 1163 // Get parent reply 1164 while ( $ancestor = bbp_get_reply( $id ) ) { 1165 1166 // Does parent have a parent? 1167 $grampy_id = bbp_get_reply_to( $ancestor->ID ); 1168 1169 // Loop detection: If the ancestor has been seen before, break. 1170 if ( empty( $ancestor->post_parent ) || ( $grampy_id === $reply_id ) || in_array( $grampy_id, $ancestors ) ) { 1171 break; 1172 } 1173 1174 $id = $ancestors[] = $grampy_id; 1175 } 1176 } 1177 } 1178 1179 return apply_filters( 'bbp_get_reply_ancestors', $ancestors, $reply_id ); 1132 1180 } 1133 1181
Note: See TracChangeset
for help on using the changeset viewer.