Plugin Directory

Changeset 5078


Ignore:
Timestamp:
02/12/2006 02:10:19 AM (21 years ago)
Author:
doryphores
Message:

Modified regular expression to allow for extra attributes in link tags when using "replace all mp3 links option"

Also fixed a problem with clip sequences and ap_instances array
Issue : 36,37

File:
1 edited

Legend:

Unmodified
Added
Removed
  • audio-player/trunk/plugin/audio-player.php

    r5007 r5078  
    173173
    174174        // Replace mp3 links
    175         if( in_array( "links", $ap_behaviour ) ) $content = preg_replace_callback( "/<a href=\"([^\"]+\.mp3)\">[^<]+<\/a>/", "ap_replace", $content );
     175        if( in_array( "links", $ap_behaviour ) ) $content = preg_replace_callback( "/<a ([^=]+=\"[^\"]+\" )*href=\"([^\"]+\.mp3)\"( [^=]+=\"[^\"]+\")*>[^<]+<\/a>/", "ap_replace", $content );
    176176       
    177177        // Replace [audio syntax]
    178         if( in_array( "default", $ap_behaviour ) ) $content = preg_replace_callback( "/\[audio:([^]]+)]/", "ap_replace", $content );
     178        if( in_array( "default", $ap_behaviour ) ) $content = preg_replace_callback( "/\[audio:(([^]]+))]/", "ap_replace", $content );
    179179
    180180        // Enclosure integration
    … …  
    187187                $postfixAudio = get_option( "audio_player_postfixaudio" );
    188188                if( $postfixAudio != "" ) $postfixAudio = "," . $postfixAudio;
    189        
     189
    190190                if( count($enclosure) > 0 ) {
    191191                        for($i = 0;$i < count($enclosure);$i++) {
    … …  
    204204function ap_replace($matches) {
    205205        global $ap_audioURL, $ap_instances;
    206         // Split optins
    207         $data = preg_split("/[\|\¦]/", $matches[1]);
     206        // Split options
     207        $data = preg_split("/[\|]/", $matches[2]);
    208208        $files = array();
    209209       
    … …  
    216216        // If file doesn't start with http://, assume it is in the default audio folder
    217217        foreach( explode( ",", $data[0] ) as $afile ) {
    218                 if(strpos($afile, "http://") !== 0) array_push( $files, $ap_audioURL . "/" . $afile );
    219                 else array_push( $files, $afile );
     218                if(strpos($afile, "http://") !== 0) $afile = $ap_audioURL . "/" . $afile;
     219                array_push( $files, $afile );
     220
     221                // Add source file to instances already added to the post
     222                array_push( $ap_instances, $afile );
    220223        }
    221224
    … …  
    235238        }
    236239       
    237         // Add source file to instances already added to the post
    238         array_push( $ap_instances, $file );
    239 
    240240        // Return player instance code
    241241        return ap_getplayer( $file, $options );
Note: See TracChangeset for help on using the changeset viewer.