开始修改主要 bbPress 模板

开始修改主要 bbPress 模板

此页面的目标受众是基本熟悉编辑 WordPress 主题模板的人。

如果您只是选择 bbPress 并且想要对正在呈现的模板进行一些基本更改,例如删除 WordPress 评论代码或任何仅应在博客文章中显示的帖子元,那么请按照本指南进行操作。

在 bbPress 的普通安装中,该插件会从您当前活动的 WordPress 主题中查找以下模板,并将论坛 “注入” 到它找到的第一个模板中。

它将找到具有下面列出的名称的任何页面模板。

  • plugin-bbpress.php
  • bbpress.php
  • forums.php
  • forum.php
  • generic.php
  • page.php
  • single.php
  • singular.php
  • index.php

对于 WordPress 主题,最常见的是将论坛代码注入 page.php 文件。要找到确切的文件,请安装插件 What The File 并转到您网站的 bbPress 论坛部分并检查您的 WordPress 工具栏,看看要修改的确切文件是什么。

然后您可以复制您找到的文件并将其重命名为上面列出的任何文件名,并确保它位于您的主题根目录中。

wp-content/themes/%mytheme%/bbpress.php 其中 %mytheme% 是您当前活动主题的名称。

建议使用子主题,以免在下次更新主题时丢失任何更改。

毕竟,您可以自定义新的 bbpress.php 文件以删除任何不需要的代码/设计您的 bbPress 论坛,bbPress 插件应该选择该模板并使用该自定义模板呈现其所有页面。

示例模板

不要只是将此代码复制并粘贴到空白模板中。所有的主题都不一样。将其用作指南。

请阅读代码中的注释。

<?php
 
/*
*
* The template for displaying all bbPress pages
*
* This is the template that displays all bbPress pages by default.
* Please note that this is the template of all bbPress pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package WordPress
* @subpackage Theme
*/
 
 
/*
Self explanatory its a functions that gets your header template.
*/
 
get_header(); ?>
 
 
<?php
/*
Surrounding Classes for the site
 
These are different every theme and help with structure and layout
 
These could be SPANs or DIVs and with entirely different classes.
*/
?>
 
<div id="primary" class="site-content">
 
<div id="content" role="main">
 
 
<?php
/*
Start the Loop
*/
?>
 
<?php while ( have_posts() ) : the_post(); ?>
 
 
<?php
/*
This is the start of the page and also the insertion of the post classes.
 
Post classes are very handy to style your forums.
*/
?>
 
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 
 
<?php
/*
This is the title wrapped in a header tag
 
and a class to better style the title for your theme
*/
?>
 
<header class="entry-header">
 
<h1 class="entry-title"><?php the_title(); ?></h1>
 
</header>
 
 
<?php
/*
This is the content wrapped in a div
 
and class to better style the content
*/
?>
 
<div class="entry-content">
<?php the_content(); ?>
</div>
 
<!-- .entry-content -->
 
 
<?php
/*
End of Page
*/
?>
 
</article>
 
<!-- #post -->
<?php endwhile; // end of the loop. ?>
 
</div>
 
<!-- #content -->
 
</div>
 
<!-- #primary -->
 
 
<?php
/*
This is code to display the sidebar and the footer.
 
Remove the sidebar code to get full-width forums.
 
This would also need CSS to make it actually full width.
*/
?>
 
<?php get_sidebar(); ?>
<?php get_footer(); ?>

为 bbPress 论坛呈现自定义模板代码的另一种方法是在 PHP if 语句中使用条件标记,例如 is_bbpress() 。

这是一个例子。

<?php if ( is_bbpress() ) : ?>
 
<div class="abc">
 
This content should show if it is bbPress
 
    </div>
 
<?php else : ?>
 
<div class="xyz">
 
This should show if it is not bbPress
 
    </div>
 
<?php endif; ?>

GSoC2013

GSoC2013

GSoC2013
Codex Home → GSoC2013
Table of contents

Introduction
Timeline
Ideas
Mentors

Introduction
bbPress is a fully-integrated forum plugin for the popular WordPress web software. It provides forum functionality for over a few hundred thousand WordPress sites, and is most popular for powering the WordPress.com and WordPress.org support sections.
Google Summer of Code is a program in which Google sponsors exceptional college students to develop open source code under the guidance of mentoring open source projects. This year, bbPress is hoping to be a mentoring organisation.
If you know you want to propose a GSoC project around bbPress, but aren’t sure what you want to do, check out our Ideas list below. If you have your own idea for a project, include it in your application and describe it thoroughly. You are not limited to ideas from this list.
Timeline

March 18, 19:00 UTC: Mentoring organizations can begin submitting applications to Google.
March 29, 19:00 UTC: Mentoring organization application deadline.
April 1 – 5: Google program administrators review organization applications.
April 8 19:00 UTC: List of accepted mentoring organizations published on the Google Summer of Code 2013 site.
April 9 – 21: Would-be student participants discuss application ideas with mentoring organizations.
April 22, 19:00 UTC: Student application period opens.
May 3, 19:00 UTC: Student application deadline.

Ideas
Quick Edit forums and topics on dashboard
https://bbpress.trac.wordpress.org/ticket/1394
Provide Quick Edit functionality for forums and topics.
Admin Bar Support
https://bbpress.trac.wordpress.org/ticket/1439
Add admin bar UI and improve code for marking a user as Spam.
Akismet admin UI
https://bbpress.trac.wordpress.org/ticket/1616
Finishing up the API for and building the bbPress/Akismet admin UI to display the spam history and Akismet results.
Bulk actions for forums
https://bbpress.trac.wordpress.org/ticket/1723
Provide Bulk Actions for forums, such as marking topics as closed/spam/etc.
Moderator control panels
https://bbpress.trac.wordpress.org/ticket/1721
Create a `/moderate` section for moderators to use without needing to visit the `wp-admin` area.
Direct login and register links to bbpress login or register page templates
https://bbpress.trac.wordpress.org/ticket/1756
Create direct login and register pages, and/or a sidebar Widget, for bbPress users to avoid sending them to `wp-login.php`.
Very long load times when posting replies if topic has many subscribers
https://bbpress.trac.wordpress.org/ticket/2162
Create a mail queue on `wp_cron` to avoid long loads when a new reply is posted to a topic with many subscribers.
Auto refreshing new replies
https://bbpress.trac.wordpress.org/ticket/1907
AJAX all of the things!
User signatures/sigfiles
(No ticket yet.)
Mentors

John James Jacoby, jjj
bbPress Lead Developer. Interested in projects around BuddyPress and bbPress.

Jennifer M. Dodd, jmdodd
bbPress Core Contributor. Interested in improving moderator experience and capabilities and adding popular user-requested functionality.

Daniel Dvorkin, MZAWeb
bbPress Contributor. Interested mostly in performance, AJAXifing all the things and security, but always open to fun challenges.

启用可视化编辑器

启用可视化编辑器

在 bbPress 2.3.1 中,WordPress 的可视化编辑器默认为关闭。要重新打开它,请在插件或主题的 functions.php 文件中尝试以下代码片段:

function bbp_enable_visual_editor( $args = array() ) {
    $args['tinymce'] = true;
    return $args;
}
add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

您还可以通过在函数中添加更多参数来自定义可视化编辑器。

使用下面的此功能仅显示可视化编辑器,而根本不显示 html 编辑器。

function bbp_enable_visual_editor( $args = array() ) {
    $args['tinymce'] = true;
    $args['quicktags'] = false;
    return $args;
}
add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

如果您使用像 TinyMCE Advanced 这样的插件,您还可以显示其他媒体按钮,如表情按钮以插入表情。

使用下面的这个函数代替添加新的参数,以便能够添加新的媒体,如表情按钮。

function bbp_enable_visual_editor( $args = array() ) {
    $args['tinymce'] = true;
    $args['teeny'] = false;
    return $args;
}
add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );

请注意,如果您在可视化编辑器中禁用 teeny 模式并通过 TinyMCE Advanced 插件允许其他媒体按钮,您可能需要添加到此功能并将其放入您的子主题 functions.php 文件中,以允许您的用户使用一些按钮,如表格按钮。

在某些情况下,粘贴到可视化编辑器中的文本会带来不需要的样式和 HTML 标记。您可以使用另一个函数来强制清除粘贴的文本。这将删除诸如杂散 HTML 之类的内容,但保留粗体和斜体等基础知识。

function bbp_tinymce_paste_plain_text( $plugins = array() ) {
    $plugins[] = 'paste';
    return $plugins;
}
add_filter( 'bbp_get_tiny_mce_plugins', 'bbp_tinymce_paste_plain_text' );

 

Drupal

Drupal

Drupal
Codex Home → Getting Started → Importing Data → Import Forums → Drupal
Drupal v7.22 Importer for bbPress
Note: This current implementation is for the Drupal ‘Out of the Box’ forums, if you are looking to convert ‘Drupal Advanced Forums’ or ‘Artesian Forum’ for Drupal create a ticket on Trac and we will see how we go.
FAQ & Known Issues
Forums

Forum ‘Categories’ are imported as a ‘Forum’ – You must manually configure the forum types for ‘category’ forum type after the import and recounts have finished.

Topics & Replies

Sticky topics ‘topic status’ are not set during import, manually ‘stick’ any topics after import and recounts are complete. (See trac ticket #2126)

Users

User passwords are NOT converted when importing existing Drupal users, during the import you will see the following error which can be ignored though your users will have to reset their passwords manually with WordPress or request a password reset. Please see Trac Ticket #2375 for more details.

Notice: Undefined variable: user_pass in /home/ntwb/public_html/dev.ntwb.co/wp-includes/user.php on line 1297

Any custom Drupal roles are not converted, any users you wish to make ‘moderators’ or ‘keymasters’ you will have to assign these roles manually via the main WordPress Admin User panel (/wp-admin/users.php).
Users who have been disabled are now imported, if the user content was “unpublished” these are now imported to bbPress with status “pending” and need to be “approved”, if the user was disabled and the user content kept, the user topics and replies will be published with the user ID set to Anoyomous, this mimics Drupal’s existing behaviour for handing disabled and deleted users and content.

References
Original Importer and discussion by @vogelsang https://bbpress.org/forums/topic/importing-from-drupal/
Drupal v8 Importer for bbPress
Drupal v8 is now in ‘alpha’ and will be supported once the final v8 is released.