bp_blogs_setup_activity_loop_globals( object $activity )
Utility function to set up some variables for use in the activity loop.
Description
Grabs the blog’s comment depth and the post’s open comment status options for later use in the activity and activity comment loops.
This is to prevent having to requery these items later on.
See also
Parameters
- $activity
-
(Required) The BP_Activity_Activity object.
Source
File: bp-blogs/bp-blogs-activity.php
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | function bp_blogs_setup_activity_loop_globals( $activity ) { if ( ! is_object ( $activity ) ) { return ; } // The activity type does not support comments or replies ? stop now! if ( ! bp_activity_type_supports( $activity ->type, 'post-type-comment-reply' ) ) { return ; } if ( empty ( $activity ->id ) ) { return ; } // If we've already done this before, stop now! if ( isset( buddypress()->blogs->allow_comments[ $activity ->id ] ) ) { return ; } $allow_comments = bp_blogs_comments_open( $activity ); $thread_depth = bp_blogs_get_blogmeta( $activity ->item_id, 'thread_comments_depth' ); $moderation = bp_blogs_get_blogmeta( $activity ->item_id, 'comment_moderation' ); // Initialize a local object so we won't have to query this again in the // comment loop. if ( empty ( buddypress()->blogs->allow_comments ) ) { buddypress()->blogs->allow_comments = array (); } if ( empty ( buddypress()->blogs->thread_depth ) ) { buddypress()->blogs->thread_depth = array (); } if ( empty ( buddypress()->blogs->comment_moderation ) ) { buddypress()->blogs->comment_moderation = array (); } /* * Cache comment settings in the buddypress() singleton for later reference. * * See bp_blogs_disable_activity_commenting() / bp_blogs_can_comment_reply(). * * thread_depth is keyed by activity ID instead of blog ID because when we're * in an actvity comment loop, we don't have access to the blog ID... * * Should probably object cache these values instead... */ buddypress()->blogs->allow_comments[ $activity ->id ] = $allow_comments ; buddypress()->blogs->thread_depth[ $activity ->id ] = $thread_depth ; buddypress()->blogs->comment_moderation[ $activity ->id ] = $moderation ; } |
Changelog
Version | Description |
---|---|
BuddyPress 2.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.