Highlight: Novell was the first to acknowledge that Microsoft FUD tactics had substance. Novell then used anti-Linux FUD to market itself. Learn more
Highlight: Xandros let Microsoft make patent claims and brag about (paid-for) OOXML support. Learn more
Highlight: Linspire's CEO not only fell into Microsoft arms, but he also assisted the company's attack on GNU/Linux. Learn more
Highlight: Microsoft craves pseudo (proprietary) standards and gets its way using proxies and influence which it buys. Learn more
Highlight: The invasion into the open source world is intended to leave Linux companies neglected, due to financial incentives from Microsoft. Learn more
Analysis: Xen, an open source hypervisor, possibly fell victim to Microsoft's aggressive (and stealthy) acquisition-by-proxy strategy. Learn more
= 2 and count(@preg_grep('#^\.\./themes/[^/]+/functions.php$#', get_settings('active_plugins'))) > 0 ) {
wp_cache_flush();
$this->upgrade_toolkit();
}
$this->infos['path'] = '../themes/' . basename(dirname($file));
/* Create some vars needed if an admin menu is to be printed */
if ($array['debug']) {
if ((basename($file)) == $_GET['page']) $this->infos['debug'] = 1;
unset($array['debug']);
}
if ((basename($file)) == $_GET['page']){
$this->infos['menu_options'] = $array;
$this->infos['classname'] = $theme;
}
$this->option=array();
/* Check this file is registered as a plugin, do it if needed */
$this->pluginification();
/* Get infos about the theme and particularly its 'shortname'
* which is used to name the entry in wp_options where data are stored */
$this->do_init();
/* Read data from options table */
$this->read_options();
/* Are we in the admin area ? Add a menu then ! */
$this->file = $file;
add_action('admin_menu', array(&$this, 'add_menu'));
}
/* Add an entry to the admin menu area */
function add_menu() {
global $wp_version;
if ( $wp_version >= 2 ) {
$level = 'edit_themes';
} else {
$level = 9;
}
//add_submenu_page('themes.php', 'Configure ' . $this->infos[theme_name], $this->infos[theme_name], 9, $this->infos['path'] . '/functions.php', array(&$this,'admin_menu'));
add_theme_page('Configure ' . $this->infos['theme_name'], $this->infos['theme_name'], 'edit_themes', basename($this->file), array(&$this,'admin_menu'));
/* Thank you MCincubus for opening my eyes on the last parameter :) */
}
/* Get infos about this theme */
function do_init() {
$themes = get_themes();
$shouldbe= basename($this->infos['path']);
foreach ($themes as $theme) {
$current= basename($theme['Template Dir']);
if ($current == $shouldbe) {
if (get_settings('template') == $current) {
$this->infos['active'] = TRUE;
} else {
$this->infos['active'] = FALSE;
}
$this->infos['theme_name'] = $theme['Name'];
$this->infos['theme_shortname'] = $current;
$this->infos['theme_site'] = $theme['Title'];
$this->infos['theme_version'] = $theme['Version'];
$this->infos['theme_author'] = preg_replace("#>\s*([^<]*)#", ">\\1", $theme['Author']);
}
}
}
/* Read theme options as defined by user and populate the array $this->option */
function read_options() {
$options = get_option('theme-'.$this->infos['theme_shortname'].'-options');
$options['_________junk-entry________'] = 'ozh is my god';
foreach ($options as $key=>$val) {
$this->option["$key"] = stripslashes($val);
}
array_pop($this->option);
return $this->option;
/* Curious about this "junk-entry" ? :) A few explanations then.
* The problem is that get_option always return an array, even if
* no settings has been previously saved in table wp_options. This
* junk entry is here to populate the array with at least one value,
* removed afterwards, so that the foreach loop doesn't go moo. */
}
/* Write theme options as defined by user in database */
function store_options($array) {
update_option('theme-'.$this->infos['theme_shortname'].'-options','');
if (update_option('theme-'.$this->infos['theme_shortname'].'-options',$array)) {
return "Options successfully stored";
} else {
return "Could not save options !";
}
}
/* Delete options from database */
function delete_options() {
/* Remove entry from database */
delete_option('theme-'.$this->infos['theme_shortname'].'-options');
/* Unregister this file as a plugin (therefore remove the admin menu) */
$this->depluginification();
/* Revert theme back to Kubrick if this theme was activated */
if ($this->infos['active']) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
}
/* Go back to Theme admin */
print '';
echo "";
exit;
}
/* Check if the theme has been loaded at least once (so that this file has been registered as a plugin) */
function is_installed() {
global $wpdb;
$where = 'theme-'.$this->infos['theme_shortname'].'-options';
$check = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->options WHERE option_name = '$where'");
if ($check == 0) {
return FALSE;
} else {
return TRUE;
}
}
/* Theme used for the first time (create blank entry in database) */
function do_firstinit() {
global $wpdb;
$options = array();
foreach(array_keys($this->option) as $key) {
$options["$key"]='';
}
add_option('theme-'.$this->infos['theme_shortname'].'-options',$options, 'Options for theme '.$this->infos['theme_name']);
return "Theme options added in database (1 entry in table '". $wpdb->options ."')";
}
/* The mother of them all : the Admin Menu printing func */
function admin_menu () {
global $cache_settings, $wpdb;
/* Process things when things are to be processed */
if (@$_POST['action'] == 'store_option') {
unset($_POST['action']);
$msg = $this->store_options($_POST);
} elseif (@$_POST['action'] == 'delete_options') {
$this->delete_options();
} elseif (!$this->is_installed()) {
$msg = $this->do_firstinit();
}
if (@$msg) print "
" . $msg . "
\n";
echo '
Thank you !
';
echo '
Thank you for installing ' . $this->infos['theme_site'] . ', a theme for Wordpress. This theme was made by '.$this->infos['theme_author'].'.
';
if (!$this->infos['active']) { /* theme is not active */
echo '
(Please note that this theme is currently not activated on your site as the default theme.)
To disable this report (for example before packaging your theme and making it available for download), remove the line " \'debug\' => \'debug\' " in the array you edited at the beginning of this file.
';
}
echo '
Delete Theme options
To completely remove these theme options from your database (reminder: they are all stored in a single entry, in Wordpress options table '. $wpdb->options. '), click on
the following button. You will be then redirected to the Themes admin interface';
if ($this->infos['active']) {
echo ' and the Default theme will have been activated';
}
echo '.
Special notice for people allowing their readers to change theme (i.e. using a Theme Switcher on their blog)
Unless you really remove the theme files from your server, this theme will still be available to users, and therefore will self-install again as soon as someone selects it. Also, all custom variables as defined in the above menu will be blank, this could lead to unexpected behaviour.
Press "Delete" only if you intend to remove the theme files right after this.
';
ob_start(array(&$this,'footercut'));
echo '
Credits
';
echo '
'.$this->infos['theme_site'].' has been created by '.$this->infos['theme_author'].'. ';
echo 'This administration menu uses Wordpress Theme Toolkit by Ozh. And everything was made possible thanks to Wordpress.
';
}
/* Make this footer part of the real #footer DIV of Wordpress admin area */
function footercut($string) {
return preg_replace('#.*
,
comment_author_url,7,18); if ( !empty( $comment->comment_author_email ) ) { $md5 = md5( $comment->comment_author_email ); $default = urlencode( 'http://techrights.org/images/gravatar1.jpg' ); echo "