tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
add_image_size( 'scrawl-featured-header', '2000', '1500', true );
add_image_size( 'scrawl-site-logo', '300', '300' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'scrawl' ),
'social' => __( 'Social Links', 'scrawl' ),
) );
add_editor_style( array( 'editor-style.css', scrawl_fonts_url(), get_template_directory_uri() . '/fonts/genericons/genericons.css' ) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
/*
* Enable support for Post Formats.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'audio', 'chat', 'status'
) );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'scrawl_custom_background_args', array(
'default-color' => 'fffdfd',
) ) );
}
add_action( 'after_setup_theme', 'scrawl_setup' );
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function scrawl_widgets_init() {
register_sidebar( array(
'name' => __( 'Slide-Out Sidebar', 'scrawl' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '',
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'scrawl_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function scrawl_scripts() {
wp_enqueue_style( 'scrawl-style', get_stylesheet_uri(), array(), '20201020' );
wp_enqueue_style( 'scrawl-fonts', scrawl_fonts_url(), array(), null );
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '3.3' );
wp_enqueue_script( 'scrawl-script', get_template_directory_uri() . '/js/scrawl.js', array( 'jquery' ), '20150309', true );
wp_enqueue_script( 'scrawl-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'scrawl_scripts', 1 );
/**
* Register Google Fonts
*/
function scrawl_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Lora, translate this to 'off'. Do not translate
* into your own language.
*/
$lora = _x( 'on', 'Lora font: on or off', 'scrawl' );
/* Translators: If there are characters in your language that are not
* supported by Merriweather, translate this to 'off'. Do not translate
* into your own language.
*/
$merriweather = _x( 'on', 'Merriweather font: on or off', 'scrawl' );
$font_families = array();
if ( 'off' !== $lora && 'off' !== $merriweather ) {
if ( 'off' !== $lora ) {
$font_families[] = 'Lora:400,700';
}
if ( 'off' !== $merriweather ) {
$font_families[] = 'Merriweather:400italic,400,700,700italic';
}
}
$query_args = array(
'family' => implode( '|', $font_families ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
return $fonts_url;
}
/**
* Enqueue Google Fonts for custom headers
*/
function scrawl_admin_scripts( $hook_suffix ) {
wp_enqueue_style( 'scrawl-fonts', scrawl_fonts_url(), array(), null );
}
add_action( 'admin_enqueue_scripts', 'scrawl_admin_scripts' );
if ( ! function_exists( 'scrawl_featured_header' ) ) :
function scrawl_featured_header() {
if ( ! has_post_thumbnail() || ! is_single() ) {
return;
}
$img = wp_get_attachment_image_src( get_post_thumbnail_id(), 'scrawl-featured-header' );
?>