<?php
/*
Plugin Name: Comment to SMS
Plugin URI: http://ddhr.org/code/comment-to-sms/
Description: Notifies blog owner of new comment via text message.
Version: 0.5
Author: David Hosier
Author URI: http://ddhr.org/
*/
function comment_to_sms($comment_id, $comment_type='') {
global $wpdb;
$smsnumber = 'xxxyyyzzzz@sprint-verizon-att-tmobile.com';
$comment = get_comment($comment_id);
$post = get_post($comment->comment_post_ID);
$user = get_userdata( $post->post_author );
$blogname = '['.get_option('blogname').'] Comment';
$wp_email = 'comment@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
$notify_message = $comment->comment_author.' on '.$post->post_title.': '.$comment->comment_content;
$from = "From: \"$blogname\" <$wp_email>";
$message_headers = "MIME-Version: 1.0\n"
. "$from\n"
. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
if($comment->user_id != $post->post_author && $comment->comment_approved == 1) {
@wp_mail($smsnumber, '', $notify_message, $message_headers);
}
return true;
}
add_action('comment_post', 'comment_to_sms');
?>