Plugin Directory

Changeset 715058


Ignore:
Timestamp:
05/18/2013 09:08:32 PM (13 years ago)
Author:
zslabs
Message:

1.2.2 Push

Location:
roots-plug/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • roots-plug/trunk/RootsPlug/Cleanup.php

    r708057 r715058  
    6060        add_filter( 'dynamic_sidebar_params', array( $this, 'widget_first_last_classes' ) );
    6161        add_filter( 'template_redirect', array( $this, 'search_redirect' ) );
     62        add_filter( 'img_caption_shortcode', array( $this, 'image_caption_cleanup' ), 10, 3 );
    6263
    6364        if ( !( is_admin() || in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) ) {
     
    105106    public function clean_style_tag( $input ) {
    106107
    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 );
    108109        // Only display media if it's print
    109110        $media = $matches[3][0] === 'print' ? ' media="print"' : '';
     
    160161    public function root_relative_url( $input ) {
    161162
    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        }
    165170    }
    166171
     
    309314
    310315    /**
     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    /**
    311353     * Helper method to parse multiple filters from array
    312354     * @param array $tags
  • roots-plug/trunk/readme.txt

    r708059 r715058  
    55Requires at least: 3.5
    66Tested up to: 3.5
    7 Stable tag: 1.2.1
     7Stable tag: 1.2.2
    88License: GPLv2
    99
     
    3030
    3131== Changelog ==
     32
     33= 1.2.2 =
     34* Updated relative URL function (for external URLs)
     35* Image caption shortcode cleanup (removed inline width attribute)
    3236
    3337= 1.2.1 =
  • roots-plug/trunk/roots-plug.php

    r708059 r715058  
    44Plugin URI: http://zslabs.com
    55Description: Base plugin
    6 Version: 1.2.1
     6Version: 1.2.2
    77Author: Zach Schnackel
    88Author URI: http://zslabs.com
     
    7373     * @var string
    7474     */
    75     public $version = '1.2.1';
     75    public $version = '1.2.2';
    7676
    7777    /**
Note: See TracChangeset for help on using the changeset viewer.