Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created June 14, 2012 10:33
Show Gist options
  • Save mattboon/2929500 to your computer and use it in GitHub Desktop.
Save mattboon/2929500 to your computer and use it in GitHub Desktop.
WordPress - Remove inline CSS from .wp-caption (plugin)
<?php
/*
Plugin Name: FixWpCaption
Plugin URI: #
Description: Removes inline CSS from .wp-caption
*/
class FixWpCaption{
public function __construct(){
add_filter('img_caption_shortcode', array($this, 'fixcaption'), 10, 3);
}
public function fixcaption($x=null, $attr, $content){
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) ) {
return $content;
}
return '<aside class="wp-caption ' . $align . '">'
. $content . '<p class="wp-caption-text">' . $caption . '</p></aside>';
}
}
$FixWpCaption = new FixWpCaption();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment