Conflict with 'Toggle wpautop' plugin makes Community Events unusable

Home Forums Calendar Products Community Events Conflict with 'Toggle wpautop' plugin makes Community Events unusable

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1298867
    Lou
    Participant

    See https://sandbox.steeplechasers.org/events/community/add

    Major Problem – existing venue and organizer pick list is garbled with raw json

    Minor Problems – too much vertical space in the EVENT TIME & DATE section, EVENT DESCRIPTION has Visual and Text buttons which don’t seem to do anything, and are not explained.

    I am seeing some errors in the console:

    add:1930 Uncaught SyntaxError: Unexpected token <
    add:2054 Uncaught SyntaxError: Unexpected token <
    select2.min.js:21 Uncaught query function not defined for Select2 saved_tribe_venue

    In the javascript on the page I see extra [p] (change [] to angle bracket) tags. I suspected it is happening because we have Toggle wpautop plugin installed. When I deactivated that plugin all looks good. I’ve reactivated it so you can see the behavior, but I also suspect you can reproduce locally.

    We do use Toggle wpautop, and it would break some of our pages to deactivate it. Normally this can be deactivated on a page by page basis with a checkbox (Disable wpautop), but for the community/add page there is no page in the database, nor is there a template I can use to create a page.

    As it is we can’t use Community Events. Hopefully you have a workaround.

    Any advice?

    • This topic was modified 8 years, 10 months ago by Lou.
    #1299007
    Lou
    Participant

    Looks like toggle-wpautop.php has the following, so my need is to set _lp_disable_wpautop into the post metadata for the ‘post’ which is the event editor (and any other community events views). Please tell me what is the best way to do this.

    		function the_post( $post ) {
    			if ( get_post_meta( $post->ID, '_lp_disable_wpautop', true ) ) {
    				remove_filter( 'the_content', 'wpautop' );
    				remove_filter( 'the_excerpt', 'wpautop' );
    			} else {
    				if ( ! has_filter( 'the_content', 'wpautop' ) ) {
    					add_filter( 'the_content', 'wpautop' );
    				}
    
    				if ( ! has_filter( 'the_excerpt', 'wpautop' ) ) {
    					add_filter( 'the_excerpt', 'wpautop' );
    				}
    			}
    		}
    #1299348
    Andras
    Keymaster

    Hey Lou,

    Thanks for using our plugins and welcome to the forums!

    I’m sorry about this issue and the conflict with the wpautop pluign, that is unfortunate.

    The code you shared gave me an idea. It might be enough to write a snippet into your functions.php file that checks if you are on the community events edit page (tribe_is_community_edit_event_page), and if yes, then simply do the remove_filters.

    Does this help you get started? Let me know.

    Cheers,
    Andras

    #1299387
    Lou
    Participant

    I will try this. I’m a bit murky about what happens when and how to hook my function in, but I will do some research. I will report back my results.

    #1299575
    Lou
    Participant

    Thanks for the idea. I was able to resolve the conflict by adding the following code in my theme’s functions.php file. Note I could do this only because I have complete control of my theme. Casual theme and plugin users would have to figure out another way to get this workaround into their system.

    /**
     * Detect plugin. For use on Front End only. See https://codex.wordpress.org/Function_Reference/is_plugin_active
     */
    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    /* 
    ** Special processing to avoid conflicts between Toggle wpautop and The Events Calendar Community Events.
    ** An alternate solution would be to make this occur first and update_post_meta( $post_id, '_lp_disable_wpautop', 1 ) 
    ** but that is a bit less direct. However this assumes understanding of Toggle wpautop internals.
    */
    if ( is_plugin_active('toggle-wpautop/toggle-wpautop.php') 
    		&& is_plugin_active('the-events-calendar-community-events/tribe-community-events.php') ) {
    	if ( ! function_exists( 'steeps_the_post' ) ) :
    	function steeps_the_post( $post ) {
    		// remove wpautop for tribe community events
    		// without this extra <p> tags are generated in these pages by Toggle wpautop plugin, causing javascript errors
    		if ( tribe_is_community_edit_event_page () ) {
    			remove_filter( 'the_content', 'wpautop' );
    			remove_filter( 'the_excerpt', 'wpautop' );
    		}
    	}
    	add_action( 'the_post', 'steeps_the_post', 11 );	// needs to be higher priority than the_post in LP_Toggle_wpautop.__construct
    	endif; // steeps_the_post
    }
    #1299658
    Lou
    Participant

    Actually https://sandbox.steeplechasers.org/events/community/list was garbled with a lot of extra [br] tags. I had to modify my code to check for tribe_is_community_my_events_page() as well.

    /**
     * Detect plugin. For use on Front End only. See https://codex.wordpress.org/Function_Reference/is_plugin_active
     */
    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
    /**
     * Special processing to avoid conflicts between Toggle wpautop and The Events Calendar Community Events.
     * An alternate solution would be to make this occur first and update_post_meta( $post_id, '_lp_disable_wpautop', 1 ) 
     * but that is a bit less direct. However this assumes understanding of Toggle wpautop internals.
     */
    if ( is_plugin_active('toggle-wpautop/toggle-wpautop.php') 
    		&& is_plugin_active('the-events-calendar-community-events/tribe-community-events.php') ) {
    	if ( ! function_exists( 'steeps_the_post' ) ) :
    	function steeps_the_post( $post ) {
    		// remove wpautop for tribe community events
    		// without this extra <p> tags are generated in these pages by Toggle wpautop plugin, causing javascript errors
    		if ( tribe_is_community_edit_event_page() || tribe_is_community_my_events_page() ) {
    			remove_filter( 'the_content', 'wpautop' );
    			remove_filter( 'the_excerpt', 'wpautop' );
    		}
    	}
    	endif; // steeps_the_post
    	add_action( 'the_post', 'steeps_the_post', 11 );	// needs to be higher priority than the_post in LP_Toggle_wpautop.__construct
    }
    #1300235
    Andras
    Keymaster

    Lou, I’m stoked to hear you managed to fix it. This is awesome!

    Thanks for sharing your solution!

    Since the issue seems resolved I am going to close this ticket, but if you need anything else related to this topic or another please post a new one in the forum and we will be happy to help you out.

    Good luck with your project!

    Cheers,
    Andras

    PS: If you like our plugins, and you didn’t yet do so 🙂 we would be happy to receive a review in the wordpress.org repository. Thanks!
    https://wordpress.org/support/plugin/the-events-calendar/reviews/

    PS2: We’d be also grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Doublethanks!

     

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Conflict with 'Toggle wpautop' plugin makes Community Events unusable’ is closed to new replies.