前言
决定当 动态数据标签出现在另一个动态数据标签的输出中时,是否应被递归解析。默认情况下,出于安全和性能考虑禁用此功能。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/code/echo_everywhere', function( $echo_everywhere ) {
// Enable recursive parsing of tags
// WARNING: Use with caution as this may lead to infinite loops or security vulnerabilities
return true;
} );
参数
$echo_everywhere(bool):是否允许递归解析 标签。默认为 false。
示例代码
筛选返回值
add_filter( 'bricks/code/echo_everywhere', function( $echo_everywhere ) {
// Enable recursive parsing of tags
// WARNING: Use with caution as this may lead to infinite loops or security vulnerabilities
return true;
} );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/code/echo_everywhere', function( $value, $echo_everywhere ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。