'sidebar', 'id' => 'sidebar', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', )); } // hack to add a class to the body tag when the sidebar is active function blueprint_has_sidebar($classes) { if (is_active_sidebar('sidebar')) { // add 'class-name' to the $classes array $classes[] = 'has_sidebar'; } // return the $classes array return $classes; } add_filter('body_class','blueprint_has_sidebar'); ?> 'd8e8e7', 'text' => '000000', 'link' => '3d4b4e', 'border' => 'CCCCCC', 'url' => '99AA88', ); } class blueprint { var $options = array(); var $defaults = array(); /* * Constructor * * Fired at Wordpress after_setup_theme (see add_action at the end * of the class), registers the theme capabilities, navigation menus, * as well as the set of actions and filters used by Blueprint. * * $this->options is used to store all the theme options, while * $this->defaults holds their default values. * */ function __construct() { // Load Blueprint text domain load_theme_textdomain( 'blueprint', get_template_directory() . '/languages' ); // Default options, lower-level ones are added during first run $this->defaults = array( 'color-scheme' => 'default' ); // Enables support for custom backgrounds add_custom_background(); // Theme supports add_theme_support( 'automatic-feed-links' ); add_theme_support( 'custom-header', array( 'random-default' => true ) ); // Load options $this->load_options(); // Register our primary navigation (top left) and 404 page links add_theme_support( 'nav_menus' ); register_nav_menu( 'primary', __( 'Primary Navigation Menu', 'blueprint' ) ); /* * Actions * * Registers admin settings, adds the menu options, * color scheme preview scripts (sidebar), custom header * */ add_action( 'admin_init', array( &$this, 'register_admin_settings' ) ); add_action( 'admin_menu', array( &$this, 'add_admin_options' ) ); add_action( 'wp_enqueue_scripts', array( &$this, 'color_scheme_scripts' ) ); add_action( 'admin_print_styles-appearance_page_theme-options', array( &$this, 'admin_styles' ) ); add_action( 'after_setup_theme', array( &$this, 'blueprint_custom_header_setup' ), 11 ); } /* * Load Options * * Fired during theme setup, loads all the options into $options * array accessible from all other functions. * @uses get_option() */ function load_options(){ $this->options = (array) get_option( 'blueprint-options', $this->defaults ); } /* * Valid Color Schemes * * This function returns an array of available color schemes, where * an array key is the value used in the database and the HTML layout, * and value is used for captions. The function is used for theme settins * page as well as options validation. Default is blue. * */ function get_valid_color_schemes() { $color_schemes = array( 'default' => array( 'name' => __( 'Default', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/default/preview.png' ), 'black' => array( 'name' => __( 'Black', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/black/preview.png' ), 'white' => array( 'name' => __( 'White', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/white/preview.png' ), 'red' => array( 'name' => __( 'Red', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/red/preview.png' ), 'orange' => array( 'name' => __( 'Orange', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/orange/preview.png' ), 'yellow' => array( 'name' => __( 'Yellow', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/yellow/preview.png' ), 'green' => array( 'name' => __( 'Green', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/green/preview.png' ), 'purple' => array( 'name' => __( 'Purple', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/purple/preview.png' ), 'gray' => array( 'name' => __( 'Gray', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/gray/preview.png' ), 'brown' => array( 'name' => __( 'Brown', 'blueprint' ), 'preview' => get_template_directory_uri() . '/colors/brown/preview.png' ), 'custom' => array( 'name' => __( 'Custom', 'blueprint' ), 'preview' => get_template_directory_uri() . '/preview.png' ) ); return apply_filters( 'blueprint_color_schemes', $color_schemes ); } /* * Color Schemes Head * * Enqueue any scripts or style necessary to display the chosen color * scheme. This is passed through an action too for child themes. * */ function color_scheme_scripts() { if ( isset( $this->options['color-scheme'] ) ) { if ( $this->options['color-scheme'] == 'default' ) { wp_enqueue_style( 'blueprint-default', get_template_directory_uri() . '/colors/default/default.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'black' ) { wp_enqueue_style( 'blueprint-black', get_template_directory_uri() . '/colors/black/black.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'white' ) { wp_enqueue_style( 'blueprint-white', get_template_directory_uri() . '/colors/white/white.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'red' ) { wp_enqueue_style( 'blueprint-red', get_template_directory_uri() . '/colors/red/red.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'orange' ) { wp_enqueue_style( 'blueprint-orange', get_template_directory_uri() . '/colors/orange/orange.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'yellow' ) { wp_enqueue_style( 'blueprint-yellow', get_template_directory_uri() . '/colors/yellow/yellow.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'green' ) { wp_enqueue_style( 'blueprint-green', get_template_directory_uri() . '/colors/green/green.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'purple' ) { wp_enqueue_style( 'blueprint-purple', get_template_directory_uri() . '/colors/purple/purple.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'gray' ) { wp_enqueue_style( 'blueprint-gray', get_template_directory_uri() . '/colors/gray/gray.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'brown' ) { wp_enqueue_style( 'blueprint-brown', get_template_directory_uri() . '/colors/brown/brown.css', array(), null ); } elseif ( $this->options['color-scheme'] == 'custom' ) { wp_enqueue_style( 'blueprint-custom', get_template_directory_uri() . '/custom.css', array(), null ); } do_action( 'blueprint_enqueue_color_scheme', $this->options['color-scheme'] ); } else { wp_enqueue_style( 'default', get_template_directory_uri() . '/colors/default/default.css', array(), null ); } wp_register_style( 'blueprint-fonts', 'http://fonts.googleapis.com/css?family=Cousine' ); wp_enqueue_style( 'blueprint-fonts' ); wp_enqueue_style( 'style', get_stylesheet_uri() ); } /* * Register Settings * * Fired during admin_init, this function registers the settings used * in the Theme options section, as well as attaches a validator to * clean up the icoming data. * */ function register_admin_settings() { register_setting( 'blueprint-options', 'blueprint-options', array( &$this, 'validate_options' ) ); // Settings fields and sections add_settings_section( 'section_general', ' ', '__return_null', 'blueprint-options' ); //Theme only has one section, therefore $callback is null add_settings_field( 'color-scheme', __( 'Color Scheme', 'blueprint' ), array( &$this, 'setting_color_scheme' ), 'blueprint-options', 'section_general' ); } /* * Options Validation * * This function is used to validate the incoming options, mostly from * the Theme Options admin page. * */ function validate_options($options) { // Theme options. $options['color-scheme'] = array_key_exists( $options['color-scheme'], $this->get_valid_color_schemes() ) ? $options['color-scheme'] : 'default'; return $options; } /* * Add Menu Options * * Registers a Theme Options page that appears under the Appearance * menu in the WordPress dashboard. Uses the theme_options to render * the page contents, requires edit_theme_options capabilities. * */ function add_admin_options() { add_theme_page( __( 'Theme Options', 'blueprint' ), __( 'Theme Options', 'blueprint' ), 'edit_theme_options', 'theme-options', array( &$this, 'theme_options' ) ); } /* * Comment walker * * This is used in the comments template, does the comments rendering. * Taken from Twenty Ten and localized. Nothing much here. * */ function comment_walker($comment, $args, $depth) { $GLOBALS['comment'] = $comment; switch ($comment->comment_type): case'': ?>
  • >

    comment_approved == '0' ): ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>



  • get_valid_color_schemes(); foreach ( $color_schemes as $value => $scheme ): ?>
    options['color-scheme'] ); ?> type="radio" name="blueprint-options[color-scheme]" id="blueprint-color-scheme-" value="" />

    options; $color = $options['color-scheme']; if ( isset( $color ) ) { if ( 'white' == $color ) { $blueprint_header_color = '000000'; } else { $blueprint_header_color = 'ffffff'; } } define( 'HEADER_TEXTCOLOR', $blueprint_header_color ); // By leaving empty, we allow for random image rotation. define( 'HEADER_IMAGE', '' ); // The height and width of your custom header. // Add a filter to header_image_width and header_image_height to change these values. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'header_image_width', 505 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'header_image_height', 150 ) ); // Add a way for the custom header to be styled in the admin panel that controls custom headers add_custom_image_header( array( &$this, 'blueprint_header_style' ), array( &$this, 'blueprint_admin_header_style' ), array( &$this, 'blueprint_admin_header_image' ) ); } /** * Styles the header image and text displayed on the blog * * */ function blueprint_header_style() { // If no custom options for text are set, let's bail // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank' ) or any hex value if ( HEADER_TEXTCOLOR == get_header_textcolor() ) return; // If we get this far, we have custom styles. Let's do this. ?> Header admin panel. * * Referenced via add_custom_image_header() in setup(). * */ function blueprint_admin_header_style() { wp_register_style( 'blueprint-fonts', 'http://fonts.googleapis.com/css?family=Cousine' ); wp_enqueue_style( 'blueprint-fonts' ); ?> Header admin panel. * * Referenced via add_custom_image_header() in setup(). * */ function blueprint_admin_header_image() { ?>

    onclick="return false;" href="">

    >

    For a transparent background the image needs to be the exact size mentioned below. When WordPress crops an image it gets saved as a .jpg, removing transparency. To work around this edit the functions.php file by visiting the Editor option under the appearance menu. Look for the following code about 4/5 of the way down.

    define( 'HEADER_IMAGE_WIDTH', apply_filters( 'header_image_width', 505 ) );
    define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'header_image_height', 150 ) );

    Edit the width and height to fit the image you wish to use. Use 505 or less for the width. BE CAREFUL, and if you accidently break your site, follow these instructions. After saving the changes you can upload your file and maintain transparency.