Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/09/2012 10:36:36 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Blogs component. See #3989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-activity.php

    r5302 r5686  
    11<?php
    2 /******************************************************************************
    3  * These functions handle the recording, deleting and formatting of activity and
    4  * notifications for the user and for this specific component.
     2
     3/**
     4 * BuddyPress Blogs Activity
     5 *
     6 * @package BuddyPress
     7 * @subpackage BlogsActivity
    58 */
    69
     
    811if ( !defined( 'ABSPATH' ) ) exit;
    912
    10 
     13/**
     14 * Register activity actions for the blogs component
     15 *
     16 * @since BuddyPress (1.0)
     17 * @package BuddyPress
     18 * @subpackage BlogsActivity
     19 * @global type $bp
     20 * @return boolean
     21 */
    1122function bp_blogs_register_activity_actions() {
    1223    global $bp;
    1324
    14     if ( !bp_is_active( 'activity' ) )
     25    // Bail if activity is not active
     26    if ( ! bp_is_active( 'activity' ) )
    1527        return false;
    1628
     
    2335add_action( 'bp_register_activity_actions', 'bp_blogs_register_activity_actions' );
    2436
     37/**
     38 * Record the activity to the actvity stream
     39 *
     40 * @since BuddyPress (1.0)
     41 * @package BuddyPress
     42 * @subpackage BlogsActivity
     43 * @global BuddyPress $bp
     44 * @param array $args
     45 * @return boolean
     46 */
    2547function bp_blogs_record_activity( $args = '' ) {
    2648    global $bp;
    2749
    28     if ( !bp_is_active( 'activity' ) )
     50    // Bail if activity is not active
     51    if ( ! bp_is_active( 'activity' ) )
    2952        return false;
    3053
     
    4669
    4770    // Remove large images and replace them with just one image thumbnail
    48     if ( bp_is_active( 'activity' ) && !empty( $content ) )
     71    if ( !empty( $content ) )
    4972        $content = bp_activity_thumbnail_content_images( $content, $primary_link );
    5073
     
    6790}
    6891
     92/**
     93 * Delete a blogs activity stream item
     94 *
     95 * @since BuddyPress (1.0)
     96 * @package BuddyPress
     97 * @subpackage BlogsActivity
     98 * @global BuddyPress $bp
     99 * @param array $args
     100 * @return If activity is not active
     101 */
    69102function bp_blogs_delete_activity( $args = true ) {
    70103    global $bp;
    71104
    72     if ( bp_is_active( 'activity' ) ) {
    73         $defaults = array(
    74             'item_id'           => false,
    75             'component'         => $bp->blogs->id,
    76             'type'              => false,
    77             'user_id'           => false,
    78             'secondary_item_id' => false
    79         );
     105    // Bail if activity is not active
     106    if ( ! bp_is_active( 'activity' ) )
     107        return false;
    80108
    81         $params = wp_parse_args( $args, $defaults );
    82         extract( $params, EXTR_SKIP );
     109    $defaults = array(
     110        'item_id'           => false,
     111        'component'         => $bp->blogs->id,
     112        'type'              => false,
     113        'user_id'           => false,
     114        'secondary_item_id' => false
     115    );
    83116
    84         bp_activity_delete_by_item_id( array(
    85             'item_id'           => $item_id,
    86             'component'         => $component,
    87             'type'              => $type,
    88             'user_id'           => $user_id,
    89             'secondary_item_id' => $secondary_item_id
    90         ) );
    91     }
     117    $params = wp_parse_args( $args, $defaults );
     118    extract( $params, EXTR_SKIP );
     119
     120    bp_activity_delete_by_item_id( array(
     121        'item_id'           => $item_id,
     122        'component'         => $component,
     123        'type'              => $type,
     124        'user_id'           => $user_id,
     125        'secondary_item_id' => $secondary_item_id
     126    ) );
    92127}
    93128
Note: See TracChangeset for help on using the changeset viewer.