/**
 * tarski_bodyclass() - Returns the classes that should be applied to the document body.
 * 
 * @since 1.2
 * @param boolean $return
 * @return string $classes
 * @hook filter tarski_bodyclass
 * Filter the classes applied to the document body by Tarski.
 */
function tarski_bodyclass($return = false)
{
    if (get_tarski_option('centred_theme')) {
        // Centred or not
        $classes[] = 'centre';
    }
    if (get_tarski_option('swap_sides')) {
        // Swapped or not
        $classes[] = 'janus';
    }
    if (get_tarski_option('style')) {
        // Alternate style
        $stylefile = get_tarski_option('style');
        $stylename = str_replace('.css', '', $stylefile);
        if (is_valid_tarski_style($stylefile)) {
            $classes[] = $stylename;
        }
    }
    if (get_bloginfo('text_direction') == 'rtl') {
        $classes[] = 'rtl';
    }
    // Filters should return an array
    $classes = apply_filters('tarski_bodyclass', $classes);
    // But if they don't, it won't implode
    if (is_array($classes)) {
        $classes = implode(' ', $classes);
    }
    if ($return) {
        return $classes;
    } else {
        echo $classes;
    }
}
Beispiel #2
0
/**
 * Return a list of alternate stylesheets, both from the Tarski directory and
 * the child theme (if one is being used).
 *
 * @uses get_tarski_option
 * @uses is_valid_tarski_style
 * @uses wp_get_theme
 *
 * @return array
 */
function _tarski_list_alternate_styles()
{
    $styles = array();
    $dirs = array('Tarski' => get_template_directory());
    $current_style = get_tarski_option('style');
    $current_theme = wp_get_theme()->Name;
    if (get_template_directory() != get_stylesheet_directory()) {
        $dirs[$current_theme] = get_stylesheet_directory();
    }
    foreach ($dirs as $theme => $dir) {
        $dirpath = $dir . '/styles';
        if (is_dir($dirpath)) {
            $style_dir = dir($dirpath);
        } else {
            continue;
        }
        while ($file = $style_dir->read()) {
            if (is_valid_tarski_style($file)) {
                $is_current = is_string($current_style) && $current_theme == 'Tarski' && $current_style == $file || $current_style[0] == $theme && $current_style[1] == $file;
                $prefix = $theme . '/';
                $styles[] = array('name' => $prefix . $file, 'public' => ($theme == 'Tarski' ? '' : $prefix) . $file, 'current' => $is_current);
            }
        }
    }
    return $styles;
}
Beispiel #3
0
/**
 * Add Tarski-specific classes to the body element.
 *
 * @since 3.0
 *
 * @uses get_tarski_option
 * @uses is_valid_tarski_style
 * @uses get_bloginfo
 *
 * @param array $classes
 * @return array
 */
function tarski_body_class($classes)
{
    if (get_tarski_option('centred_theme')) {
        $classes[] = 'centre';
    }
    if (get_tarski_option('swap_sides')) {
        $classes[] = 'janus';
    }
    if (get_tarski_option('style')) {
        $style = get_tarski_option('style');
        $file = is_array($style) ? $style[1] : $style;
        if (is_valid_tarski_style($file)) {
            $classes[] = preg_replace('/^(.+)\\.css$/', '\\1', $file);
        }
    }
    if (get_bloginfo('text_direction') == 'rtl') {
        $classes[] = 'rtl';
    }
    return $classes;
}
Beispiel #4
0
 /**
  * tarski_options_update() - Sets Options properties to the values set on the Options page.
  * 
  * Note that this function doesn't save anything to the database, that's the
  * preserve of save_tarski_options().
  * @since 2.0
  * @see save_tarski_options()
  */
 function tarski_options_update()
 {
     if ($_POST['update_notification'] == 'off') {
         $this->update_notification = false;
     } elseif ($_POST['update_notification'] == 'on') {
         $this->update_notification = true;
     }
     $header = $_POST['header_image'];
     if (isset($header)) {
         $header = str_replace('-thumb', '', $header);
         $this->header = $header;
     }
     $nav_pages = $_POST['nav_pages'];
     if (isset($nav_pages)) {
         $nav_pages = implode(',', $nav_pages);
         $this->nav_pages = $nav_pages;
     } else {
         $this->nav_pages = false;
     }
     $collapsed_pages = $_POST['collapsed_pages'];
     if (isset($collapsed_pages)) {
         $this->collapsed_pages = $collapsed_pages;
     } else {
         $this->collapsed_pages = '';
     }
     $stylefile = $_POST['alternate_style'];
     if (is_valid_tarski_style($stylefile)) {
         $this->style = $stylefile;
     } elseif (!$stylefile) {
         $this->style = false;
     }
     $this->display_title = (bool) $_POST['display_title'];
     $this->display_tagline = (bool) $_POST['display_tagline'];
     $this->show_categories = (bool) $_POST['show_categories'];
     $this->tags_everywhere = (bool) $_POST['tags_everywhere'];
     $this->use_pages = (bool) $_POST['use_pages'];
     $this->centred_theme = (bool) $_POST['centred_theme'];
     $this->swap_sides = (bool) $_POST['swap_sides'];
     $this->swap_title_order = (bool) $_POST['swap_title_order'];
     $this->asidescategory = $_POST['asides_category'];
     $this->nav_extlinkcat = $_POST['nav_extlinkcat'];
     $this->home_link_name = $_POST['home_link_name'];
     $this->sidebar_pp_type = $_POST['sidebar_pp_type'];
     $this->show_authors = tarski_should_show_authors();
     unset($this->deleted);
 }
_e('This link is not displayed when you have a static front page.', 'tarski');
?>
</p>
	</div></div>
	
	<div class="secondary">
		<div class="section">
			<h3><?php 
_e('Alternate Style', 'tarski');
?>
</h3>
		<?php 
$style_dir = dir(TEMPLATEPATH . '/styles');
if ($style_dir) {
    while (($file = $style_dir->read()) !== false) {
        if (is_valid_tarski_style($file)) {
            $styles[] = $file;
        }
    }
}
if ($style_dir && $styles) {
    ?>
			<select name="alternate_style" id="alternate_style" size="1">
				<option<?php 
    if (!get_tarski_option('style')) {
        echo ' selected="selected"';
    }
    ?>
 value=""><?php 
    _e('Default style', 'tarski');
    ?>
Beispiel #6
0
 /**
  * Sets TarskiOptions properties to the values set on the Options page.
  *
  * Note that this function doesn't save anything to the database, that's the
  * preserve of save_tarski_options().
  *
  * @since 2.0
  * @see save_tarski_options()
  */
 function tarski_options_update()
 {
     if (isset($_POST['alternate_style'])) {
         $style = array_slice(preg_split('/\\//', $_POST['alternate_style']), 0, 2);
         $this->style = count($style) > 1 && is_valid_tarski_style($style[1]) ? $style : false;
     }
     if (isset($_POST['sidebar_pp_type']) && $_POST['sidebar_pp_type'] == "main") {
         $this->sidebar_pp_type = "main";
     } else {
         $this->sidebar_pp_type = "";
     }
     $this->display_title = (bool) $_POST['display_title'];
     $this->display_tagline = (bool) $_POST['display_tagline'];
     $this->show_categories = (bool) $_POST['show_categories'];
     $this->tags_everywhere = (bool) $_POST['tags_everywhere'];
     $this->centred_theme = (bool) $_POST['centred_theme'];
     $this->swap_sides = (bool) $_POST['swap_sides'];
     $this->swap_title_order = (bool) $_POST['swap_title_order'];
     $this->featured_header = (bool) $_POST['featured_header'];
     unset($this->deleted);
 }