#mt-debug-bar .mt-debug-bar-title { margin-bottom: 1em; } #mt-debug-bar .mt-debug-bar-section { padding: .5em .5em .5em 1em; } '; $html .= '
'; $html .= '

' . esc_html__( 'The Events Calendar JSON-LD Data', 'tribe-common' ) . '

'; $json_ld_data = array_filter( (array) tribe_cache()['json-ld-data'] ); if ( ! empty( $json_ld_data ) ) { $html .= '
'; $html .= sprintf( '
The request produced %d JSON-LD data %s.

', count( $json_ld_data ), count( $json_ld_data ) > 1 ? 'scripts' : 'script' ); $html .= '

Copy the code below and paste it into ' . '' . 'Google\'s Structured Data Testing Tool' . '' . ' to test it using the Code Snippet option.


'; foreach ( $json_ld_data as $full_entry ) { preg_match( '/(?^\\s*]*?>\\s*)(?.*)(?\\s<\\/script>)$/uism', $full_entry, $frags ); if ( isset( $frags['open'], $frags['json'], $frags['close'] ) ) { // Let's try and format it if we've got all the pieces. $full_entry = $frags['open'] . json_encode( json_decode( $frags['json'], true ), JSON_PRETTY_PRINT ) . $frags['close']; } $html .= sprintf( '
%s
', esc_html( $full_entry ) ); } $html .= '
'; } $html .= '
'; echo $html; } }