Untitled diff

Created Diff never expires
178 removals
334 lines
168 additions
324 lines
<?php
<?php
/**
/**
* Spun functions and definitions
* Spun functions and definitions
*
*
* @package Spun
* @package Spun
* @since Spun 1.0
*/
*/
/**
/**
* Set the content width based on the theme's design and stylesheet.
* Set the content width based on the theme's design and stylesheet.
*
*
* @since Spun 1.0
*/
*/
if ( ! isset( $content_width ) )
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
$content_width = 700; /* pixels */
if ( ! function_exists( 'spun_setup' ) ):
if ( ! function_exists( 'spun_setup' ) ):
/**
/**
* Sets up theme defaults and registers support for various WordPress features.
* Sets up theme defaults and registers support for various WordPress features.
*
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
* support post thumbnails.
*
*
* @since Spun 1.0
*/
*/
function spun_setup() {
function spun_setup() {
/**
/**
* Custom template tags for this theme.
*/
require( get_template_directory() . '/inc/template-tags.php' );
/**
* Custom functions that act independently of the theme templates
*/
require( get_template_directory() . '/inc/tweaks.php' );
/* Jetpack Infinite Scroll */
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => 'page',
'render' => 'spun_infinite_scroll',
'posts_per_page' => 15,
'footer_widgets' => array( 'sidebar-1', 'sidebar-2', 'sidebar-3' ),
) );
/* Load the proper content template */
function spun_infinite_scroll() {
while( have_posts() ) {
the_post();
get_template_part( 'content', 'home' );
}
}
/**
* Make theme available for translation
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* Translations can be filed in the /languages/ directory
* If you're building a theme based on Spun, use a find and replace
* If you're building a theme based on Spun, use a find and replace
* to change 'spun' to the name of your theme in all the template files
* to change 'spun' to the name of your theme in all the template files
*/
*/
load_theme_textdomain( 'spun', get_template_directory() . '/languages' );
load_theme_textdomain( 'spun', get_template_directory() . '/languages' );
/**
/**
* Add default posts and comments RSS feed links to head
* Add default posts and comments RSS feed links to head
*/
*/
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'automatic-feed-links' );
/**
/**
* Enable support for Post Thumbnails
* Enable support for Post Thumbnails
*/
*/
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 360, 360, true );
add_image_size( 'home-post', 360, 360, true );
add_image_size( 'single-post', 700, 467, true );
add_image_size( 'single-post', 700, 999 );
/**
/**
* This theme uses wp_nav_menu() in one location.
* This theme uses wp_nav_menu() in one location.
*/
*/
register_nav_menus( array(
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'spun' ),
'primary' => __( 'Primary Menu', 'spun' ),
) );
) );
/**
/**
* Add support for custom backgrounds
* Add support for custom backgrounds
*/
*/
add_theme_support( 'custom-background' );
add_theme_support( 'custom-background' );
/**
* Add support for editor styles
*/
add_editor_style();
/**
/**
* Add support for Post Formats
* Add support for Post Formats
*/
*/
add_theme_support( 'post-formats', array( 'aside', 'gallery', 'image', 'quote', 'status' ) );
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status', 'gallery' ) );
}
}
endif; // spun_setup
endif; // spun_setup
add_action( 'after_setup_theme', 'spun_setup' );
add_action( 'after_setup_theme', 'spun_setup' );
/* Filter to add author credit to Infinite Scroll footer */
function spun_footer_credits( $credit ) {
$credit = sprintf( __( '%3$s | Theme: %1$s by %2$s.', 'spun' ), 'Spun', '<a href="http://carolinemoore.net/" rel="designer">Caroline Moore</a>', '<a href="http://wordpress.org/" title="' . esc_attr( __( 'A Semantic Personal Publishing Platform', 'spun' ) ) . '" rel="generator">Proudly powered by WordPress</a>' );
return $credit;
}
add_filter( 'infinite_scroll_credit', 'spun_footer_credits' );
/**
* Filter archives to display one less post per page to account for the .page-title circle
*/
function limit_posts_per_archive_page() {
if ( ! is_home() && is_archive() || is_search() ) {
$posts_per_page = intval( get_option( 'posts_per_page' ) ) - 1;
set_query_var( 'posts_per_page', $posts_per_page );
}
}
add_filter( 'pre_get_posts', 'limit_posts_per_archive_page' );
/**
/**
* Register widgetized area and update sidebar with default widgets
* Register widgetized area and update sidebar with default widgets
*
*
* @since Spun 1.0
*/
*/
function spun_widgets_init() {
function spun_widgets_init() {
register_sidebar( array(
register_sidebar( array(
'name' => __( 'Sidebar 1', 'spun' ),
'name' => __( 'Sidebar 1', 'spun' ),
'id' => 'sidebar-1',
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
'after_title' => '</h1>',
) );
) );
register_sidebar( array(
register_sidebar( array(
'name' => __( 'Sidebar 2', 'spun' ),
'name' => __( 'Sidebar 2', 'spun' ),
'id' => 'sidebar-2',
'id' => 'sidebar-2',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
'after_title' => '</h1>',
) );
) );
register_sidebar( array(
register_sidebar( array(
'name' => __( 'Sidebar 3', 'spun' ),
'name' => __( 'Sidebar 3', 'spun' ),
'id' => 'sidebar-3',
'id' => 'sidebar-3',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
'after_title' => '</h1>',
) );
) );
}
}
add_action( 'widgets_init', 'spun_widgets_init' );
add_action( 'widgets_init', 'spun_widgets_init' );
/**
/**
* Enqueue scripts and styles
* Enqueue scripts and styles
*/
*/
function spun_scripts() {
function spun_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'spun-toggle', get_template_directory_uri() . '/js/toggle.js', array( 'jquery' ), '20121005', true );
wp_enqueue_script( 'spun-toggle', get_template_directory_uri() . '/js/toggle.js', array( 'jquery' ), '20121005', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
wp_enqueue_script( 'comment-reply' );
}
}
if ( is_singular() && wp_attachment_is_image() ) {
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
}
wp_enqueue_style( 'spun-quicksand' );
wp_enqueue_style( 'spun-quicksand' );
wp_enqueue_style( 'spun-playfair' );
wp_enqueue_style( 'spun-playfair' );
wp_enqueue_style( 'spun-nunito' );
wp_enqueue_style( 'spun-nunito' );
}
}
add_action( 'wp_enqueue_scripts', 'spun_scripts', 1 );
add_action( 'wp_enqueue_scripts', 'spun_scripts', 1 );
function spun_options_styles() {
/*
if ( false == get_theme_mod( 'spun_grayscale', false ) ) : ?>
* Change the theme's accent color
<style type="text/css">
* Not yet working with the Customizer
.blog .hentry a .attachment-home-post,
* @todo find a way to reset to default values
.archive .hentry a .attachment-home-post,
* /
.search .hentry a .attachment-home-post {
function spun_custom_color() {
filter: grayscale(100%);
//If a custom accent color is set, use it!
-webkit-filter: grayscale(100%);
if ( '' != get_theme_mod( 'spun_color' ) ) {
-webkit-filter: grayscale(1); /* Older versions of webkit */
-moz-filter: grayscale(100%);
$color = esc_html( get_theme_mod( 'spun_color' ) ); ?>
-o-filter: grayscale(100%);
-ms-filter: grayscale(100%); /* IE 10 */
filter: gray; /* IE 9 */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox */
}
@media screen and ( max-width: 800px ) {
/* Remove hover effects for touchscreens */
.blog .hentry a .attachment-home-post,
.archive .hentry a .attachment-home-post,
.search .hentry a .attachment-home-post {
filter:none;
-webkit-filter:none;
-moz-filter:none;
-o-filter:none;
}
}
</style>
<?php
endif;
if ( false == get_theme_mod( 'spun_opacity', false ) ) : ?>
<style type="text/css">
<style type="text/css">
::selection,
.site-content #nav-below .nav-previous a,
button:hover,
.site-content #nav-below .nav-next a,
html input[type="button"]:hover,
.site-content #image-navigation .nav-previous a,
input[type="reset"]:hover,
.site-content #image-navigation .nav-next a,
input[type="submit"]:hover,
.comment-navigation .nav-next,
.site-description,
.comment-navigation .nav-previous,
.hentry.no-thumbnail:hover,
#infinite-handle span,
.page-links a:hover span.active-link,
.sidebar-link,
a.comment-reply-link,
a#cancel-comment-reply-link,
.comments-link a,
.hentry.no-thumbnail,
button,
html input[type="button"],
input[type="reset"],
input[type="submit"],
.site-footer {
opacity: .2;
}
.site-header,
.entry-meta-wrapper,
.comment-meta,
.page-links span.active-link,
.page-links span.active-link,
.page-header h1,
.page-links a span.active-link {
a.comment-reply-link:hover,
opacity: .3;
a#cancel-comment-reply-link:hover,
.comments-link a:hover,
.sidebar-link:hover {
background-color: <?php echo $color; ?>;
}
}
.comments-link a:hover .tail {
@media screen and ( max-width: 800px ) {
border-top-color: <?php echo $color; ?>;
/* Increase opacity for small screen sizes and touch screens */
.site-header,
.site-content #nav-below .nav-previous a,
.site-content #nav-below .nav-next a,
.site-content #image-navigation .nav-previous a,
.site-content #image-navigation .nav-next a,
.comment-navigation .nav-next a,
.comment-navigation .nav-previous a,
#infinite-handle span,
.sidebar-link,
a.comment-reply-link,
a#cancel-comment-reply-link,
.site-footer,
.comments-link a,
.comment-meta,
.entry-meta-wrapper,
.hentry.no-thumbnail,
.page-links span.active-link,
.page-links a span.active-link {
opacity: 1;
}
}
}
.entry-title,
</style>
.entry-title a,
<?php
.entry-content a,
endif;
.entry-content a:visited,
.widget a,
if ( false == get_theme_mod( 'spun_titles', false ) ) : ?>
.widget a:visited,
<style type="text/css">
.main-navigation a,
.hentry .thumbnail-title {
.main-navigation a:visited,
display: none;
.main-navigation ul ul .parent > a::after,
.main-small-navigation a,
.main-small-navigation a:visited,
.menu-toggle {
color: <?php echo $color; ?>;
}
}
</style>
</style>
<?php
<?php
}
endif;
}
}
add_action( 'wp_head', 'spun_options_styles', 1 );
if ( '' != get_theme_mod( 'spun_color' ) )
add_action( 'wp_head', 'spun_custom_color', 99 );*/
/**
/**
* Enqueue scripts and styles in custom header admin
* Register Google Fonts
*/
*/
function spun_admin_scripts( $hook_suffix ) {
function spun_google_fonts() {
if ( 'appearance_page_custom-header' != $hook_suffix )
$protocol = is_ssl() ? 'https' : 'http';
return;
wp_enqueue_style( 'spun-playfair' );
/* translators: If there are characters in your language that are not supported
by Playfair, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Playfair font: on or off', 'spun' ) ) {
}
wp_register_style( 'spun-playfair', "$protocol://fonts.googleapis.com/css?family=Playfair+Display:400,700,400italic,700italic" );
add_action( 'admin_enqueue_scripts', 'spun_admin_scripts' );
/**
}
* Register Google Fonts
*/
/* translators: If there are characters in your language that are not supported
function spun_register_fonts() {
by Quicksand, translate this to 'off'. Do not translate into your own language. */
$protocol = is_ssl() ? 'https' : 'http';
if ( 'off' !== _x( 'on', 'Quicksand font: on or off', 'spun' ) ) {
wp_register_style(
wp_register_style( 'spun-quicksand', "$protocol://fonts.googleapis.com/css?family=Quicksand:300" );
'spun-quicksand',
"$protocol://fonts.googleapis.com/css?family=Quicksand:300",
array(),
'20121005'
);
wp_register_style(
'spun-playfair',
"$protocol://fonts.googleapis.com/css?family=Playfair+Display:400,700,400italic,700italic",
array(),
'20121005'
);
wp_register_style(
'spun-nunito',
"$protocol://fonts.googleapis.com/css?family=Nunito:300",
array(),
'20121005'
);
}
add_action( 'init', 'spun_register_fonts' );
}
/* translators: If there are characters in your language that are not supported
by Nunito, translate this to 'off'. Do not translate into your own language. */
/**
if ( 'off' !== _x( 'on', 'Nunito font: on or off', 'spun' ) ) {
* Implement the Custom Header feature
*/
require( get_template_directory() . '/inc/custom-header.php' );
/**
wp_register_style( 'spun-nunito', "$protocol://fonts.googleapis.com/css?family=Nunito:300" );
* Remove widget title header if no title is entered.
* @todo Remove this function when this is fixed in core.
*/
function spun_calendar_widget_title( $title = '', $instance = '', $id_base = '' ) {
}
if ( 'calendar' == $id_base && '&nbsp;' == $title )
$title = '';
return $title;
}
}
add_filter( 'widget_title', 'spun_calendar_widget_title', 10, 3 );
add_action( 'init', 'spun_google_fonts' );
/**
/**
* Count the number of active sidebars and generate an ID to style them.
* Filter TinyMCE CSS path to include Google Fonts.
*
* Adds additional stylesheets to the TinyMCE editor if needed.
*
* @param string $mce_css CSS path to load in TinyMCE.
* @return string Filtered CSS path.
*/
*/
function typo_mce_css( $mce_css ) {
$protocol = is_ssl() ? 'https' : 'http';
$font_url = $protocol . '://fonts.googleapis.com/css?family=Quicksand:300|Playfair+Display:400,700,400italic,700italic';
function spun_count_sidebars() {
if ( empty( $font_url ) )
$count = 0;
return $mce_css;
if ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) )
if ( ! empty( $mce_css ) )
$count = 'one';
$mce_css .= ',';
if ( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) ||
$mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) );
is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-3' ) ||
is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) )
$count = 'two';
if ( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) )
return $mce_css;
$count = 'three';
print $count;
}
}
add_filter( 'mce_css', 'typo_mce_css' );
/**
/**
* Add color change theme options in the Customizer
* Enqueue Google Fonts for custom headers
* @todo find a way to reset to default values
*/
function spun_admin_scripts( $hook_suffix ) {
function spun_customize( $wp_customize ) {
$wp_customize->add_setting( 'spun_color', array(
if ( 'appearance_page_custom-header' != $hook_suffix )
'default' => '',
return;
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'spun_color', array(
wp_enqueue_style( 'spun-playfair' );
'label' => 'Accent Color',
wp_enqueue_style( 'spun-quicksand' );
'section' => 'colors',
'default' => '',
)
) );
}
}
add_action( 'admin_enqueue_scripts', 'spun_admin_scripts' );
/**
* Implement the Custom Header feature
*/
require( get_template_directory() . '/inc/custom-header.php' );
add_action( 'customize_register', 'spun_customize' );*/
/**
* Load Jetpack compatibility file.
*/
if ( file_exists( get_template_directory() . '/inc/jetpack.php' ) )
require get_template_directory() . '/inc/jetpack.php';
/**
* Custom template tags for this theme.
*/
require( get_template_directory() . '/inc/template-tags.php' );
/**
* Custom functions that act independently of the theme templates
*/
require( get_template_directory() . '/inc/extras.php' );
/**
* Customizer support for theme options
*/
require( get_template_directory() . '/inc/customizer.php' );