function mb_reset_reply_data($post, $reset_latest = false) { $post = is_object($post) ? $post : get_post($post); $topic_id = $post->post_parent; $forum_id = mb_get_topic_forum_id($topic_id); $topic_last_reply = mb_get_topic_last_reply_id($topic_id); $forum_last_reply = mb_get_forum_last_reply_id($forum_id); /* Reset topic reply count. */ mb_reset_topic_reply_count($topic_id); /* Reset topic voices. */ mb_reset_topic_voices($topic_id); /* Reset reply positions. */ mb_reset_reply_positions($topic_id); /* Reset forum reply count. */ mb_reset_forum_reply_count($forum_id); /* If this is the last topic reply, reset topic latest data. */ if ($post->ID === absint($topic_last_reply) || true === $reset_latest) { mb_reset_topic_latest($topic_id); } /* If this is the last reply, reset forum latest data. */ if ($post->ID === absint($forum_last_reply) || true === $reset_latest) { mb_reset_forum_latest($forum_id); } /* Reset user topic count. */ mb_set_user_reply_count($post->post_author); }
function mb_topic_post_updated($post_id, $post_after, $post_before) { /* Bail if this is not the topic post type. */ if (mb_get_topic_post_type() !== $post_after->post_type) { return; } /* If the topic parent (forum) has changed. */ if ($post_after->post_parent !== $post_before->post_parent) { /* Reset forum topic count. */ mb_reset_forum_topic_count($post_after->post_parent); mb_reset_forum_topic_count($post_before->post_parent); /* Reset forum reply count. */ mb_reset_forum_reply_count($post_after->post_parent); mb_reset_forum_reply_count($post_before->post_parent); /* Reset forum latest data. */ mb_reset_forum_latest($post_after->post_parent); mb_reset_forum_latest($post_before->post_parent); } }
/** * Resets a specific forum's data. * * @since 1.0.0 * @access public * @param object|int $post * @return void */ function mb_reset_forum_data($post) { /* Get the forum ID. */ $forum_id = is_object($post) ? mb_get_forum_id(get_post($post)->ID) : mb_get_forum_id($post); /* Reset subforum count. */ mb_reset_forum_subforum_count($forum_id); /* Reset forum topic count. */ mb_reset_forum_topic_count($forum_id); /* Reset forum reply count. */ mb_reset_forum_reply_count($forum_id); /* Reset forum latest. */ mb_reset_forum_latest($forum_id); }