Show
Ignore:
Timestamp:
09/04/08 11:03:46 (4 months ago)
Author:
chrismeller
Message:

Added compatibility with the WP-Footnotes plugin, which uses different syntax. Thanks to Caius for the regex foo!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plugins/footnotes/trunk/footnotes.plugin.php

    r757 r890  
    1919class Footnotes extends Plugin 
    2020{ 
    21     const VERSION = '2.2'; 
     21    const VERSION = '2.3'; 
    2222    private $footnotes; 
    2323    private $current_id; 
     
    3434            'authorurl' => 'http://habariproject.org', 
    3535            'version' => self::VERSION, 
    36             'description' => 'Use footnotes in your posts. Syntax: <footnote>Your footnote</footnote>, wherever you want the reference point to be. Everything is done automatically. You can also cite a source using a url attribute like this <footnote url="http://foo.bar/foo/">Title</footnote>.', 
     36            'description' => 'Use footnotes in your posts. Syntax: <footnote>Your footnote</footnote>, wherever you want the reference point to be. Everything is done automatically. You can also cite a source using a url attribute like this <footnote url="http://foo.bar/foo/">Title</footnote>. Also now supports ((WP-Footnotes syntax, for compatibility.)).', 
    3737            'license' => 'Apache License 2.0' 
    3838        ); 
     
    7373 
    7474        // If there are no footnotes, save the trouble and just return it as is. 
    75         if ( strpos( $content, '<footnote' ) === false ) { 
     75        if ( strpos( $content, '<footnote' ) === false && strpos( $content, ' ((' ) === false ) { 
    7676            return $content; 
    7777        } 
     
    8181         
    8282        $this->post= $post; 
    83         $return = preg_replace_callback( '/<footnote(\s+url=[\'"].*[\'"])?>(.*)<\/footnote>/Us', array('self', 'add_footnote'), $content ); 
    84  
     83        $return = preg_replace_callback( '/(?:<footnote(\s+url=[\'"].*[\'"])?>|\s\(\()(.*)(?:\)\)|<\/footnote>)/Us', array('self', 'add_footnote'), $content ); 
     84         
    8585        if ( count( $this->footnotes ) == 0 ) { 
    8686            return $content;