'd8e8e7',
'text' => '000000',
'link' => '3d4b4e',
'border' => 'CCCCCC',
'url' => '99AA88',
);
}
add_theme_support( 'print-style' );
class San_Kloud {
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 San Kloud.
*
* $this->options is used to store all the theme options, while
* $this->defaults holds their default values.
*
*/
function __construct() {
// Load San Kloud text domain
load_theme_textdomain( 'san-kloud', 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_theme_support( 'custom-background' );
// Theme supports
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image', 'chat', 'video', 'audio' ) );
// 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', 'san-kloud' ) );
/*
* Actions
*
* Registers sidebars for widgets, registers admin settings, adds the menu options,
* color scheme preview scripts (sidebar), custom header
*
*/
add_action( 'widgets_init', array( &$this, 'register_sidebars' ) );
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, 'san_kloud_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( 'sankloud-options', $this->defaults );
}
/*
* Register Sidebars
*
* Registers a single right sidebar ready for widgets.
*
*/
function register_sidebars() {
register_sidebar( array(
'name' => __( 'Sidebar', 'san-kloud' ),
'id' => 'sidebar-1',
'description' => 'Main sidebar displayed on every page',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
/*
* 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', 'san-kloud' ),
'preview' => get_template_directory_uri() . '/colors/default/preview.png'
),
'orange' => array(
'name' => __( 'Orange', 'san-kloud' ),
'preview' => get_template_directory_uri() . '/colors/orange/preview.png'
),
'green' => array(
'name' => __( 'Green', 'san-kloud' ),
'preview' => get_template_directory_uri() . '/colors/green/preview.png'
)
);
return apply_filters( 'sankloud_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( 'sankloud-default', get_template_directory_uri() . '/colors/default/default.css', array(), null );
} elseif ( $this->options['color-scheme'] == 'orange' ) {
wp_enqueue_style( 'sankloud-orange', get_template_directory_uri() . '/colors/orange/orange.css', array(), null );
} elseif ( $this->options['color-scheme'] == 'green' ) {
wp_enqueue_style( 'sankloud-green', get_template_directory_uri() . '/colors/green/green.css', array(), null );
}
do_action( 'sankloud_enqueue_color_scheme', $this->options['color-scheme'] );
} else {
wp_enqueue_style( 'default', get_template_directory_uri() . '/colors/default/default.css', array(), null );
}
wp_enqueue_style( 'sankloud-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( 'sankloud-options', 'sankloud-options', array( &$this, 'validate_options' ) );
// Settings fields and sections
add_settings_section( 'section_general', ' ', '__return_null', 'sankloud-options' ); //Theme only has one section, therefore $callback is null
add_settings_field( 'color-scheme', __( 'Color Scheme', 'san-kloud' ), array( &$this, 'setting_color_scheme' ), 'sankloud-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', 'san-kloud' ), __( 'Theme Options', 'san-kloud' ), '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 'pingback' :
case 'trackback' :
?>
>
get_valid_color_schemes();
foreach ( $color_schemes as $value => $scheme ):
?>
options;
$color = $options['color-scheme'];
if ( isset( $color ) ) {
if ( 'green' == $color ) {
$san_kloud_header_color = 'bc214a';
}
else if ( 'orange' == $color ) {
$san_kloud_header_color = 'fd853e';
}
else {
$san_kloud_header_color = 'f9984d';
}
}
add_theme_support( 'custom-header', apply_filters( 'san_kloud_custom_header_args', array(
'default-image' => '',
'default-text-color' => $san_kloud_header_color,
'width' => 940,
'height' => 250,
'flex-height' => true,
'wp-head-callback' => array( $this, 'san_kloud_header_style' ),
'admin-head-callback' => array( $this, 'san_kloud_admin_header_style' ),
'admin-preview-callback' => array( $this, 'san_kloud_admin_header_image' ),
) ) );
}
/**
* Styles the header image and text displayed on the blog
*
*
*/
function san_kloud_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.
*/
function san_kloud_admin_header_style() {
wp_register_style( 'sankloud-fonts', 'https://fonts.googleapis.com/css?family=Hammersmith+One|Kreon:300,700|Arvo:700' );
wp_enqueue_style( 'sankloud-fonts' );
?>
Header admin panel.
*/
function san_kloud_admin_header_image() { ?>
>
tag based on what is being viewed.
*
* @since San Kloud 1.0.5
*/
function sankloud_wp_title( $title, $sep ) {
global $page, $paged;
if ( is_feed() )
return $title;
// Add the blog name
$title .= get_bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " $sep $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
$title .= " $sep " . sprintf( __( 'Page %s', 'san-kloud' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'sankloud_wp_title', 10, 2 );
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
comment_approved == '0' ): ?>