__( 'Primary Menu', '8bit' ),
) );
// Add theme support
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'custom-logo', array(
'width' => 400,
'height' => 150,
'flex-height' => true,
'flex-width' => true,
) );
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
// Custom image size for displaying in posts
add_image_size( 'article', 580, 700, true );
// Available for translation
load_theme_textdomain( '8bit', get_template_directory() . '/languages' );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'eightbit_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => get_template_directory_uri() . '/assets/img/dots.png',
'default-repeat' => 'repeat',
'default-position-x' => 'left',
'default-position-y' => 'top',
'default-size' => 'auto',
'default-attachment' => 'fixed',
) ) );
// Visual editor stylesheet
add_editor_style( 'editor.css' );
}
}
add_action( 'after_setup_theme', 'eightbit_setup' );
// Register widget area
function eightbit_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', '8bit' ),
'id' => 'sidebar',
'description' => '',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'eightbit_widgets_init' );
// Enqueue scripts and styles
function eightbit_scripts() {
wp_enqueue_style( 'eightbit-style', get_template_directory_uri() . '/style-min.css', array(), '1.0', "all" );
wp_enqueue_style( 'eightbit-google-fonts', 'https://fonts.googleapis.com/css?family=Barlow:400,400i,600&subset=latin-ext', '1.0' );
wp_enqueue_script( 'eightbit-nprogress', get_template_directory_uri() . '/assets/js/nprogress.min.js', array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'eightbit-customjs', get_template_directory_uri() . '/assets/js/custom-min.js', array(), '1.0', true );
wp_localize_script( 'eightbit-ajax', 'ajax', array( 'url' => admin_url( 'admin-ajax.php' ) ) );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'eightbit_scripts' );
// Customizer theme options
function eightbit_customizer_main_color() {
$eightbit_color_setting = get_theme_mod( 'eightbit_color_setting' );
if ( get_theme_mod( 'eightbit_color_setting' ) && $eightbit_color_setting != '#ffffff' ) :?>
theme_location == 'primary' ) ) {
return $items;
}
return $items . '' . get_search_form( false ) . '';
}
// Custom CSS styles for Live Customizer
function eightbit_custom_customize_enqueue() {
wp_enqueue_style( 'customizer-css', get_stylesheet_directory_uri() . '/assets/css/customizer.css' );
}
add_action( 'customize_controls_enqueue_scripts', 'eightbit_custom_customize_enqueue' );
// Posts pagination
function brutalistthemes_pagination() {
global $wp_query;
$pagination = array(
'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
'format' => '?page=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
'prev_text' => '',
'next_text' => '',
'type' => 'list'
);
return paginate_links( $pagination );
}
// Related posts
function brutalistthemes_related_posts( $args = array() ) {
global $post;
// default args
$args = wp_parse_args( $args, array(
'post_id' => ! empty( $post ) ? $post->ID : '',
'taxonomy' => 'category',
'limit' => 3,
'post_type' => ! empty( $post ) ? $post->post_type : 'post',
'orderby' => 'date',
'order' => 'DESC'
) );
// check taxonomy
$registered_taxonomies = get_taxonomies();
if ( ! in_array( $args['taxonomy'], $registered_taxonomies ) ) {
return;
}
// post taxonomies
$taxonomies = wp_get_post_terms( $args['post_id'], $args['taxonomy'], array( 'fields' => 'ids' ) );
if ( empty( $taxonomies ) ) {
return;
}
// query
$related_posts = get_posts( array(
'post__not_in' => (array) $args['post_id'],
'post_type' => $args['post_type'],
'tax_query' => array(
array(
'taxonomy' => $args['taxonomy'],
'field' => 'term_id',
'terms' => $taxonomies
),
),
'posts_per_page' => $args['limit'],
'orderby' => $args['orderby'],
'order' => $args['order']
) );
include( locate_template( 'partials/related.php', false, false ) );
wp_reset_postdata();
}
// Signature
function brutalistthemes_signature() {
global $post;
$signatureImg = esc_url( get_theme_mod( 'brutalistthemes_signature_image_setting' ) );
$signatureWidth = esc_html( get_theme_mod( 'brutalistthemes_signature_size_setting' ) );
if ( get_theme_mod( 'brutalistthemes_signature_image_setting' ) && get_theme_mod( 'brutalistthemes_signature_size_setting' ) ) { ?>
' . esc_html__( ' Tagged %1$s', '8bit' ) . '', $tags_list ); // WPCS: XSS OK.
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
}
}
}
// Post author
if ( ! function_exists( 'brutalistthemes_posted_by' ) ) {
function brutalistthemes_posted_by() {
$byline = sprintf(
esc_html_x( 'by %s', 'post author', '8bit' ),
'' . esc_html( get_the_author() ) . ''
);
echo '' . $byline . ''; // WPCS: XSS OK.
}
}
// Post category
if ( ! function_exists( 'brutalistthemes_posted_cat' ) ) {
function brutalistthemes_posted_cat() {
foreach ( ( get_the_category() ) as $category ) {
echo '' . $category->cat_name . ' ';
}
}
}
// Post date
function brutalistthemes_posted_on( $args = array() ) {
$time_string = '';
$time_string_1 = '';
$time_string_2 = '';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date( 'd M Y' ) )
);
$time_string_1 = sprintf( $time_string_1,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date( 'd M Y' ) )
);
$time_string_2 = sprintf( $time_string_2,
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date( 'd M Y' ) )
);
$posted_on = sprintf(
esc_html( '%s', 'post date', 'steampunk' ),
'' . $time_string_1 . ''
);
$updated_on = sprintf(
esc_html( '%s', 'post date', 'steampunk' ),
'' . $time_string_2 . ''
);
$postedupdated_on = sprintf(
esc_html( '%s', 'post date', 'steampunk' ),
'' . $time_string . ''
);
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
echo 'Published on ' . $posted_on . ' — Last update: ' . $updated_on . '
';
} else {
echo 'Published on ' . $postedupdated_on . '
';
}
}
// Includes
require get_template_directory() . '/inc/customizer.php';