Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MMB
File: Comment.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*************************************************************
[2] Fix | Delete
* comment.class.php
[3] Fix | Delete
* Get comments
[4] Fix | Delete
* Copyright (c) 2011 Prelovac Media
[5] Fix | Delete
* www.prelovac.com
[6] Fix | Delete
**************************************************************/
[7] Fix | Delete
class MMB_Comment extends MMB_Core
[8] Fix | Delete
{
[9] Fix | Delete
public function get_comments($args)
[10] Fix | Delete
{
[11] Fix | Delete
/** @var wpdb $wpdb */
[12] Fix | Delete
global $wpdb;
[13] Fix | Delete
[14] Fix | Delete
$where = '';
[15] Fix | Delete
[16] Fix | Delete
extract($args);
[17] Fix | Delete
[18] Fix | Delete
if (!empty($filter_comments)) {
[19] Fix | Delete
$where .= " AND (c.comment_author LIKE '%".esc_sql($filter_comments)."%' OR c.comment_content LIKE '%".esc_sql($filter_comments)."%')";
[20] Fix | Delete
}
[21] Fix | Delete
$comment_array = array();
[22] Fix | Delete
$comment_statuses = array('approved', 'pending', 'spam', 'trash');
[23] Fix | Delete
foreach ($args as $checkbox => $checkbox_val) {
[24] Fix | Delete
if ($checkbox_val == "on") {
[25] Fix | Delete
$status_val = str_replace("mwp_get_comments_", "", $checkbox);
[26] Fix | Delete
if ($status_val == 'approved') {
[27] Fix | Delete
$status_val = 1;
[28] Fix | Delete
} elseif ($status_val == 'pending') {
[29] Fix | Delete
$status_val = 0;
[30] Fix | Delete
}
[31] Fix | Delete
$comment_array[] = "'".$status_val."'";
[32] Fix | Delete
}
[33] Fix | Delete
}
[34] Fix | Delete
if (!empty($comment_array)) {
[35] Fix | Delete
$where .= " AND c.comment_approved IN (".implode(",", $comment_array).")";
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
$sql_query = "$wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID ".$where;
[39] Fix | Delete
[40] Fix | Delete
$comments_total = $wpdb->get_results("SELECT count(*) as total_comments FROM ".$sql_query);
[41] Fix | Delete
$total = $comments_total[0]->total_comments;
[42] Fix | Delete
$comments_approved = $this->comment_total();
[43] Fix | Delete
[44] Fix | Delete
$query_comments = $wpdb->get_results("SELECT c.comment_ID, c.comment_post_ID, c.comment_author, c.comment_author_email, c.comment_author_url, c.comment_author_IP, c.comment_date, c.comment_content, c.comment_approved, c.comment_parent, p.post_title, p.post_type, p.guid FROM ".$sql_query." ORDER BY c.comment_date DESC LIMIT 500");
[45] Fix | Delete
$comments = array();
[46] Fix | Delete
foreach ($query_comments as $comments_info) {
[47] Fix | Delete
$comment_total_approved = 0;
[48] Fix | Delete
if (isset($comments_approved[$comments_info->comment_post_ID]['approved'])) {
[49] Fix | Delete
$comment_total_approved = $comments_approved[$comments_info->comment_post_ID]['approved'];
[50] Fix | Delete
}
[51] Fix | Delete
$comment_total_pending = 0;
[52] Fix | Delete
if (isset($comments_approved[$comments_info->comment_post_ID]['pending'])) {
[53] Fix | Delete
$comment_total_pending = $comments_approved[$comments_info->comment_post_ID]['pending'];
[54] Fix | Delete
}
[55] Fix | Delete
$comment_parent_author = '';
[56] Fix | Delete
if ($comments_info->comment_parent > 0) {
[57] Fix | Delete
$select_parent_author = "SELECT comment_author FROM $wpdb->comments WHERE comment_ID = ".$comments_info->comment_parent;
[58] Fix | Delete
$select_parent_author_res = $wpdb->get_row($select_parent_author);
[59] Fix | Delete
$comment_parent_author = $select_parent_author_res->comment_author;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
$comments[$comments_info->comment_ID] = array(
[63] Fix | Delete
"comment_post_ID" => $comments_info->comment_post_ID,
[64] Fix | Delete
"comment_author" => $comments_info->comment_author,
[65] Fix | Delete
"comment_author_email" => $comments_info->comment_author_email,
[66] Fix | Delete
"comment_author_url" => $comments_info->comment_author_url,
[67] Fix | Delete
"comment_author_IP" => $comments_info->comment_author_IP,
[68] Fix | Delete
"comment_date" => $comments_info->comment_date,
[69] Fix | Delete
"comment_content" => htmlspecialchars($comments_info->comment_content),
[70] Fix | Delete
"comment_approved" => $comments_info->comment_approved,
[71] Fix | Delete
"comment_parent" => $comments_info->comment_parent,
[72] Fix | Delete
"comment_parent_author" => $comment_parent_author,
[73] Fix | Delete
"post_title" => htmlspecialchars($comments_info->post_title),
[74] Fix | Delete
"post_type" => $comments_info->post_type,
[75] Fix | Delete
"guid" => $comments_info->guid,
[76] Fix | Delete
"comment_total_approved" => $comment_total_approved,
[77] Fix | Delete
"comment_total_pending" => $comment_total_pending,
[78] Fix | Delete
);
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
return array('comments' => $comments, 'total' => $total);
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
public function comment_total()
[85] Fix | Delete
{
[86] Fix | Delete
/** @var wpdb $wpdb */
[87] Fix | Delete
global $wpdb;
[88] Fix | Delete
$totals = array();
[89] Fix | Delete
$select_total_approved = "SELECT COUNT(*) as total, p.ID FROM $wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID AND c.comment_approved = 1 GROUP BY p.ID";
[90] Fix | Delete
$select_total_approved_res = $wpdb->get_results($select_total_approved);
[91] Fix | Delete
[92] Fix | Delete
if (!empty($select_total_approved_res)) {
[93] Fix | Delete
foreach ($select_total_approved_res as $row) {
[94] Fix | Delete
$totals[$row->ID]['approved'] = $row->total;
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
$select_total_pending = "SELECT COUNT(*) as total, p.ID FROM $wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID AND c.comment_approved = 0 GROUP BY p.ID";
[98] Fix | Delete
$select_total_pending_res = $wpdb->get_results($select_total_pending);
[99] Fix | Delete
if (!empty($select_total_pending_res)) {
[100] Fix | Delete
foreach ($select_total_pending_res as $row) {
[101] Fix | Delete
$totals[$row->ID]['pending'] = $row->total;
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
return $totals;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
public function bulk_action_comments($args)
[109] Fix | Delete
{
[110] Fix | Delete
$docomaction = $args['docomaction'];
[111] Fix | Delete
[112] Fix | Delete
foreach ($args as $val) {
[113] Fix | Delete
if (!empty($val) && is_numeric($val)) {
[114] Fix | Delete
if ($docomaction == 'delete') {
[115] Fix | Delete
wp_delete_comment($val, true);
[116] Fix | Delete
} elseif ($docomaction == 'unapprove' || $docomaction == 'untrash' || $docomaction == 'unspam') {
[117] Fix | Delete
wp_set_comment_status($val, 'hold');
[118] Fix | Delete
} elseif ($docomaction == 'approve') {
[119] Fix | Delete
wp_set_comment_status($val, 'approve');
[120] Fix | Delete
} elseif ($docomaction == 'spam') {
[121] Fix | Delete
wp_set_comment_status($val, 'spam');
[122] Fix | Delete
} elseif ($docomaction == 'trash') {
[123] Fix | Delete
wp_set_comment_status($val, 'trash');
[124] Fix | Delete
}
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
return "comments updated";
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function