grunion_handle_bulk_spam

The Jetpack by WordPress.com grunion handle bulk spam function.

Description

grunion_handle_bulk_spam(); 

Usage

  1. if ( !function_exists( 'grunion_handle_bulk_spam' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/contact-form/admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = grunion_handle_bulk_spam(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/modules/contact-form/admin.php  
  1. function grunion_handle_bulk_spam() { 
  2. global $pagenow; 
  3.  
  4. if ( 'edit.php' != $pagenow 
  5. || ( empty( $_REQUEST['post_type'] ) || 'feedback' != $_REQUEST['post_type'] ) ) 
  6. return; 
  7.  
  8. // Slip in a success message 
  9. if ( ! empty( $_REQUEST['message'] ) && 'marked-spam' == $_REQUEST['message'] ) 
  10.  
  11. if ( ( empty( $_REQUEST['action'] ) || 'spam' != $_REQUEST['action'] ) && ( empty( $_REQUEST[''] ) || 'spam' != $_REQUEST[''] ) ) { 
  12. return; 
  13.  
  14. check_admin_referer('bulk-posts'); 
  15.  
  16. if ( empty( $_REQUEST['post'] ) ) { 
  17. wp_safe_redirect( wp_get_referer() ); 
  18. exit; 
  19.  
  20. $post_ids = array_map( 'intval', $_REQUEST['post'] ); 
  21.  
  22. foreach( $post_ids as $post_id ) { 
  23. if ( ! current_user_can( "edit_page", $post_id ) ) { 
  24. wp_die( __( 'You are not allowed to manage this item.', jetpack ) ); 
  25.  
  26. $post = array( 
  27. 'ID' => $post_id,  
  28. 'post_status' => 'spam',  
  29. ); 
  30. $akismet_values = get_post_meta( $post_id, '_feedback_akismet_values', true ); 
  31. wp_update_post( $post ); 
  32.  
  33. /** 
  34. * Fires after a comment has been marked by Akismet. 
  35. * Typically this means the comment is spam. 
  36. * @module contact-form 
  37. * @since 2.2.0 
  38. * @param string $comment_status Usually is 'spam', otherwise 'ham'. 
  39. * @param array $akismet_values From '_feedback_akismet_values' in comment meta 
  40. */ 
  41. do_action( 'contact_form_akismet', 'spam', $akismet_values ); 
  42.  
  43. $redirect_url = add_query_arg( 'message', 'marked-spam', wp_get_referer() ); 
  44. wp_safe_redirect( $redirect_url ); 
  45. exit;