tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/* Add support for editor styles */
add_editor_style( array( 'editor-style.css', libre_fonts_url() ) );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary Menu', 'libre' ),
) );
/*
* 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( 'libre_custom_background_args', array(
'default-color' => 'ffffff',
) ) );
}
endif; // libre_setup
add_action( 'after_setup_theme', 'libre_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function libre_content_width() {
$GLOBALS['content_width'] = apply_filters( 'libre_content_width', 739 );
}
add_action( 'after_setup_theme', 'libre_content_width', 0 );
/*
* Adjust $content_width for full-width page template
*/
if ( ! function_exists( 'libre_content_width' ) ) :
function libre_content_width() {
global $content_width;
if ( is_page_template( 'fullwidth-page.php' ) ) {
$content_width = 1088; //pixels
}
}
add_action( 'template_redirect', 'libre_content_width' );
endif; // if ! function_exists( 'libre_content_width' )
/**
* Register widget area.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function libre_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'libre' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Widgets 1', 'libre' ),
'id' => 'footer-1',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Widgets 2', 'libre' ),
'id' => 'footer-2',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Widgets 3', 'libre' ),
'id' => 'footer-3',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'libre_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function libre_scripts() {
wp_enqueue_style( 'libre-style', get_stylesheet_uri() );
wp_enqueue_style( 'libre-libre', libre_fonts_url(), array(), null );
wp_enqueue_script( 'libre-script', get_template_directory_uri() . '/js/libre.js', array( 'jquery' ), '20150623', true );
$adminbar = is_admin_bar_showing();
wp_localize_script( 'libre-script', 'libreadminbar', array( $adminbar ) );
wp_enqueue_script( 'libre-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'libre-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', 'libre_scripts' );
/**
* Register Google Fonts
*/
function libre_fonts_url() {
$fonts_url = '';
/* 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.
*/
$libre = esc_html_x( 'on', 'Libre Baskerville font: on or off', 'libre' );
if ( 'off' !== $libre ) {
$font_families = array();
$font_families[] = 'Libre Baskerville:400,400italic,700';
$query_args = array(
'family' => urlencode( 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 libre_admin_scripts( $hook_suffix ) {
wp_enqueue_style( 'libre-libre', libre_fonts_url(), array(), null );
}
add_action( 'admin_print_styles-appearance_page_custom-header', 'libre_admin_scripts' );
/*
* Filters the Categories archive widget to add a span around the post count
*/
function libre_cat_count_span( $links ) {
$links = str_replace( ' (', '(', $links );
$links = str_replace( ')', ')', $links );
return $links;
}
add_filter( 'wp_list_categories', 'libre_cat_count_span' );
/*
* Add a span around the post count in the Archives widget
*/
function libre_archive_count_span( $links ) {
$links = str_replace( ' (', '(', $links );
$links = str_replace( ')', ')', $links );
return $links;
}
add_filter( 'get_archives_link', 'libre_archive_count_span' );
if ( ! function_exists( 'libre_continue_reading_link' ) ) :
/**
* Returns an ellipsis and "Continue reading" plus off-screen title link for excerpts
*/
function libre_continue_reading_link() {
return '… ' . sprintf( wp_kses_post( __( 'Continue reading %1$s →', 'libre' ) ), esc_attr( strip_tags( get_the_title() ) ) ) . '';
}
endif; // libre_continue_reading_link
/**
* Replaces "[...]" (appended to automatically generated excerpts) with libre_continue_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*/
function libre_auto_excerpt_more( $more ) {
return libre_continue_reading_link();
}
add_filter( 'excerpt_more', 'libre_auto_excerpt_more' );
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*
* To override this link in a child theme, remove the filter and add your own
* function tied to the get_the_excerpt filter hook.
*/
function libre_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= libre_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'libre_custom_excerpt_more' );
/*
* Custom comments display to move Reply link,
* used in comments.php
*/
function libre_comments( $comment, $args, $depth ) {
?>