window.location.replace('${_SERVER['REQUEST_URI']}');\n";
exit;
}
// if no widgets, don't use the widgets sidebar
if(!function_exists('register_sidebar') && get_tarski_option('sidebar_type') == 'widgets') {
update_tarski_option('sidebar_type', '');
}
// set default sidebar type
if(!get_tarski_option('sidebar_type')) {
// default to widgets if available, otherwise use the Tarski sidebar
if(function_exists('register_sidebar')) {
update_tarski_option('sidebar_type', 'widgets');
} else {
update_tarski_option('sidebar_type', 'tarski');
}
}
// Constants file include
@include(TEMPLATEPATH . '/constants.php');
// Localisation
load_theme_textdomain('tarski');
// Options page and dashboard injections
add_action('admin_head', 'tarski_inject_scripts');
add_action('activity_box_end', 'update_dashboard');
// Widgets
if(function_exists('register_sidebar')) {
register_sidebar(array(
'name' => __('Main Sidebar', 'tarski'),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
register_sidebar(array(
'name' => __('Footer Widgets', 'tarski'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
));
}
// custom header API
if(function_exists('add_custom_image_header')) {
define('HEADER_TEXTCOLOR', '');
define('HEADER_IMAGE', '%s/headers/' . get_tarski_option('header')); // %s is theme dir uri
define('HEADER_IMAGE_WIDTH', 720);
define('HEADER_IMAGE_HEIGHT', 180);
define('NO_HEADER_TEXT', true );
function tarski_admin_header_style() { ?>
'value'); with all options to save queries
function update_tarski_options($array) {
global $tarski_options;
foreach($array as $name => $value) {
$tarski_options[$name] = $value;
}
update_option('tarski_options', serialize($tarski_options));
flush_tarski_options();
}
// detect WordPress MultiUser - http://mu.wordpress.org/
function detectWPMU() {
return function_exists('is_site_admin');
}
// Dashboard update notification
function update_dashboard() {
global $installedVersion;
if(!detectWPMU()) {
echo "" . __("Tarski Updates", "tarski") . "
\n";
if(get_tarski_option('update_notification') == 'true') {
echo "\n";
} else {
echo "" . __("Update notification for the Tarski theme ", "tarski") . "" . __("is currently turned off", "tarski") . "" . __(".", "tarski") . "
\n";
}
}
}
// Multiple user check
$count_users = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->usermeta WHERE `meta_key` = '" . $wpdb->prefix . "user_level' AND `meta_value` > 1");
if ($count_users > 1) { $multipleAuthors = 1; }
// Clean page linkage
function link_pages_without_spaces() {
ob_start();
link_pages('Pages', '
', 'number', '', '', '%', '');
$text = ob_get_contents();
ob_end_clean();
$text = str_replace(' ', '>', $text);
echo $text;
}
// Header image check
if(get_tarski_option('header') == 'blank.gif') {
$noHeaderImage = true;
}
// Header image status output
function tarski_header_status() {
global $noHeaderImage;
if($noHeaderImage) {
return 'noheaderimage';
} else {
return 'headerimage';
}
}
// Header image output
function tarski_headerimage() {
if($_SERVER['HTTP_HOST'] == 'themes.wordpress.net') { // Makes the theme preview work properly
$headerImage = 'http://tarskitheme.com/wp-content/themes/tarski/headers/greytree.jpg';
} else {
if(get_tarski_option('header')) {
if(get_tarski_option('header') != 'blank.gif') {
$headerImage = get_bloginfo('template_directory') . '/headers/' . get_tarski_option('header');
}
} else {
$headerImage = get_bloginfo('template_directory') . '/headers/greytree.jpg';
}
}
if($headerImage) {
echo '\n";
}
}
// Site title output
function tarski_title($type = 'title') {
$titleSep = '·';
// tarski_title('header') is for use within the document
if ($type == 'header') {
if(is_home()) { $prefix = ''; $suffix = '
'; }
else { $prefix = ''; $suffix = '
'; }
echo $prefix . get_bloginfo('name') . $suffix . "\n";
}
// tarski_title() is for use within the document
else { echo get_bloginfo('name');
if (is_home()) { if (get_bloginfo('description') != '') { echo ' ' . $titleSep . ' ' . get_bloginfo('description'); } }
elseif (is_search()) { echo ' ' . $titleSep . ' Search results'; }
elseif (is_month()) { echo ' ' . $titleSep . ' '; single_month_title(' '); }
else { wp_title($titleSep); }
}
}
// Navbar
function tarski_navbar() {
$current = 'class="nav-current" ';
if(is_home()) { $homeStatus = $current; }
echo '' . __('Home', 'tarski') . "\n";
global $wpdb;
$nav_pages = get_tarski_option('nav_pages');
if($nav_pages) {
$nav_pages = explode(',', $nav_pages);
foreach($nav_pages as $page) {
if(is_page($page)) { $pageStatus = $current; } else { $pageStatus = ''; }
echo ' posts WHERE ID = $page") . '" ' . $pageStatus . 'href="' . get_permalink($page) . '">' . $wpdb->get_var("SELECT post_title from $wpdb->posts WHERE ID = $page") . '' . "\n";
}
}
global $navbarInclude;
if($navbarInclude) {
echo $navbarInclude . "\n";
}
if(is_user_logged_in()) {
echo '' . __('Site Admin', 'tarski') . '' . "\n";
}
}
// Body classes
function tarski_bodyclass() {
if(get_tarski_option('centered_theme')) { // Centred or not
echo 'center';
} else {
echo 'left';
}
if(get_tarski_option('swap_sides')) { // Swapped or not
echo ' janus';
}
if(get_tarski_option('style')) { // Alternate style
echo ' ' . str_replace('.css', '', get_tarski_option('style'));
}
if (is_page() || is_single() || is_404()) { // Is it a single page?
echo ' single';
}
global $headerImageSet;
if($headerImageSet == false) { // No header image
echo ' noheader';
}
}
// A better the_date() function
function tarski_date() {
global $post;
return mysql2date(get_settings('date_format'), $post->post_date);
}
// Tarski excerpts
// Code shamelessly borrowed from http://guff.szub.net/2005/02/26/the-excerpt-reloaded/
function tarski_excerpt($excerpt_length = 120, $allowedtags = '', $filter_type = 'none', $use_more_link = 1, $more_link_text = '(more...)', $force_more = 1, $fakeit = 1, $no_more = 0, $more_tag = 'div', $more_link_title = 'Continue reading this entry', $showdots = 1) {
global $post;
if (!empty($post->post_password)) { // if there's a password
if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match cookie
if(is_feed()) { // if this runs in a feed
$output = __('This entry is protected.','tarski');
} else {
$output = get_the_password_form();
}
}
return $output;
}
if($fakeit == 2) { // force content as excerpt
$text = $post->post_content;
} elseif($fakeit == 1) { // content as excerpt, if no excerpt
$text = (empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
} else { // excerpt no matter what
$text = $post->post_excerpt;
}
if($excerpt_length < 0) {
$output = $text;
} else {
if(!$no_more && strpos($text, '')) {
$text = explode('', $text, 2);
$l = count($text[0]);
$more_link = 1;
} else {
$text = explode(' ', $text);
if(count($text) > $excerpt_length) {
$l = $excerpt_length;
$ellipsis = 1;
} else {
$l = count($text);
$more_link_text = '';
$ellipsis = 0;
}
}
for ($i=0; $i<$l; $i++)
$output .= $text[$i] . ' ';
}
if('all' != $allowed_tags) {
$output = strip_tags($output, $allowedtags);
}
$output = rtrim($output, "\s\n\t\r\0\x0B");
$output = ($fix_tags) ? $output : balanceTags($output);
$output .= ($showdots && $ellipsis) ? '...' : '';
switch($more_tag) {
case('div') :
$tag = 'div';
break;
case('span') :
$tag = 'span';
break;
case('p') :
$tag = 'p';
break;
default :
$tag = 'span';
break;
}
if ($use_more_link && $more_link_text) {
if($force_more) {
$output .= ' <' . $tag . ' class="more-link">' . $more_link_text . '' . $tag . '>' . "\n";
} else {
$output .= ' <' . $tag . ' class="more-link">' . $more_link_text . '' . $tag . '>' . "\n";
}
}
$output = apply_filters($filter_type, $output);
return $output;
}
// Options page JS and CSS injection
function tarski_inject_scripts() {
if(substr($_SERVER['REQUEST_URI'], -39, 39) == 'wp-admin/themes.php?page=tarski-options') { // Ugly
echo "\n\n";
echo '' . "\n";
echo '' . "\n";
// Empty JavaScript file we might have a use for in the future
// echo '' . "\n";
echo '' . "\n";
echo "\n";
}
}
// Update function
// I r serious cat. This r serious function.
function tarskiupdate() {
global $wpdb, $user_ID;
get_currentuserinfo();
if ( !empty($_POST) ) {
if($_POST['tarski_update_notification'] == __('Turn update notification off?', 'tarski')) {
update_tarski_option('update_notification', 'false');
} elseif($_POST['tarski_update_notification'] == __('Turn update notification on?', 'tarski')) {
update_tarski_option('update_notification', 'true');
}
if (isset($_POST['about_text'])) {
$about = $_POST['about_text'];
update_tarski_option('blurb', $about, '','');
}
if (isset($_POST['header_image'])) {
$header = $_POST['header_image'];
$header = @str_replace("-thumb", "", $header);
update_tarski_option('header', $header, '','');
}
$nav_pages = implode(',', $_POST['nav_pages']);
update_tarski_options(array(
'footer_recent' => $_POST['footer']['recent'],
'sidebar_pages' => $_POST['sidebar']['pages'],
'sidebar_links' => $_POST['sidebar']['links'],
'sidebar_comments' => $_POST['sidebar']['comments'],
'sidebar_custom' => $_POST['sidebar']['custom'],
'sidebar_onlyhome' => $_POST['sidebar']['onlyhome'],
'display_title' => $_POST['display_title'],
'display_tagline' => $_POST['display_tagline'],
'hide_categories' => $_POST['hide_categories'],
'use_pages' => $_POST['use_pages'],
'centered_theme' => $_POST['centered_theme'],
'swap_sides' => $_POST['swap_sides'],
'asidescategory' => $_POST['asides_category'],
'style' => $_POST['alternate_style'],
'ajax_tags' => $_POST['ajax_tags'],
'nav_pages' => $nav_pages,
'sidebar_type' => $_POST['sidebartype']
));
}
}
// if we can't find Tarski installed let's go ahead and install all the options that run Tarski. This should run only one more time for all our existing users, then they will just be getting the upgrade function if it exists.
if (!get_tarski_option('installed')) {
add_tarski_option('installed', $installedVersion);
add_tarski_option('header', 'greytree.jpg');
add_tarski_option('blurb', __('This is the about text', 'tarski'));
}
// Here we handle upgrading our users with new options and such. If tarski_installed is in the DB but the version they are running is lower than our current version, trigger this event.
elseif (get_tarski_option('installed') < $installedVersion) {
if(get_tarski_option('installed') < 1.1) {
add_tarski_option('asidescategory', '0');
}
update_tarski_option('installed', $installedVersion);
}
// This adds the Tarski Options page
add_action('admin_menu', 'tarski_addmenu');
function tarski_addmenu() {
add_submenu_page('themes.php', __('Tarski Options','tarski'), __('Tarski Options','tarski'), 'edit_themes', 'tarski-options', 'tarski_admin');
}
function tarski_admin() {
require(TEMPLATEPATH . '/library/options-page.php');
}
function tarski_get_output($code) {
ob_start();
eval($code);
$return = ob_get_contents();
ob_end_clean();
return $return;
}
// ~fin~ ?>