bbp_update_forum_last_topic_id (intforum_id美元,inttopic_id美元)
更新论坛最后一个主题号
描述
参数
- forum_id美元
-
(int)(可选)论坛id
- topic_id美元
-
(int)(可选)主题id
返回
(保龄球)成功时真,失败时假
源
函数bbp_update_forum_last_topic_id($forum_id = 0, $topic_id = 0) {$forum_id = bbp_get_forum_id($forum_id);//定义局部变量$children_last_topic = 0;//做一些计算如果不手动设置if(空($topic_id)){//循环通过儿童和添加在一起的论坛回复计数$children = bbp_forum_query_subforum_ids($forum_id);If (!empty($children)) {foreach ((array) $children作为$child) {$children_last_topic = bbp_update_forum_last_topic_id($child);//递归}}//设置最近的主题查询vars $post_vars = array('post_parent' => $forum_id, 'post_type' => bbp_get_topic_post_type(), 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'numberposts' => 1);$recent_topic = get_posts($post_vars);if (!empty($recent_topic)) {$topic_id = $recent_topic[0]->ID;}} // Cast as integer in case of empty or string $topic_id = (int) $topic_id;$children_last_topic = (int) $children_last_topic;//如果子论坛有更高的id,使用If (!empty($children) && ($children_last_topic > $topic_id)) $topic_id = $children_last_topic; // Update the last public topic ID if ( bbp_is_topic_published( $topic_id ) ) update_post_meta( $forum_id, '_bbp_last_topic_id', $topic_id ); return (int) apply_filters( 'bbp_update_forum_last_topic_id', $topic_id, $forum_id ); }
更新日志
版本 | 描述 |
---|---|
bbPress (r2625) | 介绍了。 |