Thursday, May 3, 2007

Show information about the currently activated theme

In WP normally you hardcode information about the current theme showing link to author's site, version and name etc. Information is stored in the CSS file of that WP theme. In Habari information is stored in a xml file in the theme folder and you could allow users of your theme to extract information from there.

Class ThisTheme extends Theme
function show()
$activetheme_name = Options::get('theme_dir');
$thistheme_path = HABARI_PATH.'/user/themes/'.$activetheme_name;
$thistheme_info = simplexml_load_file($thistheme_path.'/theme.xml');
$output = "This Theme: ".$thistheme_info->name;
$output .= " ".$thistheme_info->version." by ";
$output .= "[a href=\"".$thistheme_info->url."\"]".$thistheme_info->author."[/a]";
$output .= " for ".$thistheme_info->template_engine;
echo $output;

Copy the above into your theme.php file of your theme and add [?php ThisTheme::show(); ?] to your footer perhaps on a new line.

No comments:

Post a Comment