Changeset 1156333
- Timestamp:
- 05/08/2015 04:43:08 PM (11 years ago)
- Location:
- wpautop-control/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
wpautop-control.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpautop-control/trunk/readme.txt
r655413 r1156333 2 2 3 3 Contributors: bigsmoke 4 Donate link: http://www.bi smoke.us/donate/4 Donate link: http://www.bigsmoke.us/donate/ 5 5 Tags: wpautop, filter 6 6 Requires at least: 3.0 7 Tested up to: 3.2.18 Stable tag: 1. 37 Tested up to: 4.2.2 8 Stable tag: 1.4 9 9 10 10 Adds a global setting to turn the wpautop filter on and off. It also allows you to override this default for any post by adding a wpautop custom field. … … 29 29 You can set the field's value to `true`, `yes` or `on` if you do want WordPress to use its `wpautop` filter to add `<p>` and `<br>` tags for you. (Of course, this only makes sense if you've globally disabled `wpautop` in the included option screen.) 30 30 31 = How do I turn of line-end break insertions? = 32 33 Set the field's value to '-break' to just disable the conversion of newlines to `<br/>` tags within paragraphs. 34 35 31 36 == Changelog == 37 38 = 1.4 = 39 * Jesse Jacobson contributed a new feature, which disables only the conversion of newlines into `<br/>` tags within paragraphs. This is useful, for example, when writing Markdown with a text editor like Vim. 32 40 33 41 = 1.3 = -
wpautop-control/trunk/wpautop-control.php
r367680 r1156333 4 4 Plugin URI: http://blog.bigsmoke.us/tag/wpautop-control/ 5 5 Description: This plugin allows you fine control of when and when not to enable the wpautop filter on posts. 6 Author: Rowan Rodrik van der Molen 7 Author URI: http://blog.bigsmoke.us /8 Version: 1. 06 Author: Rowan Rodrik van der Molen, Jesse Jacobsen <jmatjac@gmail.com>. 7 Author URI: http://blog.bigsmoke.us 8 Version: 1.4 9 9 */ 10 10 … … 29 29 <?php settings_fields('wpautop-control') ?> 30 30 31 <p>Normally, WordPress filters your posts' content using the wpautop filter. Roughly, what this filter does is that it replaces newlines and empty lines with <tt><br /></tt> or <tt><p></tt>. The setting below lets you turn this filter on or off. (You can later override it on a post-by-post basis by setting the wpautop custom field to ‘true’ or ‘false’.)</p>31 <p>Normally, WordPress filters your posts' content using the wpautop filter. What this filter does is that it replaces single newlines with <tt><br /></tt> and empty lines with <tt><p></tt>. The setting below lets you turn this filter on or off. (You can later override it on a post-by-post basis by setting the wpautop custom field to ‘default’, ‘-breaks’, or ‘off’.)</p> 32 32 33 33 <table class="form-table"> … … 35 35 <th scope="row">wpautop filter on by default?</th> 36 36 <td> 37 <label><input type="radio" name="wpautop_on_by_default" value="1" <?php if ( get_option('wpautop_on_by_default') == '1' ) echo 'checked="1"' ?>> yes <small>(WordPress' default behaviour)</small></label><br /> 38 <label><input type="radio" name="wpautop_on_by_default" value="0" <?php if ( get_option('wpautop_on_by_default') == '0' ) echo 'checked="1"' ?>> no <small>(turn of WordPress' auto-formatting, except for selected posts)</small></label> 37 <label><input type="radio" name="wpautop_by_default" value="default" <?php if ( get_option('wpautop_by_default') == 'default' ) echo 'checked="1"' ?>> default <small>(WordPress' default behaviour)</small></label><br /> 38 <label><input type="radio" name="wpautop_by_default" value="-breaks" <?php if ( get_option('wpautop_by_default') == '-breaks' ) echo 'checked="1"' ?>> -breaks <small>(turn off WordPress' line breaks)</small></label><br /> 39 <label><input type="radio" name="wpautop_by_default" value="off" <?php if ( get_option('wpautop_by_default') == 'off' ) echo 'checked="1"' ?>> off <small>(turn off WordPress' auto-formatting)</small></label> 39 40 </td> 40 41 </table> … … 49 50 50 51 function wpautop_control_settings() { 51 register_setting('wpautop-control', 'wpautop_ on_by_default', 'intval');52 register_setting('wpautop-control', 'wpautop_by_default'); 52 53 } 53 54 } … … 61 62 $post_wpautop_value = get_post_meta($post->ID, 'wpautop', true); 62 63 63 $default_wpautop_value = intval( get_option('wpautop_on_by_default', '1'));64 $default_wpautop_value = get_option('wpautop_by_default', 'default'); 64 65 65 66 $remove_filter = false; 66 if ( empty($post_wpautop_value) ) 67 $remove_filter = ! $default_wpautop_value; 68 elseif ( in_array($post_wpautop_value, array('true', 'on', 'yes')) ) 69 $remove_filter = false; 70 elseif ( in_array($post_wpautop_value, array('false', 'off', 'no')) ) 71 $remove_filter = true; 67 if ( empty($post_wpautop_value) || ! in_array($post_wpautop_value, array( "default", "-breaks", "off") ) ) 68 $filter_type = $default_wpautop_value; 69 else 70 $filter_type = $post_wpautop_value; 72 71 73 if ( $remove_filter ) { 72 if ( $filter_type == "default" ) { 73 // Leave WordPress wpautop behavior in place 74 } elseif ( $filter_type == "-breaks" ) { 75 // Remove the wpautop filter and install our own 76 remove_filter('the_content', 'wpautop'); 77 remove_filter('the_excerpt', 'wpautop'); 78 add_filter('the_content', function ($pee) { return wpautop($pee, false); } ); 79 add_filter('the_excerpt', function ($pee) { return wpautop($pee, false); } ); 80 } elseif ( $filter_type == "off" ) { 81 // Remove the wpautop filter completely 74 82 remove_filter('the_content', 'wpautop'); 75 83 remove_filter('the_excerpt', 'wpautop');
Note: See TracChangeset
for help on using the changeset viewer.