📄 原始资料 | 展开查看原始 JSON(bricks-remote_get.json){ “name”: “bricks/remote_get”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-remote_get/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/remote_get”, “description”: { “en”: “Filters the arguments p…
📄 原始资料 | 展开查看原始 JSON(bricks-remote_get.json)
{
"name": "bricks/remote_get",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-remote_get/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/remote_get",
"description": {
"en": "Filters the arguments passed to wp_remote_get() when Bricks performs a remote GET request (e.g., fetching templates, community library).",
"zh": "筛选当 Bricks 执行远程 GET 请求时传递给 wp_remote_get() 的参数(例如获取模板、社区库)。"
},
"parameters": [
{
"name": "args",
"type": "array",
"type_zh": null,
"description": {
"en": "Array of arguments for wp_remote_get() (e.g., timeout , sslverify ).",
"zh": "wp_remote_get() 的参数数组(例如 timeout、sslverify)。"
}
},
{
"name": "url",
"type": "string",
"type_zh": null,
"description": {
"en": "The URL being requested.",
"zh": "正在请求的 URL。"
}
}
],
"example_usage": "add_filter( 'bricks/remote_get', function( $args, $url ) {\n // Example: Increase timeout for specific API requests\n if ( strpos( $url, 'api.example.com' ) !== false ) {\n $args['timeout'] = 60;\n }\n\n\n return $args;\n}, 10, 2 );"
}
前言
筛选当 Bricks 执行远程 GET 请求时传递给 wp_remote_get() 的参数(例如获取模板、社区库)。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/remote_get', function( $args, $url ) {
// Example: Increase timeout for specific API requests
if ( strpos( $url, 'api.example.com' ) !== false ) {
$args['timeout'] = 60;
}
return $args;
}, 10, 2 );
参数
$args (array):wp_remote_get() 的参数数组(例如 timeout、sslverify)。
$url (string):正在请求的 URL。
示例代码
筛选返回值
add_filter( 'bricks/remote_get', function( $args, $url ) {
// Example: Increase timeout for specific API requests
if ( strpos( $url, 'api.example.com' ) !== false ) {
$args['timeout'] = 60;
}
return $args;
}, 10, 2 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/remote_get', function( $value, $args ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。