File: /var/www/html/insiders/wp-load/wp-content/plugins/gutenmate/block-library/post-read-more.php
<?php
/**
* Renders the `gtm/post-read-more` 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 featured image for the current post.
*/
function gtm_render_block_post_read_more( $attr, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$post_ID = $block->context['postId'];
$inner_html = '';
if ( $attr['display'] == 'icon' ) {
$inner_html .= gtm_icon( ! empty( $attr['icon'] ) ? $attr['icon'] : 'read-more' );
}
$inner_html .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( get_permalink( $post_ID ) ), esc_html__( 'Read more', 'gutenmate' ) );
$wrapper_attributes = get_block_wrapper_attributes( ['class' => ''] );
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
$inner_html
);
}
/**
* Registers the `gtm/post-read-more` block on the server.
*/
function gtm_register_block_post_read_more() {
gtm_register_block_type( 'post-read-more', [
'render_callback' => 'gtm_render_block_post_read_more',
] );
}
add_action( 'init', 'gtm_register_block_post_read_more', 20 );
add_filter( 'gtm.BlockStyleCompiler.gtm/post-read-more', 'gtm_compile_block_css_post_read_more', 10, 3 );
function gtm_compile_block_css_post_read_more( $output, $attributes, $blockName ) {
$block_style = ['classes' => [], 'style' => []];
$block_style['classes'][] = 'gtm-block';
if ( $attributes['enableLinkUnderline'] ) {
$block_style['classes'][] = 'gtm-has-post-read-more-link-underline';
}
if ( $attributes['enableLinkHoverUnderline'] ) {
$block_style['classes'][] = 'gtm-has-post-read-more-hover-underline';
}
gtm_css_compileCssVar( $block_style, "post-read-more-link-color", gtm_css_parseColorValue( $attributes['linkColor'] ) );
gtm_css_compileCssVar( $block_style, "post-read-more-link-hover-color", gtm_css_parseColorValue( $attributes['linkHoverColor'] ) );
if ( $attributes['display'] !== 'name' ) {
gtm_css_compileCssVar( $block_style, "post-read-more-icon-spacing", gtm_css_parseSpacingValue( $attributes['iconSpacing'] ) );
gtm_css_compileCssVar( $block_style, "post-read-more-icon-size", $attributes['iconSize'] );
gtm_css_compileCssVar( $block_style, "post-read-more-icon-color", gtm_css_parseColorValue( $attributes['iconColor'] ) );
gtm_css_compileCssVar( $block_style, "post-read-more-icon-hover-color", gtm_css_parseColorValue( $attributes['iconHoverColor'] ) );
}
// 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'] ),
];
}