Changeset 1045461
- Timestamp:
- 12/16/2014 05:34:55 AM (11 years ago)
- Location:
- post-thumbnail-extras
- Files:
-
- 6 edited
- 1 copied
-
tags/6.0 (copied) (copied from post-thumbnail-extras/trunk)
-
tags/6.0/README.txt (modified) (3 diffs)
-
tags/6.0/php/shortcode.php (modified) (2 diffs)
-
tags/6.0/post-thumbnail-extras.php (modified) (1 diff)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/php/shortcode.php (modified) (2 diffs)
-
trunk/post-thumbnail-extras.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
post-thumbnail-extras/tags/6.0/README.txt
r982766 r1045461 4 4 Tags: post-thumbnail, post thumbnail, featured image, awesome, media library, shortcode, shortcodes 5 5 Requires at least: 2.5 6 Tested up to: 4.0 6 Tested up to: 4.0.x 7 7 Stable tag: trunk 8 8 License: GPLv2 … … 55 55 == Changelog == 56 56 57 = 6.0 = 58 59 * Added `ptx_html_attrs` filter for modifying the html output 60 * Fixed the `shortcode_atts` so that the `shortcode_atts_ptx` filter will fire 61 57 62 = 5.0 = 58 63 … … 80 85 == Upgrade Notice == 81 86 82 = 5.0 =87 = 6.0 = 83 88 84 Upgrade for wordpress 3.8 and bug fixes89 Added some filters -
post-thumbnail-extras/tags/6.0/php/shortcode.php
r982765 r1045461 9 9 add_filter( 'image_size_names_choose', array( $this, 'image_sizes' ) ); 10 10 add_filter( 'wp_prepare_attachment_for_js', array( $this, 'fix_attachment' ), 10, 3 ); 11 add_filter( 'ptx_html_attrs', array( $this, 'html_attrs' ), 10, 2 ); 11 12 } 12 13 … … 23 24 public function parse_shortcode( $attrs ) { 24 25 $post = get_post(); 25 extract(shortcode_atts( array(26 $a = shortcode_atts( array( 26 27 'id' => get_post_thumbnail_id( $post->ID ), 27 28 'size' => 'thumbnail', 28 29 'class' => 'pt-post-thumbnail', 29 'link' => 'none' 30 ), $attrs ) ); 30 'link' => 'none', 31 'html_attrs' => 'class', // should be a list of attrs to look for (comma-separated) 32 ), $attrs, 'ptx' ); 31 33 32 if ( ! wp_attachment_is_image( $ id) ) return;34 if ( ! wp_attachment_is_image( $a['id'] ) ) return; 33 35 34 $html = wp_get_attachment_image( $id, $size, false, array( 'class' => $class ));36 $html_attrs = apply_filters('ptx_html_attrs', array(), $a); 35 37 36 switch( $link ) { 38 $html = wp_get_attachment_image( $a['id'], $a['size'], false, $html_attrs ); 39 40 switch( $a['link'] ) { 37 41 case 'none': 38 42 return $html; 39 43 break; 40 44 case 'file': 41 $link_url = wp_get_attachment_url( $ id);45 $link_url = wp_get_attachment_url( $a['id'] ); 42 46 break; 43 47 case 'post': 44 $link_url = get_attachment_link( $ id);48 $link_url = get_attachment_link( $a['id'] ); 45 49 break; 46 50 default: 47 $link_url = $ link;51 $link_url = $a['link']; 48 52 } 49 53 50 54 return "<a href='$link_url'>$html</a>"; 55 } 56 57 /** 58 * Add attributes to the html src 59 * @param $attrs that have been defined already 60 * @param $attrs defined from the shortcode 61 */ 62 public function html_attrs( $attrs, $shortcode_attrs ) { 63 foreach ( explode(',', $shortcode_attrs['html_attrs']) as $attr) { 64 if ( in_array( $attr, $shortcode_attrs ) ) { 65 $attrs[$attr] = $shortcode_attrs[$attr]; 66 } 67 } 68 return $attrs; 51 69 } 52 70 -
post-thumbnail-extras/tags/6.0/post-thumbnail-extras.php
r982765 r1045461 5 5 Author: sewpafly 6 6 Author URI: http://sewpafly.github.io/post-thumbnail-editor/ 7 Version: 5.17 Version: 6.0 8 8 Description: Little things that make using post thumbnails easier 9 9 */ -
post-thumbnail-extras/trunk/README.txt
r982766 r1045461 4 4 Tags: post-thumbnail, post thumbnail, featured image, awesome, media library, shortcode, shortcodes 5 5 Requires at least: 2.5 6 Tested up to: 4.0 6 Tested up to: 4.0.x 7 7 Stable tag: trunk 8 8 License: GPLv2 … … 55 55 == Changelog == 56 56 57 = 6.0 = 58 59 * Added `ptx_html_attrs` filter for modifying the html output 60 * Fixed the `shortcode_atts` so that the `shortcode_atts_ptx` filter will fire 61 57 62 = 5.0 = 58 63 … … 80 85 == Upgrade Notice == 81 86 82 = 5.0 =87 = 6.0 = 83 88 84 Upgrade for wordpress 3.8 and bug fixes89 Added some filters -
post-thumbnail-extras/trunk/php/shortcode.php
r982765 r1045461 9 9 add_filter( 'image_size_names_choose', array( $this, 'image_sizes' ) ); 10 10 add_filter( 'wp_prepare_attachment_for_js', array( $this, 'fix_attachment' ), 10, 3 ); 11 add_filter( 'ptx_html_attrs', array( $this, 'html_attrs' ), 10, 2 ); 11 12 } 12 13 … … 23 24 public function parse_shortcode( $attrs ) { 24 25 $post = get_post(); 25 extract(shortcode_atts( array(26 $a = shortcode_atts( array( 26 27 'id' => get_post_thumbnail_id( $post->ID ), 27 28 'size' => 'thumbnail', 28 29 'class' => 'pt-post-thumbnail', 29 'link' => 'none' 30 ), $attrs ) ); 30 'link' => 'none', 31 'html_attrs' => 'class', // should be a list of attrs to look for (comma-separated) 32 ), $attrs, 'ptx' ); 31 33 32 if ( ! wp_attachment_is_image( $ id) ) return;34 if ( ! wp_attachment_is_image( $a['id'] ) ) return; 33 35 34 $html = wp_get_attachment_image( $id, $size, false, array( 'class' => $class ));36 $html_attrs = apply_filters('ptx_html_attrs', array(), $a); 35 37 36 switch( $link ) { 38 $html = wp_get_attachment_image( $a['id'], $a['size'], false, $html_attrs ); 39 40 switch( $a['link'] ) { 37 41 case 'none': 38 42 return $html; 39 43 break; 40 44 case 'file': 41 $link_url = wp_get_attachment_url( $ id);45 $link_url = wp_get_attachment_url( $a['id'] ); 42 46 break; 43 47 case 'post': 44 $link_url = get_attachment_link( $ id);48 $link_url = get_attachment_link( $a['id'] ); 45 49 break; 46 50 default: 47 $link_url = $ link;51 $link_url = $a['link']; 48 52 } 49 53 50 54 return "<a href='$link_url'>$html</a>"; 55 } 56 57 /** 58 * Add attributes to the html src 59 * @param $attrs that have been defined already 60 * @param $attrs defined from the shortcode 61 */ 62 public function html_attrs( $attrs, $shortcode_attrs ) { 63 foreach ( explode(',', $shortcode_attrs['html_attrs']) as $attr) { 64 if ( in_array( $attr, $shortcode_attrs ) ) { 65 $attrs[$attr] = $shortcode_attrs[$attr]; 66 } 67 } 68 return $attrs; 51 69 } 52 70 -
post-thumbnail-extras/trunk/post-thumbnail-extras.php
r982765 r1045461 5 5 Author: sewpafly 6 6 Author URI: http://sewpafly.github.io/post-thumbnail-editor/ 7 Version: 5.17 Version: 6.0 8 8 Description: Little things that make using post thumbnails easier 9 9 */
Note: See TracChangeset
for help on using the changeset viewer.