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' );
add_image_size( 'brazilcolors-thumb', 550, 360, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'menu-1' => esc_html__( 'Primary', 'brazil-colors' ),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'brazilcolors_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
// Declare WooCommerce support.
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
) );
//Starter content
add_theme_support('starter-content', array(
// Static front page set to Home, posts page set to Blog
'options' => array(
'show_on_front' => 'page',
'page_on_front' => '{{home}}',
'page_for_posts' => '{{blog}}',
),
// Starter pages to include
'posts' => array(
'home',
'about' => array(
'post_content' => '
Babybel cheese slices say cheese. Pepper jack red leicester macaroni cheese.
Cheese triangles caerphilly manchego cheese triangles fromage frais gouda melted cheese red leicester. Hard cheese port-salut caerphilly cheese slices cottage cheese fromage frais pecorino.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Cheesecake boursin cheese and wine. Ricotta swiss cheese strings fromage cheese and wine red leicester emmental croque monsieur. Fondue smelly cheese red leicester lancashire when the cheese comes out everybodys happy emmental babybel when the cheese comes out everybodys happy.
'
),
'contact',
'blog'
),
// Add pages to primary navigation menu
'nav_menus' => array(
'menu-1' => array(
'name' => __('Primary', 'brazil-colors'),
'items' => array(
'home_link',
'page_about',
'page_blog',
'page_contact',
),
)
),
));
}
endif;
add_action( 'after_setup_theme', 'brazilcolors_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 brazilcolors_content_width() {
$GLOBALS['content_width'] = apply_filters( 'brazilcolors_content_width', 640 );
}
add_action( 'after_setup_theme', 'brazilcolors_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function brazilcolors_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'brazil-colors' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'brazil-colors' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 1', 'brazil-colors' ),
'id' => 'sidebar-2',
'description' => esc_html__( 'Add widgets here.', 'brazil-colors' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 2', 'brazil-colors' ),
'id' => 'sidebar-3',
'description' => esc_html__( 'Add widgets here.', 'brazil-colors' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 4', 'brazil-colors' ),
'id' => 'sidebar-4',
'description' => esc_html__( 'Add widgets here.', 'brazil-colors' ),
'before_widget' => '',
'before_title' => '',
) );
if( class_exists( 'WooCommerce' ) ) :
// If Woocommerce is active, create the Woocommerce sidebar
register_sidebar( array(
'name' => esc_html__( 'Woocommerce', 'brazil-colors' ),
'id' => 'sidebar-5',
'description' => esc_html__( 'Add widgets here.', 'brazil-colors' ),
'before_widget' => '',
'before_title' => '',
) );
endif;
}
add_action( 'widgets_init', 'brazilcolors_widgets_init' );
/**
* Filter the except length to 20 words.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function brazilcolors_custom_excerpt_length( $length ) {
if( ! is_admin() ) :
return 20;
else :
return $length;
endif;
}
add_filter( 'excerpt_length', 'brazilcolors_custom_excerpt_length', 999 );
/**
* Place a cart icon with number of items and total cost in the menu bar.
*
* Source: http://wordpress.org/plugins/woocommerce-menu-bar-cart/
*/
function brazilcolors_wcmenucart($menu, $args) {
// Check if WooCommerce is active and add a new item to a menu assigned to Primary Navigation Menu location
if ( ! class_exists( 'WooCommerce' ) || 'menu-1' !== $args->theme_location ) :
return $menu;
endif;
ob_start();
global $woocommerce;
$viewing_cart = __('View your shopping cart', 'brazil-colors');
$start_shopping = __('Start shopping', 'brazil-colors');
$cart_url = wc_get_cart_url();
$shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
$cart_contents_count = $woocommerce->cart->cart_contents_count;
$cart_total = $woocommerce->cart->get_cart_total();
// Uncomment the line below to hide nav menu cart item when there are no items in the cart
// if ( $cart_contents_count > 0 ) {
if ($cart_contents_count == 0) {
$menu_item = '
';
$args['next_text'] = '';
return $args;
}
add_filter( 'woocommerce_pagination_args', 'brazilcolors_woo_pagination' );
/**
* Customize the Read More Button
**/
function brazilcolors_modify_read_more_link() {
return '' . __( 'Continue reading "%s"', 'brazil-colors' ) . '';
}
add_filter( 'the_content_more_link', 'brazilcolors_modify_read_more_link' );
/**
* Check if is Blog set archive page
*/
function brazilcolors_is_blog() {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
/**
* Enqueue scripts and styles.
*/
function brazilcolors_scripts() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap/bootstrap.css' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome-4.7.0/css/font-awesome.min.css' );
wp_enqueue_style( 'superslides-style', get_template_directory_uri() . '/css/superslides.css' );
wp_enqueue_style( 'pace-style', get_template_directory_uri() . '/css/pace-theme-center-circle.css' );
wp_enqueue_style( 'select2-style', get_template_directory_uri() . '/css/select2.css' );
wp_enqueue_style( 'brazilcolors-style', get_stylesheet_uri() );
wp_enqueue_script( 'brazilcolors-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '20180115', true );
if( brazilcolors_get_theme_mod( 'mcn_layout_archive_content' ) == 'masonry' && (is_home() || is_archive()) ) :
wp_enqueue_script( 'masonry' );
endif;
wp_enqueue_script( 'brazilcolors-main-scripts', get_template_directory_uri() . '/js/main.js', array(), '20180131', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) :
wp_enqueue_script( 'comment-reply' );
endif;
}
add_action( 'wp_enqueue_scripts', 'brazilcolors_scripts' );
/**
* Enqueue scripts and styles in the Wordpress admin.
*/
function brazilcolors_custom_admin_style() {
wp_register_style( 'brazilcolors-admin-css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'brazilcolors-admin-css' );
}
add_action( 'admin_enqueue_scripts', 'brazilcolors_custom_admin_style' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Site Origin Page Builder Enhancements.
*/
require get_template_directory() . '/inc/siteorigin-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Custom meta boxes.
*/
require get_template_directory() . '/inc/custom-meta-boxes.php';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
/**
* TGM Plugins Activation.
*/
require_once get_template_directory() . '/inc/class-tgm-plugin-activation.php';
require_once get_template_directory() . '/inc/plugins-activation.php';