function ubersmake_custom_header_setup() { $args = array('default-image' => '%2$s/images/headers/atrium.jpg', 'default-text-color' => '000', 'width' => apply_filters('pilcrow_header_image_width', 990), 'height' => apply_filters('pilcrow_header_image_height', 257), 'wp-head-callback' => 'pilcrow_header_style', 'admin-head-callback' => 'pilcrow_admin_header_style', 'admin-preview-callback' => 'pilcrow_admin_header_image'); $options = pilcrow_get_theme_options(); if (in_array($options['theme_layout'], array('content-sidebar', 'sidebar-content'))) { $args['width'] = apply_filters('pilcrow_header_image_width', 770); $args['height'] = apply_filters('pilcrow_header_image_height', 200); } add_theme_support('custom-header', apply_filters('pilcrow_custom_header_args', $args)); set_post_thumbnail_size(get_custom_header()->width, get_custom_header()->height, true); register_default_headers(array('atrium' => array('url' => '%2$s/images/headers/atrium.jpg', 'thumbnail_url' => '%2$s/images/headers/atrium-thumbnail.jpg', 'description' => _x('Atrium', 'Header image description', 'ubersmake'), 'source' => 'https://www.flickr.com/photos/ubersmake/14967126893/'), 'cafe' => array('url' => '%2$s/images/headers/cafe.jpg', 'thumbnail_url' => '%2$s/images/headers/cafe-thumbnail.jpg', 'description' => _x('Cafe', 'Header image description', 'ubersmake'), 'source' => 'https://www.flickr.com/photos/ubersmake/15836437415/'), 'causeway' => array('url' => '%2$s/images/headers/causeway.jpg', 'thumbnail_url' => '%2$s/images/headers/causeway-thumbnail.jpg', 'description' => _x('Causeway', 'Header image description', 'ubersmake'), 'source' => 'https://www.flickr.com/photos/ubersmake/14975660961/'), 'edinburgh' => array('url' => '%2$s/images/headers/edinburgh.jpg', 'thumbnail_url' => '%2$s/images/headers/edinburgh-thumbnail.jpg', 'description' => _x('edinburgh', 'Header image description', 'ubersmake'), 'source' => 'https://www.flickr.com/photos/ubersmake/15062454096/'), 'paris' => array('url' => '%2$s/images/headers/paris.jpg', 'thumbnail_url' => '%2$s/images/headers/paris-thumbnail.jpg', 'description' => _x('Paris', 'Header image description', 'ubersmake'), 'source' => 'https://www.flickr.com/photos/ubersmake/15174505258/'))); }
/** * Setup the WordPress core custom header feature. * * @uses pilcrow_header_style() * @uses pilcrow_admin_header_style() * @uses pilcrow_admin_header_image() * * @package Pilcrow */ function pilcrow_custom_header_setup() { $args = array('default-image' => '%s/images/headers/books.jpg', 'default-text-color' => '000', 'width' => apply_filters('pilcrow_header_image_width', 990), 'height' => apply_filters('pilcrow_header_image_height', 257), 'wp-head-callback' => 'pilcrow_header_style', 'admin-head-callback' => 'pilcrow_admin_header_style', 'admin-preview-callback' => 'pilcrow_admin_header_image'); $options = pilcrow_get_theme_options(); if (in_array($options['theme_layout'], array('content-sidebar', 'sidebar-content'))) { $args['width'] = apply_filters('pilcrow_header_image_width', 770); $args['height'] = apply_filters('pilcrow_header_image_height', 200); } add_theme_support('custom-header', apply_filters('pilcrow_custom_header_args', $args)); // We'll be using post thumbnails for custom header images on posts and pages. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. set_post_thumbnail_size(get_custom_header()->width, get_custom_header()->height, true); // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers(array('books' => array('url' => '%s/images/headers/books.jpg', 'thumbnail_url' => '%s/images/headers/books-thumbnail.jpg', 'description' => _x('Books', 'Header image description', 'pilcrow')), 'record' => array('url' => '%s/images/headers/record.jpg', 'thumbnail_url' => '%s/images/headers/record-thumbnail.jpg', 'description' => _x('Record', 'Header image description', 'pilcrow')), 'pattern' => array('url' => '%s/images/headers/pattern.jpg', 'thumbnail_url' => '%s/images/headers/pattern-thumbnail.jpg', 'description' => _x('Pattern', 'Header image description', 'pilcrow')))); }
/** * Create the options page */ function pilcrow_theme_options_do_page() { if (!isset($_REQUEST['settings-updated'])) { $_REQUEST['settings-updated'] = false; } ?> <div class="wrap"> <?php screen_icon(); echo "<h2>" . get_current_theme() . __(' Theme Options', 'pilcrow') . "</h2>"; ?> <?php if (false !== $_REQUEST['settings-updated']) { ?> <div class="updated fade"><p><strong><?php _e('Options saved', 'pilcrow'); ?> </strong></p></div> <?php } ?> <form method="post" action="options.php"> <?php settings_fields('pilcrow_options'); ?> <?php $options = pilcrow_get_theme_options(); ?> <table class="form-table"> <?php /** * Pilcrow Color Scheme */ ?> <tr valign="top"><th scope="row"><?php _e('Color Scheme', 'pilcrow'); ?> </th> <td> <select name="pilcrow_theme_options[color_scheme]"> <?php $selected = $options['color_scheme']; $p = ''; $r = ''; foreach (pilcrow_color_schemes() as $option) { $label = $option['label']; if ($selected == $option['value']) { // Make default first in list $p = "\n\t<option selected='selected' value='" . esc_attr($option['value']) . "'>{$label}</option>"; } else { $r .= "\n\t<option value='" . esc_attr($option['value']) . "'>{$label}</option>"; } } echo $p . $r; ?> </select> <label class="description" for="pilcrow_theme_options[color_scheme]"><?php _e('Select a default color scheme', 'pilcrow'); ?> </label> </td> </tr> <?php /** * Pilcrow Layout */ ?> <tr valign="top" id="pilcrow-layouts"><th scope="row"><?php _e('Default Layout', 'pilcrow'); ?> </th> <td> <fieldset><legend class="screen-reader-text"><span><?php _e('Default Layout', 'pilcrow'); ?> </span></legend> <?php if (!isset($checked)) { $checked = ''; } foreach (pilcrow_layouts() as $option) { $radio_setting = $options['theme_layout']; if ('' != $radio_setting) { if ($options['theme_layout'] == $option['value']) { $checked = "checked=\"checked\""; } else { $checked = ''; } } ?> <div class="layout"> <label class="description"> <input type="radio" name="pilcrow_theme_options[theme_layout]" value="<?php echo esc_attr($option['value']); ?> " <?php echo $checked; ?> /> <span> <img src="<?php echo get_template_directory_uri(); ?> /images/<?php echo $option['value']; ?> .png"/> <?php echo $option['label']; ?> </span> </label> </div> <?php } ?> </fieldset> </td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Options', 'pilcrow'); ?> " /> </p> </form> </div> <?php }
<?php /** * The Sidebar containing the primary and secondary widget areas. * * @package Pilcrow * @since Pilcrow 1.0 */ /* If the current layout is no-sidebar, let's just get out of here. * If the current layout is a 3-column one with 2 sidebars on the right or left * Pilcrow enables a "Feature Widget Area" that should span both sidebar columns * and adds a containing div around the main sidebars for the content-sidebar-sidebar * and sidebar-sidebar-layouts so the layout holds together with a short content area and long featured widget area */ $options = pilcrow_get_theme_options(); if ('no-sidebar' == $options['theme_layout']) { return; } $feature_widget_area_layouts = array('content-sidebar-sidebar', 'sidebar-sidebar-content'); if (in_array($options['theme_layout'], $feature_widget_area_layouts)) { ?> <div id="main-sidebars"> <?php if (is_active_sidebar('sidebar-3')) { ?> <div id="feature" class="widget-area" role="complementary"> <ul class="xoxo sidebar-list"> <?php dynamic_sidebar('sidebar-3');
/** * Returns the current pilcrow layout as selected in the theme options * * @since pilcrow 1.0 */ function pilcrow_current_layout() { $options = pilcrow_get_theme_options(); $current_layout = $options['theme_layout']; $two_columns = array( 'content-sidebar', 'sidebar-content' ); $three_columns = array( 'content-sidebar-sidebar', 'sidebar-sidebar-content', 'sidebar-content-sidebar' ); if ( in_array( $current_layout, $two_columns ) ) return 'two-column ' . $current_layout; elseif ( in_array( $current_layout, $three_columns ) ) return 'three-column ' . $current_layout; else return $current_layout; }
/** * Create the options page */ function pilcrow_theme_options_do_page() { $options = pilcrow_get_theme_options(); ?> <div class="wrap"> <?php screen_icon(); ?> <h2><?php printf(__('%s Theme Options', 'pilcrow'), wp_get_theme()); ?> </h2> <?php settings_errors(); ?> <form method="post" action="options.php"> <?php settings_fields('pilcrow_options'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Color Scheme', 'pilcrow'); ?> </th> <td> <select name="pilcrow_theme_options[color_scheme]"> <?php foreach (pilcrow_color_schemes() as $scheme) { ?> <option value="<?php echo esc_attr($scheme['value']); ?> " <?php selected($options['color_scheme'], $scheme['value']); ?> ><?php echo $scheme['label']; ?> </option> <?php } ?> </select> <label class="description" for="pilcrow_theme_options[color_scheme]"><?php _e('Select a default color scheme', 'pilcrow'); ?> </label> </td> </tr> <tr valign="top" id="pilcrow-layouts"> <th scope="row"><?php _e('Default Layout', 'pilcrow'); ?> </th> <td> <fieldset> <legend class="screen-reader-text"><span><?php _e('Default Layout', 'pilcrow'); ?> </span></legend> <?php foreach (pilcrow_layouts() as $layout) { ?> <div class="layout"> <label class="description"> <input type="radio" name="pilcrow_theme_options[theme_layout]" value="<?php echo esc_attr($layout['value']); ?> " <?php checked($options['theme_layout'], $layout['value']); ?> /> <span> <img src="<?php echo get_template_directory_uri(); ?> /images/<?php echo $layout['value']; ?> .png"/> <?php echo $layout['label']; ?> </span> </label> </div> <?php } ?> </fieldset> </td> </tr> </table> <?php submit_button(); ?> </form> </div> <?php }