• Resolved knievel

    (@knievel)


    Hi there,

    we have installed the events calendar community plugin and could not get the picture upload to work, due to p tags being inserted inside onpage javascript.

    After some research we detected that the cause for this is the following code in BadgeOS file content-filters.php from line 115 on:

    function badgeos_reformat_entries( $content ) {
    
            wp_enqueue_style( 'badgeos-front' );
    
            $badge_id = get_the_ID();
    
            // filter, but only on the main loop!
            if ( !badgeos_is_main_loop( $badge_id ) )
                   return wpautop( $content );
    

    Right now we just removed the wpautop function around the returned content and the picture upload now works fine.

    Are you aware of this behaviour and is there any chance of a fix?

    • This topic was modified 4 years, 8 months ago by knievel.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author learningtimes

    (@learningtimes)

    Hi @knievel

    We have double-checked the BadgeOS plugin with the Event Calender and found it is working fine. However, Event Calender Community is a premium add-on and we don’t have access to it. It would be easy to diagnose the issue if you can elaborate the issue a bit more by providing the exact error from error log.

    Thanks

    Thread Starter knievel

    (@knievel)

    Hi @learningtimes,

    thanks for your response.

    These are errors in the console:
    add:2432 Uncaught SyntaxError: Unexpected token ‘<‘
    add:2558 Uncaught SyntaxError: Unexpected token ‘<‘

    The source code of the events community plugins edit page looks like this:

    
    <p><script>
    ( function( $ ) {
    	$('#event_tribe_venue').on( 'blur', '.linked-post-name', function () {
    		var input = $(this);
    		var group = input.parents('tbody');</p>
    <p>		// Not actually populated with anything? Don't bother validating
    		if ( ! input.val().length ) {
    			return;
    		}</p>
    <p>		$.post( TEC.ajaxurl, {
    				action: 'tribe_event_validation',
    				nonce: '1d79a4f898',
    				type: 'tribe_venue',
    				name: input.val()
    			},
    			function ( result ) {
    				if ( 1 == result ) {
    					group.find('.tribe-tribe_venue-error').remove();
    				} else {
    					group.find('.tribe-tribe_venue-error').remove();
    					input.after('</p>
    <div class="tribe-tribe_venue-error error form-invalid">Veranstaltungsort Name existiert bereits</div>
    <p>');
    				}
    			}
    		);
    	})
    } )( jQuery );
    </script><br />
    

    As you can see there are <p> tags inserted all over the place.
    When deactivating badgeos everything works fine again.
    I suppose you shouldn’t always use wpautop on the content, even if it is not the badgeos main loop, but eventually this could also be a problem of the events community plugin.

    Anyway I have dug a little bit deeper into this, cause my first solution needed to alter the code of the badgeos plugin which always is bad and it also removed paragraphs on single event pages.

    So I finally went with this snippet in my childs theme functions.php:

    
    /**
     * avoid conflict between badgeos and events calendar community plugin
     */
    if (
        is_plugin_active( 'badgeos/badgeos.php' ) &&
        is_plugin_active( 'the-events-calendar-community-events/tribe-community-events.php' )
    ) :
            if ( ! function_exists( 'tribe_events_community_wpautop_fix' ) ) :
            function tribe_events_community_wpautop_fix( $content ) {
                    // remove the filter set by badgeos when on event community pages
                    if ( tribe_is_community_edit_event_page() || tribe_is_community_my_events_page() ) :
                            remove_filter( 'the_content', 'badgeos_reformat_entries', 9 );
                    endif;
                    return $content;
            }
            endif;
            add_filter( 'the_content', 'tribe_events_community_wpautop_fix', 10 );
    endif;
    

    This simply adds another filter for the_content which removes the one that badgeos has set but only for the pages of the events community plugin.

    Plugin Author learningtimes

    (@learningtimes)

    Hi @knievel

    Thanks for sharing the details.

    It seems that the code from the calendar community add-on should be updated as adding <p> tags using javascript code is not a good idea. It may have conflicts with other plugins too.
    As far as the BadgeOS is concerned, we can’t remove the wpautop function because WordPress uses this functions in default and removing this functions may creates lots of layout issues for users. The possible solution is to remove the wpautop function for the specific page and that’s what you did.

    Thanks

    Plugin Author learningtimes

    (@learningtimes)

    Hi @knievel

    Since we have not heard from you in a while, we are now closing this thread. If you still need help, don’t hesitate to let us know.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wpautop breaks other plugins’ is closed to new replies.