acf_serialize_block_attributes()
This directly copied from the WordPress core serialize_block_attributes()
We need this in order to make sure that block attributes are stored in a way that is consistent with how Gutenberg sends them over from JS, and so that things like wp_kses() work as expected. Copied from core to get around a bug that was fixed in 5.8.1 or on the off chance that folks are still using WP 5.3 or below.
TODO: Remove this when we refactor acf_parse_save_blocks_callback() use serialize_block(), or when we're confident that folks aren't using WP versions prior to 5.8.
Хуков нет.
Возвращает
Строку
. Serialized attributes.
Использование
acf_serialize_block_attributes( $block_attributes );
- $block_attributes(массив) (обязательный)
- Attributes object.
Список изменений
С версии 5.12 | Введена. |
Код acf_serialize_block_attributes() acf serialize block attributes ACF 6.0.4
function acf_serialize_block_attributes( $block_attributes ) { $encoded_attributes = wp_json_encode( $block_attributes, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); $encoded_attributes = preg_replace( '/--/', '\\u002d\\u002d', $encoded_attributes ); $encoded_attributes = preg_replace( '/</', '\\u003c', $encoded_attributes ); $encoded_attributes = preg_replace( '/>/', '\\u003e', $encoded_attributes ); $encoded_attributes = preg_replace( '/&/', '\\u0026', $encoded_attributes ); // Regex: /\\"/. $encoded_attributes = preg_replace( '/\\\\"/', '\\u0022', $encoded_attributes ); return $encoded_attributes; }