• Resolved makbeta

    (@makbeta)


    I use the version 1.0 of the plugin in a WordPress 5.4.1 that’s running on the Classic Editor.

    Problem
    When I insert rows and column shorttags on a following line, the rendered code renders paragraphs between columns. When I insert extra spaces between tags, the tags are rendered correctly. Including details for replication below.

    Proposed Solutions
    1. Ideal solution would be for the plugin to always strip out paragraphs and new lines between columns.
    2. If the solution #1 is not an option please update TinyMCE plugin to render the tags with spacing that would generate accurate markup.

    Thank you.

    Problem replication
    When I use the editor plugin it gives me the following code:

    
    [GDC_row]
    [GDC_column size="third"]
    Your content here
    [/GDC_column]
    [GDC_column size="two-thirds"]
    Your content here
    [/GDC_column]
    [/GDC_row]
    

    Which renders as broken code:

    
    <div class="gdc_row"><p></p>
    <div class="gdc_column gdc_cthird">
    <div class="gdc_inner">
    Your content here
    </div>
    </div>
    <p></p>
    <div class="gdc_column gdc_ctwo-thirds">
    <div class="gdc_inner">
    Your content here
    </div>
    </div>
    <p>
    </p></div>
    

    However, when I update the short tags to have extra spaces:

    
    [GDC_row]
    
    [GDC_column size="third"]
    Your content here
    [/GDC_column]
    
    [GDC_column size="two-thirds"]
    Your content here
    [/GDC_column]
    
    [/GDC_row]
    

    The rendered HTML is correct:

    
    <div class="gdc_row">
    <div class="gdc_column gdc_cthird">
    <div class="gdc_inner">
    Your content here
    </div>
    </div>
    <div class="gdc_column gdc_ctwo-thirds">
    <div class="gdc_inner">
    Your content here
    </div>
    </div>
    </div>
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WP Darko

    (@spwebguy)

    Hello there,

    You might want to take a look at this:
    https://wpcrux.com/blog/disable-wpautop/

    You can disable auto paragraphs in WordPress. Our plugin isn’t adding p tags for you.

    Hope this helps, keep me posted.

    Thread Starter makbeta

    (@makbeta)

    Dear @spwebguy,

    While the plugin is not inserting paragraphs the inserted code doesn’t work with the default WordPress configuration when the wpautop is enabled. As mentioned above the plugin seems to handle one configuration of new lines better than others. And it’s the code that is inserted by the plugin that fails to be properly rendered.

    Sadly, disabling the auto paragraphs is not a viable solution because it will break the display of the content on the existing site. Also, what if the users decide to insert multiple paragraphs in a column? By default, p tags are not inserted by the WordPress classic editor. So the use of the plugin becomes more and more difficult. Since the plugin doesn’t work as designed out of box it may result in a low adoption rates and eventually obsolescence.

    What I propose is to solve the problem so the plugin works as expected out of the box, not requiring two to three additional workarounds to be implemented by a developer.

    **Proposed solution**
    Before the shortcodes are replaced, the plugin should strip out all the white spaces between [GD_] & [/GD_] shortcuts. The spaces everywhere else should be kept intact. This should ensure that all columns are rendered without any extra markup between then.

    I can also write a code snippet for the solution, if that helps. I could apply the solution to the work I’m doing. However, that would prevent the site I’m working on from receiving updates for the plugin. I suspect that many other people will run into the same problem and I want to make sure that it’s solved for all the people and this plugin has a good and long life.

    Thank you for your consideration.

    • This reply was modified 4 years, 6 months ago by makbeta.
    Plugin Author WP Darko

    (@spwebguy)

    Hello @makbeta,

    We do not have a lot of time to work on this plugin at the moment but what you say makes total sense. We clearly want to keep this plugin updated with the least friction possible for our users.

    What do you think about this: https://s000.tinyupload.com/download.php?file_id=69723356967052192163&t=6972335696705219216348563

    We’ve cleaned the content a little bit using the following:

    $output = strstr($output, '[GDC_');
    $output = preg_replace( "/<br \/>|<br>|<br >|\n/", "", $output );

    In the future we’d like to make this plugin simpler, I’m aware that there are better ways to handle this. If you would like to propose a solution (snippet) we’d be happy to take a look at it.

    Thank you for your feedback and the time spent writing these messages.

    Thread Starter makbeta

    (@makbeta)

    @spwebguy,

    Your solution didn’t quite work. I have spend a bit of time and it seems that the more precise regular expressions are needed to target only the space between tags.

    I am including the code below that worked for me. It removes all spacers between rows and columns, but keep line breaks within columns. Hope this helps.

    
    function gsc_row_sc( $atts, $content = null ) {
        $before_column_regex = '/^(\s*(<p>)*(<\/p>)*(<br \/>)*(<br>)*)*(\[GDC_column)/';
        $mid_column_regex = '/(\[\/GDC_column\])(\s*(<p>)*(<\/p>)*(<br \/>)*(<br>)*)*(\[GDC_column)/';
        $last_column_regex = '/(\[\/GDC_column\])(\s*(<p>)*(<\/p>)*(<br \/>)*(<br>)*)*$/';
    
        $new_content = trim(strstr($content, '[GDC_'));
        $new_content = preg_replace($before_column_regex, "$6", $new_content);
        $new_content = preg_replace($mid_column_regex, "$1$7", $new_content);
        $new_content = preg_replace($last_column_regex, "$1", $new_content);
        $output = '<div class="gdc_row">' . $new_content . '</div>';
    
        return do_shortcode($output);
    
    }
    
    Plugin Author WP Darko

    (@spwebguy)

    Hi @makbeta,

    We’ve tested this and it’s working pretty well. We’ve updated the code (version 1.1) and will improve this solution in the future (if need be).

    Thank you for your contribution, it is making the plugin better.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Automatic paragraphs are inserted around shorttags between columns’ is closed to new replies.