修改 bbPress 模板

修改 bbPress 模板

bbPress 有許多模板可以改變論壇的顯示方式,您可以更改這些模板以完全改變論壇的顯示方式。

您會在以下位置找到這些模板

wp-content/plugins/bbpress/templates/default/bbpress/

論壇的索引從使用開始

content-archive-forum.php

如果您打開它,您會看到他們使用函數 bbp_get_template_part 調用了另一個模板

<?php bbp_get_template_part( 'loop', 'forums'); ?>

(這轉化為 loop-forums.php)

這反過來又叫

<?php bbp_get_template_part( 'loop', 'single-forum'); ?>

(這轉化為 loop-single-forum)

等等。

如果您需要更改 bbpress 模板,那麼您真的應該在子主題中執行此操作,否則主題升級將覆蓋它。

有關如何設置子主題的信息,請參閲

函數文件和子主題 – 解釋!

更改模板

在您的主題中創建一個 bbPress 文件夾:

wp-content/%yourthemename%/bbpress

其中 %yourthemename% 是您的主題名稱。

然後進入

wp-content/plugins/bbpress/templates/default/bbpress/

將您想要更改的任何文件複製到主題中的 bbPress 文件夾中。 bbPress 現在將使用此文件而不是默認文件,您可以修改此文件。

刪除 bbPress

刪除 bbPress

刪除 bbPress 數據

默認情況下,如果插件被停用和刪除,bbPress 不會刪除任何數據,因此如果您當前安裝的 bbPress 有問題,您可以安裝插件的乾淨版本,並且仍然像以前一樣擁有所有數據。

如果您決定不運行 bbPress 並且您已經選擇要刪除 bbPress 創建的所有先前數據,則可以運行重置論壇工具來刪除所有 bbPress 數據。

  1. 登錄您的 WordPress 後端。
  2. 轉至工具 > 論壇 > 重置論壇。
  3. 選中 「您確定要執行此操作嗎?」 複選框。
  4. 可選:您可能還想檢查刪除導入的用户?因為一旦 bbPress 被重置,刪除這些用户所需的元數據也將被刪除。
  5. 單擊重置 bbPress 。

請注意,如果您看到 「刪除轉換表... 失敗」,如果您沒有從其他論壇系統導入,看到此信息是正常的,因為在導入過程中會添加一個額外的數據庫表。

使用重置論壇工具將從您的 WordPress 數據庫中刪除所有 bbPress 數據,包括自定義文章類型、話題標籤分類法和 bbPress 用户元數據。

但是,在舊版本的 bbPress 中存在一個錯誤,即 bbPress 不會完全刪除用户角色。 (參見 #2580

因此,如果您使用的是舊版本的 bbPress,請在您的子主題 functions.php 文件中添加此功能。

$wp_roles = new WP_Roles(); $wp_roles->remove_role("bbp_keymaster"); $wp_roles->remove_role("bbp_moderator"); $wp_roles->remove_role("bbp_participant"); $wp_roles->remove_role("bbp_spectator"); $wp_roles->remove_role("bbp_blocked");

刷新您的網站,現在所有與 bbPress 相關的用户角色都已從數據庫中刪除。之後,您可以從子主題的 functions.php 文件中刪除代碼。

現在刪除所有 bbPress 數據後,您可以繼續卸載 bbPress 。

卸載 bbPress

如果您因為核心文件被修改而需要安裝新版本的 bbPress,您遇到了想要嘗試修復的嚴重問題,或者您只是不想再使用 bbPress,您可以按照以下步驟操作從您的站點卸載 bbPress 。

  1. 登錄您的 WordPress 後端。
  2. 轉到插件 > 已安裝的插件。
  3. 向下滾動,直到看到 bbPress,然後單擊停用。
  4. 頁面重新加載後,向下滾動到 bbPress 插件,現在單擊紅色的刪除鏈接。
  5. 您現在將看到一個確認刪除 bbPress 插件的屏幕,如果您確定要從安裝中刪除 bbPress,請點擊 OK 。按鈕。
  6. bbPress 現在已從您的站點中卸載。

單站點

單站點

自動插件安裝

  1. 登錄您的 WordPress 後端。
  2. 轉到 插件 > 添加插件。
  3. 您將看到特色插件的 bbPress 部分,您可以從那裏安裝,或者您可以在搜索欄中鍵入 「bbPress」 並按 Enter 鍵來搜索插件。
  4. 單擊立即安裝。
  5. 現在啓用 bbPress 插件。

手動插件安裝

使用 WordPress 的插件上傳器

  1. https://bbpress.org/download/ 或 https://wordpress.org/plugins/bbpress/下載 bbPress 插件 。
  2. 轉到 插件> 添加插件
  3. 然後單擊頂部的上傳插件按鈕。
  4. 單擊 「選擇文件」,然後選擇您下載的 bbPress zip 文件。
  5. 點擊立即安裝,現在啓用。

使用 FTP

  1. https://bbpress.org/download/ 或 https://wordpress.org/plugins/bbpress/下載 bbPress 插件 。
  2. 下載文件後,解壓,將插件文件夾解壓到桌面
  3. 您可以啓動您喜歡的 FTP 客户端,如 FileZilla
  4. 在您的計算機上找到並打開包含新插件的文件夾。
  5. 將 bbPress 文件夾從您的計算機上傳到/wp-content/plugins 。
  6. 登錄您的 WordPress 網站。
  7. 轉到 插件 > 已安裝插件。
  8. 單擊 bbPress 插件上的啓用。

詳細的模板層次結構

詳細的模板層次結構

[撰寫中…]

用户個人資料模板

single-user-[nicename].php // 單用户 nicename

single-user-[user_id].php // 單用户 ID

single-user.php // 單用户

user.php // 用户

用户資料編輯模板

single-user-edit-[nicename].php // 單用户編輯 nicename

single-user- edit- [user_id].php // 單用户編輯 ID

single-user-edit.php // 單用户編輯

user-edit. php // 用户編輯

user.php

用户收藏夾模板

single-user-favorites-[nicename].php // 單用户收藏 nicename

single-user-favorites-[user_id].php // 單用户收藏 ID

favorites-[nicename].php // 收藏夾 nicename

favorites-[user_id] .php // 收藏夾 ID

favorites.php // 收藏夾

user.php

用户訂閲模板

single-user-subscriptions-[nicename].php // 單用户

single-user-subscriptions-[user_id].php // 單用户

subscriptions-[nicename].php // 訂閲 nicename

subscriptions-[user_id] .php // 訂閲 ID

subscriptions.php // 訂閲

user.php

視圖模板

single-view-[view_id].php // 單視圖 ID

view-[view_id].php // 視圖 ID

single-view.php // 單視圖

view.php

搜索模板

page-forum-search.php // 單次搜索

forum-search.php // 搜索

單個論壇模板

single-[forum].php// 單個論壇

論壇存檔模板

archive-[forum].php // 論壇存檔

論壇編輯模板

single-[forum]-edit.php // 單個論壇編輯

單個話題模板

single-[topic].php

話題存檔模板

archive-[topic].php // 話題存檔

話題編輯模板

single-[topic]-edit.php // 單個話題編輯

話題拆分模板

single-topic-split.php // 話題拆分

話題合併模板

single-[topic]-merge.php // 話題合併

單個回覆模板

single-[reply].php

回覆編輯模板

single-[reply]-edit.php // 單個回覆編輯

回覆移動模板

single-[reply]-move.php // 回覆移動

話題標籤模板

taxonomy-[tt_slug].php // 單話題標籤 slug

taxonomy-[tt_id].php // 單話題標籤 ID

話題標籤編輯模板

taxonomy-[tt_slug]-edit.php // 單話題標籤編輯 slug

taxonomy-[tt_id]-edit.php // 單話題標籤編輯 ID

配置 bbPress

配置 bbPress

啓用後,bbPress 會將菜單項添加到 WordPress 後端菜單。這些是:

  1. bbPress 創建三種自定義文章類型並將它們添加到導航菜單:論壇、話題和回覆。使用這些菜單項來創建和管理您的論壇。
  2. 在設置 > 論壇中找到的子菜單。自定義這些設置以更好地控制 bbPress 。

這些指南將幫助您配置和設置一切。

創建內容

這將幫助您為 bbPress 站點創建論壇、話題和回覆等內容。

論壇設置

這將幫助您為論壇配置 bbPress 設置。

Custom Capabilities

Custom Capabilities

Custom Capabilities
Codex Home → Custom Capabilities
Whilst bbPress provides a good set of forum roles, with distinct capabilities, you may want to amend these or add new names.
However the latest combination of WordPress and bbPress does not work if the code to do this is in the functions.php file of the child theme (or indeed parent theme!).
If you put this code in a plugin, it seems to work fine.
If you are comfortable in changing files and FTPing them to your site, then visit bbpress role adder – Robin W』s website (rewweb.co.uk) for a plugin and template that should work
Adding new names
At the simplest levels, you can add a new role name and give it existing capabilities
This can be useful just for your own admin purposes, but also if like me you hate the 「keymaster」 role name, just create a new role and give it keymaster capabilities.
The following code creates three new roles with names 『name 1′,』name 2′ and 『name 3′ the first role has participant, the second moderator and the third keymaster.
Simply amend the code to create as many roles with whatever capabilities you need
add_action (『wp_loaded』 , 『load_new_roles』) ;
function load_new_roles ()
{
add_filter( 『bbp_get_dynamic_roles』, 『add_custom_role』, 1 );
}
function add_custom_role( $bbp_roles )
{
$bbp_roles[『my_custom_role1』] = array(
『name』 =>』name 1′,
『capabilities』 =>bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
);
$bbp_roles[『my_custom_role2』] = array(
『name』 =>』name 2′,
『capabilities』 =>bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
);
$bbp_roles[『my_custom_role3』] = array(
『name』 =>』name 3′,
『capabilities』 =>bbp_get_caps_for_role( bbp_get_keymaster_role() ) // the same capabilities as keymaster
);
return $bbp_roles;
}
Creating new roles
If you want to add a new roles with specific capabilities, then you can add these
The code below adds a role called 『tutor』 simply change the word tutor wherever it occurs to the name you want and decide what capabilities you want to the role to have.
//code to add tutor role

add_action ('wp_loaded' , 'load_new_roles') ;

function load_new_roles ()
{
add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
}
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles['bbp_tutor'] = array(
'name' =>'Tutor',
'capabilities' =>custom_capabilities( 'bbp_tutor' )
);

return $bbp_roles;
}

function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == 'bbp_tutor' )
$caps = custom_capabilities( $role );

return $caps;
}

function custom_capabilities( $role )
{
switch ( $role )
{

/* Capabilities for 'tutor' role */
case 'bbp_tutor':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' =>false,

// Forum caps
'publish_forums' =>false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => true,
'read_hidden_forums' => false,

// Topic caps
'publish_topics' => true,
'edit_topics' => true,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => true,

// Reply caps
'publish_replies' => true,
'edit_replies' => true,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => true,

// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);

break;

default :
return $role;
}
}
The code below adds two roles, tutor and pupil. Using this you should be able to add any number of roles
add_action ('wp_loaded' , 'load_new_roles') ;

function load_new_roles () {
add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
}
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles['bbp_tutor'] = array(
'name' =>'Tutor',
'capabilities' =>custom_capabilities( 'bbp_tutor' )
);

/* Add a role called pupil */
$bbp_roles['bbp_pupil'] = array(
'name' =>'Pupil',
'capabilities' =>custom_capabilities( 'bbp_pupil' )
);

return $bbp_roles;
}

function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == 'bbp_tutor' )
$caps = custom_capabilities( $role );

if( $role == 'bbp_pupil' )
$caps = custom_capabilities( $role );

return $caps;
}

function custom_capabilities( $role )
{
switch ( $role )
{

/* Capabilities for 'tutor' role */
case 'bbp_tutor':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' =>false,

// Forum caps
'publish_forums' => false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => true,
'read_hidden_forums' => false,

// Topic caps
'publish_topics' => true,
'edit_topics' => true,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => true,

// Reply caps
'publish_replies' => true,
'edit_replies' => true,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => true,

// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);

/* Capabilities for 'pupil' role */
case 'bbp_pupil':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' => false,

// Forum caps
'publish_forums' => false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => true,
'read_hidden_forums' => false,

// Topic caps
'publish_topics' => true,
'edit_topics' => true,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => true,

// Reply caps
'publish_replies' => true,
'edit_replies' => true,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => true,

// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);

break;

default :
return $role;
}
}

導入疑難解答

導入疑難解答

特定論壇導入

確保您還檢查每個論壇導入器法典頁面以瞭解與每個論壇相關的特定問題,列表可在此處找到。

導入被 「卡住」

導入話題或回覆時,導入可能會 「卡住」 並且導入將不再繼續導入。

這些類型的錯誤通常是由於該帖子中的某些編碼問題造成的。有時這是從在某個時候完成的編碼轉換為 UTF8 。不管它是什麼,如果不對查詢設置時間限制並將差異一分為二,直到我們可以縮小違規條目的範圍並跳過它,這幾乎是不可能檢測到的。因為查詢自然會花費很長時間,並且會導致丟失數據,所以我對這種方法不滿意。

解決方法是查找並刪除有問題的話題或回覆,這既耗時又棘手,但這是現階段的唯一方法。

這是我如何調試它並找到有問題的話題/回覆:

  • 導入掛起後,單擊 stop,記下它的位置,例如 Converting 11,299 – 11,300
  • start 再次單擊,導入將從停止的地方繼續
  • 如果它再次掛起,請注意它再次達到的位置
  • 完成後製作源數據庫的新副本
  • 現在刪除數據庫中所有不在導入過程中失敗的行範圍內的行
  • 使用此數據庫執行全新導入,並將 「行數限制」 設置設置為 「1」
  • 導入應該掛在有問題的話題/回覆上
  • 再次,記下它的話題/回覆
  • 點擊停止,再次點擊開始繼續
  • 一旦您有您的違規者名單並且導入完成,從數據庫中刪除這些行並再次測試以確保它完成而不會掛起
  • 現在回到您的完整數據庫 (可能是原始數據庫的副本) 從數據庫中刪除這些相同的行並再次運行導入

調整 MySQL

當您有非常大的論壇要導入時,可能需要很長時間。

@ezyridah 執行了 100 萬多條消息的 MyBB 導入,接近 4 萬個話題和 400 多個成員,耗時約 48 小時,他添加了一些自定義 PHP 和 MySQL 調整,有助於加快速度,您可以看到他使用了哪些設置在這裏,請注意,這是非常先進的,不適合膽小的人。

西裏爾字母用户名

如果您需要在導入之前導入用户 'Cyrillic' 安裝並啓用 @SergeyBiryukovAllow Cyrillic Usernames

安裝之前

安裝之前

在您的站點上安裝 bbPress 之前,請閲讀以下指南,因為它們包含有關安裝前要做什麼的有用信息,以及有關 bbPress 及其在您站點上安裝的內容的信息。

備份您的數據庫和文件

備份您的站點非常重要,建議在您的站點進行任何重大更改之前進行備份。在本指南中,您將學習如何手動或使用自動化服務備份您的站點。

系統和服務器要求

在您的站點上運行任何新的 PHP 軟件之前,瞭解服務器要求總是好的。

WordPress 版本兼容性

bbPress 在最新可用版本的 WordPress 上運行時效果最佳。

存儲的數據庫數據

本指南將向您展示 bbPress 在 WordPress 中存儲其所有數據的位置。一些第一次從不同論壇解決方案遷移的用户通常對了解這些信息感興趣。

bbPress 用户角色和能力

bbPress 內置了幾個用户角色,每個角色具有特定的功能,以便他們可以管理特定區域或被授予在 bbPress 中執行特定操作的能力。本指南將列出有哪些角色以及它們的作用。