Skip to:
Content

BuddyPress.org

Ticket #5936: bp-activity-actions-5936-2.diff

File bp-activity-actions-5936-2.diff, 6.5 KB (added by tw2113, 10 years ago)
  • src/bp-activity/bp-activity-actions.php

     
    1515/**
    1616 * Allow core components and dependent plugins to register activity actions.
    1717 *
    18  * @since BuddyPress (1.2)
     18 * @since BuddyPress (1.2.0)
    1919 *
    2020 * @uses do_action() To call 'bp_register_activity_actions' hook.
    2121 */
    2222function bp_register_activity_actions() {
     23
     24        /**
     25         * Fires on bp_init to allow core componants and dependent plugins to register activity actions.
     26         *
     27         * @since BuddyPress (1.2.0)
     28         */
    2329        do_action( 'bp_register_activity_actions' );
    2430}
    2531add_action( 'bp_init', 'bp_register_activity_actions', 8 );
     
    96102                $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
    97103        }
    98104
    99         // Allow redirect to be filtered
     105        /**
     106         * Filter the intended redirect url before the redirect occurs for the single activity item.
     107         *
     108         * @since BuddyPress (1.2.2)
     109         *
     110         * @param array Array with url to redirect to and activity related to the redirect.
     111         */
    100112        if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url', array( $redirect, &$activity ) ) ) {
    101113                bp_core_redirect( bp_get_root_domain() );
    102114        }
     
    149161        if ( ! bp_activity_user_can_delete( $activity ) )
    150162                return false;
    151163
    152         // Call the action before the delete so plugins can still fetch information about it
     164        /**
     165         * Fires before the deletion so plugins can still fetch information about it.
     166         *
     167         * @since BuddyPress (1.5.0)
     168         *
     169         * @param int $activity_id The activity ID.
     170         * @param int $user_id The user associated with the activity.
     171         */
    153172        do_action( 'bp_activity_before_action_delete_activity', $activity_id, $activity->user_id );
    154173
    155174        // Delete the activity item and provide user feedback
     
    158177        else
    159178                bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
    160179
     180        /**
     181         * Fires after the deletion so plugins can act afterwards based on the activity.
     182         *
     183         * @since BuddyPress (1.1.0)
     184         *
     185         * @param int $activity_id The activity ID.
     186         * @param int $user_id The user associated with the activity.
     187         */
    161188        do_action( 'bp_activity_action_delete_activity', $activity_id, $activity->user_id );
    162189
    163190        // Check for the redirect query arg, otherwise let WP handle things
     
    203230        // Check nonce
    204231        check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
    205232
    206         // Call an action before the spamming so plugins can modify things if they want to
     233        /**
     234         * Fires before the marking activity as spam so plugins can modify things if they want to.
     235         *
     236         * @since BuddyPress (1.6.0)
     237         *
     238         * @param int    $activty_id Activity ID to be marked as spam.
     239         * @param object $activity Activity object for the ID to be marked as spam.
     240         */
    207241        do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
    208242
    209243        // Mark as spam
     
    213247        // Tell the user the spamming has been succesful
    214248        bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
    215249
     250        /**
     251         * Fires after the marking activity as spam so plugins can act afterwards based on the activity.
     252         *
     253         * @since BuddyPress (1.6.0)
     254         *
     255         * @param int $activty_id Activity ID that was marked as spam.
     256         * @param int $user_id User ID associated with activity.
     257         */
    216258        do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
    217259
    218260        // Check for the redirect query arg, otherwise let WP handle things
     
    253295        // Check the nonce
    254296        check_admin_referer( 'post_update', '_wpnonce_post_update' );
    255297
    256         // Get activity info
     298        /**
     299         * Filters the content provided in the activity input field.
     300         *
     301         * @since BuddyPress (1.2.0)
     302         *
     303         * @param string $whats-new Activity message being posted.
     304         */
    257305        $content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
    258306
    259307        if ( ! empty( $_POST['whats-new-post-object'] ) ) {
     308
     309                /**
     310                 * Filters the item type that the activity update should be associated with.
     311                 *
     312                 * @since BuddyPress (1.2.0)
     313                 *
     314                 * @param string $whats-new-post-object Item type to associate with.
     315                 */
    260316                $object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
    261317        }
    262318
    263319        if ( ! empty( $_POST['whats-new-post-in'] ) ) {
     320
     321                /**
     322                 * Filters what component the activity is being to.
     323                 *
     324                 * @since BuddyPress (1.2.0)
     325                 *
     326                 * @param string $whats-new-post-in Chosen component to post activity to.
     327                 */
    264328                $item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
    265329        }
    266330
     
    280344                        $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
    281345                }
    282346
    283         // Special circumstance so let filters handle it
    284347        } else {
     348
     349                /**
     350                 * Filters activity object for BuddyPress core and plugin authors before posting activity update.
     351                 *
     352                 * @since BuddyPress (1.2.0)
     353                 *
     354                 * @param string $object Activity item being associated to.
     355                 * @param string $item_id Component ID being posted to.
     356                 * @param string $content Activity content being posted.
     357                 */
    285358                $activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
    286359        }
    287360
     
    322395        // Check the nonce
    323396        check_admin_referer( 'new_activity_comment', '_wpnonce_new_activity_comment' );
    324397
     398        /**
     399         * Filters the activity ID a comment will be in reply to.
     400         *
     401         * @since BuddyPress (1.2.0)
     402         *
     403         * @param string $comment_form_id ID of the activity being replied to.
     404         */
    325405        $activity_id = apply_filters( 'bp_activity_post_comment_activity_id', $_POST['comment_form_id'] );
     406
     407        /**
     408         * Filters the comment content for a comment reply.
     409         *
     410         * @since BuddyPress (1.2.0)
     411         *
     412         * @param string $ac_input_activity_id Comment content being posted.
     413         */
    326414        $content = apply_filters( 'bp_activity_post_comment_content', $_POST['ac_input_' . $activity_id] );
    327415
    328416        if ( empty( $content ) ) {
     
    640728        if ( ! bp_get_option( 'wordpress_api_key' ) && ! defined( 'WPCOM_API_KEY' ) )
    641729                return;
    642730
    643         // Bail if BuddyPress Activity Akismet support has been disabled by another plugin
     731        /**
     732         * Filters if BuddyPress Activity Akismet support has been disabled by another plugin.
     733         *
     734         * @since BuddyPress (1.6.0)
     735         *
     736         * @param bool bp_is_akismet_active Return value of bp_is_akismet_active boolean function.
     737         */
    644738        if ( ! apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) )
    645739                return;
    646740