public function subscribe_from_comment($cid, $comment = null)
 {
     $cid = (int) $cid;
     $opts = $this->options;
     $mc4wp = MC4WP_Lite::get_instance();
     if (!is_object($comment)) {
         $comment = get_comment($cid);
     }
     // check if comment has been marked as spam or not
     if ($comment->comment_karma == 0) {
         // check if commenter wanted to be subscribed
         $subscribe = get_comment_meta($cid, 'mc4wp_subscribe', true);
         if ($subscribe == 1) {
             $email = $comment->comment_author_email;
             $ip = $comment->comment_author_IP;
             $name = $comment->comment_author;
             $result = $mc4wp->subscribe('checkbox', $email, array(), array('name' => $name, 'ip' => $ip));
             if ($result === true) {
                 update_comment_meta($cid, 'mc4wp_subscribe', 'subscribed', 1);
             } else {
                 // something went wrong
                 $error = $result;
                 // show error to admins only
                 if (current_user_can('manage_options')) {
                     if ($error == 'no_lists_selected') {
                         die("\n\t\t\t\t\t\t\t\t<h3>MailChimp for WordPress - configuration error</h3>\n\t\t\t\t\t\t\t\t<p><strong>Error:</strong> No lists have been selected. Go to the <a href=\"" . get_admin_url(null, "admin.php?page=mailchimp-for-wp&tab=checkbox-settings") . "\">MailChimp for WordPress options page</a> and select at least one list to subscribe commenters to.</p>\n\t\t\t\t\t\t\t\t<p><em>PS. don't worry, this error message will only be shown to WP Administrators.</em></p>\n\t\t\t\t\t\t\t\t");
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
function cer_comment_status_changed($comment_id, $comment_status)
{
    $comment_object = get_comment($comment_id);
    if ($comment_status == 'approve') {
        cer_comment_notification($comment_object->comment_ID, $comment_object);
    }
}
Exemple #3
0
 /**
  * Executed comment posted
  *
  * @param int $comment_id
  */
 public function comment_posted($comment_id)
 {
     $comment = get_comment($comment_id);
     if ($this->is_thread(get_post_type($comment->comment_post_ID))) {
         // This may anonymous comment.
         if ($this->input->post('_nichancommentnonce') && $comment->user_id && $comment->user_id == $this->option->post_as) {
             // Mark this as anonymous comment
             update_comment_meta($comment_id, '_is_anonymous', 1);
             // If hash exists, save it
             if ($this->option->use_trip && ($trip = $this->input->post('trip'))) {
                 update_comment_meta($comment_id, '_trip', $this->hash->generate($trip));
             }
             // Put cookie for anonymous user.
             if (isset($_COOKIE['nichan_posted'])) {
                 $cookies = explode('-', $_COOKIE['nichan_posted']);
             } else {
                 $cookies = array();
             }
             if (false === array_search($comment->comment_post_ID, $cookies)) {
                 $cookies[] = $comment->comment_post_ID;
             }
             setcookie('nichan_posted', implode('-', $cookies), current_time('timestamp', true) + 60 * 30, '/');
         }
     }
 }
 /**
  * save old notification data from notification table v200 into new created table and drop old table
  */
 public function wc_save_notification_data_v200($wc_old_notification_table_name)
 {
     $sql_post_notification_data = "SELECT * FROM `" . $wc_old_notification_table_name . "` WHERE `post_id` > 0;";
     $sql_comment_notification_data = "SELECT * FROM `" . $wc_old_notification_table_name . "` WHERE `comment_id` > 0;";
     $post_notifications_data = $this->db->get_results($sql_post_notification_data, ARRAY_A);
     $comment_notifications_data = $this->db->get_results($sql_comment_notification_data, ARRAY_A);
     $inserted_post_ids = array();
     foreach ($post_notifications_data as $p_notification_data) {
         $email = $p_notification_data['email'];
         $post_id = $p_notification_data['post_id'];
         $inserted_post_ids[] = $post_id;
         $subscribtion_type = "post";
         $activation_key = md5($email . uniqid() . time());
         $sql_add_old_post_notification = "INSERT INTO `" . $this->email_notification . "` (`email`, `subscribtion_id`, `post_id`, `subscribtion_type`, `activation_key`, `confirm`) VALUES('{$email}', {$post_id}, {$post_id}, '{$subscribtion_type}', '{$activation_key}', '1');";
         $this->db->query($sql_add_old_post_notification);
     }
     foreach ($comment_notifications_data as $c_notification_data) {
         $email = $c_notification_data['email'];
         $comment_id = $c_notification_data['comment_id'];
         $comment = get_comment($comment_id);
         if (!$this->wc_has_comment_notification($comment->comment_post_ID, $comment_id, $email)) {
             $subscribtion_type = "comment";
             $activation_key = md5($email . uniqid() . time());
             $sql_add_old_post_notification = "INSERT INTO `" . $this->email_notification . "` (`email`, `subscribtion_id`, `post_id`, `subscribtion_type`, `activation_key`, `confirm`) VALUES('{$email}', {$comment_id}, {$comment->comment_post_ID}, '{$subscribtion_type}', '{$activation_key}', '1');";
             $this->db->query($sql_add_old_post_notification);
         }
     }
     $sql_drop_old_notification_table = "DROP TABLE `" . $wc_old_notification_table_name . "`;";
     $this->db->query($sql_drop_old_notification_table);
 }
/**
 * Sends a notification if a comment is approved
 * @param  int    $commentId     The comment ID
 * @param  string $commentStatus The new comment status
 * @return boolean
 */
function cren_comment_status_update($commentId, $commentStatus)
{
    $comment = get_comment($commentId);
    if ($commentStatus == 'approve') {
        cren_comment_notification($comment->comment_id, $comment);
    }
}
 /**
  * @since 1.1.9
  * @param $comment_id
  */
 function _save_review_stats($comment_id)
 {
     $comemntObj = get_comment($comment_id);
     $post_id = $comemntObj->comment_post_ID;
     if (get_post_type($post_id) == 'st_holidays') {
         $all_stats = $this->get_review_stats();
         $st_review_stats = STInput::post('st_review_stats');
         if (!empty($all_stats) and is_array($all_stats)) {
             $total_point = 0;
             foreach ($all_stats as $key => $value) {
                 if (isset($st_review_stats[$value['title']])) {
                     $total_point += $st_review_stats[$value['title']];
                     //Now Update the Each Stat Value
                     update_comment_meta($comment_id, 'st_stat_' . sanitize_title($value['title']), $st_review_stats[$value['title']]);
                 }
             }
             $avg = round($total_point / count($all_stats), 1);
             //Update comment rate with avg point
             $rate = wp_filter_nohtml_kses($avg);
             if ($rate > 5) {
                 //Max rate is 5
                 $rate = 5;
             }
             update_comment_meta($comment_id, 'comment_rate', $rate);
             //Now Update the Stats Value
             update_comment_meta($comment_id, 'st_review_stats', $st_review_stats);
         }
         if (STInput::post('comment_rate')) {
             update_comment_meta($comment_id, 'comment_rate', STInput::post('comment_rate'));
         }
         //review_stats
         $avg = STReview::get_avg_rate($post_id);
         update_post_meta($post_id, 'rate_review', $avg);
     }
 }
 public function wp_set_comment_status($comment_id, $comment_status)
 {
     if (!get_comment($comment_id)) {
         return;
     }
     $update = new Listify_Rating_Listing(array('object_id' => get_comment($comment_id)->comment_post_ID, 'rating' => true));
 }
/**
 * Push a notification to user after a reply is posted.
 *
 * @since 0.0.1
 */
function vp_push_notify($comment_ID)
{
    $comment = get_comment($comment_ID);
    $parent_id = $comment->comment_parent;
    if ('0' == $parent_id) {
        return;
    }
    $parent = get_comment($parent_id);
    $parent_user_id = $parent->user_id;
    if ('0' == $parent_user_id) {
        return;
    }
    // if the reply is post by youself, don't push notify
    if ($comment->user_id == $parent_user_id) {
        return;
    }
    $notifications = get_user_meta($parent_user_id, 'v2press_notifications', true);
    if (!is_array($notifications) || empty($notifications)) {
        $notifications = array();
    }
    $notifications[] = $comment_ID;
    update_user_meta($parent_user_id, 'v2press_notifications', $notifications);
    $count = (int) get_user_meta($parent_user_id, 'v2press_notifications_unread', true);
    $count++;
    update_user_meta($parent_user_id, 'v2press_notifications_unread', $count);
}
/** Called to indicate that the given comment deserves a claim. */
function _clm_comment_submit_claim($id)
{
    $comment = get_comment($id, 'OBJECT');
    // Verify that we have enough information to claim
    $blog = $comment->comment_author_url;
    if (strlen($blog) < 8) {
        // Nope. Doesn't look like a decent URL
        return;
    }
    // Get the URL of the claim service
    clm_loadSib('network.php');
    $claimUrl = _clm_claim_discover($blog);
    if (!$claimUrl) {
        // There's no URL
        return;
    }
    // Send the claim
    $post = get_post($comment->comment_post_ID);
    $request = array('title' => $post->post_title, 'blog_name' => get_bloginfo('name'), 'blog_url' => get_bloginfo('wpurl'), 'type' => 'comment', 'item' => '', 'email' => $comment->comment_author_email, 'excerpt' => substr(strip_tags($comment->comment_content), 0, 255), 'url' => get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID);
    $request['charset'] = get_option('blog_charset');
    foreach (array_keys($request) as $key) {
        $request[$key] = urlencode($request[$key]);
    }
    $claimUrl .= '?';
    $first = true;
    foreach ($request as $key => $value) {
        if (!$first) {
            $claimUrl .= '&';
        }
        $first = false;
        $claimUrl .= $key . '=' . $value;
    }
    $r = @file($claimUrl);
    // We should check the return type here. But why bother?
}
/**
 * Processes the comment data, and sends the lead if appropriate.
 *
 * @param int $id The ID of the comment
 * @return void
 **/
function salesforce_process_comment($comment_id)
{
    if (get_comment_meta($comment_id, 'salesforce_lead_submitted', true)) {
        return;
    }
    $options = get_option('salesforce2');
    if (!$options['commentstoleads']) {
        return;
    }
    $comment = get_comment($comment_id);
    $post = get_post($comment->comment_post_ID);
    // Some plugins use comments on custom post types for all kinds of things
    $allowed_types = apply_filters('salesforce_allowed_comment_to_lead_types', array('post', 'page'));
    if (!in_array($post->post_type, $allowed_types)) {
        return;
    }
    $first_name = get_comment_meta($comment_id, 'author_first_name', true);
    $last_name = get_comment_meta($comment_id, 'author_last_name', true);
    // Let's get at least some name data in from legacy comments
    if (!$first_name && !$last_name) {
        $first_name = $comment->comment_author;
    }
    $lead_data = array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $comment->comment_author_email, 'lead_source' => 'Web comment, ' . get_site_url(), 'URL' => $comment->comment_author_url, 'description' => $comment->comment_content);
    if (submit_salesforce_form($lead_data, $options)) {
        add_comment_meta($comment_id, 'salesforce_lead_submitted', 1);
    }
}
Exemple #11
0
 public function delete_comment()
 {
     $args = $args = explode('-', sanitize_text_field($_REQUEST['args']));
     if (!ap_user_can_delete_comment($args[0])) {
         $result = array('status' => false, 'message' => __('You do not have permission to delete this comment', 'ap'));
         die(json_encode($result));
     }
     $action = 'delete-comment-' . $args[0];
     if (wp_verify_nonce($args[1], $action)) {
         $comment = get_comment($args[0]);
         $delete = wp_delete_comment($args[0], true);
         if ($delete) {
             $post_type = get_post_type($comment->comment_post_ID);
             do_action('ap_after_delete_comment', $comment, $post_type);
             if ($post_type == 'question') {
                 ap_do_event('delete_comment', $comment, 'question');
             } elseif ($post_type == 'answer') {
                 ap_do_event('delete_comment', $comment, 'answer');
             }
         }
         $result = array('status' => true, 'message' => __('Comment deleted successfully', 'ap'));
         die(json_encode($result));
     }
     die;
 }
 public function handle_comment_log($comment_ID, $comment = null)
 {
     if (is_null($comment)) {
         $comment = get_comment($comment_ID);
     }
     $action = 'created';
     switch (current_filter()) {
         case 'wp_insert_comment':
             $action = 1 === (int) $comment->comment_approved ? 'approved' : 'pending';
             break;
         case 'edit_comment':
             $action = 'updated';
             break;
         case 'delete_comment':
             $action = 'deleted';
             break;
         case 'trash_comment':
             $action = 'trashed';
             break;
         case 'untrash_comment':
             $action = 'untrashed';
             break;
         case 'spam_comment':
             $action = 'spammed';
             break;
         case 'unspam_comment':
             $action = 'unspammed';
             break;
     }
     $this->_add_comment_log($comment_ID, $action, $comment);
 }
 public function setUp()
 {
     parent::setUp();
     $comment_ids = $this->factory->comment->create_post_comments($this->factory->post->create());
     $this->comment = get_comment($comment_ids[0]);
     $this->client->do_sync();
 }
/**
 * WordPress评论回复邮件提醒防垃圾评论版
 * 作者:露兜
 * 博客:http://www.ludou.org/
 */
function zws_comment_mail_notify($comment_id, $comment_status)
{
    // 评论必须经过审核才会发送通知邮件
    if ($comment_status !== 'approve' && $comment_status !== 1) {
        return;
    }
    $comment = get_comment($comment_id);
    if ($comment->comment_parent != '0') {
        $parent_comment = get_comment($comment->comment_parent);
        // 邮件接收者email
        $to = trim($parent_comment->comment_author_email);
        // 邮件标题
        $subject = '您收到来自[' . get_option("blogname") . ']的动态消息';
        // 邮件内容,自行修改,支持HTML
        $message = '
<div style="border:1px solid #AAAAAA;background:#f5f5f5;line-height:35px;padding:20px;border-radius:8px;font-size: 14px;width:600px;margin:0 auto;">
      <h2 style="background:#52b8cb;color:#f5f5f5;font-size:16px;line-height:20px;text-shadow:1px 1px 5px #b1b1b1;font-weight:normal;padding:10px;">您在 <font style="font-weight:700;"> ' . get_option('blogname') . '</font> 的评论有新回复啦!</h2>
      <p><font color="#52b8cb">' . $parent_comment->comment_author . '</font> 童鞋,你曾经在《' . get_the_title($comment->comment_post_ID) . '》留言说:</p> 
      <p style="background-color: #DDD;padding:5px 8px;margin:5px 15px;text-indent:2em;">' . $parent_comment->comment_content . '</p> 
      <p><font color="#52b8cb">' . $comment->comment_author . '</font> 给你的回应是:</p> 
      <p style="background-color: #DDD;padding:5px 8px;margin:5px 15px;text-indent:2em;">' . $comment->comment_content . '</p> 
      <p>猛击这里:<a href="' . htmlspecialchars(get_comment_link($comment->comment_parent)) . '"><font color="#52b8cb">查看完整评论</font></a>, 欢迎再次访问<a href="' . home_url() . '"><font color="#52b8cb">' . get_option('blogname') . '</font></a></p>
      <p>(此邮件由系统自动发送,请勿回复)</p> 
    </div>';
        $message_headers = "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
        // 不用给不填email的评论者和管理员发提醒邮件
        if ($to != '' && $to != get_bloginfo('admin_email')) {
            @wp_mail($to, $subject, $message, $message_headers);
        }
    }
}
 /**
  * Send notifications appropriate for a newly published comment.
  *
  * Top level comments go to all post subscribers, replies optionally to the replyee.
  *
  * @param object|int $comment_id_or_object
  * @param string $chunk Optional identifier for this chunk (to avoid cron collisions)
  * @param int $retry_wait_seconds Minimum time to wait if a retry is necessary, or null to disable retry
  */
 public static function send_notifications($comment_id_or_object, $chunk = '', $retry_wait_seconds = null)
 {
     $comment = get_comment($comment_id_or_object);
     self::handle_new_subscriber($comment);
     $batch = new Prompt_Comment_Email_Batch($comment);
     Prompt_Factory::make_mailer($batch, null, $chunk)->set_retry_wait_seconds($retry_wait_seconds)->send();
 }
 /**
  * Get contribution
  *
  * @since 1.0.0
  * @param bool $the_contribution (default: false)
  * @param array $args (default: array())
  * @return WC_Contribution
  */
 public function wc_product_reviews_pro_get_contribution($the_contribution = false, $args = array())
 {
     global $comment;
     if (false === $the_contribution) {
         $the_contribution = $comment;
     } elseif (is_numeric($the_contribution)) {
         $the_contribution = get_comment($the_contribution);
     }
     if (!$the_contribution) {
         return false;
     }
     if (is_object($the_contribution)) {
         $comment_id = absint($the_contribution->comment_ID);
         $comment_type = $the_contribution->comment_type;
     }
     // Create a WC coding standards compliant class name e.g. WC_Product_Type_Class instead of WC_Product_type-class
     $classname = 'WC_Contribution_' . implode('_', array_map('ucfirst', explode('-', $comment_type)));
     /**
      * Filter classname so that the class can be overridden if extended.
      *
      * @since 1.0.0
      * @param string $classname The class name.
      * @param srting $comment_type The comment type.
      * @param int $comment_id The comment id.
      */
     $classname = apply_filters('woocommerce_contribution_class', $classname, $comment_type, $comment_id);
     if (!class_exists($classname)) {
         $classname = 'WC_Contribution_Review';
     }
     return new $classname($the_contribution, $args);
 }
Exemple #17
0
 public function flush_by_comment($cid)
 {
     global $nginxchampuru;
     $com = get_comment($cid);
     $mode = $nginxchampuru->get_flush_method("comment");
     self::flush_caches($mode, $com->comment_post_ID);
 }
 /**
  * save old notification data from notification table v200 into new created table and drop old table
  */
 public function saveNotificationDataV200($oldNotificationTableName)
 {
     $sqlPostNotificationData = "SELECT * FROM `" . $oldNotificationTableName . "` WHERE `post_id` > 0;";
     $sqlCommentNotificationData = "SELECT * FROM `" . $oldNotificationTableName . "` WHERE `comment_id` > 0;";
     $postNotificationsData = $this->db->get_results($sqlPostNotificationData, ARRAY_A);
     $commentNotificationsData = $this->db->get_results($sqlCommentNotificationData, ARRAY_A);
     $insertedPostIds = array();
     foreach ($postNotificationsData as $pNotificationData) {
         $email = $pNotificationData['email'];
         $postId = $pNotificationData['post_id'];
         $insertedPostIds[] = $postId;
         $subscribtionType = "post";
         $activationKey = md5($email . uniqid() . time());
         $sqlAddOldPostNotification = "INSERT INTO `" . $this->emailNotification . "` (`email`, `subscribtion_id`, `post_id`, `subscribtion_type`, `activation_key`, `confirm`) VALUES('{$email}', {$postId}, {$postId}, '{$subscribtionType}', '{$activationKey}', '1');";
         $this->db->query($sqlAddOldPostNotification);
     }
     foreach ($commentNotificationsData as $cNotificationData) {
         $email = $cNotificationData['email'];
         $commentId = $cNotificationData['comment_id'];
         $comment = get_comment($commentId);
         if (!$this->wc_has_comment_notification($comment->comment_post_ID, $commentId, $email)) {
             $subscribtionType = "comment";
             $activationKey = md5($email . uniqid() . time());
             $sqlAddOldPostNotification = "INSERT INTO `" . $this->emailNotification . "` (`email`, `subscribtion_id`, `post_id`, `subscribtion_type`, `activation_key`, `confirm`) VALUES('{$email}', {$commentId}, {$comment->comment_post_ID}, '{$subscribtionType}', '{$activationKey}', '1');";
             $this->db->query($sqlAddOldPostNotification);
         }
     }
     $sqlDropOldNotificationTable = "DROP TABLE `" . $oldNotificationTableName . "`;";
     $this->db->query($sqlDropOldNotificationTable);
 }
Exemple #19
0
 public static function getById($commentId, $userId = null)
 {
     if ($comment = get_comment($commentId)) {
         if (empty($userId) or $comment->user_id == $userId) {
             return new self($comment);
         }
     }
 }
function wpc_pre_update_comment_time($comment_id, $status)
{
    //comment_post sends along a status, if it's "succes", $status == 1
    if ($status == 1) {
        $comment = get_comment($comment_id);
        wpc_update_comment_time($comment);
    }
}
 public static function getById($commentId, $userId = null)
 {
     if ($comment = get_comment($commentId) and $comment->comment_type == self::COMMENT_TYPE) {
         if (empty($userId) or $comment->user_id == $userId) {
             return new self($comment);
         }
     }
 }
Exemple #22
0
function flamingo_insert_comment($comment_id)
{
    $comment = get_comment($comment_id);
    if (1 != (int) $comment->comment_approved) {
        return;
    }
    Flamingo_Contact::add(array('email' => $comment->comment_author_email, 'name' => $comment->comment_author, 'channel' => 'comment'));
}
 public function show($id, $cropped = false)
 {
     $comment = get_comment($id);
     if (!empty($comment)) {
         $comment = new $this->model_name($comment, $this->meta_key, $cropped);
     }
     return $comment;
 }
Exemple #24
0
 public function commentOfId($id)
 {
     $comment = get_comment($id, ARRAY_A);
     if ($comment) {
         $comment = $this->mapData($comment);
     }
     return $comment;
 }
 public function get_object_by_id($object_type, $id)
 {
     $comment_id = intval($id);
     if ($object_type === 'comment' && ($comment = get_comment($comment_id))) {
         return $this->filter_comment($comment);
     }
     return false;
 }
Exemple #26
0
/**
	logged action: new comment
	**/
function userpro_sc_new_comment($comment_ID, $comment_status)
{
    global $userpro_social;
    if ($comment_status == 1) {
        $comment = get_comment($comment_ID, ARRAY_A);
        $post = get_post($comment['comment_post_ID']);
        $userpro_social->log_action('new_comment', $comment['user_id'], $comment['comment_post_ID'], $post->post_title);
    }
}
 public function get_by_id($id)
 {
     $comment = get_comment($id);
     if ($comment->comment_post_ID != $this->post_id || $comment->comment_type != $this->key || $comment->comment_approved != $this->key) {
         return null;
     }
     $entries = self::entries_from_comments(array($comment));
     return $entries[0];
 }
Exemple #28
0
 /**
  * @see CPAC_Column::get_value()
  * @since 2.0
  */
 function get_value($id)
 {
     $comment = get_comment($id);
     $value = $this->get_asset_image('no.png');
     if ($comment->comment_approved) {
         $value = $this->get_asset_image('checkmark.png');
     }
     return $value;
 }
Exemple #29
0
 /**
  * Comment change action
  *
  * @param integer $comment_id
  */
 function on_comment_change($comment_id)
 {
     $post_id = 0;
     if ($comment_id) {
         $comment = get_comment($comment_id, ARRAY_A);
         $post_id = !empty($comment['comment_post_ID']) ? (int) $comment['comment_post_ID'] : 0;
     }
     $this->on_post_change($post_id);
 }
Exemple #30
0
 public function get($arg)
 {
     $comment_id = (int) $arg;
     $comment = get_comment($comment_id);
     if (is_null($comment)) {
         return false;
     }
     return $comment;
 }