コード例 #1
0
ファイル: secondary.php プロジェクト: alicam/vanilla-theme
/**
* Displays the secondary widget area
* Check if the widget area is active or if the default is set to home
* If neither is true, don't display the XHTML
*
* @since 0.2.2
*/
function hybrid_get_secondary()
{
    global $hybrid_settings;
    if ($hybrid_settings['secondary_inserts_default'] && is_sidebar_active(__('Secondary Home', 'hybrid')) && !is_page_template('no-widgets.php') || is_sidebar_active(hybrid_secondary_var()) && !is_page_template('no-widgets.php')) {
        ?>

		<div id="secondary">
		<?php 
        hybrid_before_secondary();
        // Before secondary hook
        if (dynamic_sidebar(hybrid_secondary_var())) {
        } else {
            if ($hybrid_settings['secondary_inserts_default']) {
                if (dynamic_sidebar(__('Secondary Home', 'hybrid'))) {
                }
            }
        }
        hybrid_after_secondary();
        // After secondary hook
        ?>
		</div>

	<?php 
    }
}
コード例 #2
0
/**
* Dynamic body class based on page
*
* @since 0.1
*/
function hybrid_body_class()
{
    global $wp_query, $hybrid_settings;
    $class = array();
    if (is_front_page() || is_home()) {
        $class[] = 'home';
        $class[] = 'front-page';
    } elseif (is_attachment()) {
        global $post;
        $class[] = 'attachment';
        if (wp_attachment_is_image($post->ID)) {
            $class[] = 'attachment-image';
        }
        $mime = get_post_mime_type($post->ID);
        $class[] = 'attachment-' . str_replace('/', '-', $mime);
    } elseif (is_single()) {
        $class[] = 'single';
        $class[] = 'single-' . $wp_query->post->ID;
        if (function_exists('is_sticky')) {
            if (is_sticky($wp_query->post->ID)) {
                $class[] = 'single-sticky';
            }
        }
    } elseif (is_page()) {
        $class[] = 'page page-' . $wp_query->post->ID;
        if (is_page_template()) {
            $class[] = 'page-template';
            $class[] = 'page-template-' . str_replace('.php', '', get_post_meta($wp_query->post->ID, '_wp_page_template', true));
        }
    } elseif (is_category()) {
        $cat = $wp_query->get_queried_object();
        $class[] = 'category';
        $class[] = 'category-' . $cat->slug;
    } elseif (is_tag()) {
        $tags = $wp_query->get_queried_object();
        $class[] = 'tag';
        $class[] = 'tag-' . $tags->slug;
    } elseif (is_search()) {
        $class[] = 'search';
    } elseif (is_404()) {
        $class[] = 'error-404';
    } elseif (is_year()) {
        $class[] = 'year';
    } elseif (is_month()) {
        $class[] = 'month';
    } elseif (is_day()) {
        $class[] = 'day';
    } elseif (is_time()) {
        $class[] = 'time';
    } elseif (is_author()) {
        $author = $wp_query->get_queried_object();
        $class[] = 'author';
        $class[] = ' author-' . $author->user_nicename;
    }
    if (is_user_logged_in()) {
        $class[] = 'logged-in';
    } else {
        $class[] = 'not-logged-in';
    }
    if (is_date()) {
        $class[] = 'date';
    }
    if (is_archive()) {
        $class[] = 'archive';
    }
    if (is_paged()) {
        $class[] = 'paged';
    }
    if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
        $class[] = 'paged';
        $class[] = 'paged-' . $page;
        if (is_home() || is_front_page()) {
            $class[] = 'home-paged-' . $page;
        } elseif (is_attachment()) {
            $class[] = 'attachment-paged-' . $page;
        } elseif (is_single()) {
            $class[] = 'single-paged-' . $page;
        } elseif (is_page()) {
            $class[] = 'page-paged-' . $page;
        } elseif (is_category()) {
            $class[] = 'category-paged-' . $page;
        } elseif (is_tag()) {
            $class[] = 'tag-paged-' . $page;
        } elseif (is_date()) {
            $class[] = 'date-paged-' . $page;
        } elseif (is_author()) {
            $class[] = 'author-paged-' . $page;
        } elseif (is_search()) {
            $class[] = 'search-paged-' . $page;
        }
    }
    if (is_comments_popup()) {
        $class[] = 'comments-popup';
    }
    if ($hybrid_settings['primary_inserts_default']) {
        if (!is_sidebar_active(__('Primary Home', 'hybrid')) && !is_sidebar_active(hybrid_primary_var())) {
            $class[] = 'no-primary-widgets';
            $no_primary_widgets = true;
        }
    } else {
        if (!is_sidebar_active(hybrid_primary_var())) {
            $class[] = 'no-primary-widgets';
            $no_primary_widgets = true;
        }
    }
    if ($hybrid_settings['secondary_inserts_default']) {
        if (!is_sidebar_active(__('Secondary Home', 'hybrid')) && !is_sidebar_active(hybrid_secondary_var())) {
            $class[] = 'no-secondary-widgets';
            $no_secondary_widgets = true;
        }
    } else {
        if (!is_sidebar_active(hybrid_secondary_var())) {
            $class[] = 'no-secondary-widgets';
            $no_secondary_widgets = true;
        }
    }
    if (is_page_template('no-widgets.php')) {
        $class[] = 'no-widgets';
        $no_widgets = true;
    }
    if ($no_widgets || $no_primary_widgets && $no_secondary_widgets) {
        $class[] = 'no-default-widgets';
    } else {
        $class[] = 'has-widgets';
    }
    $class = join(' ', $class);
    echo $class;
}