Changeset 7395 for trunk/bp-activity/bp-activity-akismet.php
- Timestamp:
- 10/08/2013 08:57:41 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-akismet.php
r6825 r7395 1 1 <?php 2 2 /** 3 * Akismet support for BuddyPress' Activity Stream 3 * Akismet support for BuddyPress' Activity Stream. 4 4 * 5 5 * @package BuddyPress … … 11 11 if ( !defined( 'ABSPATH' ) ) exit; 12 12 13 /** 14 * Akismet support for the Activity component. 15 * 16 * @since BuddyPress (1.6) 17 */ 13 18 class BP_Akismet { 14 19 /** 15 * The activity last marked as spam 20 * The activity last marked as spam. 16 21 * 17 22 * @access protected … … 22 27 23 28 /** 24 * Constructor 29 * Constructor. 25 30 * 26 31 * @since BuddyPress (1.6) … … 31 36 32 37 /** 33 * Hook Akismet into the activity stream 38 * Hook Akismet into the activity stream. 34 39 * 35 40 * @since BuddyPress (1.6) … … 65 70 * akismet_comment_row_action() function. Thanks! 66 71 * 67 * @param array $actions The hover links 68 * @param array $activity The activity for the current row being processed 69 * @return array The hover links 70 * @since BuddyPress (1.6) 72 * @since BuddyPress (1.6) 73 * 74 * @param array $actions The hover links. 75 * @param array $activity The activity for the current row being processed. 76 * @return array The hover links. 71 77 */ 72 78 function comment_row_action( $actions, $activity ) { … … 111 117 112 118 /** 113 * Adds a nonce to the member profile status form, and to the reply form of each activity stream item. 114 * This is used by Akismet to help detect spam activity. 119 * Generate nonces for activity forms. 120 * 121 * These nonces appear in the member profile status form, as well as in 122 * the reply form of each activity item. The nonces are, in turn, used 123 * by Akismet to help detect spam activity. 124 * 125 * @since BuddyPress (1.6) 115 126 * 116 127 * @see http://plugins.trac.wordpress.org/ticket/1232 117 * @since BuddyPress (1.6)118 128 */ 119 129 public function add_activity_stream_nonce() { … … 131 141 132 142 /** 133 * Check the member's latest (activity) update to see if it's the item that was (just) marked as spam. 134 * 135 * This can't be done in BP_Akismet::check_activity() due to BP-Default's AJAX implementation; see bp_dtheme_post_update(). 136 * 137 * @param string $content Activity update text 138 * @param int $user_id User ID 139 * @param int $activity_id Activity ID 143 * Clean up the bp_latest_update usermeta in case of spamming. 144 * 145 * Run just after an update is posted, this method check to see whether 146 * the newly created update has been marked as spam by Akismet. If so, 147 * the cached update is cleared from the user's 'bp_latest_update' 148 * usermeta, ensuring that it won't appear in the member header and 149 * elsewhere in the theme. 150 * 151 * This can't be done in BP_Akismet::check_activity() due to the 152 * default AJAX implementation; see bp_dtheme_post_update(). 153 * 154 * @since BuddyPress (1.6) 155 * 140 156 * @see bp_dtheme_post_update() 141 * @since BuddyPress (1.6) 157 * 158 * @param string $content Activity update text. 159 * @param int $user_id User ID. 160 * @param int $activity_id Activity ID. 142 161 */ 143 162 public function check_member_activity_update( $content, $user_id, $activity_id ) { … … 212 231 213 232 /** 214 * Get a list of filterable types of activity item that we want Akismet toautomatically check for spam.215 * 216 * @ return array List of activity types217 * @since BuddyPress (1.6)233 * Get a filterable list of activity types that Akismet should automatically check for spam. 234 * 235 * @since BuddyPress (1.6) 236 * 218 237 * @static 238 * 239 * @return array List of activity types. 219 240 */ 220 241 public static function get_activity_types() { … … 223 244 224 245 /** 225 * Mark activity item as spam 246 * Mark activity item as spam. 247 * 248 * @since BuddyPress (1.6) 226 249 * 227 250 * @param BP_Activity_Activity $activity 228 251 * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed). 229 * @since BuddyPress (1.6)230 252 */ 231 253 public function mark_as_spam( $activity, $source ) { … … 237 259 238 260 /** 239 * Mark activity item as ham 261 * Mark activity item as ham. 262 * 263 * @since BuddyPress (1.6) 240 264 * 241 265 * @param BP_Activity_Activity $activity 242 266 * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed). 243 * @since BuddyPress (1.6)244 267 */ 245 268 public function mark_as_ham( $activity, $source ) { … … 252 275 253 276 /** 254 * Build a data package for the Akismet service to inspect 255 * 256 * @param BP_Activity_Activity $activity 277 * Build a data package for the Akismet service to inspect. 278 * 279 * @since BuddyPress (1.6) 280 * 257 281 * @see http://akismet.com/development/api/#comment-check 258 * @since BuddyPress (1.6)259 282 * @static 283 * 284 * @param BP_Activity_Activity $activity Activity item data. 260 285 */ 261 286 public static function build_akismet_data_package( $activity ) { … … 291 316 292 317 /** 293 * Check if the activity item is spam or ham 294 * 295 * @param BP_Activity_Activity $activity The activity item to check 318 * Check if the activity item is spam or ham. 319 * 320 * @since BuddyPress (1.6) 321 * 296 322 * @see http://akismet.com/development/api/ 297 * @since BuddyPress (1.6)298 323 * @todo Spam counter? 299 324 * @todo Auto-delete old spam? 325 * 326 * @param BP_Activity_Activity $activity The activity item to check. 300 327 */ 301 328 public function check_activity( $activity ) { … … 333 360 334 361 /** 335 * Update activity meta after a manual spam change (user initiated) 336 * 337 * @param BP_Activity_Activity $activity The activity to check 338 * @since BuddyPress (1.6) 362 * Update activity meta after a manual spam change (user-initiated). 363 * 364 * @since BuddyPress (1.6) 365 * 366 * @param BP_Activity_Activity $activity The activity to check. 339 367 */ 340 368 public function update_activity_spam_meta( $activity ) { … … 349 377 350 378 /** 351 * Update activity meta after a manual ham change (user initiated) 352 * 353 * @param BP_Activity_Activity $activity The activity to check 354 * @since BuddyPress (1.6) 379 * Update activity meta after a manual ham change (user-initiated). 380 * 381 * @since BuddyPress (1.6) 382 * 383 * @param BP_Activity_Activity $activity The activity to check. 355 384 */ 356 385 public function update_activity_ham_meta( $activity ) { … … 365 394 366 395 /** 367 * Update activity meta after an automatic spam check (not user initiated) 368 * 369 * @param BP_Activity_Activity $activity The activity to check 370 * @since BuddyPress (1.6) 396 * Update activity meta after an automatic spam check (not user-initiated). 397 * 398 * @since BuddyPress (1.6) 399 * 400 * @param BP_Activity_Activity $activity The activity to check. 371 401 */ 372 402 public function update_activity_akismet_meta( $activity ) { … … 400 430 401 431 /** 402 * Contact Akismet to check if this is spam or ham 403 * 404 * Props to WordPress core Akismet plugin for alot of this 432 * Contact Akismet to check if this is spam or ham. 433 * 434 * Props to WordPress core Akismet plugin for alot of this. 435 * 436 * @since BuddyPress (1.6) 405 437 * 406 438 * @global string $akismet_api_host 407 439 * @global string $akismet_api_port 408 * @param array $activity_data Packet of information to submit to Akismet 409 * @param string $check "check" or "submit" 410 * @param string $spam "spam" or "ham" 411 * @since BuddyPress (1.6) 440 * 441 * @param array $activity_data Packet of information to submit to Akismet. 442 * @param string $check "check" or "submit". 443 * @param string $spam "spam" or "ham". 444 * @return array $activity_data Activity data, with Akismet data added. 412 445 */ 413 446 public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) { … … 478 511 479 512 /** 480 * Filters user agent when sending to Akismet. 481 * 482 * @param string $user_agent 483 * @since BuddyPress (1.6) 513 * Filters user agent when sending to Akismet to add BuddyPress info. 514 * 515 * @since BuddyPress (1.6) 516 * 517 * @param string $user_agent User agent string, as generated by Akismet. 518 * @return string $user_agent Modified user agent string. 484 519 */ 485 520 public function buddypress_ua( $user_agent ) { … … 491 526 * Adds a "History" meta box to the activity edit screen. 492 527 * 493 * @param string $screen_action The type of screen that has been requested 494 * @since BuddyPress (1.6) 528 * @since BuddyPress (1.6) 529 * 530 * @param string $screen_action The type of screen that has been requested. 495 531 */ 496 532 function add_history_metabox( $screen_action ) { … … 504 540 505 541 /** 506 * History meta box for the Activity admin edit screen 507 * 508 * @param object $item Activity item 509 * @since BuddyPress (1.6) 542 * History meta box for the Activity admin edit screen. 543 * 544 * @since BuddyPress (1.6) 545 * 546 * @see http://buddypress.trac.wordpress.org/ticket/3907 510 547 * @todo Update activity meta to allow >1 record with the same key (iterate through $history). 511 * @see http://buddypress.trac.wordpress.org/ticket/3907 548 * 549 * @param object $item Activity item. 512 550 */ 513 551 function history_metabox( $item ) { … … 523 561 524 562 /** 525 * Update an activity item's Akismet history 526 * 527 * @param int $activity_id Activity item ID 528 * @param string $message Human-readable description of what's changed 529 * @param string $event The type of check we were carrying out 530 * @since BuddyPress (1.6) 563 * Update an activity item's Akismet history. 564 * 565 * @since BuddyPress (1.6) 566 * 567 * @param int $activity_id Activity item ID. 568 * @param string $message Human-readable description of what's changed. 569 * @param string $event The type of check we were carrying out. 531 570 */ 532 571 public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) { … … 543 582 544 583 /** 545 * Get an activity item's Akismet history 546 * 547 * @param int $activity_id Activity item ID 548 * @return array The activity item's Akismet history 549 * @since BuddyPress (1.6) 584 * Get an activity item's Akismet history. 585 * 586 * @since BuddyPress (1.6) 587 * 588 * @param int $activity_id Activity item ID. 589 * @return array The activity item's Akismet history. 550 590 */ 551 591 public function get_activity_history( $activity_id = 0 ) { … … 562 602 563 603 /** 564 * Delete s old spam activity meta data, as _bp_akismet_submission meta can be large.604 * Delete old spam activity meta data 565 605 * 566 * @global object $bp BuddyPress global settings 567 * @global wpdb $wpdb WordPress database object 606 * This is done as a clean-up mechanism, as _bp_akismet_submission meta can 607 * grow to be quite large. 608 * 568 609 * @since BuddyPress (1.6) 610 * 611 * @global object $bp BuddyPress global settings. 612 * @global wpdb $wpdb WordPress database object. 569 613 */ 570 614 function bp_activity_akismet_delete_old_metadata() {
Note: See TracChangeset
for help on using the changeset viewer.