<!--more--> in BB text module

add_filter( 'fl_builder_render_module_content', function( $content, $module ) {

	if ( $module instanceof FLRichTextModule && strstr( $content, '<!--more' ) ) {
		$content   = str_replace( '<div class="fl-rich-text">', '', $content );
		$content   = preg_replace( '#</div>$#', '', $content );
		$parts     = get_extended( $content );
		$main      = balanceTags( $parts['main'], true );
		$main      = preg_replace( '/<([^<\/>]*)>([\s]*?|(?R))<\/\1>/imsU', '', $main );
		$more_text = $parts['more_text'] ? $parts['more_text'] : 'Read More...';
		$main     .= sprintf( '<a class="read-more-link-%s" href="#">%s</a><script>jQuery(".read-more-link-%s").on("click", function(e){e.preventDefault();jQuery(".read-more-%s").fadeIn()})</script>', $module->node, $more_text, $module->node, $module->node );

		$extended = balanceTags( $parts['extended'], true );
		$extended = preg_replace( '/<([^<\/>]*)>([\s]*?|(?R))<\/\1>/imsU', '', $extended );
		$extended = sprintf( '<div style="display:none" class="read-more-%s">%s</div>', $module->node, $extended );

		$content = sprintf( '<div class="fl-rich-text">%s%s</div>', $main, $extended );
		return $content;
	}

	return $content;
}, 10, 2 );
remove_filter( 'mce_buttons', 'FLBuilder::editor_buttons' );
1 Like