Commit f558a62c authored by lucha's avatar lucha
Browse files

Carrington Blog 2.3.1

parent 23d95544
# Carrington CMS Theme Framework for WordPress
http://carringtontheme.com
by Crowd Favorite
http://crowdfavorite.com
Released under the GPL license
http://www.opensource.org/licenses/gpl-license.php
---
## Online Developer Resources
Please see the latest online developer resources for Carrington here:
http://carringtontheme.com/developers/
## What is Carrington?
1. A collection of elegant, high-end WordPress themes for end-users.
2. A designer and developer friendly CMS theme framework for WordPress.
3. A set of best practices for theme organization.
## Basic Framework Concept
Carrington is a CMS theme framework that virtually eliminates the need for custom conditional code in themes. Instead, template naming conventions along with the Carrington engine replace the need for this conditional code.
Theme functionality is broken up into thoughtfully crafted abstractions to enable customizations at different levels (the loop, the post/page content, comments, etc.) and the Carrington engine chooses which template to be used for each segment of the theme.
The abstractions and supported template types are designed to easily handle most of the customization scenarios we commonly see without the need to write custom code to use them.
## Context and Templates
WordPress provides a number of functions to help you determine what type of view a theme is showing. These include:
- `is_home()`
- `is_single()`
- `is_page()`
- `is_archive()`
- `in_category()`
- etc.
Carrington abstracts these to deduce a "context" that is used when selecting a template. There are three context types used by the Carrington framework:
1. Comment (dirs: comment)
2. Post (dirs: content, excerpt)
3. General (dirs: attachment, comments, footer, header, loop, posts, sidebar, single)
Each directory implements one of these contexts for selecting the appropriate template to use. Templates are used in page views based on how they match the given context(s) for the overall page and the specific pieces of content being displayed.
Read about the options available in each directory in the README file for that directory.
Note: "default.php" is a supported default file name for all directories, however we have found in real world usage that {dirname}-default.php is a preferable naming system. When you have a half-dozen "default.php" files open in your favorite text editor, telling them apart in the file list can be more difficult than it should be.
## Theme Organization
WordPress themes generally have a file structure similar to this:
- 404.php
- archive.php
- archives.php
- [...]
- sidebar.php
- single.php
- style.css
While this organization works well in many instances, it doesn't well support the concept of atomic elements that are combined to create a theme. For example, a representation of just a post's content, or just a comment, is not represented here.
Carrington respects the supported WordPress file naming conventions (for example `get_header()` will still work), but eschews them in favor of an organizational structure that better suits the abstraction and customization commonly needed for a WordPress theme.
Template files are layered into each other using the following basic approach:
1. top level templates that include
2. common elements like a header, footer and sidebar along with a
3. loop that includes
4. atomic post/page content or excerpt templates and, where appropriate, a
5. comments area template that includes
6. atomic template for comments and a
7. template for the comment form
## Actions and Filters
The Carrington core is a theme framework, not a parent/child theme system. It includes a core set of functions that enable the override template hierarchy. These functions include actions and filters where appropriate so that their functionality can be customized and overridden as needed. These actions and filters use the same hook and filter system used in the WordPress core.
### Filters
- `cfct_context` - allows you to apply filters to the return value of the `cfct_context()` function; the function that checks to see what posts file, loop file, etc. to show.
- `cfct_filename` - filter the output of the `cfct_filename()` function.
- `cfct_general_match_order` - set the order in which general templates are chosen (make it check for a cat-general template ahead of a cat-news template, etc.).
- `cfct_choose_general_template` - filter the output of the `cfct_choose_general_template()` function (the selected general template).
- `cfct_single_match_order` - set the order in which single and content templates are chosen (make it check for author templates ahead of meta template, etc.).
- `cfct_choose_single_template` - filter the output of the `cfct_choose_single_template()` function (the selected single template).
- `cfct_choose_content_template` - filter the output of the `cfct_choose_content_template()` function (the selected content template).
- `cfct_comment_match_order` - set the order in which content templates are chosen (make it check for role templates ahead of user templates, etc.).
- `cfct_choose_comment_template` - filter the output of the `cfct_choose_comment_template()` function (the selected comment template).
- `cfct_meta_templates` - filter the return value of the `cfct_meta_templates()` function (change the list of files returned).
- `cfct_cat_templates` - filter the return value of the `cfct_cat_templates()` function (change the list of files returned).
- `cfct_tag_templates` - filter the return value of the `cfct_tag_templates()` function (change the list of files returned).
- `cfct_author_templates` - filter the return value of the `cfct_author_templates()` function (change the list of files returned).
- `cfct_role_templates` - filter the return value of the `cfct_role_templates()` function (change the list of files returned).
- `cfct_parent_templates` - filter the return value of the `cfct_role_templates()` function (change the list of files returned).
- `cfct_single_templates` - filter the return value of the `cfct_parent_templates()` function (change the list of files returned).
- `cfct_comment_templates` - filter the return value of the `cfct_single_templates()` function (change the list of files returned).
`cfct_post_gallery_columns` - set the number of columns to show in the gallery.
`gallery_style` - retained from the WP function code copied in and altered for gallery display.
`cfct_option_defaults` - allows you to set defaults (alter/add/etc.) for Carrington options.
`cfct_files_{path}` - allows you to define the available files for a path.
### Actions
- `cfct_settings_form` - allows you to add your own fields to the Carrington Settings form (left for compatibility` - recommend using _top and _bottom as needed instead of this).
- `cfct_settings_form_top` - allows you to add your own fields at the top of the Carrington Settings form.
- `cfct_settings_form_bottom` - allows you to add your own fields at the bottom of the Carrington Settings form.
- `cfct_settings_form_after` - allows you to add your content after the Carrington Settings form. Useful if you want to add a second form to the page, or some other content.
- `cfct_update_settings` - allows you to take action when the Carrington settings are being saved (perhaps to also save fields you've added in the `cfct_settings_form` action).
## Plugins
Any .php files in the *plugins/* directory will be automatically loaded by Carrington. This is a great way to bundle in custom functions or to hook into Carrington's actions or filters and be able to distribute everything as a single theme package.
---
## Tips
There is very minor extra processing associated with the file system and context checks that Carrington requires. This overhead is virtually unnoticeable, however the use of a caching plugin is recommended as a general best practice.
<?php
$url = trailingslashit(get_template_directory_uri());
define('CFCT_ASSETS_URL', $url.'assets/');
wp_enqueue_style(
'carrington',
CFCT_ASSETS_URL.'css/css.php',
array(),
CFCT_VER
);
wp_enqueue_script('jquery');
wp_enqueue_script(
'carrington',
CFCT_ASSETS_URL.'js/carrington.js',
array('jquery'),
CFCT_VER
);
if (cfct_get_option('cfct_ajax_load') == 'yes') {
cfct_ajax_load();
}
if (cfct_get_option('cfct_lightbox') != 'no') {
wp_enqueue_script(
'cfct_thickbox',
$url.'carrington-core/lightbox/thickbox.js',
array('jquery'),
CFCT_VER
);
wp_enqueue_style(
'cfct_thickbox',
$url.'carrington-core/lightbox/css/thickbox.css',
array(),
CFCT_VER
);
}
/* Additional stuff to put in wp_head */
function cfct_blog_head() {
cfct_get_option('cfct_ajax_load') == 'no' ? $ajax_load = 'false' : $ajax_load = 'true';
echo '
<script type="text/javascript">
var CFCT_URL = "'.home_url().'";
var CFCT_AJAX_LOAD = '.$ajax_load.';
</script>
';
if (cfct_get_option('cfct_lightbox') != 'no') {
echo '
<script type="text/javascript">
tb_pathToImage = "' . get_template_directory_uri() . '/carrington-core/lightbox/img/loadingAnimation.gif";
jQuery(function($) {
$("a.thickbox").each(function() {
var url = $(this).attr("rel");
var post_id = $(this).parents("div.post, div.page").attr("id");
$(this).attr("href", url).attr("rel", post_id);
});
});
</script>';
}
// preview
if (isset($_GET['cfct_action']) && $_GET['cfct_action'] == 'custom_color_preview' && current_user_can('manage_options')) {
cfct_blog_custom_colors('preview');
}
else if (cfct_get_option('cfct_custom_colors') == 'yes') {
cfct_blog_custom_colors();
}
if (cfct_get_option('cfct_custom_header_image') == 'yes') {
$header_image = cfct_get_option('cfct_header_image');
if ($header_image != 0 && $img = wp_get_attachment_image_src($header_image, 'large')) {
?>
<style type="text/css">
#header .wrapper {
background-image: url(<?php echo $img[0]; ?>);
background-repeat: no-repeat;
min-height: <?php echo $img[2]; ?>px;
}
</style>
<?php
}
else {
?>
<style type="text/css">
#header .wrapper {
background-image: url();
}
</style>
<?php
}
}
}
add_action('wp_head', 'cfct_blog_head');
function cfct_blog_custom_colors($type = 'option') {
$colors = cfct_get_custom_colors($type);
if (get_option('cfct_header_image_type') == 'light') {
$header_img_type = 'light';
$header_grad_type = 'dark';
}
else {
$header_img_type = 'dark';
$header_grad_type = 'light';
}
get_option('cfct_footer_image_type') == 'light' ? $footer_img_type = 'light' : $footer_img_type = 'dark';
?>
<style type="text/css">
#header {
background-color: #<?php echo $colors['cfct_header_background_color']; ?>;
color: #<?php echo $colors['cfct_header_text_color']; ?>;
}
#header a,
#header a:visited {
color: #<?php echo $colors['cfct_header_link_color']; ?>;
}
#sub-header,
.nav ul{
background-color: #<?php echo $colors['cfct_header_nav_background_color']; ?>;
color: #<?php echo $colors['cfct_header_nav_text_color']; ?>;
}
#sub-header a,
#sub-header a:visited,
.nav li li a,
.nav li li a:visited {
color: #<?php echo $colors['cfct_header_nav_link_color']; ?> !important;
}
h1,
h1 a,
h1 a:hover,
h1 a:visited {
color: #<?php echo $colors['cfct_page_title_color']; ?>;
}
h2,
h2 a,
h2 a:hover,
h2 a:visited {
color: #<?php echo $colors['cfct_page_subtitle_color']; ?>;
}
a,
a:hover,
a:visited {
color: #<?php echo $colors['cfct_link_color']; ?>;
}
.hentry .edit,
.hentry .edit a,
.hentry .edit a:visited,
.hentry .edit a:hover,
.comment-reply-link,
.comment-reply-link:visited,
.comment-reply-link:hover {
background-color: #<?php echo $colors['cfct_link_color']; ?>;
}
#footer {
background-color: #<?php echo $colors['cfct_footer_background_color']; ?>;
color: #<?php echo $colors['cfct_footer_text_color']; ?>;
}
#footer a,
#footer a:visited {
color: #<?php echo $colors['cfct_footer_link_color']; ?>;
}
#footer p#developer-link a,
#footer p#developer-link a:visited {
background-image: url(<?php echo CFCT_ASSETS_URL; ?>img/footer/by-crowd-favorite-<?php echo $footer_img_type; ?>.png);
}
<?php
if (cfct_get_option('cfct_css_background_images') != 'no') {
?>
#header {
background-image: url(<?php echo CFCT_ASSETS_URL; ?>img/header/gradient-<?php echo $header_grad_type; ?>.png);
}
#header .wrapper {
background-image: url(<?php echo CFCT_ASSETS_URL; ?>img/header/texture-<?php echo $header_img_type; ?>.png);
}
#footer {
background-image: url(<?php echo CFCT_ASSETS_URL; ?>img/footer/gradient-<?php echo $footer_img_type; ?>.png);
}
<?php
}
?>
</style>
<?php
}
?>
\ No newline at end of file
## image/
This directory holds templates for images/attachments.
## General Context
When choosing a template to use in the General Context, the Carrington engine looks at the type of request is being fulfilled. It will identify the request as the home page, a category archive, and individual post, etc.
There is additional checking done for single post requests. All options in the Content Context are supported here with a 'single-' prefix added to the file. See specifics below.
A "default" template is required, and will be used when there are no other templates that match a given comment. This could be because no other templates have been created, or because the comment in question doesn't match the templates that are available.
By default, conditions are checked in this order:
1. author
2. role
3. category
4. tag
5. single
6. default (home, search, archive, 404, etc.)
This can be altered using the `cfct_general_match_order` hook.
### Supported Templates (General Context)
- *{dirname}-default.php* (or default.php) - Used when there are no other templates that match for a given page/post.
- *archive.php* - Used for date archives or if there are no specific category, author or tag templates.
- *author.php* - Used for author archive lists.
- *author-{username}.php* - Used when the post/page is authored by a specific user. For example, a template with a file name of _author-jsmith.php_ would be used for a post/page by user _jsmith_. Any WordPress username can take the place of {username} in the file name.
- *role-{rolename}.php - Used when the post author has a particular role. This might be the role of _contributor_, _author_, _editor_, etc. and use a file of _role-contributor.php_, _role_author.php_, etc. where the role name takes the place of the {rolename} in the file name.
- *category.php* - Used for category archive lists.
- *cat-{slug}.php* - Used fr displaying a given category. The category is matched by the "slug" - for example a post in category "General" (with a category slug of "general") could use a template of _cat-general.php_.
- *home.php* - Used when on the home page.
- *page.php* - Used for pages that do not match any other contextual templates.
- *search.php* - Used when displaying search results.
- *single.php* - Used for single post pages.
- *single-{content context filenames}.php* - Used for single post pages.
- *tag.php* - Used for tag archive lists.
- *tag-{slug}.php* - Used for displaying a given tag. The tag is matched by the "slug" - for example a post in tag "News" (with a tag slug of "news") could use a template of _tag-news.php_.
...@@ -28,13 +28,13 @@ global $post; ...@@ -28,13 +28,13 @@ global $post;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11"> <head profile="http://gmpg.org/xfn/11">
<title><?php wp_title( '-', true, 'right' ); echo esc_html( get_bloginfo('name') ); ?></title> <title><?php wp_title( '-', true, 'right' ); echo wp_specialchars( get_bloginfo('name'), 1 ); ?></title>
<meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<link href="<?php bloginfo('url') ?>" rel="home" /> <link href="<?php bloginfo('url') ?>" rel="home" />
<link rel="alternate" type="application/rss+xml" href="<?php bloginfo('rss2_url') ?>" title="<?php esc_attr(printf( __( '%s latest posts', 'carrington' ), get_bloginfo('name')) ) ?>" /> <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('rss2_url') ?>" title="<?php printf( __( '%s latest posts', 'carrington' ), wp_specialchars( get_bloginfo('name'), 1 ) ) ?>" />
<link rel="alternate" type="application/rss+xml" href="<?php bloginfo('comments_rss2_url') ?>" title="<?php esc_attr(printf( __( '%s latest comments', 'carrington' ), get_bloginfo('name')) ) ?>" /> <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('comments_rss2_url') ?>" title="<?php printf( __( '%s latest comments', 'carrington' ), wp_specialchars( get_bloginfo('name'), 1 ) ) ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url') ?>" /> <link rel="pingback" href="<?php bloginfo('pingback_url') ?>" />
<?php wp_get_archives('type=monthly&format=link'); ?> <?php wp_get_archives('type=monthly&format=link'); ?>
......
# Carrington Core Changelog # Carrington Core Framework Changelog
## 3.4
- Remove Thickbox code (if your theme needs this, please include it in the theme).
- Remove color picker code (if your theme needs this, please include it in the theme).
- Remove archive/category posts per page default override (can be re-enabled by theme).
- Bring in expected globals in templates. Can be disabled via filter (`cfct_template_file_globals`) if desired.
## 3.3.1
- Update header code option name to match that used in wp_head filter
## 3.3
- Implemented support for feed-{post context} templates in content/ and excerpt/ dirs
- Refactor options display
- Add utility function to return template instead of echoing
- Converted Carrington Settings pages to utilize the WordPress Settings API
- Remove compatibility functions, no longer supporting versions of WordPress that old
- Misc. changes to support new WP APIs and best practices
## 3.1
- Updated some variable names
- Support for custom taxonomies within the general context
- Implemented checked and selected functions for options
- E_NOTICE clean
- Added PHP doc blocks
- Support for post formats in the single context
- Added support for custom post type archive pages in general context
- Relies on features in WordPress 3.1
## 3.0.1 ## 3.0.1
......
<?php <?php
// This file is part of the Carrington Core Platform for WordPress // This file is part of the Carrington Theme Framework for WordPress
// http://crowdfavorite.com/wordpress/carrington-core/ // http://carringtontheme.com
// //
// Copyright (c) 2008-2012 Crowd Favorite, Ltd. All rights reserved. // Copyright (c) 2008-2010 Crowd Favorite, Ltd. All rights reserved.
// http://crowdfavorite.com // http://crowdfavorite.com
// //
// Released under the GPL license // Released under the GPL license
...@@ -19,313 +19,77 @@ if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); } ...@@ -19,313 +19,77 @@ if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
// - add admin page for config settings // - add admin page for config settings
function cfct_option_css() {
}
/**
* Add a menu option under the admin themes menu
*
**/
function cfct_admin_menu() { function cfct_admin_menu() {
add_theme_page( if (!current_user_can('manage_options')) {
return;
}
add_submenu_page(
'themes.php',
apply_filters('cfct_admin_settings_title', __('Carrington Theme Settings', 'carrington')), apply_filters('cfct_admin_settings_title', __('Carrington Theme Settings', 'carrington')),
apply_filters('cfct_admin_settings_menu', __('Theme Settings', 'carrington')), apply_filters('cfct_admin_settings_menu', __('Theme Settings', 'carrington')),
'edit_theme_options', 0,
'carrington-settings', 'carrington-settings',
'cfct_settings_form' 'cfct_settings_form'
); );
} }
add_action('admin_menu', 'cfct_admin_menu'); add_action('admin_menu', 'cfct_admin_menu');
/**
* Add a menu option under the admin admin bar
*
**/
function cfct_admin_bar() {
global $wp_admin_bar;
if (current_user_can('edit_theme_options')) {
$wp_admin_bar->add_menu(array(
'id' => 'theme-settings',
'title' => apply_filters('cfct_admin_settings_menu', __('Theme Settings', 'carrington')),
'href' => admin_url('themes.php?page=carrington-settings'),
'parent' => 'appearance'
));
}
}
add_action('wp_before_admin_bar_render', 'cfct_admin_bar');
/**
* Deprecated in favor of WP Core Settings API
**/
function cfct_admin_request_handler() { function cfct_admin_request_handler() {
_deprecated_function(__FUNCTION__, '3.2'); if (isset($_POST['cf_action'])) {
} switch ($_POST['cf_action']) {
case 'cfct_update_settings':
/** call_user_func($_POST['cf_action']);
* Deprecated in favor of WP Core Settings API wp_redirect(trailingslashit(get_bloginfo('wpurl')).'wp-admin/themes.php?page=carrington-settings&updated=true');
**/
function cfct_update_settings() {
_deprecated_function(__FUNCTION__, '3.2');
}
/**
* Register Theme Settings screen options using WP Settings API
*/
function cfct_register_options() {
global $cfct_hidden_fields;
$yn_options = array(
'yes' => __('Yes', 'carrington'),
'no' => __('No', 'carrington')
);
$cfct_options = array(
'cfct' => array(
'label' => '',
//This is a callback, use cfct_options_blank to display nothing
'description' => 'cfct_options_blank',
'fields' => array(
'about' => array(
'type' => 'textarea',
'label' => __('About text (shown in sidebar)', 'carrington'),
'cols' => 60,
'rows' => 5,
'name' => 'about_text',
),
'header' => array(
'type' => 'textarea',
'label' => __('Header code (analytics, etc.)', 'carrington'),
'name' => 'wp_head',
),
'footer' => array(
'type' => 'textarea',
'label' => __('Footer code (analytics, etc.)', 'carrington'),
'name' => 'wp_footer',
),
'copyright' => array(
'type' => 'text',
'label' => __('Copyright / legal footer text', 'carrington'),
'name' => 'copyright',
'help' => '<br /><span class="cfct-help">'.__('(add %Y to output the current year)', 'carrington').'</span>',
'class' => 'cfct-text-long',
),
'login' => array(
'type' => 'radio',
'label' => __('Show log in/out links in footer', 'carrington'),
'name' => 'login_link_enabled',
'options' => $yn_options,
),
'credit' => array(
'type' => 'radio',
'label' => __('Give credit in footer', 'carrington'),
'name' => 'credit',
'options' => $yn_options,
),
/**
'radio' => array(
'type' => 'radio',
'label' => __('Radio Buttons', 'carrington'),
'name' => 'radio_test',
'options' => array(
'value_one' => 'Radio Bar',