for posts and comments.
add_theme_support( 'automatic-feed-links' );
/*
* This theme supports all available post formats.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'structured-post-formats', array(
'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
) );
/*
* Custom callback to make it easier for our fixed navbar to coexist with
* the WordPress toolbar. See `.wp-toolbar` in style.css.
*
* @see WP_Admin_Bar::initialize()
*/
add_theme_support( 'admin-bar', array(
'callback' => '__return_false'
) );
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) );
/*
* This theme uses a custom image size for featured images, displayed on
* "standard" posts and pages.
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 604, 270, true );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
}
add_action( 'after_setup_theme', 'twentythirteen_setup' );
/**
* Returns the Google font stylesheet URL, if available.
*
* The use of Source Sans Pro and Bitter by default is localized. For languages
* that use characters not supported by the font, the font can be disabled.
*
* @since Twenty Thirteen 1.0
*
* @return string Font stylesheet or empty string if disabled.
*/
function twentythirteen_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Source Sans Pro, translate this to 'off'. Do not translate
* into your own language.
*/
$source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' );
/* Translators: If there are characters in your language that are not
* supported by Bitter, translate this to 'off'. Do not translate into your
* own language.
*/
$bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' );
if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) {
$font_families = array();
if ( 'off' !== $source_sans_pro )
$font_families[] = 'Source+Sans+Pro:400,700,300italic,400italic,700italic';
if ( 'off' !== $bitter )
$font_families[] = 'Bitter:400,700';
$protocol = is_ssl() ? 'https' : 'http';
$query_args = array(
'family' => implode( '|', $font_families ),
'subset' => 'latin,latin-ext',
);
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
}
return $fonts_url;
}
/**
* Loads our special font CSS file.
*
* To disable in a child theme, use wp_dequeue_style()
* function mytheme_dequeue_fonts() {
* wp_dequeue_style( 'twentythirteen-fonts' );
* }
* add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );
*
* Also used in the Appearance > Header admin panel:
* @see twentythirteen_custom_header_setup()
*
* @since Twenty Thirteen 1.0
*
* @return void
*/
function twentythirteen_fonts() {
$fonts_url = twentythirteen_fonts_url();
if ( ! empty( $fonts_url ) )
wp_enqueue_style( 'twentythirteen-fonts', esc_url_raw( $fonts_url ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'twentythirteen_fonts' );
/**
* Adds additional stylesheets to the TinyMCE editor if needed.
*
* @uses twentythirteen_fonts_url() to get the Google Font stylesheet URL.
*
* @since Twenty Thirteen 1.0
*
* @param string $mce_css CSS path to load in TinyMCE.
* @return string
*/
function twentythirteen_mce_css( $mce_css ) {
$fonts_url = twentythirteen_fonts_url();
if ( empty( $fonts_url ) )
return $mce_css;
if ( ! empty( $mce_css ) )
$mce_css .= ',';
$mce_css .= esc_url_raw( str_replace( ',', '%2C', $fonts_url ) );
return $mce_css;
}
add_filter( 'mce_css', 'twentythirteen_mce_css' );
/**
* Enqueues scripts and styles for front end.
*
* @since Twenty Thirteen 1.0
*
* @return void
*/
function twentythirteen_scripts_styles() {
global $wp_styles;
/*
* Adds JavaScript to pages with the comment form to support sites with
* threaded comments (when in use).
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
// Adds Masonry to handle vertical alignment of footer widgets.
if ( is_active_sidebar( 'sidebar-1' ) )
wp_enqueue_script( 'jquery-masonry' );
// Loads JavaScript file with functionality specific to Twenty Thirteen.
wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20130211', true );
// Loads our main stylesheet.
wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() );
// Loads the Internet Explorer specific stylesheet.
wp_enqueue_style( 'twentythirteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentythirteen-style' ), '20130213' );
$wp_styles->add_data( 'twentythirteen-ie', 'conditional', 'lt IE 9' );
}
add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' );
/**
* Creates a nicely formatted and more specific title element text for output
* in head of document, based on current view.
*
* @since Twenty Thirteen 1.0
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string Filtered title.
*/
function twentythirteen_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentythirteen' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
/**
* Registers two widget areas.
*
* @since Twenty Thirteen 1.0
*
* @return void
*/
function twentythirteen_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Widget Area', 'twentythirteen' ),
'id' => 'sidebar-1',
'description' => __( 'Appears in the footer section of the site', 'twentythirteen' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Secondary Widget Area', 'twentythirteen' ),
'id' => 'sidebar-2',
'description' => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
'before_widget' => '',
'before_title' => '