• Hi, I am using a lightbox plugin to display the login form, but for some reason whenever a user is not logged in to the site all HTML comments are being wrapped in P tags.

    The issue appears to be linked to the plugin somehow as when I remove the shortcode from the lightbox then the page displays correctly.

    I am guessing that the WordPress function to add paragraphs to content is somehow causing this, but I’m not sure why the login form would make it interact in this way. Any ideas?

    https://wordpress.org/plugins/wp-members/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter PaulH wp

    (@paulh-wp)

    I have tried adding code to disable the wpautop function (below), but the problem still remains. Not sure if the plugin is using this function, if not it may be some other reason that is causing this to happen.

    remove_filter( 'the_content', 'wpautop' );
    remove_filter( 'the_excerpt', 'wpautop' );
    Plugin Author Chad Butler

    (@cbutlerjr)

    The plugin does not add these tags, they are added by WP’s wpautop function.

    When used in the main content area, the plugin already removes wpautop so that this does not occur.

    Unless your lightbox uses WP’s content or excerpt functions, removing those filters (the_content / the_excerpt) wouldn’t turn off wpautop for your lightbox. My guess would be the ligthbox does not apply those filters.

    Thread Starter PaulH wp

    (@paulh-wp)

    I have been doing some testing on a blank page and found that whenever any code is added other than the forms shortcodes I get p tags wrapped around the HTML comments.

    I tried adding just the forms and everything was fine, but when I added the social login plugin under the WP-Members login form the problem returned.

    I then decided to search for where the plugin was dealing with wpautop and found the following code.

    if ( strstr( $content, '[wpmem_txt]' ) ) {
    
    	// Fix the wptexturize.
    
    	remove_filter( 'the_content', 'wpautop' );
    
    	remove_filter( 'the_content', 'wptexturize' );
    
    	add_filter( 'the_content', 'wpmem_texturize', 999 );
    
    }

    This code is located in both class-wp-members.php and shortcodes.php which when removed seems to fix the issue.

    The problem I have now is that there is [wpmem_txt][/wpmem_txt] wrapped around both forms as well as having to deal with updates to the plugin in future.

    Any ideas on what I can do to solve this issue?

    Plugin Author Chad Butler

    (@cbutlerjr)

    This code is located in both class-wp-members.php and shortcodes.php which when removed seems to fix the issue.

    Interesting, since that is where the plugin is actually removing wpautop.

    I might suspect that in the case of where you are implementing this it may be that process runs the wpautop filter after this point (it is assuming WP’s priority of 10 on the_content filter).

    You can ask the shortcode to remove the [wpmem_txt] shortcode by adding the texturize parameter in the shortcode, such as:

    [wpmem_form login texturize=”false”]

    Thread Starter PaulH wp

    (@paulh-wp)

    I have managed to get everything working properly by adjusting the code as shown below, but as soon as I add the wpmem_texturize call the problem returns.

    if ( strstr( $content, '[wpmem_txt]' ) ) {
    
    			// Fix the wptexturize.
    
    			remove_filter( 'the_content', 'wpautop' );
    
                            $content = str_replace( array( '[wpmem_txt]', '[/wpmem_txt]' ), array( '', '' ), $content );
    
    }

    The problem seems to be linked to wpmem_texturize somehow as everything else works fine until i add this line back in.

    add_filter( 'the_content', 'wpmem_texturize', 999 );

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘HTML commnets wrapped in P tag when not logged in’ is closed to new replies.