本文整理汇总了PHP中get_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP get_comment函数的具体用法?PHP get_comment怎么用?PHP get_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_comment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subscribe_from_comment
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");
}
}
}
}
}
}
示例2: cer_comment_status_changed
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);
}
}
示例3: comment_posted
/**
* 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, '/');
}
}
}
示例4: wc_save_notification_data_v200
/**
* 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);
}
示例5: cren_comment_status_update
/**
* 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);
}
}
示例6: _save_review_stats
/**
* @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);
}
}
示例7: wp_set_comment_status
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));
}
示例8: vp_push_notify
/**
* 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);
}
示例9: _clm_comment_submit_claim
/** 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?
}
示例10: salesforce_process_comment
/**
* 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);
}
}
示例11: delete_comment
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;
}
示例12: handle_comment_log
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);
}
示例13: setUp
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();
}
示例14: zws_comment_mail_notify
/**
* 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);
}
}
}
示例15: send_notifications
/**
* 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();
}