📄 原始资料 | 展开查看原始 JSON(bricks-remote_post.json){ “name”: “bricks/remote_post”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-remote_post/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/remote_post”, “description”: { “en”: “Filters the argumen…
📄 原始资料 | 展开查看原始 JSON(bricks-remote_post.json)
{
"name": "bricks/remote_post",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-remote_post/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/remote_post",
"description": {
"en": "Filters the arguments passed to wp_remote_post() when Bricks performs a remote POST request (e.g., verifying license, submitting form data to webhook).",
"zh": "筛选当 Bricks 执行远程 POST 请求时传递给 wp_remote_post() 的参数(例如验证许可证、将表单数据提交到 webhook)。"
},
"parameters": [
{
"name": "args",
"type": "array",
"type_zh": null,
"description": {
"en": "Array of arguments for wp_remote_post() (e.g., body , timeout , sslverify ).",
"zh": "wp_remote_post() 的参数数组(例如 body、timeout、sslverify)。"
}
},
{
"name": "url",
"type": "string",
"type_zh": null,
"description": {
"en": "The URL being requested.",
"zh": "正在请求的 URL。"
}
}
],
"example_usage": "add_filter( 'bricks/remote_post', function( $args, $url ) {\n // Example: Add custom headers to webhook requests\n if ( strpos( $url, 'webhook.example.com' ) !== false ) {\n $args['headers']['X-Custom-Header'] = 'my-value';\n }\n\n\n return $args;\n}, 10, 2 );"
}
前言
筛选当 Bricks 执行远程 POST 请求时传递给 wp_remote_post() 的参数(例如验证许可证、将表单数据提交到 webhook)。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/remote_post', function( $args, $url ) {
// Example: Add custom headers to webhook requests
if ( strpos( $url, 'webhook.example.com' ) !== false ) {
$args['headers']['X-Custom-Header'] = 'my-value';
}
return $args;
}, 10, 2 );
参数
$args (array):wp_remote_post() 的参数数组(例如 body、timeout、sslverify)。
$url (string):正在请求的 URL。
示例代码
筛选返回值
add_filter( 'bricks/remote_post', function( $args, $url ) {
// Example: Add custom headers to webhook requests
if ( strpos( $url, 'webhook.example.com' ) !== false ) {
$args['headers']['X-Custom-Header'] = 'my-value';
}
return $args;
}, 10, 2 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/remote_post', function( $value, $args ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。