
內容簡介
此外掛程式將 WordPress 的預設評論、bbPress 和 BuddyPress 編輯器切換成使用 Gutenberg 編輯器。這些編輯器現在可以使用更豐富的編輯工具,並且可以使用完整的 Gutenberg 區塊功能。
管理員審核也使用 Gutenberg 升級,前端處理區塊。
為了增加安全性,可用區塊清單是由 WordPress 允許的標籤決定的。
Gutenberg 並非捆綁軟體,而是從 WordPress 側載的。為了更好的相容性,您應該使用 Gutenberg 的外掛程式版本,該版本通常比 WordPress 中包含的版本提前數個版本。
Gutenberg 替換條件如下:
- bbPress - 良好(需要 bbPress 2.6+)
- 評論 - 還好
- BuddyPress - 需要大量改進。
此外,此外掛程式為 Gutenberg 編輯器添加了新的區塊類型「內容嵌入」,使您可以從任何 bbPress 站點或 WordPress.com 支援頁面嵌入論壇主題。
Blocks Everywhere 在 GitHub 上開發:
https://github.com/Automattic/blocks-everywhere
注意事項
載入 Gutenberg 也會增加載入頁面的大小,您應該了解這一點,並在您的網站上接受它。
此功能尚未適用於基於區塊的佈景主題,必須是「傳統」佈景主題。
您應該使用最新版本的 Gutenberg 外掛程式。
使用教程
要啟用 Blocks Everywhere,您需要向 wp-config.php 中添加相關 define 代碼:
define( 'BLOCKS_EVERYWHERE_COMMENTS', true );
define( 'BLOCKS_EVERYWHERE_BBPRESS', true );
define( 'BLOCKS_EVERYWHERE_BUDDYPRESS', true );
您還可以使用 WordPress filter blocks_everywhere_comments、blocks_everywhere_bbpress 和 blocks_everywhere_buddypress。
要在 bbPress 中啟用後端編輯:
define( 'BLOCKS_EVERYWHERE_ADMIN', true );
或使用過濾器 blocks_everywhere_admin。後端編輯僅限具有 manage_options 能力的使用者(可以通過過濾器 blocks_everywhere_admin_cap 更改)。
要啟用電子郵件中的區塊轉換:
define( 'BLOCKS_EVERYWHERE_EMAIL', true );
或使用過濾器 blocks_everywhere_email。
要在編輯 bbPress 論壇、主題和回覆時啟用 Gutenberg,可以使用:
define( 'BLOCKS_EVERYWHERE_BBPRESS_ADMIN', true );
或使用 blocks_everywhere_bbpress_admin。
設定
某些設置可通過設置物件使用過濾器 blocks_everywhere_editor_settings 進行篩選。
allowUrlEmbed - 啟用或禁用 URL 的自動嵌入
replaceParagraphCode - 啟用自定義段落,將 HTML 和 PHP 代碼轉換為代碼塊
pastePlainText - 將所有粘貼的內容轉換為純文本
patchEmoji - 設置為 `true`,停止 twemoji 影響編輯器
iso.allowEmbeds - 啟用嵌入的列表
iso.blocks.allowBlocks - 啟用區塊的列表
Gutenberg 直接放在您的文章、論壇等內容上,這意味著編輯器的內容將看起來像它們將出現的頁面。但是,這也意味著頁面的樣式可能會影響編輯器。
我們尚無完美的方法來區分這些樣式,因此網站樣式可能會影響編輯器。
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
Switches the default WordPress editor for comments, bbPress, and BuddyPress to use Gutenberg. These can now use a richer set of editing tools, as well as having access to the full power of Gutenberg blocks.
Admin moderation is also upgraded to use Gutenberg, and blocks are processed on the front end.
For extra security the list of available blocks is determined by the allowed tags from WordPress.
Gutenberg is not bundled and instead is side-loaded from WordPress. For better compatibility you should use the plugin version of Gutenberg, which is typically several versions ahead of the one included in WordPress.
The condition of the Gutenberg replacements are:
– bbPress – good (requires bbPress 2.6+)
– comments – alright
– BuddyPress – needs a lot of work
In addition, this plugin adds a new block type “Content Embed” for the Gutenberg editor, which allows you to embed a forum topic from any bbPress site or WordPress.com Support page.
Blocks Everywhere is developed on Github at:
https://github.com/Automattic/blocks-everywhere
Caveats
The loading of Gutenberg will also increase the page size of any page it is loaded on. You should be aware of this and willing to accept this in the context of your site.
This doesn’t yet work on block-based themes – it must be a ‘classic’ theme.
You should use the latest version of the Gutenberg plugin.
Usage
To enable Blocks Everywhere you need to add the relevant define to wp-config.php:
define( 'BLOCKS_EVERYWHERE_COMMENTS', true );
define( 'BLOCKS_EVERYWHERE_BBPRESS', true );
define( 'BLOCKS_EVERYWHERE_BUDDYPRESS', true );
You can also use the WordPress filter blocks_everywhere_comments, blocks_everywhere_bbpress, and blocks_everywhere_buddypress.
To enable back-end editing in bbPress:
define( 'BLOCKS_EVERYWHERE_ADMIN', true );
Or use the filter blocks_everywhere_admin. Back-end editing is restricted to users with the manage_options capability (can be changed with the blocks_everywhere_admin_cap filter).
To enable conversion of blocks in email:
define( 'BLOCKS_EVERYWHERE_EMAIL', true );
Or use the filter blocks_everywhere_email.
To enable Gutenberg when editing bbPress forums, topics, and replies you can use:
define( 'BLOCKS_EVERYWHERE_BBPRESS_ADMIN', true );
Or use blocks_everywhere_bbpress_admin
Settings
Some settings are available through the settings object, which is filterable with blocks_everywhere_editor_settings.
allowUrlEmbed - Enable or disable auto-embed for URLs
replaceParagraphCode - Enable the custom paragraph that converts HTML and PHP code into a code block
pastePlainText - Convert all pasted content to plain text
patchEmoji - set to `true` to stop twemoji from affecting the editor
iso.allowEmbeds - List of enabled embeds
iso.blocks.allowBlocks - List of enabled blocks
iso.className - String of classes to be assigned to the editor.
iso.__experimentalOnChange - An optional callback that is triggered when the blocks are changed.
iso.__experimentalOnInput - An optional callback that is triggered when text is input.
iso.__experimentalOnSelection - An optional callback when a block is selected.
Theme compatibility
Gutenberg is placed directly on the page along with your post, forum, etc. This means the contents of the editor will look like the page they will appear on. However, it also means that styles from the page may affect the editor.
We don’t have a perfect way of separating these styles and it is possible that styles from the page or from Gutenberg may affect the other. If you are using this plugin then it is expected that you will be able to fix any differences as appropriate for your site.
A theme compatibility option is provided which might help. You can use this with:
define( 'BLOCKS_EVERYWHERE_THEME_COMPAT', true );
Or using the filter blocks_everywhere_theme_compat.
It provides some overrides for common theme issues. However, it is generally better not to require overrides so if you are able to modify your theme and make CSS more specific then that is the best route.
For example, rather than defining a global button style (which would then affect Gutenberg), make the style specific to the areas where a button will be used.
Using Content Embed block
Content Embed block uses REST API to fetch content to be embedded. This means that site contains bbPress topics to embed should have topic REST API enabled.
Blocks Everywhere enables topic REST API on its own, so if the site with bbPress have this plugin installed and configured, its topics can be embedded.
To enable Content Embed block in the editor, pass these settings to blocks_everywhere_editor_settings filter:
add_filter( 'blocks_everywhere_editor_settings', function( $settings ) {
$settings['iso']['blocks']['allowBlocks'][] = 'blocks-everywhere/support-content';
return $settings;
} );
To enable REST API for forum topics, use next filters:
add_filter( 'blocks_everywhere_admin', '__return_true' );
add_filter( 'blocks_everywhere_admin_cap', '__return_empty_string' );
REST API is only used when creating content embed and not used to view it. So blocks_everywhere_admin_cap can return specific capability to limit users who will have access to API.
In order for Content Embed block from Blocks Everywhere to load post authors, it is required to enable author data in the topic REST API. To do it, use this filter
add_action( 'bbp_get_topic_post_type_supports', function( $supports ) {
$supports[] = 'author';
return $supports;
} );
KSES
Gutenberg outputs HTML content and this may be affected by KSES (WordPress HTML sanitisation) and other sanitisation.
The plugin provides some modifications to this so it works fine with basic blocks. You may run into problems if you are using different blocks or have customised permission levels.
