Jump to content

Adding file within function without having to call file.


Recommended Posts


Hi all


i have stumbled across an issue and really need some help


i have got a function below which i am using in a wordpress plugin.


here is the code.

// Base function
function isd_s3player() {

// Plugin Url
$s3url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));

echo '<object type="application/x-shockwave-flash" data="'.$s3url.'dewplayer-playlist.swf" width="235" height="200" id="dewplayer" name="dewplayer">
    <param name="wmode" value="transparent" />
<param name="wmode" value="transparent" />
<param name="movie" value="'.$s3url.'dewplayer-playlist.swf" />
<param name="flashvars" value="showtime=true&autoreplay=true&xml='.$s3url.'playlist.php&autostart=1" />


ok the problem i am having is i cant passed the database variable to the playlist.php which the dewplayer needs to call within the function.


is their a way to somehow use or set the playlist.php in this function without having to call it seperatly???


Here is my playlist.php



$bucket	= get_option("isd-bucket");
$folder	= get_option("isd-folder");
//include the S3 class
if (!class_exists('S3'))require_once('s3/S3.php');

//AWS access info
if (!defined('awsAccessKey')) define('awsAccessKey', 'amazon key');
if (!defined('awsSecretKey')) define('awsSecretKey', 'amazon secret key');

//instantiate the class
$s3 = new S3(awsAccessKey, awsSecretKey);

// Get the contents of our bucket
$bucket_contents = $s3->getBucket($bucket,$folder);

header("Content-type: text/xml");
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$xml_output .= '<playlist version="1" xmlns="http://xspf.org/ns/0/">\n';
$xml_output .= "<trackList>\n";
foreach ($bucket_contents as $file){
$fname = $file['name'];
$furl = "http://$amazon_bucket.s3.amazonaws.com/".urlencode($fname);
if(preg_match("/\.mp3$/i", $furl))

 if (isset($outputted[$furl])) {

    $xml_output .= "\t<track>\n";
    $xml_output .= "\t\t<location>" . $furl . "</location>\n"; 

    $xml_output .= "\t\t<creator>" . $fname . "</creator>\n";
$xml_output .= "\t\t<album>" . $fname . "</album>\n";
$xml_output .= "\t\t<title>" .  basename($fname) . "</title>\n";
$xml_output .= "\t\t<annotation>I love this song</annotation>\n";
$xml_output .= "\t\t<duration>32000</duration>\n";
$xml_output .= "\t\t<image>covers/smetana.jpg</image>\n";
$xml_output .= "\t\t<info></info>\n";
$xml_output .= "\t\t<link>" . $furl . "</link>\n";
    $xml_output .= "\t</track>\n";
$outputted[$furl] = true;
$xml_output .= "</trackList>";
echo $xml_output;


ok so as you can see right at the top i am trying to grab two option from the database but it doesnt allow you to do it this way within wordpress.


So i guess what i am asking is their a way to completely skip the playlist.php file and do everything within the function???


Any help??

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.