• Resolved davidj0n

    (@davidj0n)


    Hi,

    First off. I want to thank you for this wonderful plugin. I’ve been searching a while for the ability to add custom widgets to a page. And your plugin works great!

    There is only one bug annoying me. Somehow widgets add an <p> randomly to my custom widgets. Which sometimes runes my layout. I already tried remove_filter(‘wpautop’); but that didnt help me. Do you have any idea how to fix this, or a workaround. I’ve been browsing the support discussion list but havent found a valueable solution.

    Any help would GREATLY be appreciated.

    FYI. i’m using version 1.4.5 of the siteorigins panel plugin and working on the latst (3.8.1) wordpress installation.

    https://www.ads-software.com/plugins/siteorigin-panels/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter davidj0n

    (@davidj0n)

    Incase anyone is facing the same problems. It looks like cracked the puzzle.

    What I did was add this code to my functions.php

    function my_formatter($content) {
    		       $new_content = '';
    		       $pattern_full = '{(\[raw\].*?\[/raw\])}is';
    		       $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
    		       $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
    
    		       foreach ($pieces as $piece) {
    		               if (preg_match($pattern_contents, $piece, $matches)) {
    		                       $new_content .= $matches[1];
    		               } else {
    		                       $new_content .= wptexturize(wpautop($piece));
    		               }
    		       }
    
    		       return $new_content;
    		}
    
    		remove_filter('the_content', 'wpautop');
    		remove_filter('the_content', 'wptexturize');
    
    		add_filter('the_content', 'my_formatter', 99);

    In the above code (CSS-tricks) I check if there is a [raw][/raw] wrapper the content, if so remove auto p. Otherwise keep it like wordpress renders is.

    Then I changed a little thing in the plugin, in the function ‘siteorigin_panels_filter_content’ in siteorigin-panels.php near : 569 to this.

    function siteorigin_panels_filter_content( $content ) {
    	global $post;
    
    	if ( empty( $post ) ) return $content;
    	if ( in_array( $post->post_type, siteorigin_panels_setting('post-types') ) ) {
    
    		//wrapped the rendering from panels with a raw tag, so the auto p's go to hell!
    		$panel_content = '[raw]'.siteorigin_panels_render( $post->ID ).'[/raw]';
    
    		if ( !empty( $panel_content ) ) $content = $panel_content;
    	}
    
    	return $content;
    
    }
    
    add_filter( 'the_content', 'siteorigin_panels_filter_content' );

    Hope I helped out anyone trying to crack the puzzle.

    Again, thanks for a wonderful plugin!

    Thread Starter davidj0n

    (@davidj0n)

    For anyone interested. I spoke too soon. The above changes to siteorigin-panels.php didn’t work as expected. I wrapped the [html][/html] tags too soon. In the above code a normal page (w/o panels) would not show. I first needed to check if rendered content came trough, if so. wrap it with the [html] tags.

    Code below seems to work like a charm.

    function siteorigin_panels_filter_content( $content ) {
    	global $post;
    
    	if ( empty( $post ) ) return $content;
    	if ( in_array( $post->post_type, siteorigin_panels_setting('post-types') ) ) {
    
    		$panel_content = siteorigin_panels_render( $post->ID );
    
    		// if there is panel content, wrap with html and output lovely clean HTML
    		if ( !empty( $panel_content ) ) $content = '[html]'.$panel_content.'[/html]';
    	}
    
    	return $content;
    
    }
    
    add_filter( 'the_content', 'siteorigin_panels_filter_content' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘automatic inserstion of paragraphs’ is closed to new replies.