bbp_template_include_theme_compat (字符串美元的模板''

重置主查询变量并过滤' the_content '以根据需要输出论坛模板部分。

描述

参数

美元的模板

字符串(可选)

默认值:“

文件:bp-forums /核心/ theme-compat.php

函数bbp_template_include_theme_compat($template=''){/***如果已找到根模板,则将其删除。这可防止意外*递归筛选“内容”。***链接http://bbpress.trac.wordpress.org/ticket/2429 */如果(bbp_是_template_included()){return$template;}/***如果BuddyBoss在网络级别被激活,那么操作顺序将被*颠倒,这将导致模板集成失败。如果我们在这里查看*BuddyBoss页面,请避免额外处理。**这可能比必要的更为粗暴,但在我们朝着更优雅的方向努力的同时完成*工作*/if(function_exists('is_buddypress')&&is_buddypress())返回$template;//定义局部变量$bbp_shortcodes=bbpress()->shortcodes;//如果以某种方式取消了短码,如果(!is_a($bbp_shortcodes,'bbp_shortcodes'))返回$template;/**用户*********************************************************************************************************************************************************************************************************************************************************************************************************************(bbp_is_single_user_edit()| bbp_is_single_user()){//Reset post bbp_theme_compat_Reset_post(数组('ID'=>0,'post_author'=>0,'post_date'=>0,'post_content'=>bbp_buffer_模板部分('content','single user',false),'post_type'=>0,'post_title'=>bbp获得显示的用户字段('display_name')),“post_status”=>bbp_get_public_status_id(),“is_archive”=>false,“comment_status”=>“closed”);/**论坛***************************************************************************************************///论坛存档}elseif(bbp_是论坛存档())//页面存在,该存档应为$Page=u Page=u根路径的位置(//;//我们应该替换内容吗……如果(空($page->post_content)){//使用主题存档如果('topics'==bbp_show_on_root()){$new_content=$bbp_show_短代码-$bbp_短代码-$display_topic_index();//没有页面所以显示存档}否则{$new content=$bbp_短代码->display_forum_index()}//……或者使用现有的页面内容}否则}{$new_content=apply_filters('the_content',$page->post_content)}//我们是否应该替换标题…如果(空($page->post_title)){//使用主题存档如果('topics'==bbp_show_on_root()){$new_title=bbp_get_topic_archive_title()//没有页面所以显示存档}否则{$new title=bbp_get_论坛_存档}title}//…或使用现有页面标题?}其他{$new_title=apply_filters('the_title',$page->post_title)}//Reset post bbp_主题\u compat\u Reset_post(数组('ID'=>!empty($page->ID)}$page->ID:0,'post_title'=>new title,'post_author'=>0,'post_date=>0,'post_content'=>0,'post_content'=>$new content,'post_-type'=>bbp-get-forum\u-post(),post_status'=>bbp_get_public_status_id(),'is_archive'=>true,'comment_status'=>'closed');//单个论坛}其他(bbp_is_Forum_edit()){//重置帖子bbp_主题}重置帖子(数组('id'=>bbp_get_论坛id(),'post_title'=>bbp_get论坛标题(),'post作者'>bbp论坛作者})“发布日期”=>0,“发布内容”=>bbp\u短码->显示论坛表单(),“发布类型”=>bbp\u获取论坛帖子类型(),“发布状态”=>bbp\u获取论坛帖子可见性(),“是单一的”=>true,“评论状态”=>closed”);}elseif(bbp\u是单一的论坛(),//重置帖子bbp\u主题”=>bbp获取论坛帖子可见性(),“是单一的”=>“post_title”=>bbp_get_forum_title(),“post_author”=>bbp_get_forum_author_id(),“post_date”=>0,“post_content”=>bbp_快捷码->显示论坛(数组('id'=>bbp_get_forum_id()),“post_type”=>bbp_get_forum_post_type(),“post_状态”=>bbp_get_论坛”=>,“评论状态是否真实关闭”)**主题*********************************************************************************////主题存档}其他内容(bbp_是主题存档()){//此存档应为$Page=bbp_get_Page->by_路径(bbp_get_Topic_archive_slug())的页面存在///如果(空($Page content)){$new_content=$bbp_shortcode->display_topic_index();/…或使用现有页面内容?}否则{$new_content=apply_filters('the_content',$page->post_content);}//我们是否应该替换标题…如果(空($page->post_title)){$new title=bbp_get_topic u archive_title()/…或使用现有页面标题?}其他{$new_title=apply_filters('the_title',$page->post_title);}//Reset post bbp_主题\u compat_Reset_post(数组('ID'=>!empty($page->ID)?$page->ID:0,'post_title'=>bbp_get_topic归档_title(),'post_author'=>0,'post_date=>0,'post_content'=>post_content'>$new content,'post_type'=>bbp_get_主题(),“post_status”=>bbp_get_public_status_id(),“is_archive”=>true,“comment_status”=>“closed”);//单个主题}其他内容(bbp_是主题_edit()| bbp_是单一主题()){//如果(bbp_是主题_Split()){$new_内容=bbp_缓冲区_模板}部分('form','Topic Split false',false)//合并}其他内容(bbp_是主题}{$new_content=bbp_buffer_template_part('form','topic merge',false);//编辑}seif ( bbp_is_topic_edit() ) { $new_content = $bbp_shortcodes->display_topic_form(); // Single } else { $new_content = $bbp_shortcodes->display_topic( array( 'id' => bbp_get_topic_id() ) ); } // Reset post bbp_theme_compat_reset_post( array( 'ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed' ) ); /** Replies ***********************************************************/ // Reply archive } elseif ( is_post_type_archive( bbp_get_reply_post_type() ) ) { // Reset post bbp_theme_compat_reset_post( array( 'ID' => 0, 'post_title' => __( 'Replies', 'buddyboss' ), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_reply_index(), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed' ) ); // Single Reply } elseif ( bbp_is_reply_edit() || bbp_is_single_reply() ) { // Move if ( bbp_is_reply_move() ) { $new_content = bbp_buffer_template_part( 'form', 'reply-move', false ); // Edit } elseif ( bbp_is_reply_edit() ) { $new_content = $bbp_shortcodes->display_reply_form(); // Single } else { $new_content = $bbp_shortcodes->display_reply( array( 'id' => get_the_ID() ) ); } // Reset post bbp_theme_compat_reset_post( array( 'ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed' ) ); /** Views *************************************************************/ } elseif ( bbp_is_single_view() ) { // Reset post bbp_theme_compat_reset_post( array( 'ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_view( array( 'id' => get_query_var( bbp_get_view_rewrite_id() ) ) ), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed' ) ); /** Search ************************************************************/ } elseif ( bbp_is_search() ) { // Reset post bbp_theme_compat_reset_post( array( 'ID' => 0, 'post_title' => bbp_get_search_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_search( array( 'search' => get_query_var( bbp_get_search_rewrite_id() ) ) ), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed' ) ); /** Topic Tags ********************************************************/ // Topic Tag Edit } elseif ( bbp_is_topic_tag_edit() || bbp_is_topic_tag() ) { // Stash the current term in a new var set_query_var( 'bbp_topic_tag', get_query_var( 'term' ) ); // Show topics of tag if ( bbp_is_topic_tag() ) { $new_content = $bbp_shortcodes->display_topics_of_tag( array( 'id' => bbp_get_topic_tag_id() ) ); // Edit topic tag } elseif ( bbp_is_topic_tag_edit() ) { $new_content = $bbp_shortcodes->display_topic_tag_form(); } // Reset the post with our new title bbp_theme_compat_reset_post( array( 'ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => '', 'post_title' => sprintf( __( 'Discussion Tag: %s', 'buddyboss' ), '' . bbp_get_topic_tag_name() . '' ), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed' ) ); } /** * Bail if the template already matches a Forums template. This includes * archive-* and single-* WordPress post_type matches (allowing * themes to use the expected format) as well as all Forums-specific * template files for users, topics, forums, etc... * * We do this after the above checks to prevent incorrect 404 body classes * and header statuses, as well as to set the post global as needed. * * @see http://bbpress.trac.wordpress.org/ticket/1478/ */ if ( bbp_is_template_included() ) { return $template; /** * If we are relying on Forums' built in theme compatibility to load * the proper content, we need to intercept the_content, replace the * output, and display ours instead. * * To do this, we first remove all filters from 'the_content' and hook * our own function into it, which runs a series of checks to determine * the context, and then uses the built in shortcodes to output the * correct results from inside an output buffer. * * Uses bbp_get_theme_compat_templates() to provide fall-backs that * should be coded without superfluous mark-up and logic (prev/next * navigation, comments, date/time, etc...) * * Hook into the 'bbp_get_bbpress_template' to override the array of * possible templates, or 'bbp_bbpress_template' to override the result. */ } elseif ( bbp_is_theme_compat_active() ) { bbp_remove_all_filters( 'the_content' ); $template = bbp_get_theme_compat_templates(); } return apply_filters( 'bbp_template_include_theme_compat', $template ); }

更新日志

更新日志
版本 描述
bbPress (r3032) 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队