Changeset 1418979
- Timestamp:
- 05/17/2016 05:46:46 PM (10 years ago)
- Location:
- style-stripper/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
style-stripper.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
style-stripper/trunk/readme.txt
r1234393 r1418979 3 3 Tags: remove, delete, styles, inline styles, multisite 4 4 Requires at least: 3.0 5 Tested up to: 4. 35 Tested up to: 4.5.2 6 6 Stable tag: trunk 7 7 … … 17 17 18 18 == Changelog == 19 = 1.0.1 = 20 * Updated code to better adhere to WordPress coding standards. 21 19 22 = 1.0 = 20 23 * Initial release -
style-stripper/trunk/style-stripper.php
r553997 r1418979 5 5 Description: Removes all inline style tags from the content of posts/pages/custom post types. 6 6 Author: ericjuden 7 Version: 1.0 7 Version: 1.0.1 8 8 Author URI: http://ericjuden.com 9 9 Network: true … … 11 11 12 12 class Style_Stripper { 13 function __construct() {14 add_action( 'add_meta_boxes', array(&$this, 'show_filtered_content'), 1, 2);15 add_filter( 'the_content', array(&$this, 'filter_content'));13 function __construct() { 14 add_action( 'add_meta_boxes' , array( $this, 'show_filtered_content' ) , 1 , 2 ); 15 add_filter( 'the_content' , array( $this, 'filter_content' ) ); 16 16 } 17 17 18 function clean_content( $content){18 function clean_content( $content ) { 19 19 // Search $content for style='' and style="" and remove 20 $patterns = array( '/(<[^>]+) style=".*?"/i', "/(<[^>]+) style='.*?'/i");21 $content = preg_replace( $patterns, '$1', $content);20 $patterns = array( '/(<[^>]+) style=".*?"/i' , "/(<[^>]+) style='.*?'/i" ); 21 $content = preg_replace( $patterns , '$1' , $content ); 22 22 23 return apply_filters( 'style_stripper_strip_styles', $content);23 return apply_filters( 'style_stripper_strip_styles' , $content ); 24 24 } 25 25 26 function filter_content( $content){27 $content = $this->clean_content( $content);26 function filter_content( $content ) { 27 $content = $this->clean_content( $content ); 28 28 return $content; 29 29 } 30 30 31 function show_filtered_content( $post_type, $post){32 $post->post_content = $this->clean_content( $post->post_content);31 function show_filtered_content( $post_type , $post ) { 32 $post->post_content = $this->clean_content( $post->post_content ); 33 33 } 34 34 }
Note: See TracChangeset
for help on using the changeset viewer.