]*)>(.*?)#is', static function ( $m ) use ( &$tokens ) { if ( ! preg_match( '#\btype\s*=\s*(["\']?)application/ld\+json\1#i', $m[1] ) ) { return ''; } $data = json_decode( $m[2], true ); if ( ! is_array( $data ) ) { return ''; } $key = 'nxjson' . count( $tokens ) . 'x'; $tokens[ $key ] = wp_get_inline_script_tag( wp_json_encode( $data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ), array( 'type' => 'application/ld+json' ) ); return ''; }, $html ); // An unclosed