Reputation: 141
I am working on modifying a plugin for wordpress to better suit my needs, and I need to know exactly what this code does:
if ( $single_download['uniqueid'] == null )
$link[] = array( "url" => site_url( "?downloadid=" . $single_download['id'] ), "name" => $file_name );
else
$link[] = array( "url" => site_url( "?downloadid=" . $single_download['uniqueid'] ), "name" => $file_name );
If you would need more than just this code here, could you please just explain what it is doing as far as you can tell by the scope of the code I have provided. I am assuming it is combining the different items but I am nut sure.
Edit: Sorry I should have clarified I realize what the if statement is doing, I need to know what the other line of code does.
Upvotes: 0
Views: 105
Reputation: 28906
This is a statement populates an array ($link
) with values based on the result of a test.
If the value of $single_download['uniqueid']
is null, the value of $single_download['id'] is appended to a URL. If $single_download['uniqueid']
is not null, its value is appended to the URL.
In both cases, the resultant value of the URL is inserted into the array.
Upvotes: 2
Reputation: 12244
It seems to check for a uniqueid in $single_download and if it doesn't find it, it uses the "ID" instead of "UNIQUEID"
Thats all
Upvotes: 0
Reputation: 13630
It's just building the link array item based on whether there's a uniqueid or not.
I'm not familiar with the plugin, but the $link
array apparently holds the url to download a file. If the $single_download
array has a uniqueid key that is not null, then it uses that as the download id. Otherwise, it uses the value in the id key.
I'm assuming it creates a clickable link with the url
as the source of the href and name
is the text that is clickable.
Upvotes: 0
Reputation: 25205
the code is constructing an array using one of two possible locations in the "single_download" variable to use for the download id
Upvotes: 0