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); }
/** * Returns the reply position. The reply position is stored as the `menu_order` post field. The position * indicates where the reply is in reference to the other replies for a topic. It's used for keeping * them in the correct order. * * @since 1.0.0 * @access public * @param int $reply_id * @return void */ function mb_get_reply_position($reply_id = 0) { $reply_id = mb_get_reply_id($reply_id); $reply_position = get_post_field('menu_order', $reply_id); /* If there's no reply position, we need to reset the positions for the topic's replies. */ if (0 >= $reply_position) { $topic_id = mb_get_reply_topic_id($reply_id); mb_reset_reply_positions($topic_id); $reply_position = get_post_field('menu_order', $reply_id); } return apply_filters('mb_get_reply_position', absint($reply_position), $reply_id); }