/** * WordPress.com-specific functions and definitions. * This file is centrally included from `wp-content/mu-plugins/wpcom-theme-compat.php`. * * @package Coraline */ function coraline_wpcom_setup() { global $themecolors; /** * Check the current color scheme and set the correct themecolors array */ $options = function_exists('coraline_get_theme_options') ? coraline_get_theme_options() : array(); if (!isset($options['color_scheme'])) { $options['color_scheme'] = 'light'; } if ('light' == $options['color_scheme']) { $themecolors = array('bg' => 'ffffff', 'border' => 'cccccc', 'text' => '333333', 'link' => '0060ff', 'url' => 'df0000'); } elseif ('dark' == $options['color_scheme']) { $themecolors = array('bg' => '151515', 'border' => '333333', 'text' => 'bbbbbb', 'link' => '80b0ff', 'url' => 'e74040'); } elseif ('pink' == $options['color_scheme']) { $themecolors = array('bg' => 'faccd6', 'border' => 'c59aa4', 'text' => '222222', 'link' => 'd6284d', 'url' => 'd6284d'); } elseif ('purple' == $options['color_scheme']) { $themecolors = array('bg' => 'e1ccfa', 'border' => 'c5b2de', 'text' => '333333', 'link' => '7728d6', 'url' => '7728d6'); } elseif ('brown' == $options['color_scheme']) { $themecolors = array('bg' => '9a7259', 'border' => 'b38970', 'text' => 'ffecd0', 'link' => 'ffd2b7', 'url' => 'ffd2b7'); } elseif ('red' == $options['color_scheme']) { $themecolors = array('bg' => 'a20013', 'border' => 'b92523', 'text' => 'e68d77', 'link' => 'ffd2b7', 'url' => 'ffd2b7'); } elseif ('blue' == $options['color_scheme']) { $themecolors = array('bg' => 'ccddfa', 'border' => 'b2c3de', 'text' => '333333', 'link' => '2869d6', 'url' => '2869d6'); } }
<?php /** * @package WordPress * @subpackage Coraline * @since Coraline 1.0 */ ?> <?php /* If the current layout is a 3-column one with 2 sidebars on the right or left * Coraline 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 = coraline_get_theme_options(); $current_layout = $options['theme_layout']; $feature_widget_area_layouts = array('content-sidebar-sidebar', 'sidebar-sidebar-content'); if (in_array($current_layout, $feature_widget_area_layouts)) { ?> <div id="main-sidebars"> <?php if (is_active_sidebar('feature-widget-area')) { ?> <div id="feature" class="widget-area" role="complementary"> <ul class="xoxo"> <?php dynamic_sidebar('feature-widget-area'); ?>
<?php endif; ?> <?php /* If there are no posts to display, such as an empty archive page */ ?> <?php if ( ! have_posts() ) : ?> <div id="post-0" class="post error404 not-found"> <h1 class="entry-title"><?php _e( 'Not Found', 'coraline' ); ?></h1> <div class="entry-content"> <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'coraline' ); ?></p> <?php get_search_form(); ?> </div><!-- .entry-content --> </div><!-- #post-0 --> <?php endif; ?> <?php // Start the Loop. $options = coraline_get_theme_options(); while ( have_posts() ) : the_post(); ?> <?php /* How to display posts in the Gallery category. */ ?> <?php if ( ( isset( $options['gallery_category'] ) && '0' != $options['gallery_category'] && in_category( $options['gallery_category'] ) ) || 'gallery' == get_post_format( $post->ID ) ) : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'coraline' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div class="entry-meta"> <?php coraline_posted_on(); coraline_posted_by(); ?> </div><!-- .entry-meta --> <div class="entry-content"> <?php if ( post_password_required() ) : ?> <?php the_content(); ?>
/** * Returns the current Coraline layout as selected in the theme options * * @since Coraline 1.0 */ function coraline_current_layout() { $options = coraline_get_theme_options(); $current_layout = $options['theme_layout']; $two_columns = array('content-sidebar', 'sidebar-content'); $three_columns = array('content-sidebar-sidebar', 'sidebar-content-sidebar', 'sidebar-sidebar-content'); 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 'no-sidebars'; } }
/** * Adds coraline_current_layout() and $color_scheme to the array of body classes * * @since Coraline 1.0 */ function coraline_body_class($classes) { $classes[] = coraline_current_layout(); $options = coraline_get_theme_options(); if (!empty($options['color_scheme']) && 'light' != $options['color_scheme']) { $classes[] = 'color-' . $options['color_scheme']; } return $classes; }
/** * Create the options page */ function coraline_theme_options_do_page() { if (!isset($_REQUEST['settings-updated'])) { $_REQUEST['settings-updated'] = false; } ?> <div class="wrap"> <?php screen_icon(); echo "<h2>" . sprintf(__('%1$s Theme Options', 'coraline'), get_current_theme()) . "</h2>"; ?> <?php if (false !== $_REQUEST['settings-updated']) { ?> <div class="updated fade"><p><strong><?php _e('Options saved', 'coraline'); ?> </strong></p></div> <?php } ?> <form method="post" action="options.php"> <?php settings_fields('coraline_options'); ?> <?php $options = coraline_get_theme_options(); ?> <table class="form-table"> <?php /** * Coraline Color Scheme */ ?> <tr valign="top"><th scope="row"><?php _e('Color Scheme', 'coraline'); ?> </th> <td> <select name="coraline_theme_options[color_scheme]"> <?php $selected_color = $options['color_scheme']; $p = ''; $r = ''; foreach (coraline_color_schemes() as $option) { $label = $option['label']; if ($selected_color == $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="coraline_theme_options[color_scheme]"><?php _e('Select a default color scheme', 'coraline'); ?> </label> </td> </tr> <?php /** * Coraline Layout */ ?> <tr valign="top" id="coraline-layouts"><th scope="row"><?php _e('Default Layout', 'coraline'); ?> </th> <td> <fieldset><legend class="screen-reader-text"><span><?php _e('Default Layout', 'coraline'); ?> </span></legend> <?php if (!isset($checked)) { $checked = ''; } foreach (coraline_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="coraline_theme_options[theme_layout]" value="<?php esc_attr_e($option['value'], 'coraline'); ?> " <?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> <?php /** * Coraline Aside Category */ $selected_aside_category = isset($options['aside_category']) ? $options['aside_category'] : null; if (!empty($selected_aside_category)) { ?> <tr valign="top"><th scope="row"><?php _e('Aside Category', 'coraline'); ?> </th> <td> <select name="coraline_theme_options[aside_category]"> <option value="0"><?php _e('Select a category …', 'coraline'); ?> </option> <?php $p = ''; $r = ''; foreach (get_categories(array('hide_empty' => 0)) as $category) { if ($selected_aside_category == $category->cat_name) { // Make default first in list $p = "\n\t<option selected='selected' value='" . esc_attr($category->cat_name) . "'>{$category->category_nicename}</option>"; } else { $r .= "\n\t<option value='" . esc_attr($category->cat_name) . "'>{$category->category_nicename}</option>"; } } echo $p . $r; ?> </select> <label class="description" for="coraline_theme_options[aside_category]"><?php _e('Select a category to use for shorter aside posts', 'coraline'); ?> </label> <div class="update-msg"><p>Note: Coraline now supports Post Formats! Read more at <a href="http://support.wordpress.com/posts/post-formats/">Support » Post Formats</a>.</p></div> </td> </tr> <?php } ?> <?php /** * Coraline Gallery Category */ $selected_gallery_category = isset($options['gallery_category']) ? $options['gallery_category'] : null; if (!empty($selected_gallery_category)) { ?> <tr valign="top"><th scope="row"><?php _e('Gallery Category', 'coraline'); ?> </th> <td> <select name="coraline_theme_options[gallery_category]"> <option value="0"><?php _e('Select a category …', 'coraline'); ?> </option> <?php $p = ''; $r = ''; foreach (get_categories(array('hide_empty' => 0)) as $category) { if ($selected_gallery_category == $category->cat_name) { // Make default first in list $p = "\n\t<option selected='selected' value='" . esc_attr($category->cat_name) . "'>{$category->category_nicename}</option>"; } else { $r .= "\n\t<option value='" . esc_attr($category->cat_name) . "'>{$category->category_nicename}</option>"; } } echo $p . $r; ?> </select> <label class="description" for="coraline_theme_options[gallery_category]"><?php _e('Select a category to use for posts with image galleries', 'coraline'); ?> </label> <div class="update-msg"><p>Note: Coraline now supports Post Formats! Read more at <a href="http://support.wordpress.com/posts/post-formats/">Support » Post Formats</a>.</p></div> </td> </tr> <?php } ?> </table> <p class="submit"> <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Options', 'coraline'); ?> " /> </p> </form> </div> <?php }