跳到内容

Block Logic – Full Block Display Control

v2.1.6

landwire · 2020年1月15日 上架

Block Logic adds a "Block Logic" field to the block editor, that lets you show or hide any block based on conditions.

正在使用
300+
评分
5.0 / 5
累计下载
6,937
最近更新
2026年5月30日
13 条评价需要 WordPress 6.5+已测试到 7.0.9PHP 8.0+

贡献者

截图

The 'Block logic' field at work in the block editor.
The 'Block logic' field at work in the block editor.

Block Logic adds a “Block Logic” field to the “Advanced” section of the block editor (i.e Gutenberg), that lets you show or hide any block based on conditions. You can use WordPress’ Conditional Tags or any general PHP code.

Show or hide blocks based on

  • User role
  • User login status
  • Post status
  • Date and time
  • The result of a custom PHP function

Features

  • Show or hide any block using conditions
  • Combine conditions with “and” or “or” operators. See FAQ Writing Logic Code
  • Full flexibility: use any condition you want (you can extend base functionality with filters)

Limitations

Does not work with the Classic Block, Widget Block or Widget Area Block [‘core/freeform’, ‘core/legacy-widget’, ‘core/widget-area’], as the those blocks do not support block attributes. Does also not work with the HTML Block [‘core/html’] inside the Widget Screen, as this one also does not support block attributes there.

Configuration

Just activate the plugin. The “Block Logic” textbox will then appear in the “Advanced” section of the Gutenberg editor.

Breaking changes since 2.0.0

Since version 2.0.0 the code does not get eval’d directly, but there is a whitelist of allowed functions that can be extended via a filter.

Upgrade Notice

When upgrading to version 2.x you will need to update your logic. No return is allowed anymore and no semicolons in code as only expressions are evaluated. See FAQ Section Writing Logic Code.

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums