400,
'width' => 400,
'flex-height' => true,
) );
// Enable support for Post Thumbnail
add_theme_support( 'post-thumbnails' );
add_image_size( 'brilliant-large', 780, 520, true );
add_image_size( 'brilliant-fullwidth', 1200, 520, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'main_menu' => esc_html__( 'Main Menu', 'brilliant' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'gallery', 'caption' ) );
// Enable support for Post Formats
add_theme_support('post-formats', array( 'image', 'video', 'audio', 'gallery', 'quote' ) );
// Set up the WordPress Custom Background Feature.
$defaults = array(
'default-color' => 'f4f4f4',
'default-image' => '',
);
add_theme_support( 'custom-background', $defaults );
// This theme styles the visual editor to resemble the theme style,
add_editor_style( array( 'css/editor-style.css', brilliant_fonts_url() ) );
// Custom template tags for this theme
require get_template_directory() . '/inc/template-tags.php';
// Theme Customizer
require get_template_directory() . '/inc/customizer.php';
// Load Jetpack compatibility file
require get_template_directory() . '/inc/jetpack.php';
}
endif;
add_action( 'after_setup_theme', 'brilliant_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 brilliant_content_width() {
$GLOBALS['content_width'] = apply_filters( 'brilliant_content_width', 1160 );
}
add_action( 'after_setup_theme', 'brilliant_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function brilliant_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'brilliant' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'brilliant' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area 1', 'brilliant' ),
'id' => 'footer-1',
'description' => __( 'Add widgets here to appear in your footer.', 'brilliant' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area 2', 'brilliant' ),
'id' => 'footer-2',
'description' => __( 'Add widgets here to appear in your footer.', 'brilliant' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Area 3', 'brilliant' ),
'id' => 'footer-3',
'description' => __( 'Add widgets here to appear in your footer.', 'brilliant' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'brilliant_widgets_init' );
if ( ! function_exists( 'brilliant_fonts_url' ) ) :
/**
* Register Google fonts.
*
* @return string Google fonts URL for the theme.
*/
function brilliant_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = 'latin,latin-ext';
/* translators: If there are characters in your language that are not supported by Raleway, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Raleway: on or off', 'brilliant' ) ) {
$fonts[] = 'Raleway:400,700,300,400italic,700italic';
}
/* 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: on or off', 'brilliant' ) ) {
$fonts[] = 'Playfair Display:400,700';
}
/* translators: If there are characters in your language that are not supported by Crimson Text, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Crimson Text: on or off', 'brilliant' ) ) {
$fonts[] = 'Crimson Text:400,400italic';
}
/* translators: To add an additional character subset specific to your language, translate this to 'greek', 'cyrillic', 'devanagari' or 'vietnamese'. Do not translate into your own language. */
$subset = _x( 'no-subset', 'Add new subset (greek, cyrillic, devanagari, vietnamese)', 'brilliant' );
if ( 'cyrillic' == $subset ) {
$subsets .= ',cyrillic,cyrillic-ext';
} elseif ( 'greek' == $subset ) {
$subsets .= ',greek,greek-ext';
} elseif ( 'devanagari' == $subset ) {
$subsets .= ',devanagari';
} elseif ( 'vietnamese' == $subset ) {
$subsets .= ',vietnamese';
}
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $fonts ) ),
'subset' => urlencode( $subsets ),
), '//fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
/**
* Enqueue scripts and styles.
*/
function brilliant_scripts() {
// Add Google fonts, used in the main stylesheet.
wp_enqueue_style( 'brilliant-fonts', brilliant_fonts_url(), array(), null );
// Add Icons font, used in the main stylesheet.
wp_enqueue_style( 'brilliant-icons', get_template_directory_uri() . '/fonts/elegant-icons.css', array(), '1.0.0' );
// Theme stylesheet.
wp_enqueue_style( 'brilliant-style', get_stylesheet_uri(), array(), '1.0.6' );
wp_enqueue_script( 'brilliant-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script( 'brilliant-script', get_template_directory_uri() . '/js/main.js', array( 'jquery' ), '20161104', true );
}
add_action( 'wp_enqueue_scripts', 'brilliant_scripts' );
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function brilliant_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
$blog_layout = esc_attr( get_theme_mod('blog_layout', 'blog-layout2') );
$archive_layout = esc_attr( get_theme_mod('archive_layout', 'archive-layout2') );
// Adds a class to Homepage
if ( is_home() ) {
$classes[] = $blog_layout;
}
// Adds a class to Archive and Search Pages
if ( is_archive() || is_search() ) {
$classes[] = $archive_layout;
}
return $classes;
}
add_filter( 'body_class', 'brilliant_body_classes' );
/**
* Custom Logo Backwards Compatibility with older versions of WordPress
*
*/
function brilliant_custom_logo() {
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
}
/**
* Filter the except length.
*
*/
function brilliant_excerpt_length( $excerpt_length ) {
if ( is_admin() ) {
return $excerpt_length;
}
if ( is_home() ) {
$excerpt_length = get_theme_mod( 'blog_excerpt_length', 25 );
} elseif ( is_archive() || is_search() ) {
$excerpt_length = get_theme_mod( 'archive_excerpt_length', 25 );
} else {
$excerpt_length = 25;
}
return intval($excerpt_length);
}
add_filter( 'excerpt_length', 'brilliant_excerpt_length', 999 );
/**
* Filter the "read more" excerpt string link to the post.
*
* @param string $more "Read more" excerpt string.
*/
function brilliant_excerpt_more( $more ) {
if ( is_admin() ) {
return $more;
}
if ( get_theme_mod( 'show_read_more', 1 ) ) {
$more = sprintf( '%2$s ›',
esc_url( get_permalink( get_the_ID() ) ),
__( 'Read More', 'brilliant' )
);
return ' … ' . $more;
} else {
return $more;
}
}
add_filter( 'excerpt_more', 'brilliant_excerpt_more' );
/**
* Blog: Post Templates
*
*/
function brilliant_blog_template() {
$blog_layout = get_theme_mod('blog_layout', 'blog-layout4');
if ( $blog_layout == 'blog-layout2' || $blog_layout == 'blog-layout4' ) {
$blog_template = 'content-grid';
} else {
$blog_template = 'content';
}
return sanitize_file_name($blog_template);
}
/**
* Blog: Post Columns
*
*/
function brilliant_blog_column() {
$blog_layout = get_theme_mod('blog_layout', 'blog-layout4');
if ( $blog_layout == 'blog-layout2' || $blog_layout == 'blog-layout4' ) {
$blog_column = 'col-6 col-sm-6';
} else {
$blog_column = 'col-12';
}
return esc_attr($blog_column);
}
/**
* Archive: Post Templates
*
*/
function brilliant_archive_template() {
$archive_layout = get_theme_mod('archive_layout', 'archive-layout2');
if ( $archive_layout == 'archive-layout2' ) {
$archive_template = 'content-grid';
} else {
if ( is_search() ) {
$archive_template = 'content-search';
} else {
$archive_template = 'content';
}
}
return sanitize_file_name($archive_template);
}
/**
* Archive: Post Columns
*
*/
function brilliant_archive_column() {
$archive_layout = get_theme_mod('archive_layout', 'archive-layout2');
if ( $archive_layout == 'archive-layout2' ) {
$archive_column = 'col-6 col-sm-6';
} else {
$archive_column = 'col-12';
}
return esc_attr($archive_column);
}
/**
* Prints Credits in the Footer
*/
function brilliant_credits() {
$website_credits = '';
$website_author = get_bloginfo('name');
$website_date = date_i18n(__( 'Y', 'brilliant' ) );
$website_credits = '© ' . $website_date . ' ' . $website_author;
echo esc_html($website_credits);
}
/**
* Add Upsell "pro" link to the customizer
*
*/
require_once( trailingslashit( get_template_directory() ) . '/inc/customize-pro/class-customize.php' );