| 281 | * Callback function to build the permalink to the post type |
| 282 | * |
| 283 | * @param integer $post_id the post type id |
| 284 | * @param integer $blog_id the blog id |
| 285 | * @param WP_Post $post Post object. |
| 286 | * @uses add_query_arg() To add custom args to the url |
| 287 | * @uses get_home_url() |
| 288 | * @return string the post type permalink |
| 289 | */ |
| 290 | function bp_blogs_activity_permalink_post_callback( $post_id = 0, $blog_id = 0, $post = null ) { |
| 291 | $post_permalink = add_query_arg( |
| 292 | 'p', |
| 293 | $post_id, |
| 294 | trailingslashit( get_home_url( $blog_id ) ) |
| 295 | ); |
| 296 | |
| 297 | return $post_permalink; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Callback function to build the action for the post type |
| 302 | * |
| 303 | * @param array $args the available arguments |
| 304 | * @uses bp_core_get_userlink() to build the post author profile link |
| 305 | * @uses get_blog_option() WordPress function to fetch blog meta. |
| 306 | * @return string the activity action |
| 307 | */ |
| 308 | function bp_blogs_activity_action_post_callback( $args = array() ) { |
| 309 | extract( $args, EXTR_SKIP ); |
| 310 | |
| 311 | if ( !empty( $blog_id ) ) |
| 312 | $activity_action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post_author ), '<a href="' . $post_permalink . '">' . $post_title . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); |
| 313 | else |
| 314 | $activity_action = sprintf( __( '%1$s wrote a new post, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post_author ), '<a href="' . $post_permalink . '">' . $post_title . '</a>' ); |
| 315 | |
| 316 | return $activity_action; |
| 317 | } |
| 318 | |
| 319 | /** |
323 | | // Record this in activity streams |
324 | | $post_permalink = add_query_arg( |
325 | | 'p', |
326 | | $post_id, |
327 | | trailingslashit( get_home_url( $blog_id ) ) |
| 362 | $post_type_object = get_post_type_object( $post->post_type ); |
| 363 | extract( $post_type_object->bp_tracking, EXTR_SKIP ); |
| 364 | |
| 365 | // Builds the permalink to the post_type |
| 366 | if ( !empty( $activity_permalink_post_callback ) && is_callable( $activity_permalink_post_callback ) ) |
| 367 | $post_permalink = call_user_func_array( $activity_permalink_post_callback, array( $post_id, $blog_id, $post ) ); |
| 368 | else |
| 369 | $post_permalink = bp_blogs_activity_permalink_post_callback( $post_id, $blog_id, $post ); |
| 370 | |
| 371 | $action_args = array( |
| 372 | 'post_author' => $post->post_author, |
| 373 | 'post_permalink' => $post_permalink, |
| 374 | 'post_title' => $post->post_title |
330 | | if ( is_multisite() ) |
331 | | $activity_action = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); |
| 377 | if( is_multisite() ) |
| 378 | $action_args['blog_id'] = $blog_id; |
| 379 | |
| 380 | // Builds the activity action for the post type |
| 381 | if( !empty( $activity_action_post_callback ) && is_callable( $activity_action_post_callback ) ) |
| 382 | $activity_action = call_user_func_array( $activity_action_post_callback, array( $action_args ) ); |
354 | | 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, $post, $post_permalink ), |
355 | | 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ), |
356 | | 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), |
357 | | 'type' => 'new_blog_post', |
| 407 | 'action' => apply_filters( "bp_blogs_activity_new_{$post->post_type}_action", $activity_action, $post, $post_permalink ), |
| 408 | 'content' => apply_filters( "bp_blogs_activity_new_{$post->post_type}_content", $activity_content, $post, $post_permalink ), |
| 409 | 'primary_link' => apply_filters( "bp_blogs_activity_new_{$post->post_type}_primary_link", $post_permalink, $post_id ), |
| 410 | 'type' => $type_post, |
| 427 | * Callback function to build the action for the comment on the post type |
| 428 | * |
| 429 | * @param array $args the available arguments |
| 430 | * @uses bp_core_get_userlink() to build the post author profile link |
| 431 | * @uses get_blog_option() WordPress function to fetch blog meta. |
| 432 | * @return string the activity action |
| 433 | */ |
| 434 | function bp_blogs_activity_action_comment_callback( $args = array() ) { |
| 435 | extract( $args, EXTR_SKIP ); |
| 436 | |
| 437 | if ( !empty( $blog_id ) ) |
| 438 | $activity_action = sprintf( __( '%1$s commented on the post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); |
| 439 | else |
| 440 | $activity_action = sprintf( __( '%1$s commented on the post, %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $post_title ) . '</a>' ); |
| 441 | |
| 442 | return $activity_action; |
| 443 | } |
| 444 | |
| 445 | /** |
438 | | // Prepare to record in activity streams |
439 | | if ( is_multisite() ) |
440 | | $activity_action = sprintf( __( '%1$s commented on the post, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' ); |
| 509 | // Builds the permalink to the post_type |
| 510 | if ( !empty( $activity_permalink_post_callback ) && is_callable( $activity_permalink_post_callback ) ) |
| 511 | $post_permalink = call_user_func_array( $activity_permalink_post_callback, array( $recorded_comment->comment_post_ID, $blog_id, $recorded_comment->post ) ); |
| 515 | $action_args = array( |
| 516 | 'user_id' => $user_id, |
| 517 | 'post_permalink' => $post_permalink, |
| 518 | 'post_title' => $recorded_comment->post->post_title |
| 519 | ); |
| 520 | |
| 521 | if( is_multisite() ) |
| 522 | $action_args['blog_id'] = $blog_id; |
| 523 | |
| 524 | // Builds the activity action for the post type |
| 525 | if( !empty( $activity_action_comment_callback ) && is_callable( $activity_action_comment_callback ) ) |
| 526 | $activity_action = call_user_func_array( $activity_action_comment_callback, array( $action_args ) ); |
| 527 | else |
| 528 | $activity_action = bp_blogs_activity_action_comment_callback( $action_args ); |
| 529 | |
| 530 | // Get the activity type |
| 531 | $type_comment = !empty( $type_comment ) ? $type_comment : 'new_blog_comment'; |
| 532 | |
| 533 | // Get comment link |
| 534 | $comment_link = get_comment_link( $recorded_comment->comment_ID ); |
| 535 | |
| 536 | // Get the comment content |
449 | | 'action' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_action', array( $activity_action, &$recorded_comment, $comment_link ) ), |
450 | | 'content' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_content', array( $activity_content, &$recorded_comment, $comment_link ) ), |
451 | | 'primary_link' => apply_filters_ref_array( 'bp_blogs_activity_new_comment_primary_link', array( $comment_link, &$recorded_comment ) ), |
452 | | 'type' => 'new_blog_comment', |
| 544 | 'action' => apply_filters_ref_array( "bp_blogs_activity_new_{$comment_post_type}_action", array( $activity_action, &$recorded_comment, $comment_link ) ), |
| 545 | 'content' => apply_filters_ref_array( "bp_blogs_activity_new_{$comment_post_type}_content", array( $activity_content, &$recorded_comment, $comment_link ) ), |
| 546 | 'primary_link' => apply_filters_ref_array( "bp_blogs_activity_new_{$comment_post_type}_primary_link", array( $comment_link, &$recorded_comment ) ), |
| 547 | 'type' => $type_comment, |