function wp_cache_get_postid_from_comment($comment_id, $status = 'NA') { global $super_cache_enabled, $wp_cache_request_uri; $comment = get_comment($comment_id, ARRAY_A); if ($status != 'NA') { $comment['old_comment_approved'] = $comment['comment_approved']; $comment['comment_approved'] = $status; } $postid = $comment['comment_post_ID']; // Do nothing if comment is not moderated // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world if (!preg_match('/wp-admin\\//', $wp_cache_request_uri)) { if ($comment['comment_approved'] == 'delete' && (isset($comment['old_comment_approved']) && $comment['old_comment_approved'] == 0)) { // do nothing if moderated comments are deleted if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Moderated comment deleted. Don't delete any cache files.", 4); } return $postid; } elseif ($comment['comment_approved'] == 'spam') { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Spam comment. Don't delete any cache files.", 4); } return $postid; } elseif ($comment['comment_approved'] == '0') { if ($comment['content_type'] == '') { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Moderated comment. Don't delete supercache file until comment approved.", 4); } $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved } else { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Moderated ping or trackback. Not deleting cache files..", 4); } return $postid; } } } // We must check it up again due to WP bugs calling two different actions // for delete, for example both wp_set_comment_status and delete_comment // are called when deleting a comment if ($postid > 0) { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Post {$postid} changed. Update cache.", 4); } return wp_cache_post_change($postid); } else { if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) { wp_cache_debug("Unknown post changed. Update cache.", 4); } return wp_cache_post_change(wp_cache_post_id()); } }
function wp_cache_get_postid_from_comment($comment_id) { $comment = get_commentdata($comment_id, 1, true); $postid = $comment['comment_post_ID']; // We must check it up again due to WP bugs calling two different actions // for delete, for example both wp_set_comment_status and delete_comment // are called whene deleting a comment if ($postid > 0) { return wp_cache_post_change($postid); } else { return wp_cache_post_change(wp_cache_post_id()); } }
function wp_cache_get_postid_from_comment($comment_id) { global $super_cache_enabled; $comment = get_comment($comment_id, ARRAY_A); $postid = $comment['comment_post_ID']; // Do nothing if comment is not moderated // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world if (!preg_match('/wp-admin\\//', $_SERVER['REQUEST_URI'])) { if ($comment['comment_approved'] == 'spam') { // changed from 1 to "spam" return $postid; } elseif ($comment['comment_approved'] == '0') { $super_cache_enabled = 0; // don't remove the super cache static file until comment is approved } } // We must check it up again due to WP bugs calling two different actions // for delete, for example both wp_set_comment_status and delete_comment // are called when deleting a comment if ($postid > 0) { return wp_cache_post_change($postid); } else { return wp_cache_post_change(wp_cache_post_id()); } }
function wp_cache_get_postid_from_comment($comment_id) { $comment = get_commentdata($comment_id, 1, true); $postid = $comment['comment_post_ID']; // Do nothing if comment is not moderated // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world if (!preg_match('/wp-admin\\//', $_SERVER['REQUEST_URI']) && $comment['comment_approved'] != 1) { return $post_id; } // We must check it up again due to WP bugs calling two different actions // for delete, for example both wp_set_comment_status and delete_comment // are called when deleting a comment if ($postid > 0) { return wp_cache_post_change($postid); } else { return wp_cache_post_change(wp_cache_post_id()); } }