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( 833, 0, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Header Menu', 'afterlight-2' ),
) );
// Custom logo (core)
add_theme_support( 'custom-logo', array(
'height' => 120,
'width' => 120,
'flex-width' => true,
'header-text' => array(
'site-title',
'site-description'
),
) );
/*
* 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( 'afterlight_2_custom_background_args', array(
'default-attachment' => 'fixed',
'default-color' => '1a1a1a',
'default-image' => get_template_directory_uri() . '/assets/images/background.jpg',
'default-position-x' => 'center',
'default-repeat' => 'no-repeat',
'wp-head-callback' => 'afterlight_2_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', afterlight_2_fonts_url() ) );
}
endif; // afterlight_2_setup
add_action( 'after_setup_theme', 'afterlight_2_setup' );
/**
* Return early if Site Logo is not available.
*
* @since Afterlight 1.0
*/
function afterlight_2_the_site_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
if ( ! function_exists( 'afterlight_2_custom_background_cb' ) ) :
/**
* Add a wp-head callback to the custom background
*
* @since Afterlight 1.0
*/
function afterlight_2_custom_background_cb() {
$image = get_background_image();
$color = get_background_color();
if ( empty ( $image ) && empty ( $color ) ) {
return;
}
if ( ! empty ( $image ) ) {
_custom_background_cb();
}
if ( ! empty ( $color ) && '1a1a1a' != $color ) { ?>
__( 'Footer Widget Area', 'afterlight-2' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your footer.', 'afterlight-2' ),
'before_widget' => '',
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'afterlight_2_widgets_init' );
if ( ! function_exists( 'afterlight_2_fonts_url' ) ) :
/**
* Register Google fonts for afterlight 2.
*
* @since Afterlight 1.0
*
* @return string Google fonts URL for the theme.
*/
function afterlight_2_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = 'latin,latin-ext';
/* 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', 'afterlight-2' ) ) {
$fonts[] = 'Playfair Display:400,700,400italic,700italic';
}
/* 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', 'afterlight-2' ) ) {
$fonts[] = 'Lato: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', 'afterlight-2' ) ) {
$fonts[] = 'Inconsolata:400';
}
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 Afterlight 1.0
*/
function afterlight_2_javascript_detection() {
echo "\n";
}
add_action( 'wp_head', 'afterlight_2_javascript_detection', 0 );
/**
* Enqueue scripts and styles.
*
* @since Afterlight 1.0
*/
function afterlight_2_scripts() {
// Add custom fonts, used in the main stylesheet.
wp_enqueue_style( 'afterlight-2-fonts', afterlight_2_fonts_url(), array(), null );
// Load our main stylesheet.
wp_enqueue_style( 'afterlight-2-style', get_stylesheet_uri() );
wp_enqueue_script( 'afterlight-2-skip-link-focus-fix', get_template_directory_uri() . '/assets/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( 'afterlight-2-keyboard-image-navigation', get_template_directory_uri() . '/assets/js/keyboard-image-navigation.js', array( 'jquery' ), '20150302' );
}
wp_enqueue_script( 'afterlight-2-script', get_template_directory_uri() . '/assets/js/functions.js', array( 'jquery' ), '20150302', true );
wp_localize_script( 'afterlight-2-script', 'screenReaderText', array(
'expand' => afterlight_2_get_svg( array( 'icon' => 'expand' ) ) . '' . __( 'expand child menu', 'afterlight' ) . '',
'collapse' => afterlight_2_get_svg( array( 'icon' => 'expand' ) ) . '' . __( 'collapse child menu', 'afterlight' ) . '',
) );
wp_localize_script( 'afterlight-2-script', 'toggleButtonText', array(
'menu' => __( 'Menu', 'afterlight-2' ),
'widgets' => __( 'Widgets', 'afterlight-2' ),
'both' => __( 'Menu & Widgets', 'afterlight-2' ),
) );
}
add_action( 'wp_enqueue_scripts', 'afterlight_2_scripts' );
/**
* Determine if the subscribe widget should be displayed.
* The user has to have selected it in the Customizer, and a certain shortcode needs to be available:
* either blog_subscription_form (WP.com) or jetpack_subscription_form (WordPress.org).
* For jetpack_subscription_form to be available, Jetpack needs to be installed with the Subscriptions module active.
*/
function afterlight_2_display_subscribe_widget() {
if ( get_theme_mod( 'afterlight_2_subscribe_form' ) && ( shortcode_exists( 'blog_subscription_form' ) || shortcode_exists( 'jetpack_subscription_form' ) ) ) {
return true;
} else {
return false;
}
}
/**
* Filter the subscription form shortcode to handle differences between self-hosted and WP.com.
*/
function afterlight_2_subscribe_widget() {
echo do_shortcode( apply_filters( 'afterlight_2_subscribe_widget_filter', '[jetpack_subscription_form title="' . __( 'Get email updates', 'afterlight-2' ) . '" subscribers_total="false" subscribe_logged_in="" subscribe_text=""]' ) );
}
/**
* SVG icons functions and filters.
*/
require get_parent_theme_file_path( '/inc/icon-functions.php' );
/**
* Enqueue Google fonts style to admin screen for custom header display.
*
* @since Afterlight 1.0
*/
function afterlight_2_admin_fonts() {
wp_enqueue_style( 'afterlight-2-fonts', afterlight_2_fonts_url(), array(), null );
}
add_action( 'admin_print_scripts-appearance_page_custom-header', 'afterlight_2_admin_fonts' );
/**
* 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';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Load Contact Info code.
*/
require get_template_directory() . '/contact-info/contact-info-functions.php';