Skip to:
Content

BuddyPress.org

Ticket #5938: bp-activity-akismet-5938.diff

File bp-activity-akismet-5938.diff, 4.2 KB (added by tw2113, 10 years ago)

Diff file for the akismet file hooks

  • src/bp-activity/bp-activity-akismet.php

     
    112112                if ( $desc )
    113113                        echo '<span class="akismet-status"><a href="' . esc_url( bp_get_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) ) . '#bp_activity_history">' . htmlspecialchars( $desc ) . '</a></span>';
    114114
     115                /**
     116                 * Filters the list of actions for the current activity's row.
     117                 *
     118                 * @since BuddyPress (1.6.0)
     119                 *
     120                 * @param array $actions Array of available actions for the current activity item's row.
     121                 */
    115122                return apply_filters( 'bp_akismet_comment_row_action', $actions );
    116123        }
    117124
     
    239246         * @return array List of activity types.
    240247         */
    241248        public static function get_activity_types() {
     249
     250                /**
     251                 * Filters the list of activity types that Akismet should automatically check for spam.
     252                 *
     253                 * @since BuddyPress (1.6.0)
     254                 *
     255                 * @param array Array of default activity types for Akismet to check.
     256                 */
    242257                return apply_filters( 'bp_akismet_get_activity_types', array( 'activity_comment', 'activity_update' ) );
    243258        }
    244259
     
    254269                // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update()
    255270                $this->last_activity = $activity;
    256271
     272                /**
     273                 * Fires after marking an activity item has been marked as spam.
     274                 *
     275                 * @since BuddyPress (1.6.0)
     276                 *
     277                 * @param BP_Activity_Activity $activity Activity object being marked as spam.
     278                 * @param string $source Source of the whom marked as spam. Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet".
     279                 */
    257280                do_action( 'bp_activity_akismet_mark_as_spam', $activity, $source );
    258281        }
    259282
     
    270293                if ( 'true' == bp_activity_get_meta( $activity->id, '_bp_akismet_result' ) && !bp_activity_get_meta( $activity->id, '_bp_akismet_user_result' ) )
    271294                        $activity->content = bp_activity_at_name_filter( $activity->content, $activity->id );
    272295
     296                /**
     297                 * Fires after marking an activity item has been marked as ham.
     298                 *
     299                 * @since BuddyPress (1.6.0)
     300                 *
     301                 * @param BP_Activity_Activity $activity Activity object being marked as ham.
     302                 * @param string $source Source of the whom marked as ham. Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
     303                 */
    273304                do_action( 'bp_activity_akismet_mark_as_ham', $activity, $source );
    274305        }
    275306
     
    311342                elseif ( !empty( $activity->secondary_item_id ) && !empty( $_POST['_bp_as_nonce_' . $activity->secondary_item_id] ) )
    312343                        $activity_data['akismet_comment_nonce'] = wp_verify_nonce( $_POST["_bp_as_nonce_{$activity->secondary_item_id}"], "_bp_as_nonce_{$userdata->ID}_{$activity->secondary_item_id}" ) ? 'passed' : 'failed';
    313344
     345                /**
     346                 * Filters activity data before being sent to Akismet to inspect.
     347                 *
     348                 * @since BuddyPress (1.6.0)
     349                 *
     350                 * @param array $activity_data Array of activity data for Akismet to inspect.
     351                 * @param BP_Activity_Activity $activity Activity item data.
     352                 */
    314353                return apply_filters( 'bp_akismet_build_akismet_data_package', $activity_data, $activity );
    315354        }
    316355
     
    347386
    348387                // Spam
    349388                if ( 'true' == $activity_data['bp_as_result'] ) {
    350                         // Action for plugin authors
     389                        /**
     390                         * Fires after an activity item has been proven to be spam, but before officially being marked as spam.
     391                         *
     392                         * @since BuddyPress (1.6.0)
     393                         *
     394                         * @param BP_Activity_Activity $activity The activity item proven to be spam.
     395                         * @param array $activity_data Array of activity data for item including Akismet check results data.
     396                         */
    351397                        do_action_ref_array( 'bp_activity_akismet_spam_caught', array( &$activity, $activity_data ) );
    352398
    353399                        // Mark as spam
     
    614660function bp_activity_akismet_delete_old_metadata() {
    615661        global $bp, $wpdb;
    616662
     663        /**
     664         * Filters the threshold for how many days old Akismet metadata needs to be before being automatically deleted.
     665         *
     666         * @since BuddyPress (1.6.0)
     667         *
     668         * @param integer 15 How many days old metadata needs to be.
     669         */
    617670        $interval = apply_filters( 'bp_activity_akismet_delete_meta_interval', 15 );
    618671
    619672        // Enforce a minimum of 1 day