コード例 #1
0
/**
 * Adds custom classes to the array of body classes.
 *
 * @since Buttercream 1.0
 */
function buttercream_body_classes($classes)
{
    // Adds a class of single-author to blogs with only 1 published author
    if (is_multi_author()) {
        $classes[] = 'group-blog';
    }
    $options = buttercream_get_theme_options();
    $themestyle = $options['theme_style'];
    if ($themestyle) {
        $classes[] = 'style-' . $themestyle;
    }
    return $classes;
}
コード例 #2
0
/**
 * Setup the WordPress core custom header feature.
 *
 * Use add_theme_support to register support for WordPress 3.4+
 * as well as provide backward compatibility for previous versions.
 * Use feature detection of wp_get_theme() which was introduced
 * in WordPress 3.4.
 *
 * @uses buttercream_header_style()
 * @uses buttercream_admin_header_style()
 * @uses buttercream_admin_header_image()
 *
 * @package Buttercream
 */
function buttercream_custom_header_setup()
{
    $options = buttercream_get_theme_options();
    $style = $options['theme_style'];
    $defaults = buttercream_get_layout_defaults();
    if (isset($style) && '' == $style || false == $style) {
        $style = 'cupcake';
    }
    $args = array('default-image' => $defaults['default-header-image'], 'default-text-color' => $defaults['default-color'], 'width' => 850, 'height' => 265, 'flex-height' => true, 'wp-head-callback' => 'buttercream_header_style', 'admin-head-callback' => 'buttercream_admin_header_style', 'admin-preview-callback' => 'buttercream_admin_header_image');
    $args = apply_filters('buttercream_custom_header_args', $args);
    if (function_exists('wp_get_theme')) {
        add_theme_support('custom-header', $args);
    } else {
        // Compat: Versions of WordPress prior to 3.4.
        define('HEADER_TEXTCOLOR', $args['default-text-color']);
        define('HEADER_IMAGE', $args['default-image']);
        define('HEADER_IMAGE_WIDTH', $args['width']);
        define('HEADER_IMAGE_HEIGHT', $args['height']);
        add_custom_image_header($args['wp-head-callback'], $args['admin-head-callback'], $args['admin-preview-callback']);
    }
    // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
    register_default_headers(array('cupcake' => array('url' => '%s/img/cupcake.png', 'thumbnail_url' => '%s/img/cupcake-thumb.png', 'description' => __('Confetti', 'buttercream')), 'yellow' => array('url' => '%s/img/yellow.png', 'thumbnail_url' => '%s/img/yellow-thumb.png', 'description' => __('Chocolate Orange', 'buttercream')), 'red' => array('url' => '%s/img/red.png', 'thumbnail_url' => '%s/img/red-thumb.png', 'description' => __('Red Velvet', 'buttercream'))));
}
コード例 #3
0
/**
 * Returns layout defaults
 */
function buttercream_get_layout_defaults()
{
    $options = buttercream_get_theme_options();
    $theme_style = $options['theme_style'];
    $default_theme_options = buttercream_get_default_theme_options();
    $default_theme_style = $default_theme_options['theme_style'];
    $theme_style_values = buttercream_theme_style();
    if ($theme_style) {
        $defaults = $theme_style_values[$theme_style]['defaults'];
    } else {
        $defaults = $theme_style_values[$default_theme_style]['defaults'];
    }
    return apply_filters('buttercream_get_layout_defaults', $defaults);
}
コード例 #4
0
function buttercream_alternate_default_headers()
{
    $buttercream_current_header = get_header_image();
    $buttercream_current_header_style = basename($buttercream_current_header, '.png');
    if (isset($buttercream_current_header_style) && true == buttercream_is_a_default_header()) {
        ?>

<style type="text/css">
	#header-imagesm {
		background-image:url('<?php 
        echo get_template_directory_uri();
        ?>
/img/<?php 
        echo $buttercream_current_header_style;
        ?>
-sm.png');
	}
	.bluebar {
		background-image:url('<?php 
        echo get_template_directory_uri();
        ?>
/img/bar-<?php 
        echo $buttercream_current_header_style;
        ?>
.png');
	}

	@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {

		#header-image img {
			background-image:url('<?php 
        echo get_template_directory_uri();
        ?>
/img/<?php 
        echo $buttercream_current_header_style;
        ?>
@2x.png');
			background-repeat: no-repeat;
			background-size: 850px 265px;
			padding-right: 9999px;
			background-position: 9999px;
			margin-left: -9999px;
		}

		#header-imagesm {
			background-image:url('<?php 
        echo get_template_directory_uri();
        ?>
/img/<?php 
        echo $buttercream_current_header_style;
        ?>
-sm@2x.png');
			background-size: 200px auto;
		}
	}
</style>

<?php 
    } else {
        $buttercream_options = buttercream_get_theme_options();
        $buttercream_style = $buttercream_options['theme_style'];
        ?>

	<style type="text/css">
	#header-imagesm {
		background-image:url('<?php 
        echo get_template_directory_uri();
        ?>
/img/<?php 
        echo $buttercream_style;
        ?>
-sm.png');
	}
	.bluebar {
		background-image:url('<?php 
        echo get_template_directory_uri();
        ?>
/img/bar-<?php 
        echo $buttercream_style;
        ?>
.png');
	}
	</style>
	<?php 
    }
}