1440,
'height' => 221,
'default-image' => get_template_directory_uri() . '/images/header.jpg',
'uploads' => true,
'header-text' => false
);
add_theme_support( 'custom-header', $args );
// Add support for title_tag
add_theme_support( 'title-tag' );
// Set content width
global $content_width;
if ( ! isset( $content_width ) ) $content_width = 676;
// Add support for custom background
$args = array(
'default-color' => '#f1f1f1'
);
add_theme_support( "custom-background", $args );
// Add nav menu
register_nav_menu( 'primary', __( 'Primary Menu', 'baskerville' ) );
// Make the theme translation ready
load_theme_textdomain( 'baskerville', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'baskerville_setup' );
}
/* ---------------------------------------------------------------------------------------------
ENQUEUE SCRIPTS
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_load_javascript_files' ) ) {
function baskerville_load_javascript_files() {
if ( ! is_admin() ) {
wp_register_script( 'baskerville_imagesloaded', get_template_directory_uri() . '/js/imagesloaded.pkgd.js', '', true );
wp_register_script( 'baskerville_flexslider', get_template_directory_uri() . '/js/flexslider.min.js', '', true );
wp_enqueue_script( 'baskerville_global', get_template_directory_uri() . '/js/global.js', array( 'jquery', 'masonry', 'baskerville_imagesloaded', 'baskerville_flexslider' ), '', true );
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'baskerville_load_javascript_files' );
}
/* ---------------------------------------------------------------------------------------------
ENQUEUE STYLES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_load_style' ) ) {
function baskerville_load_style() {
if ( ! is_admin() ) {
$dependencies = array();
/**
* Translators: If there are characters in your language that are not
* supported by the theme fonts, translate this to 'off'. Do not translate
* into your own language.
*/
$google_fonts = _x( 'on', 'Google Fonts: on or off', 'baskerville' );
if ( 'off' !== $google_fonts ) {
// Register Google Fonts
wp_register_style( 'baskerville_googleFonts', '//fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,400italic,700,700italic,300|Pacifico:400', false, 1.0, 'all' );
$dependencies[] = 'baskerville_googleFonts';
}
// Enqueue the styles
wp_enqueue_style( 'baskerville_style', get_template_directory_uri() . '/style.css', $dependencies, '1.0', 'all' );
}
}
add_action( 'wp_print_styles', 'baskerville_load_style' );
}
/* ---------------------------------------------------------------------------------------------
ADD EDITOR STYLES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_add_editor_styles' ) ) {
function baskerville_add_editor_styles() {
add_editor_style( 'baskerville-editor-style.css' );
/**
* Translators: If there are characters in your language that are not
* supported by the theme fonts, translate this to 'off'. Do not translate
* into your own language.
*/
$google_fonts = _x( 'on', 'Google Fonts: on or off', 'baskerville' );
if ( 'off' !== $google_fonts ) {
$font_url = '//fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,400italic,700,700italic,300';
add_editor_style( str_replace( ',', '%2C', $font_url ) );
}
}
add_action( 'init', 'baskerville_add_editor_styles' );
}
/* ---------------------------------------------------------------------------------------------
ADD FOOTER WIDGET AREAS
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_sidebar_registration' ) ) {
function baskerville_sidebar_registration() {
register_sidebar( array(
'name' => __( 'Footer A', 'baskerville' ),
'id' => 'footer-a',
'description' => __( 'Widgets in this area will be shown in the left column in the footer.', 'baskerville' ),
'before_title' => '
',
'before_widget' => ''
) );
register_sidebar( array(
'name' => __( 'Footer B', 'baskerville' ),
'id' => 'footer-b',
'description' => __( 'Widgets in this area will be shown in the middle column in the footer.', 'baskerville' ),
'before_title' => '',
'before_widget' => ''
) );
register_sidebar( array(
'name' => __( 'Footer C', 'baskerville' ),
'id' => 'footer-c',
'description' => __( 'Widgets in this area will be shown in the right column in the footer.', 'baskerville' ),
'before_title' => '',
'before_widget' => ''
) );
register_sidebar( array(
'name' => __( 'Sidebar', 'baskerville' ),
'id' => 'sidebar',
'description' => __( 'Widgets in this area will be shown in the sidebar.', 'baskerville' ),
'before_title' => '',
'before_widget' => ''
) );
}
add_action( 'widgets_init', 'baskerville_sidebar_registration' );
}
/* ---------------------------------------------------------------------------------------------
ADD THEME WIDGETS
--------------------------------------------------------------------------------------------- */
require_once( get_template_directory() . '/widgets/dribbble-widget.php' );
require_once( get_template_directory() . '/widgets/flickr-widget.php' );
/* ---------------------------------------------------------------------------------------------
ADD CLASSES TO PAGINATION
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_pagination_classes_next' ) ) {
function baskerville_pagination_classes_next() {
return 'class="post-nav-older fleft"';
}
add_filter( 'next_posts_link_attributes', 'baskerville_pagination_classes_next' );
}
if ( ! function_exists( 'baskerville_pagination_classes_prev' ) ) {
function baskerville_pagination_classes_prev() {
return 'class="post-nav-newer fright"';
}
add_filter( 'previous_posts_link_attributes', 'baskerville_pagination_classes_prev' );
}
/* ---------------------------------------------------------------------------------------------
CUSTOM NAV WALKER WITH HAS-CHILDREN CLASS
--------------------------------------------------------------------------------------------- */
class baskerville_nav_walker extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
$id_field = $this->db_fields['id'];
if ( ! empty( $children_elements[$element->$id_field] ) ) {
$element->classes[] = 'has-children';
}
Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
/* ---------------------------------------------------------------------------------------------
BODY CLASSES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_body_classes' ) ) {
function baskerville_body_classes( $classes ) {
// If has post thumbnail
$classes[] = has_post_thumbnail() ? 'has-featured-image' : 'no-featured-image';
// If is mobile
if ( wp_is_mobile() ) {
$classes[] = 'is_mobile';
}
// Replicate single classes on other pages
if ( is_singular() || is_404() ) {
$classes[] = 'single single-post';
}
return $classes;
}
add_action( 'body_class', 'baskerville_body_classes' );
}
/* ---------------------------------------------------------------------------------------------
CUSTOM EXCERPT LENGTH
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_custom_excerpt_length' ) ) {
function baskerville_custom_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'baskerville_custom_excerpt_length', 999 );
}
/* ---------------------------------------------------------------------------------------------
CUSTOM EXCERPT OUTPUT
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_new_excerpt_more' ) ) {
function baskerville_new_excerpt_more( $more ) {
return '... ' . __( 'Continue Reading', 'baskerville' ) . ' →';
}
add_filter( 'excerpt_more', 'baskerville_new_excerpt_more' );
}
/* ---------------------------------------------------------------------------------------------
BASKERVILLE META FUNCTION
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_meta' ) ) {
function baskerville_meta() { ?>
ID : get_the_ID();
$images = get_posts( array(
'orderby' => 'menu_order',
'order' => 'ASC',
'post_mime_type' => 'image',
'post_parent' => $attachment_parent,
'post_status' => null,
'post_type' => 'attachment',
'posts_per_page' => -1,
) );
if ( $images ) { ?>
ID, $size ); ?>
-
post_excerpt ) && is_single() ) : ?>
comment_type ) :
case 'pingback' :
case 'trackback' :
?>
id="comment-">
', '' ); ?>
id="li-comment-">
add_section( 'baskerville_options',
array(
'title' => __( 'Baskerville Options', 'baskerville' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Allows you to customize some settings for Baskerville.', 'baskerville'), //Descriptive tooltip
)
);
$wp_customize->add_section( 'baskerville_logo_section' , array(
'title' => __( 'Logo', 'baskerville' ),
'priority' => 40,
'description' => 'Upload a logo to replace the default site name and description in the header',
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'baskerville_logo',
array(
'sanitize_callback' => 'esc_url_raw'
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'baskerville_logo', array(
'label' => __( 'Logo', 'baskerville' ),
'section' => 'baskerville_logo_section',
'settings' => 'baskerville_logo',
) ) );
//4. We can also change built-in settings by modifying properties. For instance, let's make some stuff use live preview JS...
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
}
public static function generate_css( $selector, $style, $mod_name, $prefix='', $postfix='', $echo=true ) {
$return = '';
$mod = get_theme_mod($mod_name);
if ( ! empty( $mod ) ) {
$return = sprintf('%s { %s:%s; }',
$selector,
$style,
$prefix.$mod.$postfix
);
if ( $echo ) echo $return;
}
return $return;
}
}
// Setup the Theme Customizer settings and controls...
add_action( 'customize_register' , array( 'baskerville_Customize' , 'register' ) );
/* ---------------------------------------------------------------------------------------------
SPECIFY GUTENBERG SUPPORT
------------------------------------------------------------------------------------------------ */
if ( ! function_exists( 'baskerville_add_gutenberg_features' ) ) :
function baskerville_add_gutenberg_features() {
add_theme_support( 'align-wide' );
/* Gutenberg Palette --------------------------------------- */
add_theme_support( 'editor-color-palette', array(
array(
'name' => _x( 'Cyan', 'Name of the cyan color in the Gutenberg palette', 'baskerville' ),
'slug' => 'accent',
'color' => '#13C4A5',
),
array(
'name' => _x( 'Black', 'Name of the black color in the Gutenberg palette', 'baskerville' ),
'slug' => 'black',
'color' => '#222',
),
array(
'name' => _x( 'Dark Gray', 'Name of the dark gray color in the Gutenberg palette', 'baskerville' ),
'slug' => 'dark-gray',
'color' => '#444',
),
array(
'name' => _x( 'Medium Gray', 'Name of the medium gray color in the Gutenberg palette', 'baskerville' ),
'slug' => 'medium-gray',
'color' => '#666',
),
array(
'name' => _x( 'Light Gray', 'Name of the light gray color in the Gutenberg palette', 'baskerville' ),
'slug' => 'light-gray',
'color' => '#888',
),
array(
'name' => _x( 'White', 'Name of the white color in the Gutenberg palette', 'baskerville' ),
'slug' => 'white',
'color' => '#fff',
),
) );
/* Gutenberg Font Sizes --------------------------------------- */
add_theme_support( 'editor-font-sizes', array(
array(
'name' => _x( 'Small', 'Name of the small font size in Gutenberg', 'baskerville' ),
'shortName' => _x( 'S', 'Short name of the small font size in the Gutenberg editor.', 'baskerville' ),
'size' => 16,
'slug' => 'small',
),
array(
'name' => _x( 'Regular', 'Name of the regular font size in Gutenberg', 'baskerville' ),
'shortName' => _x( 'M', 'Short name of the regular font size in the Gutenberg editor.', 'baskerville' ),
'size' => 18,
'slug' => 'regular',
),
array(
'name' => _x( 'Large', 'Name of the large font size in Gutenberg', 'baskerville' ),
'shortName' => _x( 'L', 'Short name of the large font size in the Gutenberg editor.', 'baskerville' ),
'size' => 24,
'slug' => 'large',
),
array(
'name' => _x( 'Larger', 'Name of the larger font size in Gutenberg', 'baskerville' ),
'shortName' => _x( 'XL', 'Short name of the larger font size in the Gutenberg editor.', 'baskerville' ),
'size' => 32,
'slug' => 'larger',
),
) );
}
add_action( 'after_setup_theme', 'baskerville_add_gutenberg_features' );
endif;
/* ---------------------------------------------------------------------------------------------
GUTENBERG EDITOR STYLES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'baskerville_block_editor_styles' ) ) :
function baskerville_block_editor_styles() {
$dependencies = array();
/**
* Translators: If there are characters in your language that are not
* supported by the theme fonts, translate this to 'off'. Do not translate
* into your own language.
*/
$google_fonts = _x( 'on', 'Google Fonts: on or off', 'baskerville' );
if ( 'off' !== $google_fonts ) {
// Register Google Fonts
wp_register_style( 'baskerville-block-editor-styles-font', '//fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,400italic,700,700italic,300', false, 1.0, 'all' );
$dependencies[] = 'baskerville-block-editor-styles-font';
}
// Enqueue the editor styles
wp_enqueue_style( 'baskerville-block-editor-styles', get_theme_file_uri( '/baskerville-gutenberg-editor-style.css' ), $dependencies, '1.0', 'all' );
}
add_action( 'enqueue_block_editor_assets', 'baskerville_block_editor_styles', 1 );
endif;
?>