File: /var/www/html/insiders/wp-load/wp-content/plugins/gutenmate/block-library/direction.php
<?php
defined( 'GTM_DIRECTION_BLOCK_MARK_DONE' ) || define( 'GTM_DIRECTION_BLOCK_MARK_DONE', '<!-- gtm-direction-block-mark-done -->' );
/**
* Renders the `gtm/direction` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the post author and date for the current post.
*/
function gtm_render_block_direction( $attr, $content, $block ) {
if ( get_option( 'gtm_seo_enable_post_rich_snippets', true ) ) {
$content = gtm_str_replace_first( '<div ', '<div itemprop="step" itemscope itemtype="https://schema.org/HowToStep" ', $content );
$content = str_replace( '"wp-block-gtm-direction__title"', '"wp-block-gtm-direction__title" itemprop="text"', $content );
$content = str_replace( '<img', '<img itemprop="image"', $content );
// Add data to json-ld since google is not allow linking to microdata
add_filter( 'gtm_direction_block_schema', function ( $schema = [] ) use ( $content ) {
$schema[] = [
'@type' => 'HowToStep',
'text' => wp_strip_all_tags( $content, true ),
];
return $schema;
} );
}
// Add mark as done button
$mark_as_done = '<div class="wp-block-gtm-direction__mark-as-done-container">';
$mark_as_done .= '<i class="wp-block-gtm-direction__empty-icon gtm-icon gtm-basic-icon-circle-regular"></i>';
$mark_as_done .= '<i class="wp-block-gtm-direction__marked-icon gtm-icon gtm-basic-icon-check"></i>';
$mark_as_done .= ' '; // whitespace
$mark_as_done .= sprintf( '<span class="wp-block-gtm-direction__mark-as-done-label">%s</span>', esc_html__( 'Mark as done', 'gutenmate' ) );
$mark_as_done .= '</div>';
$mark_as_done = apply_filters( 'gtm_direction_block_mark_as_done', $mark_as_done );
$content = str_replace( GTM_DIRECTION_BLOCK_MARK_DONE, $mark_as_done, $content );
return $content;
}
/**
* Registers the `gtm/direction` block on the server.
*/
function gtm_register_block_direction() {
gtm_register_block_type( 'direction', [
'render_callback' => 'gtm_render_block_direction',
] );
}
add_action( 'init', 'gtm_register_block_direction', 20 );
add_filter( 'gtm.BlockStyleCompiler.gtm/direction', 'gtm_compile_block_css_direction', 10, 3 );
function gtm_compile_block_css_direction( $output, $attributes, $blockName ) {
$block_style = ['classes' => [], 'style' => []];
$block_style['classes'][] = 'gtm-block';
// Apply to output
$block_style['style'] = ['{{BLOCK}}' => $block_style['style']];
return [
'classes' => array_merge( $output['classes'], $block_style['classes'] ),
'style' => array_replace_recursive( $output['style'], $block_style['style'] ),
];
}