[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

bw_better_autop() – Improve wpautop and shortcode_unautop processing

You appear to be a bot. Output may be restricted

Description

Improve wpautop and shortcode_unautop processing

The purpose of this function is to defer wpautop filter processing until AFTER shortcodes are expanded By default the wpautop() filter is called at priority 10 and shortcode_unautop() is also called at priority 10 (see wp-include/default-filters.php ) do_shortcode() is called at priority 11 ( see wp-includes/shortcodes.php ) In certain circumstances wpautop() can really mess up the HTML that's generated by shortcodes such as [bw_css] since it will convert new line characters to <br /> tags I applied the suggestion from link http://stackoverflow.com/questions/5940854/disable-automatic-formatting-inside-wordpress-shortcodes but that caused WooCommerce's [add_to_cart] shortcode to fail since it created new line characters during the expansion which were then converted to unwanted paragraph end and start tags. I tried moving shortcode_unautop as well but that didn't help. A pragmatic solution for [add_to_cart] was to alter the WooCommerce code so that it doesn't create unnecessary new lines. That worked BUT the wpautop() processing still had problems with textarea tags with embedded new line characters. So the latest solution ( 2013/09/03) is to disable both wpautop() and shortcode_unautop(). and replace wpautop() by bw_wpautop() where newlines are NOT converted to breaks, performed AFTER shortcode expansion.

  1. /03/26 – And that still doesn't work when block tags (e.g div) are embedded within non-block tags ( e.g. a )
  2. /07/03 – Nor does it work when they are embedded within h3 tags!
  1. /08/26 – To allow DIY-oik shortcodes to work nicely the latest solution is that we initially disable wpautop processing
  2. and allow it to be re-introduced by using the [bw_autop] shortcode.

    Usage

    bw_better_autop( $autop );

    Parameters

    $autop
    ( bool ) optional – true if you want the bw_wpautop() filter to be run after shortcode expansion false if you want it to be removed again.

    Returns

    void

    Source

    File name: oik-css/oik-css.php
    Lines:

    1 to 49 of 49
    function bw_better_autop( $autop=false ) {
      remove_filter( 'the_content', 'wpautop' );
      remove_filter( 'the_content', 'shortcode_unautop' );
      remove_filter( 'the_content', 'wptexturize' );
      remove_filter( 'the_content', 'gutenberg_wpautop', 8 );
      //remove_filter( 'the_content', 'do_blocks', 9 );
      if ( !function_exists( "do_shortcode_earlier" ) ) {
        oik_require( "includes/shortcodes-earlier.php", "oik-css" );
      }
      oik_require( "includes/oik-filters.inc" );
      bw_replace_filter( "the_content", "do_shortcode", 11, "do_shortcode_earlier" );
      
      //add_filter( 'the_content', 'bw_tracef', 99 );
      if ( $autop ) {
        add_filter( 'the_content', 'bw_wpautop', 99);
      } else {
        remove_filter( 'the_content', 'bw_wpautop', 99 );
      } 
      //add_filter( 'the_content', 'bw_tracef', 100 );
      //add_filter( 'the_content', 'shortcode_unautop',100 );
      add_filter( 'no_texturize_shortcodes', "bw_no_texturize_shortcodes" );
      //add_filter( 'the_content', "bw_pre_texturize" );
      
      
      
    /**
     * Filter whether to skip running wptexturize().
     *
     * Passing false to the filter will effectively short-circuit wptexturize().
     * returning the original text passed to the function instead.
     *
     * The filter runs only once, the first time wptexturize() is called.
     *
     * @since 4.0.0
     *
     * @see wptexturize()
     *
     * @param bool $run_texturize Whether to short-circuit wptexturize().
     */
      $run_texturize = true; 
      $run_texturize = apply_filters( 'run_wptexturize', $run_texturize );
      if ( $run_texturize ) {
        if ( !function_exists( "wptexturize_blocks" ) ) {
          oik_require( "includes/formatting-later.php", "oik-css" );
        }  
        add_filter( 'the_content', "wptexturize_blocks", 98 );
        //add_filter( 'option_blogname', 'oik_css_pesky_shortcodes');
        //add_filter( 'oembed_response_data')
      }
    }
     

     View on GitHub View on Trac

Published: June 10, 2013 | Last updated: December 18, 2017

Information

Function name: bw_better_autop
Plugin ref: oik-css
Version: 1.1.1
Sourcefile: oik-css.php
File ref: oik-css.php
Deprecated?: No
API Letters: A,B

Recent plugin updates

oik-weight-zone-shipping v0.2.2 

Upgrade to oik-weight-zone-shipping v0.2.2 for internationalized strings for migration. This version may also resolve a problem where a Warning message is produced while listing Shipping classes.

 ...
oik-weight-zone-shipping v0.2.1 

oik-weight-zone-shipping v0.2.1 fixes a problem with v0.2.0 on worpress.org, where two new files weren't included in the SVN repository.

 ...
oik-weightcountry-shipping v1.4.0 

oik-weightcountry-shipping v1.4.0 has been tested with WordPress 5.6 and WooCommerce 4.8.0. It is no longer supported. We suggest you switch to the oik weight zone shipping plugin.

 ...
oik-weight-zone-shipping v0.2.0 

oik-weight-zone-shipping v0.2.0 now supports migration from oik weight/country shipping. You can create Multi Rate shipping tables and methods restricting shipping classes.

 ...
oik-css v1.1.1 

oik-css v1.1.1 contains an update for improved compatibility with Gutenberg. It has been tested with WordPress 5.6 and WordPress Multi Site.

 ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: [email protected]

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2021. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins