nxs_wp_allow_comment

The NextScripts: Social Networks Auto-Poster nxs wp allow comment function.

Description

nxs_wp_allow_comment( $commentdata ); 

Parameters (1)

0. $commentdata
The commentdata.

Usage

  1. if ( !function_exists( 'nxs_wp_allow_comment' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/nxs_functions.php'; 
  3.  
  4. // The commentdata. 
  5. $commentdata = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = nxs_wp_allow_comment($commentdata); 
  9.  

Defined (1)

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

/nxs_functions.php  
  1. function nxs_wp_allow_comment($commentdata) { global $wpdb; extract($commentdata, EXTR_SKIP);  
  2. // Simple duplicate check // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 
  3. $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_parent = '$comment_parent' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' "; 
  4. if ( $comment_author_email ) $dupe .= "OR comment_author_email = '$comment_author_email' "; $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; 
  5. $dupeID = $wpdb->get_var($dupe); if ( $dupeID ) { do_action( 'comment_duplicate_trigger', $commentdata ); return $dupeID; }  
  6. do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); 
  7. if ( ! empty( $user_id ) ) { $user = get_userdata( $user_id ); $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID)); } 
  8. if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { // The author and the admins get respect. 
  9. $approved = 1; 
  10. } else { // Everyone else's comments will be checked. 
  11. if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) ) $approved = 1; else $approved = 0; 
  12. if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) ) $approved = 'spam'; 
  13. } $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); return $approved;