Beispiel #1
0
function mystique_body_class($class = '')
{
    global $wp_query, $current_user, $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
    // Generic semantic classes for what type of content is displayed
    is_front_page() ? $classes[] = 'home' : null;
    // For the front page, if set
    is_home() ? $classes[] = 'blog' : null;
    // For the blog posts page, if set
    is_archive() ? $classes[] = 'archive' : null;
    is_date() ? $classes[] = 'date' : null;
    is_search() ? $classes[] = 'search' : null;
    is_attachment() ? $classes[] = 'attachment' : null;
    is_404() ? $classes[] = 'not-found' : null;
    // CSS does not allow a digit as first character
    // Special classes for BODY element when a single post
    if (is_single()) {
        $postname = $wp_query->post->post_name;
        the_post();
        // Adds 'single' class and class with the post ID
        $classes[] = 'single-post title-' . $postname;
        // Adds category classes for each category on single posts
        if ($cats = get_the_category()) {
            foreach ($cats as $cat) {
                $classes[] = 'category-' . $cat->slug;
            }
        }
        // Adds tag classes for each tags on single posts
        if ($tags = get_the_tags()) {
            foreach ($tags as $tag) {
                $classes[] = 'tag-' . $tag->slug;
            }
        }
        // Adds author class for the post author
        $classes[] = 'author-' . sanitize_title_with_dashes(strtolower(get_the_author_meta('login')));
        rewind_posts();
    } elseif (is_author()) {
        // Author name classes for BODY on author archives
        $author = $wp_query->get_queried_object();
        $classes[] = 'author';
        $classes[] = 'author-' . $author->user_nicename;
    } elseif (is_category()) {
        // Category name classes for BODY on category archvies
        $cat = $wp_query->get_queried_object();
        $classes[] = 'category';
        $classes[] = 'category-' . $cat->slug;
    } elseif (is_tag()) {
        // Tag name classes for BODY on tag archives
        $tags = $wp_query->get_queried_object();
        $classes[] = 'tag';
        $classes[] = 'tag-' . $tags->slug;
    } elseif (is_page()) {
        // Page author for BODY on 'pages'
        $pagename = $wp_query->post->post_name;
        $pageID = $wp_query->post->ID;
        $page_children = wp_list_pages("child_of={$pageID}&echo=0");
        the_post();
        $classes[] = 'single-page page-' . $pagename;
        $classes[] = 'author-' . sanitize_title_with_dashes(strtolower(get_the_author('login')));
        // Checks to see if the page has children and/or is a child page; props to Adam
        if ($page_children) {
            $classes[] = 'level-parent';
        }
        if ($wp_query->post->post_parent) {
            $classes[] = 'level-child';
        }
        rewind_posts();
    } elseif (is_search()) {
        // Search classes for results or no results
        the_post();
        if (have_posts()) {
            $classes[] = 'search-results';
        } else {
            $classes[] = 'search-no-results';
        }
        rewind_posts();
    }
    // layout type
    $classes[] = mystique_layout_type();
    $classes[] = get_mystique_option('page_width');
    // For when a visitor is logged in while browsing
    if ($current_user->ID) {
        $classes[] = 'loggedin';
    }
    // detect browser
    if ($is_lynx) {
        $browser = 'lynx';
    } elseif ($is_gecko) {
        $browser = 'gecko';
    } elseif ($is_opera) {
        $browser = 'opera';
    } elseif ($is_NS4) {
        $browser = 'ns4';
    } elseif ($is_safari) {
        $browser = 'safari';
    } elseif ($is_chrome) {
        $browser = 'chrome';
    } elseif ($is_IE) {
        $browser = 'ie';
    } else {
        $browser = 'unknown';
    }
    if ($is_iphone) {
        $browser .= '-iphone';
    }
    $classes[] = 'browser-' . $browser;
    // user classes
    if (!empty($class)) {
        if (!is_array($class)) {
            $class = preg_split('#\\s+#', $class);
        }
        $classes = array_merge($classes, $class);
    }
    $class = join(' ', apply_filters('body_class', $classes));
    echo $class;
}
Beispiel #2
0
<?php

/* Mystique/digitalnature */
$layout = mystique_layout_type();
$show_1stcolumn = $layout != 'col-1' || $_GET['preview'] == 1;
$show_2ndcolumn = $layout != 'col-1' && $layout != 'col-2-left' && $layout != 'col-2-right' || $_GET['preview'] == 1;
if ($show_1stcolumn) {
    if ($show_2ndcolumn) {
        include TEMPLATEPATH . '/sidebar2.php';
    }
    ?>

<div id="sidebar">
 <ul class="blocks">
    <?php 
    do_action('mystique_sidebar_start');
    ?>
    <?php 
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) {
        ?>

    <?php 
        if (!is_search()) {
            ?>
    <li class="block">
     <?php 
            mystique_search_form();
            ?>
    </li>
    <?php 
        }