Changeset 727581
- Timestamp:
- 06/17/2013 06:00:55 PM (13 years ago)
- Location:
- rich-tax-description-editor/trunk
- Files:
-
- 2 edited
-
main.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
rich-tax-description-editor/trunk/main.php
r727559 r727581 2 2 /* 3 3 Plugin Name: Rich Tax Description Editor 4 Plugin URI: http:// infinity-8.me4 Plugin URI: http://wordpress.org/support/plugin/rich-tax-description-editor 5 5 Description: Turns Description field on Taxonomy pages into the full scale Rich Text Editor. 6 Version: 1. 16 Version: 1.2 7 7 Author: Davit Barbakadze 8 Author URI: http:// profiles.wordpress.org/jayarjo8 Author URI: http://wordpress.org/support/profile/jayarjo 9 9 */ 10 10 11 11 require_once(dirname(__FILE__) . '/i8/class.Plugino.php'); 12 12 13 class RTE_Embed extends WP_Embed { 14 15 private $rte; 16 17 function __construct($rte) { 18 $this->rte = $rte; 19 parent::__construct(); 20 } 21 22 function shortcode( $attr, $url = '' ) { 23 global $rte; 24 25 if ( empty( $url ) ) 26 return ''; 27 28 $rawattr = $attr; 29 $attr = wp_parse_args( $attr, wp_embed_defaults() ); 30 31 // kses converts & into & and we need to undo this 32 // See http://core.trac.wordpress.org/ticket/11311 33 $url = str_replace( '&', '&', $url ); 34 35 // Look for known internal handlers 36 ksort( $this->handlers ); 37 foreach ( $this->handlers as $priority => $handlers ) { 38 foreach ( $handlers as $id => $handler ) { 39 if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { 40 if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) 41 return apply_filters( 'embed_handler_html', $return, $url, $attr ); 42 } 43 } 44 } 45 46 // Check for a cached result (stored in the post meta) 47 $cachekey = '_oembed_' . md5( $url . serialize( $attr ) ); 48 if ( $this->usecache ) { 49 $cache = $this->rte->get_cache($cachekey); 50 51 // Failures are cached 52 if ( '{{unknown}}' === $cache ) 53 return $this->maybe_make_link( $url ); 54 55 if ( ! empty( $cache ) ) 56 return apply_filters( 'embed_oembed_html', $cache, $url, $attr); 57 } 58 59 // Use oEmbed to get the HTML 60 $attr['discover'] = ( apply_filters('embed_oembed_discover', false) && author_can( $post_ID, 'unfiltered_html' ) ); 61 $html = wp_oembed_get( $url, $attr ); 62 63 // Cache the result 64 $cache = ( $html ) ? $html : '{{unknown}}'; 65 $this->rte->set_cache($cachekey, $cache, 3600 * 24 * 7); // one day 66 67 // If there was a result, return it 68 if ( $html ) 69 return apply_filters( 'embed_oembed_html', $html, $url, $attr); 70 71 // Still unknown 72 return $this->maybe_make_link( $url ); 73 } 74 } 75 76 13 77 class RTE extends RTE_Plugino { 78 79 var $rte_embed; 14 80 15 81 function __construct() … … 20 86 $this->warn("<strong>{$this->info['Name']}</strong> requires <strong><i>wp_editor API</i></strong>, which seems to be not available in <i>your version</i> of WordPress. Make sure that you are running at least <strong><i>version 3.3</i></strong>.<br /><br /> Plugin will <strong><i>deactivate</i></strong> itself now!"); 21 87 } 88 89 $this->rte_embed = new RTE_Embed($this); 22 90 } 23 91 … … 30 98 add_action("{$tax}_edit_form", array($this, 'a_term_edit_form'), 10, 2); 31 99 } 100 101 // Hack to get the [embed] shortcode to run before wpautop() 102 add_filter('term_description', array($this->rte_embed, 'run_shortcode'), 8); 32 103 104 // Shortcode placeholder for strip_shortcodes() 105 add_shortcode('embed', '__return_false'); 106 107 // Attempts to embed all URLs in a post 108 add_filter('term_description', array($this->rte_embed, 'autoembed'), 8); 109 33 110 add_filter('term_description', 'do_shortcode'); 34 111 } … … 70 147 return $description; 71 148 } 72 149 150 73 151 // truncate term description 74 152 function f_10_3__get_terms($terms, $taxonomies, $args) … … 83 161 } 84 162 163 85 164 private function to_plain_text($text) 86 165 { -
rich-tax-description-editor/trunk/readme.txt
r727559 r727581 42 42 Truncate description on listing pages. 43 43 Process shortcodes. 44 45 = 1.2 = 46 Support oEmbed.
Note: See TracChangeset
for help on using the changeset viewer.