nxs_postNewComment

The NextScripts: Social Networks Auto-Poster nxs postNewComment function.

Description

nxs_postNewComment( $cmnt, (constant) $aa = false ); 

Parameters (2)

0. $cmnt
The cmnt.
1. $aa — Optional. (constant) => false
The aa.

Usage

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

Defined (1)

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

/nxs_functions.php  
  1. if (!function_exists("nxs_postNewComment")) { function nxs_postNewComment($cmnt, $aa = false) { $cmnt['comment_post_ID'] = (int) $cmnt['comment_post_ID']; 
  2. $cmnt['comment_parent'] = isset($cmnt['comment_parent']) ? absint($cmnt['comment_parent']) : 0; $ae = get_option('admin_email'); 
  3. //$u = get_user_by( 'email', get_option('admin_email') ); $cmnt['user_id'] = $u->ID; //??? 
  4. $u = get_user_by( 'email', $cmnt['comment_author_email'] ); if (!empty($u)) $cmnt['user_id'] = $u->ID; else $cmnt['user_id'] = 0; 
  5.  
  6. $parent_status = ( 0 < $cmnt['comment_parent'] ) ? wp_get_comment_status($cmnt['comment_parent']) : '';  
  7. $cmnt['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $cmnt['comment_parent'] : 0; 
  8. $cmnt['comment_author_IP'] = ''; if (empty($cmnt['comment_agent'])) $cmnt['comment_agent'] = 'SNAP'; $cmnt['comment_date'] = get_date_from_gmt( $cmnt['comment_date_gmt'] );  
  9. $cmnt = wp_filter_comment($cmnt); if ($aa) $cmnt['comment_approved'] = 1; else $cmnt['comment_approved'] = nxs_wp_allow_comment($cmnt); // echo "INSERT"; prr($cmnt); 
  10. if ( $cmnt['comment_approved'] != 'spam' && $cmnt['comment_approved']>1 ) return $cmnt['comment_approved']; else $cmntID = wp_insert_comment($cmnt);  
  11. if (empty($cmntID)) { nxs_addToLogN('E', 'Error', 'Comments', '-=ERROR=-', print_r($cmnt, true)); return; } 
  12.  
  13. if ( 'spam' !== $cmnt['comment_approved'] ) { if ( '0' == $cmnt['comment_approved'] ) wp_notify_moderator($cmntID); $post = get_post($cmnt['comment_post_ID']); 
  14. if ( get_option('comments_notify') && $cmnt['comment_approved'] && ( ! isset( $cmnt['user_id'] ) || $post->post_author != $cmnt['user_id'] ) ) wp_notify_postauthor($cmntID);  
  15. global $wpdb, $dsq_api; 
  16. if (isset($dsq_api) && is_object($post)) { $plugins_url = str_replace( 'social-networks-auto-poster-facebook-twitter-g/', '', plugin_dir_path( __FILE__ )); require_once( $plugins_url.'disqus-comment-system/export.php');  
  17. if (function_exists('dsq_export_wp')) { 
  18. $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d", $cmntID) );  
  19. $wxr = nxs_dsq_export_wp($post, $comments); $response = $dsq_api->import_wordpress_comments($wxr, time());  
  20. }} 
  21. }  
  22. return $cmntID; 
  23. }}