Changeset 715058
- Timestamp:
- 05/18/2013 09:08:32 PM (13 years ago)
- Location:
- roots-plug/trunk
- Files:
-
- 3 edited
-
RootsPlug/Cleanup.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
roots-plug.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
roots-plug/trunk/RootsPlug/Cleanup.php
r708057 r715058 60 60 add_filter( 'dynamic_sidebar_params', array( $this, 'widget_first_last_classes' ) ); 61 61 add_filter( 'template_redirect', array( $this, 'search_redirect' ) ); 62 add_filter( 'img_caption_shortcode', array( $this, 'image_caption_cleanup' ), 10, 3 ); 62 63 63 64 if ( !( is_admin() || in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) ) { … … 105 106 public function clean_style_tag( $input ) { 106 107 107 preg_match_all( "!<link rel='stylesheet'\s?(id='[^']+' )?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches );108 preg_match_all( "!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches ); 108 109 // Only display media if it's print 109 110 $media = $matches[3][0] === 'print' ? ' media="print"' : ''; … … 160 161 public function root_relative_url( $input ) { 161 162 162 $output = wp_make_link_relative($input); 163 164 return $output; 163 preg_match( '|https?://([^/]+)(/.*)|i', $input, $matches ); 164 165 if ( isset( $matches[1] ) && isset($matches[2] ) && $matches[1] === $_SERVER['SERVER_NAME'] ) { 166 return wp_make_link_relative( $input ); 167 } else { 168 return $input; 169 } 165 170 } 166 171 … … 309 314 310 315 /** 316 * Cleanup image caption shortocde to not include width in output 317 * @return void 318 * 319 * @since 1.2.2 320 */ 321 public function image_caption_cleanup( $output, $attr, $content ) { 322 if (is_feed()) { 323 return $output; 324 } 325 326 $defaults = array( 327 'id' => '', 328 'align' => 'alignnone', 329 'width' => '', 330 'caption' => '' 331 ); 332 333 $attr = shortcode_atts($defaults, $attr); 334 335 // If the width is less than 1 or there is no caption, return the content wrapped between the [caption] tags 336 if (1 > $attr['width'] || empty($attr['caption'])) { 337 return $content; 338 } 339 340 // Set up the attributes for the caption <figure> 341 $attributes = (!empty($attr['id']) ? ' id="' . esc_attr($attr['id']) . '"' : '' ); 342 $attributes .= ' class="thumbnail wp-caption ' . esc_attr($attr['align']) . '"'; 343 344 $output = '<figure' . $attributes .'>'; 345 $output .= do_shortcode($content); 346 $output .= '<figcaption class="caption wp-caption-text">' . $attr['caption'] . '</figcaption>'; 347 $output .= '</figure>'; 348 349 return $output; 350 } 351 352 /** 311 353 * Helper method to parse multiple filters from array 312 354 * @param array $tags -
roots-plug/trunk/readme.txt
r708059 r715058 5 5 Requires at least: 3.5 6 6 Tested up to: 3.5 7 Stable tag: 1.2. 17 Stable tag: 1.2.2 8 8 License: GPLv2 9 9 … … 30 30 31 31 == Changelog == 32 33 = 1.2.2 = 34 * Updated relative URL function (for external URLs) 35 * Image caption shortcode cleanup (removed inline width attribute) 32 36 33 37 = 1.2.1 = -
roots-plug/trunk/roots-plug.php
r708059 r715058 4 4 Plugin URI: http://zslabs.com 5 5 Description: Base plugin 6 Version: 1.2. 16 Version: 1.2.2 7 7 Author: Zach Schnackel 8 8 Author URI: http://zslabs.com … … 73 73 * @var string 74 74 */ 75 public $version = '1.2. 1';75 public $version = '1.2.2'; 76 76 77 77 /**
Note: See TracChangeset
for help on using the changeset viewer.