Make WordPress Core

Opened 7 years ago

Last modified 2 weeks ago

#40958 new defect (bug)

force_balance_tags breaks Ninjaforms and probably other plugins that output html within js.

Reported by: programmin's profile programmin Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.4
Component: Shortcodes Keywords:
Focuses: ui, administration Cc:


If you have a shortcode for Ninjaforms and use the post in a context that runs force_balance_tags() it seriously breaks the script. For example if you have a form id=14, add this :


echo 'NO BALANCE:--'. apply_filters('the_content', '[ninja_form id=14]' ) .' --END NO BALANCE. ';
echo 'BALANCED:--'. force_balance_tags(apply_filters('the_content', '[ninja_form id=14]' )) .' --END BALANCED. ';

Notice that some ending /spans, /is, and or /as are added before the end script, breaking it. Seems to not be wp version dependent.

Change History (2)

#1 @programmin
7 years ago

It would be nice if there were a filter always applied at the end of the force balance function, for the possibility of cleaning up bugs like this.

#2 @boceksumuklu
2 weeks ago

Hello Programmin,

Please don't forget to replace 14 with your form id.

remove_filter( 'the_content', 'force_balance_tags' );
$content = apply_filters( 'the_content', $content_with_shortcodes );
add_filter( 'the_content', 'force_balance_tags' );

function my_ninja_form_shortcode_handler( $atts ) {
    return ninja_forms_display_form( array( 'id' => 14 ) ); // Replace 14 with your form ID
add_shortcode( 'my_ninja_form', 'my_ninja_form_shortcode_handler' );

Note: See TracTickets for help on using tickets.