function lhg_sanity_ratings() { global $lang; global $lhg_price_db; #write for com pages only if ($lang != "de") { $sql = "SELECT postid_com FROM `lhgtransverse_posts` WHERE `status_com` != 'draft'"; $results = $lhg_price_db->get_results($sql); foreach ($results as $result) { if ($result->postid_com != 0) { # store ratings of ".com" articles # # $pid = intval($result->postid_com); $post_ratings_users = get_post_meta($result->postid_com, 'ratings_users'); $post_ratings_score = get_post_meta($result->postid_com, 'ratings_score'); $post_ratings_average = get_post_meta($result->postid_com, 'ratings_average'); # ignore empty ratings if ($post_ratings_users[0] != 0 && $post_ratings_users[0] != "") { print "Post ID " . $result->postid_com . " -> " . $post_ratings_users[0] . ", " . $post_ratings_score[0] . ", " . $post_ratings_average[0] . " -- "; lhg_store_ratings($pid, $post_ratings_users[0], $post_ratings_score[0], $post_ratings_average[0]); } # store comments of ".com" articles lhg_store_comment_numbers_by_post_id($pid); } } } if ($lang == "de") { $sql = "SELECT postid_de FROM `lhgtransverse_posts` WHERE `status_com` != 'draft'"; $results = $lhg_price_db->get_results($sql); foreach ($results as $result) { if ($result->postid_de != 0) { # store ratings of ".de" articles # # $pid = intval($result->postid_de); $post_ratings_users = get_post_meta($result->postid_de, 'ratings_users'); $post_ratings_score = get_post_meta($result->postid_de, 'ratings_score'); $post_ratings_average = get_post_meta($result->postid_de, 'ratings_average'); # ignore empty ratings if ($post_ratings_users[0] != 0 && $post_ratings_users[0] != "") { print "Post ID " . $result->postid_de . " -> " . $post_ratings_users[0] . ", " . $post_ratings_score[0] . ", " . $post_ratings_average[0] . "<br>"; lhg_store_ratings($pid, $post_ratings_users[0], $post_ratings_score[0], $post_ratings_average[0]); } # store comments of ".de" articles lhg_store_comment_numbers_by_post_id($pid); } } } }
function lhg_store_comment_numbers($comment_id, $comment_approved) { if ($comment_approved === 1) { $comment = get_comment($comment_id); $post_id = $comment->comment_post_ID; lhg_store_comment_numbers_by_post_id($post_id); #error_log("Comment: $post_id "); } }