Using Template Tag Function in WordPress Theme Demo Bar Plugin

Posted in Wordpress Development on 10 September 2009 1 comment

This page is created for WordPress Theme Demo Bar plugin.

There are 2 functions available :

Function : wptdb_output()

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

Description

Allows you to output theme info in template files instead of using shortcode in post. It accepts argument in strings and works exactly like the shortcode . Introduced in version 1.4.

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

theme
(string) The theme’s folder name. 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 format id of 1

<?php 
if ( function_exists ( 'wptdb_output' ) ) {
wptdb_output( 'theme=my-theme-folder-name&format=1' );
}
?>

Display number of previews (inline)

Lunated theme has <?php 
if ( function_exists ( 'wptdb_output' ) ) {
wptdb_output( 'theme=lunated&get=hits&autop=false' );
}
?> previews in total.

Assign to variable

<?php 
if ( function_exists ( 'wptdb_output' ) ) {
$stored = wptdb_output( 'theme=lunated&get=today&echo=0' );
echo $stored;
}
?>

Argument in array form

<?php 
if ( function_exists ( 'wptdb_output' ) ) {
$stored = wptdb_output( array(
'theme' => 'lunated',
'get' => 'today',
'echo' => '0',
) );
echo $stored;
}
?>

Function : wptdb_list_themes()

Description

Allows you to display a drop-down menu (<select>) for visitors to choose and preview your non-private themes. Introduced in version 1.5

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

style
(string) Type of output. Default is “option” which output <option> to be used with <select>. Valid values:

  • option – default

hierarchical
(string) Show parent-child relationship. Default is true. Valid values:

  • 1 / true (true) – default
  • 0 / false (false)

orderby
(string) Sort themes by wordpress default method or by number of previews. Valid values:

  • default – default
  • hits

order
(string) Sort order for themes (either ascending or descending). Default is asc. Valid values:

  • asc – default
  • desc

show_hits
(string) Show number of previews beside theme name in a bracket. Default is false. Valid values:

  • true / 1
  • false / 0 – default

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

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

Display drop-down menu using default settings

<?php 
if ( function_exists ( 'wptdb_list_themes' ) ) {
echo '<select name="">';
wptdb_list_themes();
echo '</select>';
}
?>

Display drop-down menu , sort the themes by number of previews in descending order

<?php 
if ( function_exists ( 'wptdb_list_themes' ) ) {
echo '<select name="">';
wptdb_list_themes( 'orderby=hits&order=desc' );
echo '</select>';
}
?>

Display drop-down menu with number of previews shown beside the theme name

<?php 
if ( function_exists ( 'wptdb_list_themes' ) ) {
echo '<select name="">';
wptdb_list_themes( 'show_hits=1' );
echo '</select>';
}
?>

Argument in array form

<?php 
if ( function_exists ( 'wptdb_list_themes' ) ) {
echo '<select name="">';
wptdb_list_themes( array(
'orderby' => 'hits',
'order' => 'desc',
));
echo '</select>';
}
?>

 

Posted by Zen on 10 September 2009 • 8,649 visits 1 comment
Tags :


or Subscribe to specific category only :




  - 1 Comments


Jason says:

I am trying to figure out how I can use your plugin to create a theme demo bar like yours but with an additional drop down to change that themes styles. Can you let me know how to set something like this up. I would have like six themes and each one has anywhere between 5 and 8 css files. Any help would be greatly appreciated.

Leave a Reply

You must be logged in to post a comment.

Previous Post
«
Next Post
»