tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* 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' );
set_post_thumbnail_size( 256, 256, true );
add_image_size( 'resonar-large', 2000, 1500, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'resonar' ),
'social' => __( 'Social Links Menu', 'resonar' ),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'resonar_custom_background_args', array(
'default-color' => 'ffffff',
'wp-head-callback' => 'resonar_custom_background_cb'
) ) );
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
add_editor_style( array( 'editor-style.css', 'genericons/genericons.css', resonar_fonts_url() ) );
}
endif; // resonar_setup
add_action( 'after_setup_theme', 'resonar_setup' );
if ( ! function_exists( 'resonar_custom_background_cb' ) ) :
/**
* Add a wp-head callback to the custom background
*
* @since Resonar 1.0.3
*/
function resonar_custom_background_cb() {
$background_image = get_background_image();
$color = get_background_color();
if ( ! $background_image && ! $color ) {
return;
}
?>
__( 'Widget Area', 'resonar' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'resonar' ),
'before_widget' => '',
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'resonar_widgets_init' );
if ( ! function_exists( 'resonar_fonts_url' ) ) :
/**
* Register Google fonts for Resonar.
*
* @since Resonar 1.0
*
* @return string Google fonts URL for the theme.
*/
function resonar_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = 'latin,latin-ext';
/* translators: If there are characters in your language that are not supported by Libre Baskerville, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Libre Baskerville font: on or off', 'resonar' ) ) {
$fonts[] = 'Libre Baskerville:400,700,400italic';
}
/* translators: If there are characters in your language that are not supported by Lato, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'resonar' ) ) {
$fonts[] = 'Lato:400,700,900,400italic,700italic,900italic';
}
/* translators: If there are characters in your language that are not supported by Playfair Display, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Playfair Display font: on or off', 'resonar' ) ) {
$fonts[] = 'Playfair Display:400,700,400italic,700italic';
}
/* translators: If there are characters in your language that are not supported by Inconsolata, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'resonar' ) ) {
$fonts[] = 'Inconsolata:400';
}
/*
* Translators: To add an additional character subset specific to your language,
* translate this to 'cyrillic'. Do not translate into your own language.
*/
$subset = _x( 'no-subset', 'Add new subset (cyrillic)', 'resonar' );
if ( 'cyrillic' == $subset ) {
$subsets .= ',cyrillic';
}
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $fonts ) ),
'subset' => urlencode( $subsets ),
), 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
/**
* JavaScript Detection.
*
* Adds a `js` class to the root `` element when JavaScript is detected.
*
* @since Resonar 1.0
*/
function resonar_javascript_detection() {
echo "\n";
}
add_action( 'wp_head', 'resonar_javascript_detection', 0 );
/**
* Enqueue scripts and styles.
*
* @since Resonar 1.0
*/
function resonar_scripts() {
// Add custom fonts, used in the main stylesheet.
wp_enqueue_style( 'resonar-fonts', resonar_fonts_url(), array(), null );
// Add Genericons, used in the main stylesheet.
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.3' );
// Load our main stylesheet.
wp_enqueue_style( 'resonar-style', get_stylesheet_uri() );
wp_enqueue_script( 'resonar-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20150302', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'resonar-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20150302' );
}
wp_enqueue_script( 'resonar-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150302', true );
wp_localize_script( 'resonar-script', 'screenReaderText', array(
'expand' => '' . __( 'expand child menu', 'resonar' ) . '',
'collapse' => '' . __( 'collapse child menu', 'resonar' ) . '',
) );
wp_localize_script( 'resonar-script', 'toggleButtonText', array(
'menu' => __( 'Menu', 'resonar' ),
'widgets' => __( 'Widgets', 'resonar' ),
'both' => __( 'Menu & Widgets', 'resonar' ),
) );
}
add_action( 'wp_enqueue_scripts', 'resonar_scripts' );
/**
* Enqueue Google fonts style to admin screen for custom header display.
*
* @since Resonar 1.0
*/
function resonar_admin_fonts() {
wp_enqueue_style( 'resonar-fonts', resonar_fonts_url(), array(), null );
}
add_action( 'admin_print_scripts-appearance_page_custom-header', 'resonar_admin_fonts' );
/**
* Add a `screen-reader-text` class to the search form's submit button.
*
* @since Resonar 1.0
*
* @param string $html Search form HTML.
* @return string Modified search form HTML.
*/
function resonar_search_form_modify( $html ) {
return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html );
}
add_filter( 'get_search_form', 'resonar_search_form_modify' );
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function resonar_body_classes( $classes ) {
if ( is_singular() ) {
$classes[] = 'single';
}
if ( has_nav_menu( 'primary' ) ) {
$classes[] = 'custom-menu';
}
return $classes;
}
add_filter( 'body_class', 'resonar_body_classes' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';