<?php
/**
* Heading block, line style
*
*/
function be_heading_line_style( $content, $block ) {
if( 'core/heading' === $block['blockName' ] && !empty( $block['attrs'] ) && !empty( $block['attrs']['className'] ) ) {
$classes = explode( ' ', $block['attrs']['className'] );
if( in_array( 'is-style-line', $classes ) ) {
$content = be_inner_span( $content );
}
}
return $content;
}
add_filter( 'render_block', 'be_heading_line_style', 10, 2 );
/**
* Inner Span
*
*/
function be_inner_span( $content = '' ) {
$start = '">';
$start_pos = strpos( $content, $start );
$end = '</';
$end_pos = strrpos( $content, $end );
if( false !== $start_pos ) {
$content = substr_replace( $content, '</span>' . $end, $end_pos, strlen( $end ) );
$content = substr_replace( $content, $start . '<span>', $start_pos, strlen( $start ) );
}
return $content;
}