Using Template Tag Function in WordPress Extend Download Stat Plugin

Posted in Wordpress Development on 30 August 2009 1 comment

This page is created for WordPress Extend Download Stat plugin.

There are 2 functions available :

Function : wpeds_output()

Please read ” Using shortcode ” first to understand this page better.

Description

Allows you to output download stat in template files instead of using shortcode in post. It can accept argument in string or array and works exactly like the shortcode . Introduced in version 1.1

Usage
<?php 
if ( function_exists ( 'wpeds_output' ) ) {
wpeds_output($args);
}
?>
Parameters

url
(string) URL to the statistics page. Must be set.

format
(string) Format id. Default format will be used if you give an invalid format id.

get
(string) Get single info instead of using format.
Valid values : All available tags

autop
(string) Auto wrap the content with HTML paragraph <p> tag

  • true – default
  • false / 0 (to display content inline)

echo
(string) Show the result or keep it in a variable. Default is true.

  • 1 (true) – default
  • 0 (false)
Example of Usage

Display download stats using format id of 1

<?php 
if ( function_exists ( 'wpeds_output' ) ) {
wpeds_output( 'url=http://wordpress.org/extend/plugins/wordpress-theme-demo-bar/stats/&format=1' );
}
?>

Display number of download today (inline)

Wordpress Theme Demo Bar got <?php 
if ( function_exists ( 'wpeds_output' ) ) {
wpeds_output( 'url=http://wordpress.org/extend/plugins/wordpress-theme-demo-bar/stats/&get=today&autop=false' );
}
?> downloads today !!

Assign to variable

<?php 
if ( function_exists ( 'wpeds_output' ) ) {
$stored = wpeds_output( 'url=http://wordpress.org/extend/plugins/wordpress-theme-demo-bar/stats/&get=today&echo=0' );
echo $stored;
}
?>

Argument in array form

<?php 
if ( function_exists ( 'wpeds_output' ) ) {
$stored = wpeds_output( array( 
'url' => 'http://wordpress.org/extend/plugins/wordpress-theme-demo-bar/stats/',
'get' => 'today',
'echo' => '0',
) );
echo $stored;
}
?>

Function : wpeds_return_data_as_array()

Description

Allows you to get an array of saved data and assign it to a variable. It can accept argument in string or array. You can use this function to make a “download” page. Introduced in version 1.2.1

Usage
<?php 
if ( function_exists ( 'wpeds_return_data_as_array' ) ) {
wpeds_return_data_as_array($args);
}
?>
Parameters

url
(string) URL to the statistics page. If set, it returns an array of data of the selected item only. Use var_dump() to see what it has :)

gettype
(string) If set, it returns all datas of a type in array. Use var_dump() to see what it has :)
Valid values:

  • plugin
  • theme

autoformat
(string) By default, all time and number related data will be formatted based on plugin settings. Once disabled, timestamp will be returned for time-related data and unformatted numbers will be returned for number-related data.
Valid values:

  • true – default
  • false (false)
  • 0 (false)
Example of Usage

Assign all plugins data into a variable

$stored = wpeds_return_data_as_array('gettype=plugin');
var_dump($stored); //to see what's inside

Assign all themes data into a variable

$stored = wpeds_return_data_as_array('gettype=theme');
var_dump($stored); //to see what's inside

Assign a single plugin’s data into a variable

$stored = wpeds_return_data_as_array('url=http://wordpress.org/extend/plugins/wordpress-extend-download-stat/stats/');
var_dump($stored); //to see what's inside

Disable auto-formatting all date and number

$stored = wpeds_return_data_as_array('gettype=theme&autoformat=0');
var_dump($stored); //to see what's inside

Argument in array form

$stored = wpeds_return_data_as_array( array(
'gettype' => 'theme',
'autoformat' => '0',
));
var_dump($stored); //to see what's inside

 

Posted by Zen on 30 August 2009 • 2,800 visits 1 comment
Tags :


or Subscribe to specific category only :




  - 1 Comments


Sydit says:

Cool code :)

Leave a Reply

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Previous Post
«
Next Post
»