Bricks 中文文档:bricks/acf/google_map/text_output

标签TAGS: 

📎 原始资料  |  下载原始 JSON 文件 (bricks-acf-google_map-text_output.json) 前言 筛选 ACF Google Map 字段动态数据的最终 HTML 输出。该步骤发生在地址部分或坐标格式化之后。 用法 将代码加入子主题的 functions.php: add_filter( ‘bricks/acf/google_map/text_output’, function( $output, $value, $field ) { // Example: Strip HTML tags to get plain text retur…

前言

筛选 ACF Google Map 字段动态数据的最终 HTML 输出。该步骤发生在地址部分或坐标格式化之后。

用法

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

add_filter( 'bricks/acf/google_map/text_output', function( $output, $value, $field ) {
    // Example: Strip HTML tags to get plain text
    return wp_strip_all_tags( $output );
}, 10, 3 );

参数

  • $output (string):已渲染的 HTML 输出字符串。
  • $value (array):ACF Google Map 字段的原始值。
  • $field (array):ACF 字段设置。

示例代码

筛选返回值

add_filter( 'bricks/acf/google_map/text_output', function( $output, $value, $field ) {
    // Example: Strip HTML tags to get plain text
    return wp_strip_all_tags( $output );
}, 10, 3 );

根据条件短路返回原值

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

add_filter( 'bricks/acf/google_map/text_output', function( $value, $output ) {
    if ( is_admin() ) { return $value; }
    // TODO: custom logic here
    return $value;
} );

补充说明

更多细节可参考 官方文档