function evc_comments_add_comment($comment, $post_id, $widget_api_id, $comment_parent = null) { if (isset($comment['cid'])) { $comment['id'] = $comment['cid']; } $vk_item_id = 'app' . $widget_api_id . '_' . $comment['id']; $comment_wp_id = evc_get_wpid_by_vkid($vk_item_id, 'comment'); if ($comment_wp_id && isset($comment_wp_id[$vk_item_id])) { return $comment_wp_id[$vk_item_id]; } if (isset($comment['user']) && !empty($comment['user'])) { $user_wp_id = evc_get_wpid_by_vkid($comment['user']['id'], 'user'); if (!$user_wp_id) { $user_wp_id = evc_add_user($comment['user']); if (!$user_wp_id) { return false; } } else { $user_wp_id = $user_wp_id[$comment['user']['id']]; } } else { return false; } $args = array('comment_post_ID' => $post_id, 'comment_content' => $comment['text'], 'user_id' => $user_wp_id, 'comment_date' => date('Y-m-d H:i:s', $comment['date'] + get_option('gmt_offset') * 3600), 'comment_approved' => 1, 'comment_author_IP' => preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']), 'comment_agent' => substr($_SERVER['HTTP_USER_AGENT'], 0, 254)); if (isset($comment_parent) && !empty($comment_parent)) { $args['comment_parent'] = $comment_parent; } $args = apply_filters('evc_comments_add_comment_args', $args, $comment); //print__r($args); // $comment_wp_id = wp_insert_comment($args); if ($comment_wp_id) { update_comment_meta($comment_wp_id, 'vk_item_id', $vk_item_id); } return $comment_wp_id; }
/** * create a comment with type fre_invite * @param int $user_id * @param int $project * @return int $invite_id * @since 1.3.1 * @author Dakachi */ function fre_create_invite($user_id, $project_id) { global $user_ID, $current_user; $invite_id = wp_insert_comment(array('comment_post_ID' => $project_id, 'comment_author' => $current_user->data->user_login, 'comment_author_email' => $current_user->data->user_email, 'comment_content' => sprintf(__("Invite %s to bid project", 'invites-backend'), get_the_author_meta('display_name', $user_id)), 'comment_type' => 'fre_invite', 'user_id' => $user_ID, 'comment_approved' => 1)); update_comment_meta($invite_id, 'invite', $user_id); return $invite_id; }
/** * @ticket 16894 */ public function test_comment_meta_should_be_lazy_loaded_for_all_comments_in_comments_template() { global $wpdb; $p = $this->factory->post->create(array('post_status' => 'publish')); $comment_ids = $this->factory->comment->create_post_comments($p, 3); foreach ($comment_ids as $cid) { update_comment_meta($cid, 'sauce', 'fire'); } $this->go_to(get_permalink($p)); if (have_posts()) { while (have_posts()) { the_post(); // Load comments with `comments_template()`. $cform = get_echo('comments_template'); // First request will hit the database. $num_queries = $wpdb->num_queries; get_comment_meta($comment_ids[0], 'sauce'); $this->assertSame($num_queries + 1, $wpdb->num_queries); // Second and third requests should be in cache. get_comment_meta($comment_ids[1], 'sauce'); get_comment_meta($comment_ids[2], 'sauce'); $this->assertSame($num_queries + 1, $wpdb->num_queries); } } }
/** * 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, '/'); } } }
function delibera_update_comment($comment_id, $user_id, $text, $proposta) { $arrcomment = array('comment_ID' => intval($comment_id), 'comment_content' => $text, 'comment_date' => date("Y-m-d H:i:s")); wp_update_comment($arrcomment); $comment = get_comment($comment_id); $proposta_antes = get_comment_meta($comment_id, 'delibera_comment_tipo', true); if ($proposta != $proposta_antes) { if ($proposta == 'encaminhamento') { update_comment_meta($comment_id, 'delibera_comment_tipo', 'encaminhamento'); $nencaminhamentos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', true); $nencaminhamentos++; update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', $nencaminhamentos); $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true); $ndiscussoes--; update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', $ndiscussoes); } else { update_comment_meta($comment_id, 'delibera_comment_tipo', 'discussao'); $ndiscussoes = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', true); $ndiscussoes++; update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_discussoes', $ndiscussoes); $nencaminhamentos = get_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', true); $nencaminhamentos--; update_post_meta($comment->comment_post_ID, 'delibera_numero_comments_encaminhamentos', $nencaminhamentos); } } return $text; }
function dln_social_login_add_comment_meta($comment_id) { $social_login_comment_via_provider = isset($_POST['social_login_comment_via_provider']) ? $_POST['social_login_comment_via_provider'] : ''; if ($social_login_comment_via_provider != '') { update_comment_meta($comment_id, 'social_login_comment_via_provider', $social_login_comment_via_provider); } }
function activity_log($wp_comment_id = "", $lf_comment_id = "", $lf_activity_id = "") { // Use meta keys that will allow us to lookup by Livefyre comment i update_comment_meta($wp_comment_id, LF_CMETA_PREFIX . $lf_comment_id, $lf_comment_id); update_comment_meta($wp_comment_id, LF_AMETA_PREFIX . $lf_activity_id, $lf_activity_id); return false; }
function testCommentWithMeta() { $post_id = $this->factory->post->create(); $comment_id = $this->factory->comment->create(array('comment_post_ID' => $post_id)); update_comment_meta($comment_id, 'rebney', 'Winnebago Man'); update_comment_meta($comment_id, 'quote', 'Will you do me a kindness?'); $comment = new TimberComment($comment_id); $this->assertEquals('Winnebago Man', $comment->rebney); }
/** * Create a mock webhook delivery. * * @since 2.2 * @see WP_UnitTest_Factory_For_comment::create_object() * @param array $args * @return int webhook delivery (comment) ID */ public function create_object($args) { $id = parent::create_object($args); $comment_meta_args = array('_request_method' => 'POST', '_request_headers' => array('User-Agent', 'WooCommerce Hookshot'), '_request_body' => "webhook_id={$id}", '_response_code' => 200, '_response_messaage' => 'OK', '_response_headers' => array('server' => 'nginx'), '_response_body' => 'OK', '_duration' => '0.47976'); foreach ($comment_meta_args as $key => $value) { update_comment_meta($id, $key, $value); } return $id; }
function update_comment($comment_id) { $comment = get_comment($comment_id); $terms = $this->update_comment_terms($comment_id, $comment); delete_comment_meta($comment_id, $this->meta_key); foreach ($terms as $term) { update_comment_meta($comment_id, $this->meta_key, $term); } $this->update_terms($comment->comment_post_ID); }
/** * Save meta box data */ public static function save($location, $comment_id) { // Not allowed, return regular value without updating meta if (!wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data') && !isset($_POST['rating'])) { return $location; } // Update meta update_comment_meta($comment_id, 'rating', intval($_POST['rating'])); // Return regular value after updating return $location; }
public function do_save($return_val, $params, $metas, $module) { $comment_id = wp_insert_comment($params); if (!is_numeric($comment_id)) { return false; } foreach ($metas as $key => $value) { update_comment_meta($comment_id, $key, $value); } return $comment_id; }
function tracker_set_comment_status() { global $_POST; $commentid = $_POST['id']; $status = $_POST['status']; if (!current_user_can('edit_post', $commentid)) { die("Sorry you can't do that."); } add_comment_meta($commentid, 'tracker_comment_status', $status, true) or update_comment_meta($commentid, 'tracker_comment_status', $status) or die("Failed to add or update status for comment."); die("OK"); }
/** * * @since 2.0.0 * * @param object $data * @return $this */ protected function record_successful_outbound_message_batch($data) { if (empty($data->id)) { Prompt_Logging::add_error(Prompt_Enum_Error_Codes::OUTBOUND, __('Got an unrecognized outbound message batch response.', 'Postmatic'), array('result' => $data, 'comment_id' => $this->comment->comment_ID)); return $this; } $sent_ids = get_comment_meta($this->comment->comment_ID, self::$outbound_message_batch_ids_meta_key, true); $sent_ids = $sent_ids ? $sent_ids : array(); $sent_ids[] = $data->id; update_comment_meta($this->comment->comment_ID, self::$outbound_message_batch_ids_meta_key, $sent_ids); return $this; }
function wpad_edit_comment_saved() { $ignore = array('comment_status', 'comment_id', 'comment', 'action'); foreach ($_POST as $key => $value) { if (!in_array($key, $ignore)) { update_comment_meta($_POST['comment_id'], $key, $value); } } $this->set_comment_status($_POST['comment_id'], $_POST['comment_status']); $this->update_comment($_POST); die; }
function hocwp_comment_likes_ajax_callback() { $result = array(); $likes = isset($_POST['likes']) ? absint($_POST['likes']) : 0; $comment_id = isset($_POST['comment_id']) ? absint($_POST['comment_id']) : 0; $likes++; update_comment_meta($comment_id, 'likes', $likes); $result['likes'] = hocwp_number_format($likes); $_SESSION['comment_' . $comment_id . '_likes'] = 1; echo json_encode($result); die; }
/** * Save Custom Comment Field * This hook deals with the redirect after saving, we are only taking advantage of it */ function save_comment_wpse_82317($location, $comment_id) { // Not allowed, return regular value without updating meta if (!wp_verify_nonce($_POST['noncename_wpse_82317'], plugin_basename(__FILE__)) && !isset($_POST['meta_comment_field'])) { return $location; } // Convert text field into array splitted by comma $tags = array_map('trim', explode(',', $_POST['meta_tag_field'])); $tags = array_map('sanitize_text_field', $tags); // Update meta update_comment_meta($comment_id, 'meta_tag_field', implode(',', $tags)); // Return regular value after updating return $location; }
/** * Save opinion * @return bool $status */ function Save() { if (!empty($this->opinion_post_ID) && !empty($this->author_id) && !empty($this->opinion_content)) { $post_type = get_post_type($this->opinion_post_ID); // If element is a product or a product variation, we accept to save opinion if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT || $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { /** Insert comment **/ $data = array('comment_post_ID' => $this->opinion_post_ID, 'comment_author_IP' => $this->author_IP, 'comment_author' => $this->author, 'comment_author_email' => $this->author_email, 'comment_content' => $this->opinion_content, 'comment_date' => $this->opinion_date, 'user_id' => $this->author_id, 'comment_approved' => $this->opinion_approved, 'comment_type' => WPS_OPINION_ID); $this->id = wp_insert_comment($data); if (!empty($this->id)) { $status = update_comment_meta($this->id, '_wps_customer_rate', $this->opinion_rate); } } } return $status; }
function rate_comment($comment_id, $rating) { $rating = substr(trim($rating), 0, 1); $metastring = get_comment_meta($comment_id, 'qans_ratingmeta'); //use a string <averagerating>:<#ofratings> $metadata = explode(":", $metastring[0]); if ($metadata[1] == 0) { $metastring = $rating . ":1"; $newrating = $rating; } else { $newrating = ($metadata[0] * $metadata[1] + $rating) / ($metadata[1] + 1); $metadata[1]++; $metastring = $newrating . ":" . $metadata[1]; } update_comment_meta($comment_id, 'qans_ratingmeta', $metastring); //update the database $ratinghtml = "Average Rating:" . substr($newrating, 0, 3) . "/5 Your rating: " . $rating . "/5"; return $ratinghtml; //return the string }
/** * Check if the comment is spam or not * * @param $id * @param $comment */ public function check_for_spam($id, $comment) { $url = 'https://spamlytics.com/?api_action=comment_verify&api_key=' . $this->settings['api_key']; $response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 10, 'blocking' => true, 'body' => array('comment' => $comment->comment_content, 'name' => $comment->comment_author, 'email' => $comment->comment_author_email, 'website' => $comment->comment_author_url, 'ip' => $comment->comment_author_IP))); if (isset($response['body'])) { $result = json_decode($response['body']); update_comment_meta($id, 'spamlytics_result', $result->result); update_comment_meta($id, 'spamlytics_points', $result->points); if ($result->result === 'ok') { $comment = (array) $comment; $comment['comment_approved'] = 1; wp_update_comment($comment); } if ($result->result === 'spam') { $comment = (array) $comment; $comment['comment_approved'] = 'spam'; wp_update_comment($comment); } } }
function DeadLineComment() { // параметры выборки $now = current_time('mysql', 0); $results_array = get_terms('results', 'fields=ids'); $cases = get_posts(array('post_type' => 'cases', 'nopaging' => true, 'tax_query' => array(array('taxonomy' => 'results', 'operator' => 'NOT IN', 'terms' => $results_array)), 'meta_query' => array(array('key' => 'deadline_cp', 'value' => $now, 'compare' => '<', 'type' => 'DATETIME')))); //error_log("Комменты: " . print_r($cases, true)); /* foreach($cases as $case){ error_log('Post ID - ' . print_r($case->ID, true)); }*/ foreach ($cases as $case) { //setup_postdata($post); $post_id = $case->ID; //error_log('Post ID - ' . print_r($post_id, true)); $deadline_cp = get_post_meta($post_id, 'deadline_cp', true); //Проверяем наличие комментария о нарушении срока $comment_check = get_comments(array('post_id' => $post_id, 'type' => 'e_cp_deadline_fail', 'meta_key' => 'deadline_date', 'meta_value' => $deadline_cp)); //error_log('Коммент - ' . print_r($comment_check, true)); //error_log('Срок проверки - ' . print_r($deadline_cp, true)); // Если комментарии с нарушением этого срока уже есть, то переходим к следующиему посту if (!empty($comment_check)) { continue; } $responsible_id = get_post_meta($post_id, 'responsible-cp-posts-sql', true); // Проверяем наличие ответственного, заполняем переменную имени ответственного if (empty($responsible_id)) { $responsible_name = 'Отсутствует'; } else { $responsible_name = get_the_title($responsible_id); } $comment_id = wp_insert_comment(array('comment_post_ID' => $post_id, 'comment_author' => 'CasePress', 'comment_author_email' => get_option('admin_email'), 'comment_content' => "Нарушен срок: " . $deadline_cp . ". " . "Ответственный: " . $responsible_name, 'comment_type' => 'e_cp_deadline_fail', 'comment_parent' => 0, 'user_ID' => '', 'comment_approved' => true)); if ($comment_id) { update_comment_meta($comment_id, 'deadline_date', $deadline_cp); if ($responsible_id > 0) { update_comment_meta($comment_id, 'responsible_id', $responsible_id); } } } //wp_reset_postdata(); }
public function insert_duplicated_comment($comment, $dup_id, $original_cid) { global $wpdb, $iclTranslationManagement; $dup_comment_id = $this->duplicate_exists($dup_id, $original_cid); remove_action('wp_insert_comment', array($iclTranslationManagement, 'duplication_insert_comment'), 100); if ($dup_comment_id) { $comment['comment_ID'] = $dup_comment_id; wp_update_comment($comment); } else { $wpdb->insert($wpdb->comments, $comment); $dup_comment_id = $wpdb->insert_id; } add_action('wp_insert_comment', array($iclTranslationManagement, 'duplication_insert_comment'), 100); update_comment_meta($dup_comment_id, '_icl_duplicate_of', $original_cid); // comment meta $meta = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM {$wpdb->commentmeta} WHERE comment_id=%d", $original_cid)); foreach ($meta as $meta_row) { $wpdb->insert($wpdb->commentmeta, array('comment_id' => $dup_comment_id, 'meta_key' => $meta_row->meta_key, 'meta_value' => $meta_row->meta_value), array('%d', '%s', '%s')); } wp_update_comment_count_now($dup_id); }
function delibera_discordar($ID, $type = 'pauta') { $user_id = get_current_user_id(); $ip = $_SERVER['REMOTE_ADDR']; if (!delibera_ja_discordou($ID, $user_id, $ip, $type) && !(function_exists('delibera_ja_curtiu') && delibera_ja_curtiu($ID, $user_id, $ip, $type))) { if ($type == 'pauta') { $postID = $ID; $ndiscordar = get_post_meta($postID, 'delibera_numero_discordar', true); $ndiscordar++; update_post_meta($postID, 'delibera_numero_discordar', $ndiscordar); $discordaram = get_post_meta($postID, 'delibera_discordaram', true); if (!is_array($discordaram)) { $discordaram = array(); } $hora = time(); if (!array_key_exists($hora, $discordaram)) { $discordaram[$hora] = array(); } $discordaram[$hora][] = array('user' => $user_id, 'ip' => $ip); update_post_meta($postID, 'delibera_discordaram', $discordaram); } elseif ($type == 'comment') { $comment_id = $ID; $ndiscordar = intval(get_comment_meta($comment_id, 'delibera_numero_discordar', true)); $ndiscordar++; update_comment_meta($comment_id, 'delibera_numero_discordar', $ndiscordar); $discordaram = get_comment_meta($comment_id, 'delibera_discordaram', true); if (!is_array($discordaram)) { $discordaram = array(); } $hora = time(); if (!array_key_exists($hora, $discordaram)) { $discordaram[$hora] = array(); } $discordaram[$hora][] = array('user' => $user_id, 'ip' => $ip); update_comment_meta($comment_id, 'delibera_discordaram', $discordaram); } return sprintf(_n('%d discordou', '%d discordaram', $ndiscordar, 'delibera'), $ndiscordar); } }
function email_notifications_for_users() { //error_log('********************** Запланированный хук ***************************'); $comments = get_comments(array('status' => 'approve', 'meta_key' => 'email_notify', 'meta_value' => '0', 'number' => 10)); foreach ($comments as $comment) { //error_log($comment->comment_author . '<br />' . $comment->comment_content); $comment_id = $comment->comment_ID; $users = get_comment_meta($comment_id, 'notify_user'); $users_notified = get_comment_meta($comment_id, 'notified_user'); foreach ($users as $nuser_id) { //Если участник забанен, то не нужно добавлять в список уведомлений $userdata = new WP_User($nuser_id); $user_role = array_shift($userdata->roles); if ($user_role == 'banned') { continue; } //тут не плохо было бы проверить отправлено данному пользователю уже уведомление или нет if (in_array($nuser_id, $users_notified)) { continue; } //если автор комментария ест в участниках, то ему уведомление на почту не отправлять, но отмечать как уведомленный if ($comment->user_id == $nuser_id) { add_comment_meta($comment_id, 'notified_user', $nuser_id); continue; } //тут функция отправки, которая возвращает результат отправки if ($this->send_email($nuser_id, $comment)) { // если все хорошо то записываем пользователя в список отправленных уведомлений add_comment_meta($comment_id, 'notified_user', $nuser_id); } } $users_notified = get_comment_meta($comment_id, 'notified_user'); //if both lists equal - add tag about all ok if ($users == $users_notified) { update_comment_meta($comment_id, 'email_notify', '1', '0'); } } }
function bp_course_quiz_auto_submit($quiz_id, $user_id) { $quiz_auto_evaluate = get_post_meta($quiz_id, 'vibe_quiz_auto_evaluate', true); if (vibe_validate($quiz_auto_evaluate)) { // Auto Evaluate for Quiz Enabled, Quiz auto evaluate, autoevaluate $total_marks = 0; $questions = vibe_sanitize(get_post_meta($quiz_id, 'quiz_questions' . $user_id, false)); if (!isset($questions) || !is_array($questions)) { // Fallback for Older versions $questions = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_questions', false)); } if (count($questions)) { $sum = $max_sum = 0; foreach ($questions['ques'] as $key => $question) { // Grab all the Questions if (isset($question) && $question) { $type = get_post_meta($question, 'vibe_question_type', true); $auto_evaluate_question_types = vibe_get_option('auto_eval_question_type'); if (isset($auto_evaluate_question_types) && is_Array($auto_evaluate_question_types) && count($auto_evaluate_question_types)) { // Validated } else { $auto_evaluate_question_types = array('single'); } if (isset($type) && in_array($type, $auto_evaluate_question_types)) { $correct_answer = get_post_meta($question, 'vibe_question_answer', true); $comments_query = new WP_Comment_Query(); $comments = $comments_query->query(array('post_id' => $question, 'user_id' => $user_id, 'number' => 1, 'status' => 'approve')); foreach ($comments as $comment) { $comment->comment_content = trim($comment->comment_content, ','); if ($comment->comment_content == $correct_answer) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; } else { if ($type == 'multiple') { if (!strlen($comment->comment_content)) { $marks = 0; } else { $marked_answers = explode(',', $comment->comment_content); if (!is_array($marks_answers)) { // Force Array Form $marks_answers = array($marks_answers); } $correct_answers = explode(',', $correct_answer); if (!is_array($correct_answers)) { // Force Array Form $correct_answers = array($correct_answers); } sort($marked_answers); sort($correct_answers); if (array_diff($marked_answers, $correct_answers) == array_diff($correct_answers, $marked_answers)) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; } else { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $comment->comment_content, $question); } } } elseif ($type == 'smalltext' || $type == 'fillblank') { if (strpos($correct_answer, ',')) { $correct_answers_array = explode(',', $correct_answer); foreach ($correct_answers_array as $c_answer) { if (strtolower($c_answer) == strtolower($comment->comment_content)) { $marks = $questions['marks'][$key]; $total_marks = $total_marks + $marks; break; } } } } else { $marks = apply_filters('wplms_incorrect_quiz_answer', 0, $comment->comment_content, $question); } } update_comment_meta($comment->comment_ID, 'marks', $marks); } //END-For } } } if (update_post_meta($quiz_id, $user_id, $total_marks)) { $message = __('You\'ve obtained ', 'vibe') . $total_marks . __(' out of ', 'vibe') . array_sum($questions['marks']) . __(' in quiz ', 'vibe') . ' <a href="' . get_permalink($quiz_id) . '">' . get_the_title($quiz_id) . '</a>'; $sender_id = get_post_field('post_author', $quiz_id); if (!is_numeric($sender_id)) { $sender_id = get_current_user_id(); } if (function_exists('messages_new_message')) { messages_new_message(array('sender_id' => $sender_id, 'subject' => __('Quiz results available', 'vibe'), 'content' => $message, 'recipients' => $user_id)); } $max_marks = array_sum($questions['marks']); $activity_id = bp_course_record_activity(array('action' => __('Quiz Auto Evaluated', 'vibe'), 'content' => __('Quiz ', 'vibe') . get_the_title($quiz_id) . __(' auto evaluated for student ', 'vibe') . bp_core_get_userlink($user_id) . __(' with marks ', 'vibe') . ' = ' . $total_marks . __('/', 'vibe') . $max_marks, 'type' => 'evaluate_quiz', 'primary_link' => get_permalink($quiz_id), 'item_id' => $quiz_id, 'secondary_item_id' => $user_id)); bp_course_record_activity_meta(array('id' => $activity_id, 'meta_key' => 'instructor', 'meta_value' => get_post_field('post_author', $quiz_id))); do_action('badgeos_wplms_evaluate_quiz', $quiz_id, $total_marks, $user_id); } } } else { // End Auto evaluate and Send notification to instructor if (function_exists('messages_new_message')) { $instructor_id = get_post_field('post_author', $quiz_id); $course_id = get_post_meta($quiz_id, 'vibe_course', true); if (isset($course_id) && is_numeric($course_id)) { $quiz_link = '<a href="' . get_permalink($course_id) . '?action=admin&submissions">' . get_the_title($quiz_id) . '</a>'; } else { $quiz_link = get_the_title($quiz_id); } $message = sprintf(__('Quiz %s submitted by student %s for evaluation', 'vibe'), $quiz_link, bp_core_get_userlink($user_id)); messages_new_message(array('sender_id' => $user_id, 'subject' => __('Quiz submitted for evaluation', 'vibe'), 'content' => $message, 'recipients' => $instructor_id)); } } }
function sf_extend_comment_edit_metafields($comment_id) { if (!isset($_POST['extend_comment_update']) || !wp_verify_nonce($_POST['extend_comment_update'], 'extend_comment_update')) { return; } if (isset($_POST['title']) && $_POST['title'] != '') { $title = wp_filter_nohtml_kses($_POST['title']); update_comment_meta($comment_id, 'title', $title); } else { delete_comment_meta($comment_id, 'title'); } }
function duplication_edit_comment($comment_id) { global $wpdb; $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID=%d", $comment_id), ARRAY_A); unset($comment['comment_ID'], $comment['comment_post_ID']); $comment_meta = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM {$wpdb->commentmeta} WHERE comment_id=%d AND meta_key <> '_icl_duplicate_of'", $comment_id)); $original_comment = get_comment_meta($comment_id, '_icl_duplicate_of', true); if ($original_comment) { $duplicates = $wpdb->get_col($wpdb->prepare("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key='_icl_duplicate_of' AND meta_value=%d", $original_comment)); $duplicates = array($original_comment) + array_diff($duplicates, array($comment_id)); } else { $duplicates = $wpdb->get_col($wpdb->prepare("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key='_icl_duplicate_of' AND meta_value=%d", $comment_id)); } if (!empty($duplicates)) { foreach ($duplicates as $dup) { $wpdb->update($wpdb->comments, $comment, array('comment_ID' => $dup)); $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->commentmeta} WHERE comment_id=%d AND meta_key <> '_icl_duplicate_of'", $dup)); if ($comment_meta) { foreach ($comment_meta as $key => $value) { update_comment_meta($dup, $key, $value); } } } } }
function akismet_recheck_queue() { global $wpdb, $akismet_api_host, $akismet_api_port; if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) { return; } $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'", ARRAY_A); foreach ((array) $moderation as $c) { $c['user_ip'] = $c['comment_author_IP']; $c['user_agent'] = $c['comment_agent']; $c['referrer'] = ''; $c['blog'] = get_option('home'); $c['blog_lang'] = get_locale(); $c['blog_charset'] = get_option('blog_charset'); $c['permalink'] = get_permalink($c['comment_post_ID']); $c['user_role'] = ''; if (isset($c['user_ID'])) { $c['user_role'] = akismet_get_user_roles($c['user_ID']); } $id = (int) $c['comment_ID']; $query_string = ''; foreach ($c as $key => $data) { $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&'; } $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); if ('true' == $response[1]) { wp_set_comment_status($c['comment_ID'], 'spam'); update_comment_meta($c['comment_ID'], 'akismet_result', 'true'); akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam'); } elseif ('false' == $response[1]) { update_comment_meta($c['comment_ID'], 'akismet_result', 'false'); akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham'); // abnormal result: error } else { update_comment_meta($c['comment_ID'], 'akismet_result', 'error'); akismet_update_comment_history($c['comment_ID'], sprintf(__('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error'); } } wp_redirect($_SERVER['HTTP_REFERER']); exit; }
/** * Public action 'comment_post' - Store cleantalk hash in comment meta 'ct_hash' * @param int $comment_id Comment ID * @param mixed $comment_status Approval status ("spam", or 0/1), not used */ function ct_set_meta($comment_id, $comment_status) { global $comment_post_id; $hash1 = ct_hash(); if (!empty($hash1)) { update_comment_meta($comment_id, 'ct_hash', $hash1); if (function_exists('base64_encode') && isset($comment_status) && $comment_status != 'spam') { $post_url = ct_post_url($comment_id, $comment_post_id); $post_url = base64_encode($post_url); if ($post_url === false) { return false; } // 01 - URL to approved comment $feedback_request = $hash1 . ':' . '01' . ':' . $post_url . ';'; ct_send_feedback($feedback_request); } } return true; }
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"); } } } } } }