內容簡介
WordPress本身提供了將下載檔案附加到頁面的功能,但不會記錄有關這些下載的統計資訊,因此我編寫了這個外掛程式。
我應該提到,統計資訊只是另一個下載計數器的大詞,因為這是這個外掛程式的主要目的。
功能:
跟踪某个文件的下載次數。
跟踪最後的下載時間
允许您重置计数器
允许您添加计数器到内部和外部URL
可以使用时尚的URL(如/downloads/file.zip)
可以在文章中印出下載次數、檔案大小和上次修改日期。
任意节
在文章中使用标签
在撰写文章或页面时,您可能希望在文章中添加URL或下載次数。使用[ download(downloadname) ](不包括空格)将替换为下载URL,[ downloadcounter(downloadname) ]将替换为下载次数,[ downloadsize(downloadname) ]将打印下载的大小(GB、MB、KB或B),[ downloadupdated(downloadname) ] 将打印上次修改日期,使用您已指定的WordPress设置日期格式。创建超链接时,您可以例如使用Download(当然,再次强调,中括号内不带空格)。
最后,使用downloadsize或downloadupdated时,您可以指定一个额外的参数。使用downloadsize,您可以添加,false以防止使用GB、MB、kB或B后缀。例如,使用[ downloadsize(file.zip, false)]将只显示字节大小。与downloadupdated一起使用时,您可以输入PHP日期格式字符串作为额外的参数。例如,[ downloadupdated(file.zip,d-m-Y)]将显示类似27-11-2008的日期。
从PHP检索下载信息
自0.6版以来,可以使用PHP获取有关下载的信息,因此可以直接在模板或自己的外掛程式中使用此信息。目前只有一个函数很重要:
download_information($download_name, $return_information = DOWNLOAD_URL | DOWNLOAD_AMOUNT)
此函数将返回一个包含所需信息的数组。您可以通过参数$return_information指定要返回的信息。文件downloadcounter-options.php包含正确的define语句,可供使用。目前仅可用URL、Amount、Size和Last Modified Date。
使用代码
$info = download_information(wp-downloadcounter.zip, DOWNLOAD_URL | DOWNLOAD_AMOUNT | DOWNLOAD_SIZE | DOWNLOAD_LASTMODIFIED);
var_dump($info);
返回:
array(4) { ["url"]=> string(73) "http://projects.bovendeur.org/downloads/wp-downloadcounter.zip" ["amount"]=> string(4) "1878" ["size"]=> int(11006) ["lastmodified"]=> int(1228157426) }
外掛標籤
開發者團隊
原文外掛簡介
Since WordPress does offer attaching downloads to pages, but doesn’t keep track of statistical information about these downloads, I wrote this plugin.
I should mention statistical information is a big word for just another download counter, since that is main purpose of this plugin.
Features:
Keeps track of the amount of downloads of a certain file.
Keeps track of the last download time
Allows you to reset the counter
Allows you to add counters to both internal and external urls
Can use fancy urls (like /downloads/file.zip)
Can print the amount of downloads, the filesize and the last modified date in a post.
Arbitrary section
Using tags in your posts
When writing a post or a page, you may want to add the URL or the amount of downloads in your post. Using [ download(downloadname) ] (without the spaces) will be replaced with the download url, [ downloadcounter(downloadname) ] will be replaced with the amount of downloads, [ downloadsize(downloadname) ] will print the size of the download (in GB, MB, kB or B), [ downloadupdated(downloadname) ] will print the last modified date, using the WordPress setting you’ve specified for the date format. When creating a link, you could, for instance, use Download (of course, again, without the spaces within the [] brackets).
Finally, when using downloadsize of downloadupdated, you can specify one extra argument. With downloadsize, you can add ,false to prevent the usage of the GB, MB, kB or B postfixes. So, for example, using [ downloadsize(file.zip, false) ] will just display the size in bytes. With downloadupdated, you can enter a PHP date format string as extra argument. For example, [ downloadupdated(file.zip, d-m-Y) ] will display a date like 27-11-2008.
Retrieving download information from PHP
Since version 0.6 is it possible to get information about the downloads using PHP, so you can use this information directly in your templates or in you own plugins. Only one function is important at the moment:
download_information($download_name, $return_information = DOWNLOAD_URL | DOWNLOAD_AMOUNT)
This function will return an array with the requested information. You can specify what information to return by the argument $return_information. The file downloadcounter-options.php contains the correct define statements which can be used. Currently only URL, Amount, Size and Last Modified Date are available.
Using the code
$info = download_information(wp-downloadcounter.zip, DOWNLOAD_URL | DOWNLOAD_AMOUNT | DOWNLOAD_SIZE | DOWNLOAD_LASTMODIFIED);
var_dump($info);
returns:
array(4) { ["url"]=> string(73) "http://projects.bovendeur.org/downloads/wp-downloadcounter.zip" ["amount"]=> string(4) "1878" ["size"]=> int(11006) ["lastmodified"]=> int(1228157426) }
