📄 原始资料 | 展开查看原始 JSON(bricks-use_duplicate_content.json){ “name”: “bricks/use_duplicate_content”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-use_duplicate_content/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/use_duplicate_conten…
📄 原始资料 | 展开查看原始 JSON(bricks-use_duplicate_content.json)
{
"name": "bricks/use_duplicate_content",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-use_duplicate_content/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/use_duplicate_content",
"description": {
"en": "Duplicate content is available for all users with the edit_post capability. Use this feature to duplicate any post or page containing Bricks data to ensure Bricks IDs are not duplicated. The duplicate option is also available for posts without Bricks data, allowing you to duplicate standard posts without the need for a third-party plugin. In Bricks > Settings , you can configure the duplicate content behavior: Enable : Duplicate content is available for all posts. Disable globally : Duplicate content is disabled for all posts. Disable for WordPress Data : Duplicate content is disabled for posts that do not use Bricks data. This bricks/use_duplicate_content hook provides an additional layer of customization, enabling you to implement more complex logic based on your specific requirements. $use (bool) $post_id (int) $setting (string) This filter expects a boolean value: Follow setting logic + ensure the user is admin Follow setting logic + exclude post type for ACF or MB",
"zh": "重复内容功能适用于所有具有 edit_post 权限的用户。使用此功能可以复制任何包含 Bricks 数据的文章或页面,以确保 Bricks ID 不会被重复。重复选项也适用于不包含 Bricks 数据的文章,允许你无需第三方插件即可复制标准文章。在 Bricks > 设置 中,你可以配置重复内容行为:启用:所有文章都可使用重复内容。全局禁用:所有文章都禁用重复内容。针对 WordPress 数据禁用:不使用 Bricks 数据的文章禁用重复内容。此 bricks/use_duplicate_content 钩子提供了额外的自定义层,使你能够根据特定需求实现更复杂的逻辑。$use (bool) $post_id (int) $setting (string) 此筛选器期望布尔值:遵循设置逻辑 + 确保用户是管理员 遵循设置逻辑 + 排除 ACF 或 MB 的文章类型"
},
"since": "1.12",
"example_usage": "add_filter( 'bricks/use_duplicate_content', function( $use, $post_id, $settings ) {\n // Only allow if current has user administrative privileges\n $has_admin_cap = current_user_can( 'manage_options' );\n\n\n // Fulfilled the condition\n return $use && $has_admin_cap;\n}, 10, 3 );",
"additional_sections": [
{
"heading": {
"en": "Return Value",
"zh": "返回值"
},
"content": {
"en": "This filter expects a boolean value:",
"zh": "返回值:\n\n$use (bool) — 是否启用重复内容。\n$post_id (int) — 重复内容适用的文章 ID。\n$setting (string) — 设置中配置的重复内容行为。"
}
}
]
}
前言
重复内容功能适用于所有具有 edit_post 权限的用户。使用此功能可以复制任何包含 Bricks 数据的文章或页面,以确保 Bricks ID 不会被重复。重复选项也适用于不包含 Bricks 数据的文章,允许你无需第三方插件即可复制标准文章。在 Bricks > 设置 中,你可以配置重复内容行为:启用:所有文章都可使用重复内容。全局禁用:所有文章都禁用重复内容。针对 WordPress 数据禁用:不使用 Bricks 数据的文章禁用重复内容。此 bricks/use_duplicate_content 钩子提供了额外的自定义层,使你能够根据特定需求实现更复杂的逻辑。$use (bool) $post_id (int) $setting (string) 此筛选器期望布尔值:遵循设置逻辑 + 确保用户是管理员 遵循设置逻辑 + 排除 ACF 或 MB 的文章类型
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/use_duplicate_content', function( $use, $post_id, $settings ) {
// Only allow if current has user administrative privileges
$has_admin_cap = current_user_can( 'manage_options' );
// Fulfilled the condition
return $use && $has_admin_cap;
}, 10, 3 );
示例代码
筛选返回值
add_filter( 'bricks/use_duplicate_content', function( $use, $post_id, $settings ) {
// Only allow if current has user administrative privileges
$has_admin_cap = current_user_can( 'manage_options' );
// Fulfilled the condition
return $use && $has_admin_cap;
}, 10, 3 );
补充说明
更多细节可参考 官方文档。