Bricks 中文文档:bricks/export_template_args

📎 原始资料  |  下载原始 JSON 文件 (bricks-export_template_args.json) 前言 此筛选器允许你在 Bricks 中注册自定义元素事件。 用法 将代码加入子主题的 functions.php: add_filter( ‘bricks/export_template_args’, function( $args, $post_id ) { // Example: Add a custom parameter to the export URL $args[‘my_param’] = ‘value’; return $args; }, …

前言

此筛选器允许你在 Bricks 中注册自定义元素事件。

用法

将代码加入子主题的 functions.php

add_filter( 'bricks/export_template_args', function( $args, $post_id ) {
    // Example: Add a custom parameter to the export URL
    $args['my_param'] = 'value';


    return $args;
}, 10, 2 );

参数

  • $args (array):导出 URL 的查询参数数组(例如 action、nonce、templateId)。
  • $post_id (int):正在被导出的模板 ID。

示例代码

筛选返回值

add_filter( 'bricks/export_template_args', function( $args, $post_id ) {
    // Example: Add a custom parameter to the export URL
    $args['my_param'] = 'value';


    return $args;
}, 10, 2 );

根据条件短路返回原值

根据条件跳过或修改返回值:

add_filter( 'bricks/export_template_args', function( $value, $args ) {
    if ( is_admin() ) { return $value; }
    // TODO: custom logic here
    return $value;
} );

补充说明

更多细节可参考 官方文档