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' );
set_post_thumbnail_size( 326, 236, true ); //post thumbnails List
add_image_size( 'blackwhite-post-featured-full-width', 500, 180, true ); //post thumbnails featured full width
add_image_size( 'blackwhite-post-related-small', 100, 80, true ); //small size & related posts
add_image_size( 'blackwhite-post-featured', 516, 364, true ); //post thumbnails featured
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'blackwhite-lite' ),
'social-menu' => esc_html__( 'Social Profile Footer', 'blackwhite-lite' ),
'footer-menu' => esc_html__( 'Footer Menu', 'blackwhite-lite' )
) );
/*
* 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',
) );
/**
* Support Logo
*
*/
add_theme_support( 'custom-logo', array(
'height' => 90, // change to your height logo
'width' => 250, // change to your width logo
'flex-width' => true, // change to flexible width
'flex-width' => true, // change to flexible width
) );
/*
* 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',
) );
}
endif;
add_action( 'after_setup_theme', 'blackwhite_lite_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 blackwhite_lite_content_width() {
$GLOBALS['content_width'] = apply_filters( 'blackwhite_lite_content_width', 640 );
}
add_action( 'after_setup_theme', 'blackwhite_lite_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function blackwhite_lite_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'blackwhite-lite' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'blackwhite-lite' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Header Banner', 'blackwhite-lite' ),
'id' => 'header-widget',
'description' => esc_html__( 'Add widgets here.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Feature Homepage', 'blackwhite-lite' ),
'id' => 'feature-homepage',
'description' => esc_html__( 'Add widgets here to appear on magazine template.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar( array(
'name' => esc_html__( 'Magazine Homepage', 'blackwhite-lite' ),
'id' => 'magazine-homepage',
'description' => esc_html__( 'Add widgets here to appear on magazine template.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar( array(
'name' => esc_html__( 'Footer 1', 'blackwhite-lite' ),
'id' => 'footer-1',
'description' => esc_html__( 'Add widgets here.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 2', 'blackwhite-lite' ),
'id' => 'footer-2',
'description' => esc_html__( 'Add widgets here.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 3', 'blackwhite-lite' ),
'id' => 'footer-3',
'description' => esc_html__( 'Add widgets here.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 4', 'blackwhite-lite' ),
'id' => 'footer-4',
'description' => esc_html__( 'Add widgets here.', 'blackwhite-lite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'blackwhite_lite_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function blackwhite_lite_scripts() {
global $wp_query;
wp_enqueue_style( 'google-font-style', '//fonts.googleapis.com/css?family=PT+Sans:400,700');
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css' );
wp_enqueue_style( 'blackwhite-style', get_stylesheet_uri() );
wp_enqueue_style( 'blackwhite-responsive', get_template_directory_uri() . '/css/responsive.css');
wp_enqueue_style( 'blackwhite-custom-layout', get_template_directory_uri() . '/css/custom-layout.css');
wp_enqueue_script( 'jqSocialSharer', get_template_directory_uri() . '/js/jqSocialSharer.js', array(), '20151215', true );
wp_enqueue_script( 'blackwhite-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'blackwhite-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array('jquery'), '20151215', true );
wp_enqueue_script( 'blackwhite-script', get_template_directory_uri() . '/js/script.js', array(), '20160720', true );
$args = array(
'nonce' => wp_create_nonce( 'blackwhite-load-more-nonce' ),
'url' => admin_url( 'admin-ajax.php' ),
'query' => $wp_query->query,
'labels' => array('loading' => __('Loading', 'blackwhite-lite'), 'more' => __('More...', 'blackwhite-lite'))
);
wp_localize_script( 'blackwhite-script', 'blackwhiteLoadMore', $args );
}
add_action( 'wp_enqueue_scripts', 'blackwhite_lite_scripts' );
/**
|------------------------------------------------------------------------------
| Enqueue Admin scripts and styles.
|------------------------------------------------------------------------------
*/
function blackwhite_lite_admin_scripts() {
wp_enqueue_style( 'blackwhite-admin-css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
wp_enqueue_script( 'blackwhite-admin-script', get_template_directory_uri() . '/js/admin-script.js', array('jquery'), '20150226', true );
}
add_action( 'admin_enqueue_scripts', 'blackwhite_lite_admin_scripts' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
/*
|------------------------------------------------------------------------------
| Truncate string to x letters/words
|------------------------------------------------------------------------------
*/
function blackwhite_lite_truncate( $str, $length = 40, $units = 'letters', $ellipsis = ' …' ) {
if ( $units == 'letters' ) {
if ( mb_strlen( $str ) > $length ) {
return mb_substr( $str, 0, $length ) . $ellipsis;
} else {
return $str;
}
} else {
$words = explode( ' ', $str );
if ( count( $words ) > $length ) {
return implode( " ", array_slice( $words, 0, $length ) ) . $ellipsis;
} else {
return $str;
}
}
}
if ( ! function_exists( 'blackwhite_lite_excerpt' ) ) {
function blackwhite_lite_excerpt( $limit = 40 ) {
return blackwhite_lite_truncate( get_the_excerpt(), $limit, 'words' );
}
}
if ( ! function_exists('blackwhite_lite_tc_breadcrumb')) {
/**
|------------------------------------------------------------------------------
| TC Breadcrumb
|------------------------------------------------------------------------------
|
*/
function blackwhite_lite_tc_breadcrumb() {
$theme_options = blackwhite_lite_theme_options();
$breadcrumb = is_array($theme_options['breadscrumb_yoast_seo']) ? array_flip($theme_options['breadscrumb_yoast_seo']) : array();
if ( $theme_options['breadscrumb'] == 1 ) : ?>
','');
}
} else {
blackwhite_lite_breadcrumb();
}
?>