Skip to content

Commit b4c79a9

Browse files
k1sul1anttiviljami
authored andcommitted
Remove content changing filters and minify output (#62)
* Remove content changing filters and minify output
1 parent 7c899cb commit b4c79a9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

classes/class-cpt-wplf-form.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ private function __construct() {
4444
add_action( 'wp_enqueue_scripts', array( $this, 'maybe_enqueue_frontend_script' ) );
4545

4646
// default filters for the_content, but we don't want to use actual the_content
47-
add_filter( 'wplf_form', 'wptexturize' );
4847
add_filter( 'wplf_form', 'convert_smilies' );
4948
add_filter( 'wplf_form', 'convert_chars' );
50-
add_filter( 'wplf_form', 'wpautop' );
5149
add_filter( 'wplf_form', 'shortcode_unautop' );
50+
51+
remove_filter( 'wplf_form', 'wpautop' );
52+
remove_filter( 'wplf_form', 'wptexturize' );
53+
54+
// Removing wpautop isn't enough if form is used inside a ACF field or so.
55+
// Fitting the output to one line prevents <br> tags from appearing.
56+
add_filter( 'wplf_form', array( $this, 'minify_output' ) );
5257
}
5358

5459
public static function register_cpt() {
@@ -624,6 +629,10 @@ function maybe_set_404_for_single_form() {
624629
function get_publicly_visible_state( $id ) {
625630
return apply_filters( 'wplf-form-publicly-visible', false, $id );
626631
}
632+
633+
function minify_output( $html ) {
634+
return str_replace( array( "\n", "\r" ), '', $html );
635+
}
627636
}
628637

629638
endif;

0 commit comments

Comments
 (0)