WordPress.org

Plugin Directory

Changeset 588000


Ignore:
Timestamp:
08/20/12 21:30:27 (20 months ago)
Author:
evansolomon
Message:

Better logic for setting a priority

  • Instead of potentially running kses earlier, run make_clickable later
File:
1 edited

Legend:

Unmodified
Added
Removed
  • oembed-in-comments/trunk/oembed-in-comments.php

    r587998 r588000  
    4141        global $wp_embed; 
    4242 
    43         // make_clickable breaks oEmbed regex 
     43        // wp_kses_post will clobber the markup that oEmbed gave us, make sure we go later 
     44        $kses = has_filter( 'comment_text', 'wp_kses_post' ); 
     45 
     46        // make_clickable breaks oEmbed regex, make sure we go earlier 
    4447        $clickable = has_filter( 'comment_text', 'make_clickable' ); 
    45         $priority = ( $clickable ) ? $clickable - 1 : 10; 
     48 
     49        if ( ! $kses ) { 
     50            $priority = ( $clickable ) ? $clickable - 1 : false; 
     51        } 
     52        elseif ( $clickable > $kses ) { 
     53            $priority = $kses; 
     54        } 
     55        else { 
     56            // Move make_clickable later 
     57            remove_filter( 'comment_text', 'make_clickable', $clickable ); 
     58            add_filter( 'comment_text', 'make_clickable', $kses + 1 ); 
     59 
     60            $priority = $kses; 
     61        } 
     62 
    4663        add_filter( 'comment_text', array( $wp_embed, 'autoembed' ), $priority ); 
    47  
    48         // wp_kses_post will clobber the markup that oEmbed gave us 
    49         $kses_filter = has_filter( 'comment_text', 'wp_kses_post' ); 
    50         if ( ! $kses_filter ) 
    51             return; 
    52  
    53         // Move wp_kses_post to before autoembed 
    54         remove_filter( 'comment_text', 'wp_kses_post', $kses_filter ); 
    55         add_filter( 'comment_text', 'wp_kses_post', $priority - 1 ); 
    5664    } 
    5765 
Note: See TracChangeset for help on using the changeset viewer.