Skip to:
Content

BuddyPress.org

Changeset 2168 for trunk/bp-activity.php


Ignore:
Timestamp:
12/14/2009 03:24:05 PM (16 years ago)
Author:
apeatling
Message:

Committing core code support for new default theme.

Removed all deprecated code since it will be released as a separate plugin for backwards compatibility if people need it.

Removed the wire and status updates components since there is no support in the theme for these. If people still want this functionality then I'm sure there is someone in the community that could spend a bit of time and release them as plugins. I'm happy to guide.

Removed a lot of template loop duplication. There are no longer site loops and user loops (e.g. bp_has_site_groups() / bp_has_groups() ). There are now bp_has_members(), bp_has_groups(), bp_has_blogs() and you can pass a "user_id" parameter into these loops to limit results to only that user or users.

Merged activity stream functions. There are no longer functions for bp_activity_get_sitewide() / bp_activity_get_for_user() / bp_activity_get_friends_activity() instead there is simply one function: bp_activity_get() and you can pass in parameters to filter on just friends, for a single user, or anything your heart desires. Actually, filtering is extremely fine grained, so I encourage devs to check out the filter functions.

Lots of other code cleanup.

The new default theme will be committed straight after this. The original default folder will be renamed to bp-classic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2158 r2168  
    99require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' );
    1010require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' );
    11 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-widgets.php' );
    1211require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' );
    13 
    14 /* Include deprecated functions if settings allow */
    15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    16     require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
    1712
    1813function bp_activity_install() {
     
    122117function bp_activity_screen_my_activity() {
    123118    do_action( 'bp_activity_screen_my_activity' );
    124     bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
     119    bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'members/single/activity' ) );
    125120}
    126121
     
    173168    }
    174169
    175     bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'activity/single' ) );
     170    bp_core_load_template( apply_filters( 'bp_activity_template_profile_activity_permalink', 'members/single/activity/permalink' ) );
    176171}
    177172/* This screen is not attached to a nav item, so we need to add an action for it. */
     
    307302 */
    308303
    309 function bp_activity_get_sitewide( $args = '' ) {
     304function bp_activity_get( $args = '' ) {
    310305    $defaults = array(
    311306        'max' => false, // Maximum number of results to return
     
    319314
    320315        /**
    321          * Pass filters as an array:
     316         * Pass filters as an array -- all filter items can be multiple values comma separated:
    322317         * array(
    323318         *  'user_id' => false, // user_id to filter on
     
    334329    extract( $r, EXTR_SKIP );
    335330
    336     return apply_filters( 'bp_activity_get_sitewide', BP_Activity_Activity::get_sitewide_activity( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), &$r );
    337 }
    338 
    339 function bp_activity_get_for_user( $args = '' ) {
    340     global $bp;
    341 
    342     $defaults = array(
    343         'user_id' => $bp->displayed_user->id,
    344         'max' => false, // Maximum number of results to return
    345         'page' => 1, // page 1 without a per_page will result in no pagination.
    346         'per_page' => false, // results per page
    347         'sort' => 'DESC', // sort ASC or DESC
    348         'display_comments' => 'stream', // false for no comments. 'stream' for within stream display, 'threaded' for below each activity item
    349 
    350         'search_terms' => false, // Pass search terms as a string
    351         'show_hidden' => false, // Show activity items that are hidden site-wide?
    352 
    353         /* See bp_activity_get_sitewide() for filters */
    354         'filter' => array()
    355     );
    356 
    357     $r = wp_parse_args( $args, $defaults );
    358     extract( $r, EXTR_SKIP );
    359 
    360     return apply_filters( 'bp_activity_get_for_user', BP_Activity_Activity::get_activity_for_user( $user_id, $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), &$r );
    361 }
    362 
    363 function bp_activity_get_friends_activity( $user_id, $max = 30, $max_items_per_friend = false, $pag_num = false, $pag_page = false, $filter = false ) {
    364     return apply_filters( 'bp_activity_get_friends_activity', BP_Activity_Activity::get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter ), $user_id, $max_items, $max_items_per_friend, $pag_num, $pag_page, $filter );
     331    return apply_filters( 'bp_activity_get', BP_Activity_Activity::get( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), &$r );
    365332}
    366333
     
    537504}
    538505
     506/**
     507 * bp_activity_filter_template_paths()
     508 *
     509 * Add fallback for the bp-sn-parent theme template locations used in BuddyPress versions
     510 * older than 1.2.
     511 *
     512 * @package BuddyPress Core
     513 */
     514function bp_activity_filter_template_paths() {
     515    if ( 'bp-sn-parent' != basename( TEMPLATEPATH ) && !defined( 'BP_CLASSIC_TEMPLATE_STRUCTURE' ) )
     516        return false;
     517
     518    add_filter( 'bp_activity_template_my_activity', create_function( '', 'return "activity/just-me";' ) );
     519    add_filter( 'bp_activity_template_friends_activity', create_function( '', 'return "activity/my-friends";' ) );
     520    add_filter( 'bp_activity_template_profile_activity_permalink', create_function( '', 'return "activity/single";' ) );
     521
     522    /* Activity widget should only be available to older themes since the new default has it all in the template */
     523    require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-widgets.php' );
     524}
     525add_action( 'widgets_init', 'bp_activity_filter_template_paths' );
     526
    539527function bp_activity_remove_data( $user_id ) {
    540528    // Clear the user's activity from the sitewide stream and clear their activity tables
     
    547535add_action( 'make_spam_user', 'bp_activity_remove_data' );
    548536
    549 /* Ordering function - don't call this directly */
    550 function bp_activity_order_by_date( $a, $b ) {
    551     return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );
    552 }
    553 
    554537?>
Note: See TracChangeset for help on using the changeset viewer.