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 https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' => esc_html__( 'Primary', 'byakko' ), 'social' => esc_html__( 'Social Media', 'byakko' ) ) ); /* * 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', ) ); /* * Enable support for Post Formats. * See https://developer.wordpress.org/themes/functionality/post-formats/ */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', ) ); /* Enable support for editor styling */ add_editor_style( array( 'inc/css/editor-style.css', byakko_fonts_url() ) ); /* Enable support for Jetpack features */ add_image_size( 'byakko-logo', 250, 250 ); add_theme_support( 'site-logo', array( 'header-text' => 'site-title', 'size' => 'byakko-logo' ) ); add_theme_support( 'featured-content', array( 'filter' => 'byakko_get_featured_posts', 'max_posts' => 4, 'post_types' => array( 'post', 'page' ), ) ); } endif; add_action( 'after_setup_theme', 'byakko_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 byakko_content_width() { $GLOBALS['content_width'] = apply_filters( 'byakko_content_width', 840 ); } add_action( 'after_setup_theme', 'byakko_content_width', 0 ); /** * Register widget areas. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function byakko_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Footer Left Sidebar', 'byakko' ), 'id' => 'footer-l', 'description' => esc_html__( 'This sidebar appears in the footer area.', 'byakko' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'Footer Center Sidebar', 'byakko' ), 'id' => 'footer-c', 'description' => esc_html__( 'This sidebar appears in the footer area.', 'byakko' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'Footer Right Sidebar', 'byakko' ), 'id' => 'footer-r', 'description' => esc_html__( 'This sidebar appears in the footer area.', 'byakko' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'byakko_widgets_init' ); /** * Enqueue scripts and styles. */ function byakko_scripts() { wp_enqueue_style( 'byakko-google-fonts', byakko_fonts_url() ); wp_enqueue_style( 'byakko-genericons', get_template_directory_uri() . '/inc/genericons/genericons/genericons.css' ); wp_enqueue_style( 'byakko-style', get_stylesheet_uri(), array( 'byakko-google-fonts', 'byakko-genericons' ) ); wp_enqueue_script( 'byakko-functions', get_template_directory_uri() . '/js/byakko.js', array( 'jquery' ), null, true ); if ( byakko_has_featured_posts( 2 ) ) { wp_enqueue_style( 'byakko-slides-css', get_template_directory_uri() . '/inc/rslides/responsiveslides.css' ); wp_enqueue_script( 'byakko-rslides-js', get_template_directory_uri() . '/inc/rslides/responsiveslides.js', array( 'jquery' ), null, true ); wp_localize_script( 'byakko-functions', 'hasFeaturedPosts', array( 'posts' => true ) ); } wp_enqueue_script( 'byakko-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' ); } } add_action( 'wp_enqueue_scripts', 'byakko_scripts' ); /** * Allow users to dequeue Google fonts */ function byakko_fonts_url() { $fonts = array(); $fonts_url = ''; /* 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 font: on or off', 'byakko' ) ) { $fonts[] = 'Raleway:300,300italic,700,700italic'; } /* 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', 'byakko' ) ) { $fonts[] = 'Libre Baskerville:400,400italic,700,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', 'byakko' ) ) { $fonts[] = 'Inconsolata:400'; } if ( $fonts ) { $fonts_url = add_query_arg( array( 'family' => urlencode( implode( '|', $fonts ) ), ), '//fonts.googleapis.com/css' ); } return $fonts_url; } /** * Return Jetpack featured posts */ function byakko_get_featured_posts() { return apply_filters( 'byakko_get_featured_posts', array() ); } /** * Get the number of featured posts */ function byakko_has_featured_posts( $minimum = 1 ) { if ( is_paged() ) { return false; } $minimum = absint( $minimum ); $featured_posts = apply_filters( 'byakko_get_featured_posts', array() ); if ( ! is_array( $featured_posts ) || $minimum > count( $featured_posts ) ) { return false; } return true; } /** * Get IDs of featured posts */ function byakko_get_featured_ids() { $ids = array(); $featured_posts = byakko_get_featured_posts(); foreach( $featured_posts as $featured_post ) { $ids[] = $featured_post->ID; } return $ids; } /** * Set custom excerpt length */ function byakko_set_excerpt_length() { global $post; $id = $post->ID; if ( ( is_home() || is_front_page() ) && in_array( $id, byakko_get_featured_ids() ) ) { return 10; } else { return 50; } } add_filter( 'excerpt_length', 'byakko_set_excerpt_length', 99 ); if ( ! function_exists( 'byakko_read_more' ) ) : /** * Since we're using excerpts, let's make them more interesting */ function byakko_read_more( $more ) { global $post; if ( is_home() || is_front_page() ) { return '…'; } else { return sprintf( '…%2$s', esc_url( get_permalink() ), esc_html__( 'Continue Reading →', 'byakko' ) ); } } endif; add_filter( 'excerpt_more', 'byakko_read_more' ); /** * 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/extras.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php';