Add &nbsp; to last <space> in a heading module

#1

Add a nbsp to the last space in a heading module as requested.

add_filter( 'fl_builder_render_module_content', function( $out, $module ) {
	if ( 'heading' === $module->slug ) {
		$string  = $out;
		$find    = ' ';
		$replace = '&nbsp;';
		$out     = strrev( preg_replace( strrev( "/$find/" ), strrev( $replace ), strrev( $string ), 1 ) );
	}
	return $out;
2 Likes